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

java.lang.Object
  extended by org.jcp.xml.dsig.internal.dom.DOMStructure
      extended by org.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

Constructor Summary
DOMReference(org.w3c.dom.Element refElem, XMLCryptoContext context, java.security.Provider provider)
          Creates a DOMReference from an element.
DOMReference(java.lang.String uri, java.lang.String type, DigestMethod dm, java.util.List appliedTransforms, Data result, java.util.List transforms, java.lang.String id, byte[] digestValue, java.security.Provider provider)
           
DOMReference(java.lang.String uri, java.lang.String type, DigestMethod dm, java.util.List appliedTransforms, Data result, java.util.List transforms, java.lang.String id, java.security.Provider provider)
           
DOMReference(java.lang.String uri, java.lang.String type, DigestMethod dm, java.util.List transforms, java.lang.String id, java.security.Provider provider)
          Creates a Reference from the specified parameters.
 
Method Summary
 void digest(XMLSignContext signContext)
           
 boolean equals(java.lang.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.
 java.io.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.
 org.w3c.dom.Node getHere()
          Returns the here node.
 java.lang.String getId()
          Returns the optional Id attribute of this Reference, which permits this reference to be referenced from elsewhere.
 java.util.List getTransforms()
          Returns an unmodifiable list of Transforms that are contained in this Reference.
 java.lang.String getType()
          Returns the type of data referenced by this URI.
 java.lang.String getURI()
          Returns the URI of the referenced data object.
 int hashCode()
           
 void marshal(org.w3c.dom.Node parent, java.lang.String dsPrefix, DOMCryptoContext context)
           
 boolean validate(XMLValidateContext validateContext)
          Validates this reference.
 
Methods inherited from class org.jcp.xml.dsig.internal.dom.DOMStructure
isFeatureSupported
 
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
 

Constructor Detail

DOMReference

public DOMReference(java.lang.String uri,
                    java.lang.String type,
                    DigestMethod dm,
                    java.util.List transforms,
                    java.lang.String id,
                    java.security.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:
java.lang.NullPointerException - if dm is null
java.lang.ClassCastException - if any of the transforms are not of type Transform

DOMReference

public DOMReference(java.lang.String uri,
                    java.lang.String type,
                    DigestMethod dm,
                    java.util.List appliedTransforms,
                    Data result,
                    java.util.List transforms,
                    java.lang.String id,
                    java.security.Provider provider)

DOMReference

public DOMReference(java.lang.String uri,
                    java.lang.String type,
                    DigestMethod dm,
                    java.util.List appliedTransforms,
                    Data result,
                    java.util.List transforms,
                    java.lang.String id,
                    byte[] digestValue,
                    java.security.Provider provider)

DOMReference

public DOMReference(org.w3c.dom.Element refElem,
                    XMLCryptoContext context,
                    java.security.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 java.lang.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 java.lang.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 java.lang.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 java.util.List 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(org.w3c.dom.Node parent,
                    java.lang.String dsPrefix,
                    DOMCryptoContext 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 java.io.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 org.w3c.dom.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(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2000-2011 The Apache Software Foundation. All Rights Reserved.