Class Reference


public class Reference extends SignatureElementProxy
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>
See Also: