org.apache.jcp.xml.dsig.internal.dom
Class DOMReference

java.lang.Object
  extended by org.apache.jcp.xml.dsig.internal.dom.BaseStructure
      extended by org.apache.jcp.xml.dsig.internal.dom.DOMStructure
          extended by org.apache.jcp.xml.dsig.internal.dom.DOMReference
All Implemented Interfaces:
DOMURIReference, Reference, URIReference, XMLStructure

public final class DOMReference
extends DOMStructure
implements Reference, DOMURIReference

DOM-based implementation of Reference.

Author:
Sean Mullan, Joyce Leung

Field Summary
static int MAXIMUM_TRANSFORM_COUNT
          The maximum number of transforms per reference, if secure validation is enabled.
 
Constructor Summary
DOMReference(Element refElem, XMLCryptoContext context, Provider provider)
          Creates a DOMReference from an element.
DOMReference(String uri, String type, DigestMethod dm, List<? extends Transform> appliedTransforms, Data result, List<? extends Transform> transforms, String id, byte[] digestValue, Provider provider)
           
DOMReference(String uri, String type, DigestMethod dm, List<? extends Transform> appliedTransforms, Data result, List<? extends Transform> transforms, String id, Provider provider)
           
DOMReference(String uri, String type, DigestMethod dm, List<? extends Transform> transforms, String id, Provider provider)
          Creates a Reference from the specified parameters.
 
Method Summary
 void digest(XMLSignContext signContext)
           
 boolean equals(Object o)
           
 byte[] getCalculatedDigestValue()
          Returns the calculated digest value of this Reference after a validation operation.
 Data getDereferencedData()
          Returns the dereferenced data, if reference caching is enabled.
 InputStream getDigestInputStream()
          Returns the pre-digested input stream, if reference caching is enabled.
 DigestMethod getDigestMethod()
          Returns the digest method of this Reference.
 byte[] getDigestValue()
          Returns the digest value of this Reference.
 Node getHere()
          Returns the here node.
 String getId()
          Returns the optional Id attribute of this Reference, which permits this reference to be referenced from elsewhere.
 List<Transform> getTransforms()
          Returns an unmodifiable list of Transforms that are contained in this Reference.
 String getType()
          Returns the type of data referenced by this URI.
 String getURI()
          Returns the URI of the referenced data object.
 int hashCode()
           
 void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context)
           
 boolean validate(XMLValidateContext validateContext)
          Validates this reference.
 
Methods inherited from class org.apache.jcp.xml.dsig.internal.dom.BaseStructure
isFeatureSupported, textOfNode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.xml.crypto.XMLStructure
isFeatureSupported
 

Field Detail

MAXIMUM_TRANSFORM_COUNT

public static final int MAXIMUM_TRANSFORM_COUNT
The maximum number of transforms per reference, if secure validation is enabled.

See Also:
Constant Field Values
Constructor Detail

DOMReference

public DOMReference(String uri,
                    String type,
                    DigestMethod dm,
                    List<? extends Transform> transforms,
                    String id,
                    Provider provider)
Creates a Reference from the specified parameters.

Parameters:
uri - the URI (may be null)
type - the type (may be null)
dm - the digest method
transforms - a list of Transforms. The list is defensively copied to protect against subsequent modification. May be null or empty.
id - the reference ID (may be null)
Throws:
NullPointerException - if dm is null
ClassCastException - if any of the transforms are not of type Transform

DOMReference

public DOMReference(String uri,
                    String type,
                    DigestMethod dm,
                    List<? extends Transform> appliedTransforms,
                    Data result,
                    List<? extends Transform> transforms,
                    String id,
                    Provider provider)

DOMReference

public DOMReference(String uri,
                    String type,
                    DigestMethod dm,
                    List<? extends Transform> appliedTransforms,
                    Data result,
                    List<? extends Transform> transforms,
                    String id,
                    byte[] digestValue,
                    Provider provider)

