|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.xml.security.utils.ElementProxy
org.apache.xml.security.utils.SignatureElementProxy
org.apache.xml.security.signature.Reference
public class Reference
Handles <ds:Reference> elements.
This includes:
Construct a ds:Reference from an 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| Field Summary | |
|---|---|
static java.lang.String |
MANIFEST_URI
Field MANIFEST_URI |
static int |
MAXIMUM_TRANSFORM_COUNT
The maximum number of transforms per reference, if secure validation is enabled. |
static java.lang.String |
OBJECT_URI
Field OBJECT_URI |
| Fields inherited from class org.apache.xml.security.utils.ElementProxy |
|---|
baseURI, constructionElement, doc |
| Constructor Summary | |
|---|---|
protected |
Reference(org.w3c.dom.Document doc,
java.lang.String baseURI,
java.lang.String referenceURI,
Manifest manifest,
Transforms transforms,
java.lang.String messageDigestAlgorithm)
Constructor Reference |
protected |
Reference(org.w3c.dom.Element element,
java.lang.String baseURI,
Manifest manifest)
Build a Reference from an Element |
protected |
Reference(org.w3c.dom.Element element,
java.lang.String baseURI,
Manifest manifest,
boolean secureValidation)
Build a Reference from an Element |
| Method Summary | |
|---|---|
protected XMLSignatureInput |
dereferenceURIandPerformTransforms(java.io.OutputStream os)
This method returns the XMLSignatureInput which is referenced by the
URI Attribute. |
void |
generateDigestValue()
Method generateDigestValue |
java.lang.String |
getBaseLocalName()
Method getBaseLocalName |
XMLSignatureInput |
getContentsAfterTransformation()
Returns the XMLSignatureInput which is the result of the Transforms. |
XMLSignatureInput |
getContentsBeforeTransformation()
Returns the XMLSignatureInput which is created by de-referencing the URI attribute. |
byte[] |
getDigestValue()
Returns the digest value. |
java.lang.String |
getHTMLRepresentation()
Method getHTMLRepresentation |
java.lang.String |
getId()
Returns the Id attribute of this Reference element |
MessageDigestAlgorithm |
getMessageDigestAlgorithm()
Returns MessageDigestAlgorithm |
XMLSignatureInput |
getNodesetBeforeFirstCanonicalization()
This method returns the XMLSignatureInput which represents the node set before some kind of canonicalization is applied for the first time. |
ReferenceData |
getReferenceData()
Get the ReferenceData that corresponds to the cached representation of the dereferenced object before transformation. |
byte[] |
getReferencedBytes()
Method getReferencedBytes |
Transforms |
getTransforms()
Method getTransforms |
XMLSignatureInput |
getTransformsOutput()
This method only works works after a call to verify. |
java.lang.String |
getType()
Return the type atttibute of the Reference indicate whether an
ds:Object, ds:SignatureProperty, or ds:Manifest
element |
java.lang.String |
getURI()
Returns the URI of this Reference element |
void |
setId(java.lang.String id)
Sets the Id attribute of this Reference element |
void |
setType(java.lang.String type)
Sets the type atttibute of the Reference indicate whether an
ds:Object, ds:SignatureProperty, or ds:Manifest
element. |
void |
setURI(java.lang.String uri)
Sets the URI of this Reference element |
boolean |
typeIsReferenceToManifest()
Method isReferenceToManifest This returns true if the Type attribute of the
Reference element points to a #Manifest element |
boolean |
typeIsReferenceToObject()
Method isReferenceToObject This returns true if the Type attribute of the
Reference element points to a #Object element |
boolean |
verify()
Tests reference validation is success or false |
| Methods inherited from class org.apache.xml.security.utils.SignatureElementProxy |
|---|
getBaseNamespace |
| Methods inherited from class org.apache.xml.security.utils.ElementProxy |
|---|
addBase64Element, addBase64Text, addBigIntegerElement, addText, addTextElement, createElementForFamily, createElementForFamilyLocal, getBaseURI, getBigIntegerFromChildElement, getBytesFromChildElement, getBytesFromTextChild, getDefaultPrefix, getDocument, getElement, getElementPlusReturns, getTextFromChildElement, getTextFromTextChild, length, registerDefaultPrefixes, setDefaultPrefix, setElement, setXPathNamespaceContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String OBJECT_URI
public static final java.lang.String MANIFEST_URI
public static final int MAXIMUM_TRANSFORM_COUNT
| Constructor Detail |
|---|
protected Reference(org.w3c.dom.Document doc,
java.lang.String baseURI,
java.lang.String referenceURI,
Manifest manifest,
Transforms transforms,
java.lang.String messageDigestAlgorithm)
throws XMLSignatureException
doc - the Document in which XMLsignature is placedbaseURI - the URI of the resource where the XML instance will be storedreferenceURI - URI indicate where is data which will digestedmanifest - transforms - Transforms applied to datamessageDigestAlgorithm - Digest algorithm which is
applied to the data
TODO should we throw XMLSignatureException if MessageDigestAlgoURI is wrong?
XMLSignatureException
protected Reference(org.w3c.dom.Element element,
java.lang.String baseURI,
Manifest manifest)
throws XMLSecurityException
Reference from an Element
element - Reference elementbaseURI - the URI of the resource where the XML instance was storedmanifest - is the 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
XMLSecurityException
protected Reference(org.w3c.dom.Element element,
java.lang.String baseURI,
Manifest manifest,
boolean secureValidation)
throws XMLSecurityException
Reference from an Element
element - Reference elementbaseURI - the URI of the resource where the XML instance was storedmanifest - is the Manifest of SignedInfo in which the Reference occurs.secureValidation - whether secure validation is enabled or not
We need this because the Manifest has the individual ResourceResolvers which have
been set by the user
XMLSecurityException| Method Detail |
|---|
public MessageDigestAlgorithm getMessageDigestAlgorithm()
throws XMLSignatureException
MessageDigestAlgorithm
MessageDigestAlgorithm
XMLSignatureExceptionpublic void setURI(java.lang.String uri)
URI of this Reference element
uri - the URI of this Reference elementpublic java.lang.String getURI()
URI of this Reference element
URI of this Reference elementpublic void setId(java.lang.String id)
Id attribute of this Reference element
id - the Id attribute of this Reference elementpublic java.lang.String getId()
Id attribute of this Reference element
Id attribute of this Reference elementpublic void setType(java.lang.String type)
type atttibute of the Reference indicate whether an
ds:Object, ds:SignatureProperty, or ds:Manifest
element.
type - the type attribute of the Referencepublic java.lang.String getType()
type atttibute of the Reference indicate whether an
ds:Object, ds:SignatureProperty, or ds:Manifest
element
type attribute of the Referencepublic boolean typeIsReferenceToObject()
Type attribute of the
Reference element points to a #Object element
Objectpublic boolean typeIsReferenceToManifest()
Type attribute of the
Reference element points to a #Manifest element
Manifest
public void generateDigestValue()
throws XMLSignatureException,
ReferenceNotInitializedException
ReferenceNotInitializedException
XMLSignatureException
public XMLSignatureInput getContentsBeforeTransformation()
throws ReferenceNotInitializedException
ReferenceNotInitializedException - If the resolver found any
problem resolving the reference
public XMLSignatureInput getContentsAfterTransformation()
throws XMLSignatureException
XMLSignatureException
public XMLSignatureInput getNodesetBeforeFirstCanonicalization()
throws XMLSignatureException
XMLSignatureException
public java.lang.String getHTMLRepresentation()
throws XMLSignatureException
XMLSignatureExceptionpublic XMLSignatureInput getTransformsOutput()
public ReferenceData getReferenceData()
protected XMLSignatureInput dereferenceURIandPerformTransforms(java.io.OutputStream os)
throws XMLSignatureException
XMLSignatureInput which is referenced by the
URI Attribute.
os - where to write the transformation can be null.
XMLSignatureExceptionManifest.verifyReferences()
public Transforms getTransforms()
throws XMLSignatureException,
InvalidTransformException,
TransformationException,
XMLSecurityException
InvalidTransformException
TransformationException
XMLSecurityException
XMLSignatureException
public byte[] getReferencedBytes()
throws ReferenceNotInitializedException,
XMLSignatureException
ReferenceNotInitializedException
XMLSignatureException
public byte[] getDigestValue()
throws Base64DecodingException,
XMLSecurityException
Base64DecodingException - if Reference contains no proper base64 encoded data.
XMLSecurityException - if the Reference does not contain a DigestValue element
public boolean verify()
throws ReferenceNotInitializedException,
XMLSecurityException
ReferenceNotInitializedException
XMLSecurityExceptionpublic java.lang.String getBaseLocalName()
getBaseLocalName in class ElementProxy
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||