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

Print this page




 276         this.appliedTransformData = null;
 277         this.provider = provider;
 278     }
 279 
 280     public DigestMethod getDigestMethod() {
 281         return digestMethod;
 282     }
 283 
 284     public String getId() {
 285         return id;
 286     }
 287 
 288     public String getURI() {
 289         return uri;
 290     }
 291 
 292     public String getType() {
 293         return type;
 294     }
 295 
 296     public List getTransforms() {
 297         return Collections.unmodifiableList(allTransforms);
 298     }
 299 
 300     public byte[] getDigestValue() {
 301         return (digestValue == null ? null : digestValue.clone());
 302     }
 303 
 304     public byte[] getCalculatedDigestValue() {
 305         return (calcDigestValue == null ? null
 306                                         : calcDigestValue.clone());
 307     }
 308 
 309     public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
 310         throws MarshalException
 311     {
 312         if (log.isLoggable(java.util.logging.Level.FINE)) {
 313             log.log(java.util.logging.Level.FINE, "Marshalling Reference");
 314         }
 315         Document ownerDoc = DOMUtils.getOwnerDocument(parent);
 316 


 626         }
 627         result = 31 * result + digestMethod.hashCode();
 628         result = 31 * result + allTransforms.hashCode();
 629 
 630         return result;
 631     }
 632 
 633     boolean isDigested() {
 634         return digested;
 635     }
 636 
 637     private static Data copyDerefData(Data dereferencedData) {
 638         if (dereferencedData instanceof ApacheData) {
 639             // need to make a copy of the Data
 640             ApacheData ad = (ApacheData)dereferencedData;
 641             XMLSignatureInput xsi = ad.getXMLSignatureInput();
 642             if (xsi.isNodeSet()) {
 643                 try {
 644                     final Set<Node> s = xsi.getNodeSet();
 645                     return new NodeSetData() {
 646                         public Iterator iterator() { return s.iterator(); }
 647                     };
 648                 } catch (Exception e) {
 649                     // log a warning
 650                     log.log(java.util.logging.Level.WARNING, "cannot cache dereferenced data: " + e);
 651                     return null;
 652                 }
 653             } else if (xsi.isElement()) {
 654                 return new DOMSubTreeData
 655                     (xsi.getSubNode(), xsi.isExcludeComments());
 656             } else if (xsi.isOctetStream() || xsi.isByteArray()) {
 657                 try {
 658                     return new OctetStreamData
 659                         (xsi.getOctetStream(), xsi.getSourceURI(),
 660                          xsi.getMIMEType());
 661                 } catch (IOException ioe) {
 662                     // log a warning
 663                     log.log(java.util.logging.Level.WARNING, "cannot cache dereferenced data: " + ioe);
 664                     return null;
 665                 }
 666             }


 276         this.appliedTransformData = null;
 277         this.provider = provider;
 278     }
 279 
 280     public DigestMethod getDigestMethod() {
 281         return digestMethod;
 282     }
 283 
 284     public String getId() {
 285         return id;
 286     }
 287 
 288     public String getURI() {
 289         return uri;
 290     }
 291 
 292     public String getType() {
 293         return type;
 294     }
 295 
 296     public List<Transform> getTransforms() {
 297         return Collections.unmodifiableList(allTransforms);
 298     }
 299 
 300     public byte[] getDigestValue() {
 301         return (digestValue == null ? null : digestValue.clone());
 302     }
 303 
 304     public byte[] getCalculatedDigestValue() {
 305         return (calcDigestValue == null ? null
 306                                         : calcDigestValue.clone());
 307     }
 308 
 309     public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
 310         throws MarshalException
 311     {
 312         if (log.isLoggable(java.util.logging.Level.FINE)) {
 313             log.log(java.util.logging.Level.FINE, "Marshalling Reference");
 314         }
 315         Document ownerDoc = DOMUtils.getOwnerDocument(parent);
 316 


 626         }
 627         result = 31 * result + digestMethod.hashCode();
 628         result = 31 * result + allTransforms.hashCode();
 629 
 630         return result;
 631     }
 632 
 633     boolean isDigested() {
 634         return digested;
 635     }
 636 
 637     private static Data copyDerefData(Data dereferencedData) {
 638         if (dereferencedData instanceof ApacheData) {
 639             // need to make a copy of the Data
 640             ApacheData ad = (ApacheData)dereferencedData;
 641             XMLSignatureInput xsi = ad.getXMLSignatureInput();
 642             if (xsi.isNodeSet()) {
 643                 try {
 644                     final Set<Node> s = xsi.getNodeSet();
 645                     return new NodeSetData() {
 646                         public Iterator<Node> iterator() { return s.iterator(); }
 647                     };
 648                 } catch (Exception e) {
 649                     // log a warning
 650                     log.log(java.util.logging.Level.WARNING, "cannot cache dereferenced data: " + e);
 651                     return null;
 652                 }
 653             } else if (xsi.isElement()) {
 654                 return new DOMSubTreeData
 655                     (xsi.getSubNode(), xsi.isExcludeComments());
 656             } else if (xsi.isOctetStream() || xsi.isByteArray()) {
 657                 try {
 658                     return new OctetStreamData
 659                         (xsi.getOctetStream(), xsi.getSourceURI(),
 660                          xsi.getMIMEType());
 661                 } catch (IOException ioe) {
 662                     // log a warning
 663                     log.log(java.util.logging.Level.WARNING, "cannot cache dereferenced data: " + ioe);
 664                     return null;
 665                 }
 666             }