src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java

Print this page




 171                 tempObjects.add(new DOMXMLObject(nextSibling,
 172                                                  context, provider));
 173                 nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
 174             }
 175             objects = Collections.unmodifiableList(tempObjects);
 176         }
 177     }
 178 
 179     public String getId() {
 180         return id;
 181     }
 182 
 183     public KeyInfo getKeyInfo() {
 184         return ki;
 185     }
 186 
 187     public SignedInfo getSignedInfo() {
 188         return si;
 189     }
 190 
 191     public List getObjects() {
 192         return objects;
 193     }
 194 
 195     public SignatureValue getSignatureValue() {
 196         return sv;
 197     }
 198 
 199     public KeySelectorResult getKeySelectorResult() {
 200         return ksr;
 201     }
 202 
 203     public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
 204         throws MarshalException
 205     {
 206         marshal(parent, null, dsPrefix, context);
 207     }
 208 
 209     public void marshal(Node parent, Node nextSibling, String dsPrefix,
 210                         DOMCryptoContext context)
 211         throws MarshalException


 454 
 455         return result;
 456     }
 457 
 458     private void digestReference(DOMReference ref, XMLSignContext signContext)
 459         throws XMLSignatureException
 460     {
 461         if (ref.isDigested()) {
 462             return;
 463         }
 464         // check dependencies
 465         String uri = ref.getURI();
 466         if (Utils.sameDocumentURI(uri)) {
 467             String id = Utils.parseIdFromSameDocumentURI(uri);
 468             if (id != null && signatureIdMap.containsKey(id)) {
 469                 XMLStructure xs = signatureIdMap.get(id);
 470                 if (xs instanceof DOMReference) {
 471                     digestReference((DOMReference)xs, signContext);
 472                 } else if (xs instanceof Manifest) {
 473                     Manifest man = (Manifest)xs;
 474                     List manRefs = man.getReferences();

 475                     for (int i = 0, size = manRefs.size(); i < size; i++) {
 476                         digestReference((DOMReference)manRefs.get(i),
 477                                         signContext);
 478                     }
 479                 }
 480             }
 481             // if uri="" and there are XPath Transforms, there may be
 482             // reference dependencies in the XPath Transform - so be on
 483             // the safe side, and skip and do at end in the final sweep
 484             if (uri.length() == 0) {
 485                 @SuppressWarnings("unchecked")
 486                 List<Transform> transforms = ref.getTransforms();
 487                 for (Transform transform : transforms) {
 488                     String transformAlg = transform.getAlgorithm();
 489                     if (transformAlg.equals(Transform.XPATH) ||
 490                         transformAlg.equals(Transform.XPATH2)) {
 491                         return;
 492                     }
 493                 }
 494             }




 171                 tempObjects.add(new DOMXMLObject(nextSibling,
 172                                                  context, provider));
 173                 nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
 174             }
 175             objects = Collections.unmodifiableList(tempObjects);
 176         }
 177     }
 178 
 179     public String getId() {
 180         return id;
 181     }
 182 
 183     public KeyInfo getKeyInfo() {
 184         return ki;
 185     }
 186 
 187     public SignedInfo getSignedInfo() {
 188         return si;
 189     }
 190 
 191     public List<XMLObject> getObjects() {
 192         return objects;
 193     }
 194 
 195     public SignatureValue getSignatureValue() {
 196         return sv;
 197     }
 198 
 199     public KeySelectorResult getKeySelectorResult() {
 200         return ksr;
 201     }
 202 
 203     public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
 204         throws MarshalException
 205     {
 206         marshal(parent, null, dsPrefix, context);
 207     }
 208 
 209     public void marshal(Node parent, Node nextSibling, String dsPrefix,
 210                         DOMCryptoContext context)
 211         throws MarshalException


 454 
 455         return result;
 456     }
 457 
 458     private void digestReference(DOMReference ref, XMLSignContext signContext)
 459         throws XMLSignatureException
 460     {
 461         if (ref.isDigested()) {
 462             return;
 463         }
 464         // check dependencies
 465         String uri = ref.getURI();
 466         if (Utils.sameDocumentURI(uri)) {
 467             String id = Utils.parseIdFromSameDocumentURI(uri);
 468             if (id != null && signatureIdMap.containsKey(id)) {
 469                 XMLStructure xs = signatureIdMap.get(id);
 470                 if (xs instanceof DOMReference) {
 471                     digestReference((DOMReference)xs, signContext);
 472                 } else if (xs instanceof Manifest) {
 473                     Manifest man = (Manifest)xs;
 474                     List<Reference> manRefs =
 475                         DOMManifest.getManifestReferences(man);
 476                     for (int i = 0, size = manRefs.size(); i < size; i++) {
 477                         digestReference((DOMReference)manRefs.get(i),
 478                                         signContext);
 479                     }
 480                 }
 481             }
 482             // if uri="" and there are XPath Transforms, there may be
 483             // reference dependencies in the XPath Transform - so be on
 484             // the safe side, and skip and do at end in the final sweep
 485             if (uri.length() == 0) {
 486                 @SuppressWarnings("unchecked")
 487                 List<Transform> transforms = ref.getTransforms();
 488                 for (Transform transform : transforms) {
 489                     String transformAlg = transform.getAlgorithm();
 490                     if (transformAlg.equals(Transform.XPATH) ||
 491                         transformAlg.equals(Transform.XPATH2)) {
 492                         return;
 493                     }
 494                 }
 495             }