26 import java.util.ArrayList; |
26 import java.util.ArrayList; |
27 import java.util.HashMap; |
27 import java.util.HashMap; |
28 import java.util.Iterator; |
28 import java.util.Iterator; |
29 import java.util.List; |
29 import java.util.List; |
30 import java.util.Set; |
30 import java.util.Set; |
|
31 import java.util.Map; |
31 |
32 |
32 import javax.xml.parsers.ParserConfigurationException; |
33 import javax.xml.parsers.ParserConfigurationException; |
33 |
34 |
34 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; |
35 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; |
35 import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException; |
36 import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException; |
60 /** {@link java.util.logging} logging facility */ |
61 /** {@link java.util.logging} logging facility */ |
61 static java.util.logging.Logger log = |
62 static java.util.logging.Logger log = |
62 java.util.logging.Logger.getLogger(Manifest.class.getName()); |
63 java.util.logging.Logger.getLogger(Manifest.class.getName()); |
63 |
64 |
64 /** Field _references */ |
65 /** Field _references */ |
65 List _references; |
66 List<Reference> _references; |
66 Element[] _referencesEl; |
67 Element[] _referencesEl; |
67 |
68 |
68 /** Field verificationResults[] */ |
69 /** Field verificationResults[] */ |
69 private boolean verificationResults[] = null; |
70 private boolean verificationResults[] = null; |
70 |
71 |
71 /** Field _resolverProperties */ |
72 /** Field _resolverProperties */ |
72 HashMap _resolverProperties = null; |
73 Map<String,String> _resolverProperties = null; |
73 |
74 |
74 /** Field _perManifestResolvers */ |
75 /** Field _perManifestResolvers */ |
75 List _perManifestResolvers = null; |
76 List<ResourceResolver> _perManifestResolvers = null; |
76 |
77 |
77 /** |
78 /** |
78 * Consturts {@link Manifest} |
79 * Consturts {@link Manifest} |
79 * |
80 * |
80 * @param doc the {@link Document} in which <code>XMLsignature</code> is placed |
81 * @param doc the {@link Document} in which <code>XMLsignature</code> is placed |
173 throws XMLSignatureException, ReferenceNotInitializedException { |
174 throws XMLSignatureException, ReferenceNotInitializedException { |
174 |
175 |
175 for (int i = 0; i < this.getLength(); i++) { |
176 for (int i = 0; i < this.getLength(); i++) { |
176 |
177 |
177 // update the cached Reference object, the Element content is automatically updated |
178 // update the cached Reference object, the Element content is automatically updated |
178 Reference currentRef = (Reference) this._references.get(i); |
179 Reference currentRef = this._references.get(i); |
179 |
180 |
180 currentRef.generateDigestValue(); |
181 currentRef.generateDigestValue(); |
181 } |
182 } |
182 } |
183 } |
183 |
184 |
206 Reference ref = new Reference(_referencesEl[i], this._baseURI, this); |
207 Reference ref = new Reference(_referencesEl[i], this._baseURI, this); |
207 |
208 |
208 this._references.set(i, ref); |
209 this._references.set(i, ref); |
209 } |
210 } |
210 |
211 |
211 return (Reference) this._references.get(i); |
212 return this._references.get(i); |
212 |
213 |
213 } |
214 } |
214 |
215 |
215 /** |
216 /** |
216 * Sets the <code>Id</code> attribute |
217 * Sets the <code>Id</code> attribute |
321 log.log(java.util.logging.Level.FINE, "We have to follow a nested Manifest"); |
322 log.log(java.util.logging.Level.FINE, "We have to follow a nested Manifest"); |
322 |
323 |
323 try { |
324 try { |
324 XMLSignatureInput signedManifestNodes = |
325 XMLSignatureInput signedManifestNodes = |
325 currentRef.dereferenceURIandPerformTransforms(null); |
326 currentRef.dereferenceURIandPerformTransforms(null); |
326 Set nl = signedManifestNodes.getNodeSet(); |
327 Set<Node> nl = signedManifestNodes.getNodeSet(); |
327 Manifest referencedManifest = null; |
328 Manifest referencedManifest = null; |
328 Iterator nlIterator = nl.iterator(); |
329 Iterator<Node> nlIterator = nl.iterator(); |
329 |
330 |
330 findManifest: while (nlIterator.hasNext()) { |
331 findManifest: while (nlIterator.hasNext()) { |
331 Node n = (Node) nlIterator.next(); |
332 Node n = nlIterator.next(); |
332 |
333 |
333 if ((n.getNodeType() == Node.ELEMENT_NODE) && ((Element) n) |
334 if ((n.getNodeType() == Node.ELEMENT_NODE) && ((Element) n) |
334 .getNamespaceURI() |
335 .getNamespaceURI() |
335 .equals(Constants.SignatureSpecNS) && ((Element) n) |
336 .equals(Constants.SignatureSpecNS) && ((Element) n) |
336 .getLocalName().equals(Constants._TAG_MANIFEST)) { |
337 .getLocalName().equals(Constants._TAG_MANIFEST)) { |
477 * @param key the key |
478 * @param key the key |
478 * @param value the value |
479 * @param value the value |
479 */ |
480 */ |
480 public void setResolverProperty(String key, String value) { |
481 public void setResolverProperty(String key, String value) { |
481 if (_resolverProperties==null) { |
482 if (_resolverProperties==null) { |
482 _resolverProperties=new HashMap(10); |
483 _resolverProperties=new HashMap<String, String>(10); |
483 } |
484 } |
484 this._resolverProperties.put(key, value); |
485 this._resolverProperties.put(key, value); |
485 } |
486 } |
486 |
487 |
487 /** |
488 /** |