<ds:Reference> elements.
This includes:
Construct a ds:Reference from an org.w3c.dom.Element .
Create a new reference
Document doc;
MessageDigestAlgorithm sha1 = MessageDigestAlgorithm.getInstance("http://#sha1");
Reference ref = new Reference(new XMLSignatureInput(new FileInputStream("1.gif"),
"http://localhost/1.gif",
(Transforms) null, sha1);
Element refElem = ref.toElement(doc);
Verify a reference
Element refElem = doc.getElement("Reference"); // PSEUDO
Reference ref = new Reference(refElem);
String url = ref.getURI();
ref.setData(new XMLSignatureInput(new FileInputStream(url)));
if (ref.verify()) {
System.out.println("verified");
}
<element name="Reference" type="ds:ReferenceType"/>
<complexType name="ReferenceType">
<sequence>
<element ref="ds:Transforms" minOccurs="0"/>
<element ref="ds:DigestMethod"/>
<element ref="ds:DigestValue"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
<attribute name="URI" type="anyURI" use="optional"/>
<attribute name="Type" type="anyURI" use="optional"/>
</complexType>
ObjectContainer, Manifest
| Modifier and Type | Field and Description |
|---|---|
| private Element | |
| private Element | |
| private static final Logger | |
| private Manifest | |
| public static final String | MANIFEST_URI
Field MANIFEST_URI |
| public static final int | MAXIMUM_TRANSFORM_COUNT
The maximum number of transforms per reference, if secure validation is enabled. |
| public static final String | OBJECT_URI
Field OBJECT_URI |
| private ReferenceData | |
| private boolean | |
| private static final Set | |
| private Transforms | |
| private XMLSignatureInput | |
| private static boolean | useC14N11
Look up useC14N11 system property. |
| Access | Constructor and Description |
|---|---|
| protected | Reference(Document
the doc, String Document in which XMLsignature is placedthe URI of the resource where the XML instance will be stored baseURI, String URI indicate where is data which will digested referenceURI, Manifest manifest, Transforms Transforms applied to dataDigest algorithm which is
applied to the data
TODO should we throw XMLSignatureException if MessageDigestAlgoURI is wrong?Constructor Reference |
| protected | Reference(Element
Reference elementthe URI of the resource where the XML instance was stored baseURI, Manifest is the manifest)Manifest of SignedInfo in which the Reference occurs.
We need this because the Manifest has the individual ResourceResolvers which have
been set by the user |
| protected | Reference(Element
Reference elementthe URI of the resource where the XML instance was stored baseURI, Manifest is the manifest, boolean Manifest of SignedInfo in which the Reference occurs.whether secure validation is enabled or not
We need this because the Manifest has the individual secureValidation)ResourceResolvers which have
been set by the user |
| Modifier and Type | Method and Description |
|---|---|
| private void | cacheDereferencedElement(XMLSignatureInput input)
Store the dereferenced Element(s) so that it/they can be retrieved later. |
| private byte[] | Returns: reference Calculate the digest of this reference.true if validating the reference validating)Method calculateDigest |
| protected XMLSignatureInput | Returns: the element to digestwhere to write the transformation can be null. os)This method returns the |
| public void | |
| public String | getBaseLocalName()
Implements abstract com. Method getBaseLocalName Returns the localname of the Elements of the sub-class. |
| private XMLSignatureInput | |
| public XMLSignatureInput | Returns: a XMLSignatureInput with all transformations applied.Returns the XMLSignatureInput which is the result of the Transforms. |
| public XMLSignatureInput | Returns: the XMLSignatureInput of the source of this referenceReturns the XMLSignatureInput which is created by de-referencing the URI attribute. |
| public byte[] | |
| public String | |
| public String | Returns: Id theId attribute of this Reference elementReturns the |
| public MessageDigestAlgorithm | |
| public XMLSignatureInput | Returns: Gets a the node doing everything till the first c14n is neededThis method returns the XMLSignatureInput which represents the node set before some kind of canonicalization is applied for the first time. |
| private byte[] | Returns: a pre-calculated digest value.XMLSignature input)Get the pre-calculated digest value from the XMLSignatureInput. |
| public ReferenceData | getReferenceData()
Get the ReferenceData that corresponds to the cached representation of the dereferenced object before transformation. |
| public byte[] | Returns: the bytes that will be used to generated digest.Method getReferencedBytes |
| public Transforms | |
| public XMLSignatureInput | Returns: the transformed output(i.e. what is going to be digested).This method only works after a call to verify. |
| public String | Returns: thetype attribute of the ReferenceReturn the |
| public String | |
| private void | |
| public void | |
| public void | |
| public void | |
| public boolean | Returns: true if the Reference type indicates that this Reference points to aManifestMethod isReferenceToManifest
This returns true if the |
| public boolean | Returns: true if the Reference type indicates that this Reference points to anObjectMethod isReferenceToObject
This returns true if the |
| public boolean | Returns: true if reference validation is success, otherwise falseTests reference validation is success or false |
| digestMethodElem | back to summary |
|---|---|
| private Element digestMethodElem | |
| digestValueElement | back to summary |
|---|---|
| private Element digestValueElement | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG Hides com. | |
| manifest | back to summary |
|---|---|
| private Manifest manifest | |
| MANIFEST_URI | back to summary |
|---|---|
| public static final String MANIFEST_URI Field MANIFEST_URI | |
| MAXIMUM_TRANSFORM_COUNT | back to summary |
|---|---|
| public static final int MAXIMUM_TRANSFORM_COUNT The maximum number of transforms per reference, if secure validation is enabled. | |
| OBJECT_URI | back to summary |
|---|---|
| public static final String OBJECT_URI Field OBJECT_URI | |
| referenceData | back to summary |
|---|---|
| private ReferenceData referenceData | |
| secureValidation | back to summary |
|---|---|
| private boolean secureValidation | |
| TRANSFORM_ALGORITHMS | back to summary |
|---|---|
| private static final Set<String> TRANSFORM_ALGORITHMS | |
| transforms | back to summary |
|---|---|
| private Transforms transforms | |
| transformsOutput | back to summary |
|---|---|
| private XMLSignatureInput transformsOutput | |
| useC14N11 | back to summary |
|---|---|
| private static boolean useC14N11 Look up useC14N11 system property. If true, an explicit C14N11 transform will be added if necessary when generating the signature. See section 3.1.1 of http://www.w3.org/2007/xmlsec/Drafts/xmldsig-core/ for more info.
| |
| Reference | back to summary |
|---|---|
| protected Reference(Document doc, String baseURI, String referenceURI, Manifest manifest, Transforms transforms, String messageDigestAlgorithm) throws XMLSignatureException Constructor Reference
| |
| Reference | back to summary |
|---|---|
| protected Reference(Element element, String baseURI, Manifest manifest) throws XMLSecurityException Build a
| |
| Reference | back to summary |
|---|---|
| protected Reference(Element element, String baseURI, Manifest manifest, boolean secureValidation) throws XMLSecurityException Build a
| |
| cacheDereferencedElement | back to summary |
|---|---|
| private void cacheDereferencedElement(XMLSignatureInput input) Store the dereferenced Element(s) so that it/they can be retrieved later. | |
| calculateDigest | back to summary |
|---|---|
| private byte[] calculateDigest(boolean validating) throws ReferenceNotInitializedException, XMLSignatureException Method calculateDigest
| |
| dereferenceURIandPerformTransforms | back to summary |
|---|---|
| protected XMLSignatureInput dereferenceURIandPerformTransforms(OutputStream os) throws XMLSignatureException This method returns the
| |
| generateDigestValue | back to summary |
|---|---|
| public void generateDigestValue() throws XMLSignatureException, ReferenceNotInitializedException Method generateDigestValue | |
| getBaseLocalName | back to summary |
|---|---|
| public String getBaseLocalName() Implements abstract com. Doc from com. Method getBaseLocalName Returns the localname of the Elements of the sub-class.
| |
| getContentsAfterTransformation | back to summary |
|---|---|
| private XMLSignatureInput getContentsAfterTransformation(XMLSignatureInput input, OutputStream os) throws XMLSignatureException | |
| getContentsAfterTransformation | back to summary |
|---|---|
| public XMLSignatureInput getContentsAfterTransformation() throws XMLSignatureException Returns the XMLSignatureInput which is the result of the Transforms.
| |
| getContentsBeforeTransformation | back to summary |
|---|---|
| public XMLSignatureInput getContentsBeforeTransformation() throws ReferenceNotInitializedException Returns the XMLSignatureInput which is created by de-referencing the URI attribute.
| |
| getDigestValue | back to summary |
|---|---|
| public byte[] getDigestValue() throws XMLSecurityException Returns the digest value.
| |
| getHTMLRepresentation | back to summary |
|---|---|
| public String getHTMLRepresentation() throws XMLSignatureException Method getHTMLRepresentation
| |
| getId | back to summary |
|---|---|
| public String getId() Returns the
| |
| getMessageDigestAlgorithm | back to summary |
|---|---|
| public MessageDigestAlgorithm getMessageDigestAlgorithm() throws XMLSignatureException Returns | |
| getNodesetBeforeFirstCanonicalization | back to summary |
|---|---|
| public XMLSignatureInput getNodesetBeforeFirstCanonicalization() throws XMLSignatureException This method returns the XMLSignatureInput which represents the node set before some kind of canonicalization is applied for the first time.
| |
| getPreCalculatedDigest | back to summary |
|---|---|
| private byte[] getPreCalculatedDigest(XMLSignatureInput input) throws ReferenceNotInitializedException Get the pre-calculated digest value from the XMLSignatureInput.
| |
| getReferenceData | back to summary |
|---|---|
| public ReferenceData getReferenceData() Get the ReferenceData that corresponds to the cached representation of the dereferenced object before transformation. | |
| getReferencedBytes | back to summary |
|---|---|
| public byte[] getReferencedBytes() throws ReferenceNotInitializedException, XMLSignatureException Method getReferencedBytes
| |
| getTransforms | back to summary |
|---|---|
| public Transforms getTransforms() throws XMLSignatureException, InvalidTransformException, TransformationException, XMLSecurityException Method getTransforms
| |
| getTransformsOutput | back to summary |
|---|---|
| public XMLSignatureInput getTransformsOutput() This method only works after a call to verify.
| |
| getType | back to summary |
|---|---|
| public String getType() Return the
| |
| getURI | back to summary |
|---|---|
| public String getURI() Returns the
| |
| setDigestValueElement | back to summary |
|---|---|
| private void setDigestValueElement(byte[] digestValue) Method setDigestValueElement | |
| setId | back to summary |
|---|---|
| public void setId(String id) Sets the
| |
| setType | back to summary |
|---|---|
| public void setType(String type) Sets the
| |
| setURI | back to summary |
|---|---|
| public void setURI(String uri) Sets the
| |
| typeIsReferenceToManifest | back to summary |
|---|---|
| public boolean typeIsReferenceToManifest() Method isReferenceToManifest
This returns true if the
| |
| typeIsReferenceToObject | back to summary |
|---|---|
| public boolean typeIsReferenceToObject() Method isReferenceToObject
This returns true if the
| |
| verify | back to summary |
|---|---|
| public boolean verify() throws ReferenceNotInitializedException, XMLSecurityException Tests reference validation is success or false
| |