Hi Devs,
In the Reference List processor , we get decrypted nodes using the
following logic.
We keep a list of elements before decryption of an element and we compare it
with list of elements after the element is decrypted. We do this using the
the following code.
final java.util.List ret = new java.util.ArrayList();
for (
final java.util.Iterator bpos = b.iterator();
bpos.hasNext();
) {
final Node bnode = (Node) bpos.next();
final java.lang.String bns = bnode.getNamespaceURI();
final java.lang.String bln = bnode.getLocalName();
boolean found = false;
for (
final java.util.Iterator apos = a.iterator();
apos.hasNext();
) {
final Node anode = (Node) apos.next();
final java.lang.String ans = anode.getNamespaceURI();
final java.lang.String aln = anode.getLocalName();
final boolean nsmatch =
ans == null
? ((bns == null) ? true : false)
: ((bns == null) ? false : ans.equals(bns));
final boolean lnmatch =
aln == null
? ((bln == null) ? true : false)
: ((bln == null) ? false : aln.equals(bln));
if (nsmatch && lnmatch) {
found = true;
}
}
if (!found) {
ret.add(bnode);
}
As we can see, we check the presence of the elements using the qualified
names of the elements. But this not always work. Say for example, we encrypt
the signature of the message and the message also have a endorsing
signature.
List A List B
EncryptedData (Encrypted signature) Signature (Decrypted Signature)
Signature (Endorsing signature) Signature (Endorsing
Signature)
According the above logic, we will not get the decrypted signature as a new
node. So shall we check the new nodes using object references,
final java.util.List ret = new java.util.ArrayList();
for ( final java.util.Iterator bpos = b.iterator();
bpos.hasNext(); ) {
final Node bnode = (Node) bpos.next();
boolean found = false;
for (final java.util.Iterator apos = a.iterator();
apos.hasNext();) {
final Node anode = (Node) apos.next();
if (bnode.equals(anode)) {
found = true;
}
}
if (!found) {
ret.add(bnode);
}
WDYT ?
thanks,
/nandana