DOMReference

public DOMReference(Element refElem,
                    XMLCryptoContext context,
                    Provider provider)
             throws MarshalException
Creates a DOMReference from an element.

Parameters:
refElem - a Reference element
Throws:
MarshalException
Method Detail

getDigestMethod

public DigestMethod getDigestMethod()
Description copied from interface: Reference
Returns the digest method of this Reference.

Specified by:
getDigestMethod in interface Reference
Returns:
the digest method

getId

public String getId()
Description copied from interface: Reference
Returns the optional Id attribute of this Reference, which permits this reference to be referenced from elsewhere.

Specified by:
getId in interface Reference
Returns:
the Id attribute (may be null if not specified)

getURI

public String getURI()
Description copied from interface: URIReference
Returns the URI of the referenced data object.

Specified by:
getURI in interface URIReference
Returns:
the URI of the data object in RFC 2396 format (may be null if not specified)

getType

public String getType()
Description copied from interface: URIReference
Returns the type of data referenced by this URI.

Specified by:
getType in interface URIReference
Returns:
the type (a URI) of the data object (may be null if not specified)

getTransforms

public List<Transform> getTransforms()
Description copied from interface: Reference
Returns an unmodifiable list of Transforms that are contained in this Reference.

Specified by:
getTransforms in interface Reference
Returns:
an unmodifiable list of Transforms (may be empty but never null)

getDigestValue

public byte[] getDigestValue()
Description copied from interface: Reference
Returns the digest value of this Reference.

Specified by:
getDigestValue in interface Reference
Returns:
the raw digest value, or null if this reference has not been digested yet. Each invocation of this method returns a new clone to protect against subsequent modification.

getCalculatedDigestValue

public byte[] getCalculatedDigestValue()
Description copied from interface: Reference
Returns the calculated digest value of this Reference after a validation operation. This method is useful for debugging if the reference fails to validate.

Specified by:
getCalculatedDigestValue in interface Reference
Returns:
the calculated digest value, or null if this reference has not been validated yet. Each invocation of this method returns a new clone to protect against subsequent modification.

marshal

public void marshal(XmlWriter xwriter,
                    String dsPrefix,
                    XMLCryptoContext context)
             throws MarshalException
Specified by:
marshal in class DOMStructure
Throws:
MarshalException

digest

public void digest(XMLSignContext signContext)
            throws XMLSignatureException
Throws:
XMLSignatureException

validate

public boolean validate(XMLValidateContext validateContext)
                 throws XMLSignatureException
Description copied from interface: Reference
Validates this reference. This method verifies the digest of this reference.

This method only validates the reference the first time it is invoked. On subsequent invocations, it returns a cached result.

Specified by:
validate in interface Reference
Parameters:
validateContext - the validating context
Returns:
true if this reference was validated successfully; false otherwise
Throws:
XMLSignatureException - if an unexpected exception occurs while validating the reference

getDereferencedData

public Data getDereferencedData()
Description copied from interface: Reference
Returns the dereferenced data, if reference caching is enabled. This is the result of dereferencing the URI of this reference during a validation or generation operation.

Specified by:
getDereferencedData in interface Reference
Returns:
the dereferenced data, or null if reference caching is not enabled or this reference has not been generated or validated

getDigestInputStream

public InputStream getDigestInputStream()
Description copied from interface: Reference
Returns the pre-digested input stream, if reference caching is enabled. This is the input to the digest operation during a validation or signing operation.

Specified by:
getDigestInputStream in interface Reference
Returns:
an input stream containing the pre-digested input, or null if reference caching is not enabled or this reference has not been generated or validated

getHere

public Node getHere()
Description copied from interface: DOMURIReference
Returns the here node.

Specified by:
getHere in interface DOMURIReference
Returns:
the attribute or processing instruction node or the parent element of the text node that directly contains the URI

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2000–2013 The Apache Software Foundation. All rights reserved.