public class ReferenceImpl extends ReferenceType implements Reference, DOMURIReference
Reference that supports the DOM XML
representation and processing mechanism.ReferenceType.SubTreeNodeSetFixDOMStructure.NodeWrapper| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
calculatedDigestValue_
The calculated digest value.
|
protected DigestMethodImpl |
digestMethod_
The
DigestMethod. |
protected DigestValueImpl |
digestValue_
The
DigestValue. |
protected List |
distNS_
Has the distributed NamespaceDeclarations during the processing if the
Reference was built with NodeSetData as Data supplied and applied
Transforms.
|
protected boolean |
valid_
Is this
Reference valid. |
cachedCanonInputData_, cachedDereferencedData_, cachedDigestInput_, id_, result_, transforms_type_, uri_implMap_, state_, STATE_CREATED, STATE_MARSHALED, STATE_UNINITIALIZED, STATE_UNMARSHALED| Modifier | Constructor and Description |
|---|---|
|
ReferenceImpl(DOMCryptoContext context,
Node node)
Creates a new instance of this
ReferenceImpl with the
specified context and node to unmarshal from. |
|
ReferenceImpl(String uri,
DigestMethodImpl dm,
List appliedTransforms,
Data result,
List transforms,
String type,
String id)
Creates a
Reference with the specified parameters. |
|
ReferenceImpl(String uri,
DigestMethodImpl digestMethod,
List transforms,
String type,
String id)
Creates a new instance of this
ReferenceImpl with the
specified URI-attribute value, digest method, list of
TransformImpls, Type-attribute value and
Id-attribute value. |
|
ReferenceImpl(String uri,
DigestMethodImpl digestMethod,
List transforms,
String type,
String id,
byte[] digestValue)
Creates a new instance of this
ReferenceImpl with the
specified URI-attribute value, digest method, list of
TransformImpls, Type-attribute value and
Id-attribute value and pre-calculated digest value. |
protected |
ReferenceImpl(String uri,
TransformsImpl transforms,
String type,
String id)
Creates a new instance of this
ReferenceImpl with the
specified URI-attribute value, digest method, transforms of
TransformsType containing a list of
Transforms, Type-attribute value
and Id-attribute value. |
| Modifier and Type | Method and Description |
|---|---|
void |
generateReference(DOMCryptoContext context)
Calculates the digest value of this
Reference and appends a
DigestValue element with the calculated digest value. |
byte[] |
getCalculatedDigestValue()
Returns the calculated digest value of this
Reference after a
validation operation. |
protected List |
getChildStructures()
Returns the
DigestMethodImpl and DigestValueImpl. |
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. |
String |
getNamespace()
Returns the namespace URI of the represented XML element.
|
protected void |
putChildStructure(DOMStructure childStructure)
Puts the
DigestMethodImpl and DigestValueImpl. |
void |
setPreCalculatedDigestValue(DOMCryptoContext context,
byte[] digestValue)
Sets pre calculated digest value for this
Reference and appends
it to the DigestValue child before signature creation. |
boolean |
validate(XMLValidateContext validateContext)
Validates this reference.
|
boolean |
validateReference(XMLValidateContext validateContext)
Validates the Reference according to the Reference Validation rules defined
in XML-Signature Syntax and
Processing section 3.2.2
Reference Validation .
|
dereference, dereferenceAndCanonicalize, dereferenceButDontTransform, getCanonInputData, getDereferencedData, getId, getLocalName, getTransforms, marshalIDAttribute, unmarshalAttributesgetHere, getType, getURI, marshalAttributesaddBytesToElement, addBytesToElement, clearMarshalling, clearMarshalling, getBytesFromElement, getBytesFromElementStream, getChildStructureVersion, getImplClass, getInstance, getInstance, getNode, getParentStructure, getParentStructureOf, getQualifiedName, getQualifiedName, hasNSDeclAttrInScope, isFeatureSupported, isNSDeclInScope, marshal, marshalElement, newIDforLookUp, putImplClass, setBackToCompatibilityPrior1_14, setNode, setParentStructure, toString, unmarshal, unmarshalElement, unmarshalIDAttribute, unmarshalStructures, wrapNodeclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetDereferencedData, getId, getTransformsisFeatureSupportedgetHeregetType, getURIprotected DigestMethodImpl digestMethod_
DigestMethod. (may never be null)protected DigestValueImpl digestValue_
DigestValue. (may never be null)protected byte[] calculatedDigestValue_
protected boolean valid_
Reference valid.protected List distNS_
public ReferenceImpl(DOMCryptoContext context, Node node) throws MarshalException
ReferenceImpl with the
specified context and node to unmarshal from.context - the contextnode - the node to unmarshal fromMarshalException - if an exception occurs during unmarshalingprotected ReferenceImpl(String uri, TransformsImpl transforms, String type, String id)
ReferenceImpl with the
specified URI-attribute value, digest method, transforms of
TransformsType containing a list of
Transforms, Type-attribute value
and Id-attribute value.public ReferenceImpl(String uri, DigestMethodImpl digestMethod, List transforms, String type, String id)
ReferenceImpl with the
specified URI-attribute value, digest method, list of
TransformImpls, Type-attribute value and
Id-attribute value.uri - the URI-attribute value (may be null)digestMethod - the digest methodtransforms - a list of TransformImpls (may be null or empty)type - the Type-attribute value (may be null)id - the Id-attribute value (may be null)NullPointerException - if digestMethod is nullIllegalArgumentException - if uri is not RFC 2396 compliantClassCastException - if any of the transforms is not of type
TransformImplpublic ReferenceImpl(String uri, DigestMethodImpl digestMethod, List transforms, String type, String id, byte[] digestValue)
ReferenceImpl with the
specified URI-attribute value, digest method, list of
TransformImpls, Type-attribute value and
Id-attribute value and pre-calculated digest value.uri - the URI-attribute value (may be null)digestMethod - the digest methodtransforms - a list of TransformImpls (may be null or empty)type - the Type-attribute value (may be null)id - the Id-attribute value (may be null)digestValue - the pre-calculated digest value. The array is cloned to protect
against subsequent modification.NullPointerException - if digestMethod or digestValue is
nullIllegalArgumentException - if uri is not RFC 2396 compliantClassCastException - if any of the transforms is not of type
TransformImplpublic ReferenceImpl(String uri, DigestMethodImpl dm, List appliedTransforms, Data result, List transforms, String type, String id)
Reference with the specified parameters.
This method is useful when a list of transforms have already been applied
to the Reference. See for example, the
OASIS-DSS (Digital Signature Services) specification.
When an XMLSignature containing this reference is generated,
the specified transforms (if non-null) are applied to the
specified result. The Transforms element of the
resulting Reference element is set to the concatenation of the
appliedTransforms and transforms.
uri - the reference URI (may be null)dm - the digest methodappliedTransforms - a list of
Transform
s that have already been applied. The list is defensively copied
to protect against subsequent modification. The list must contain at
least one entry.result - the result of processing the sequence of
appliedTransformstransforms - a list of
Transform
s that are to be applied when generating the signature. The list
is defensively copied to protect against subsequent modification.
May be null or empty.type - the reference type, as a URI (may be null)id - the reference ID (may be null)ClassCastException - if any of the transforms (in either list) are not of type
TransformIllegalArgumentException - if uri is not RFC 2396 compliant or
appliedTransforms is emptyNullPointerException - if
dm, appliedTransforms or
result is nullpublic String getNamespace()
DOMStructuregetNamespace in class DOMStructureDOMStructure.getNamespace()public DigestMethod getDigestMethod()
javax.xml.crypto.dsig.ReferenceReference.getDigestMethod in interface ReferenceReference.getDigestMethod()public byte[] getDigestValue()
javax.xml.crypto.dsig.ReferenceReference.getDigestValue in interface Referencenull if this reference has
not been digested yet. Each invocation of this method returns a new
clone to protect against subsequent modification.Reference.getDigestValue()public byte[] getCalculatedDigestValue()
javax.xml.crypto.dsig.ReferenceReference after a
validation operation. This method is useful for debugging if the reference
fails to validate.getCalculatedDigestValue in interface Referencenull if this reference
has not been validated yet. Each invocation of this method returns
a new clone to protect against subsequent modification.Reference.getCalculatedDigestValue()public InputStream getDigestInputStream()
javax.xml.crypto.dsig.ReferencegetDigestInputStream in interface Referencenull if reference caching is not enabled or this
reference has not been generated or validatedReference.getDigestInputStream()protected List getChildStructures()
DigestMethodImpl and DigestValueImpl.getChildStructures in class ReferenceTypeDOMStructures (may be empty, but never
null)protected void putChildStructure(DOMStructure childStructure) throws MarshalException
DigestMethodImpl and DigestValueImpl.putChildStructure in class ReferenceTypechildStructure - the unmarshalled child structureMarshalExceptionpublic void generateReference(DOMCryptoContext context) throws MarshalException, XMLSignatureException
Reference and appends a
DigestValue element with the calculated digest value.context - the marshal contextMarshalException - if an exception occurs during marshalingXMLSignatureException - if an unexpected exception occurs during digestingpublic void setPreCalculatedDigestValue(DOMCryptoContext context, byte[] digestValue) throws MarshalException, XMLSignatureException
Reference and appends
it to the DigestValue child before signature creation.
DigestValue child must already exist,
but the hash value itsself must be null.
Hence the method does not override the hash that may have been already computed.
context - the marshal contextdigestValue - The digest value.MarshalException - if an exception occurs during marshalingXMLSignatureException - if an unexpected exception occurs during digestingpublic boolean validate(XMLValidateContext validateContext) throws XMLSignatureException
javax.xml.crypto.dsig.ReferenceThis method only validates the reference the first time it is invoked. On subsequent invocations, it returns a cached result.
validate in interface ReferencevalidateContext - the validating contexttrue if this reference was validated successfully;
false otherwiseXMLSignatureException - if an unexpected exception occurs while validating the referenceReference.validate(javax.xml.crypto.dsig.XMLValidateContext)public boolean validateReference(XMLValidateContext validateContext) throws XMLSignatureException
NOTE: This method assumes, that
DOMUtils.distributeNSDeclarations(Element) has been called for the
underlying document.
validateContext - the validation contexttrue if this reference is reference-valid,
false otherwiseXMLSignatureException - if an unexpected exception occurs during validation© 2002-2005 IAIK, © 2004, 2006 - 2019 Stiftung SIC