Top Description Inners Fields Constructors Methods
org.jcp.xml.dsig.internal.dom

public final Class DOMXMLSignature

extends DOMStructure
implements XMLSignature
Class Inheritance
All Implemented Interfaces
javax.xml.crypto.dsig.XMLSignature, javax.xml.crypto.XMLStructure
Imports
java.security.InvalidKeyException, .Key, .Provider, java.util.ArrayList, .Collections, .HashMap, .List, .Map, javax.xml.crypto.KeySelector, .KeySelectorException, .KeySelectorResult, .MarshalException, .XMLCryptoContext, .XMLStructure, javax.xml.crypto.dom.DOMCryptoContext, javax.xml.crypto.dsig.Manifest, .Reference, .SignatureMethod, .SignedInfo, .Transform, .XMLObject, .XMLSignContext, .XMLSignature, .XMLSignatureException, .XMLValidateContext, javax.xml.crypto.dsig.dom.DOMSignContext, .DOMValidateContext, javax.xml.crypto.dsig.keyinfo.KeyInfo, com.sun.org.apache.xml.internal.security.utils.XMLUtils, org.w3c.dom.Attr, .Document, .Element, .Node

DOM-based implementation of XMLSignature.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
private final String
private KeyInfo
private KeySelectorResult
private Element
private static final Logger
private List<XMLObject>
private Document
private final SignedInfo
private Element
private Map<String, XMLStructure>
private final XMLSignature.SignatureValue
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
public
DOMXMLSignature(SignedInfo
the SignedInfo
si
,
KeyInfo
the KeyInfo, or null if not specified
ki
,
List<? extends XMLObject>
a list of XMLObjects or null if not specified. The list is copied to protect against subsequent modification.
objs
,
String
an optional id (specify null to omit)
id
,
String
an optional id (specify null to omit)
signatureValueId
)

Creates a DOMXMLSignature from the specified components.

public
DOMXMLSignature(Element
Signature element
sigElem
,
XMLCryptoContext context, Provider provider)

Creates a DOMXMLSignature from XML.

Method Summary

Modifier and TypeMethod and Description
private void
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public String
getId()

Implements javax.xml.crypto.dsig.XMLSignature.getId.

Returns the optional Id of this XMLSignature.
public KeyInfo
getKeyInfo()

Implements javax.xml.crypto.dsig.XMLSignature.getKeyInfo.

Returns the key info of this XMLSignature.
public KeySelectorResult
getKeySelectorResult()

Implements javax.xml.crypto.dsig.XMLSignature.getKeySelectorResult.

Returns the result of the KeySelector, if specified, after this XMLSignature has been signed or validated.
public List<XMLObject>
getObjects()

Implements javax.xml.crypto.dsig.XMLSignature.getObjects.

Returns an unmodifiable list of XMLObjects contained in this XMLSignature.
public XMLSignature.SignatureValue
getSignatureValue()

Implements javax.xml.crypto.dsig.XMLSignature.getSignatureValue.

Returns the signature value of this XMLSignature.
public SignedInfo
getSignedInfo()

Implements javax.xml.crypto.dsig.XMLSignature.getSignedInfo.

Returns the signed info of this XMLSignature.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public void
public void
marshal(Node parent, Node nextSibling, String dsPrefix, DOMCryptoContext context)

public void
sign(XMLSignContext
the signing context
signContext
)

Implements javax.xml.crypto.dsig.XMLSignature.sign.

Signs this XMLSignature.
public boolean
validate(XMLValidateContext
the validating context
vc
)

Implements javax.xml.crypto.dsig.XMLSignature.validate.

Validates the signature according to the core validation processing rules.
Inherited from org.jcp.xml.dsig.internal.dom.DOMStructure:
equalsContentisFeatureSupported

Field Detail

idback to summary
private final String id
kiback to summary
private KeyInfo ki
ksrback to summary
private KeySelectorResult ksr
localSigElemback to summary
private Element localSigElem
LOGback to summary
private static final Logger LOG
objectsback to summary
private List<XMLObject> objects
ownerDocback to summary
private Document ownerDoc
siback to summary
private final SignedInfo si
sigElemback to summary
private Element sigElem
signatureIdMapback to summary
private Map<String, XMLStructure> signatureIdMap
svback to summary
private final XMLSignature.SignatureValue sv
validatedback to summary
private boolean validated
validationStatusback to summary
private boolean validationStatus

Constructor Detail

DOMXMLSignatureback to summary
public DOMXMLSignature(SignedInfo si, KeyInfo ki, List<? extends XMLObject> objs, String id, String signatureValueId)

Creates a DOMXMLSignature from the specified components.

Parameters
si:SignedInfo

the SignedInfo

ki:KeyInfo

the KeyInfo, or null if not specified

objs:List<? extends XMLObject>

a list of XMLObjects or null if not specified. The list is copied to protect against subsequent modification.

id:String

an optional id (specify null to omit)

signatureValueId:String

an optional id (specify null to omit)

Exceptions
NullPointerException:
if si is null
DOMXMLSignatureback to summary
public DOMXMLSignature(Element sigElem, XMLCryptoContext context, Provider provider) throws MarshalException

Creates a DOMXMLSignature from XML.

Parameters
sigElem:Element

Signature element

Exceptions
MarshalException:
if XMLSignature cannot be unmarshalled

Method Detail

digestReferenceback to summary
private void digestReference(DOMReference ref, XMLSignContext signContext) throws XMLSignatureException
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getIdback to summary
public String getId()

Implements javax.xml.crypto.dsig.XMLSignature.getId.

Doc from javax.xml.crypto.dsig.XMLSignature.getId.

Returns the optional Id of this XMLSignature.

Returns:String

the Id (may be null if not specified)

Annotations
@Override
getKeyInfoback to summary
public KeyInfo getKeyInfo()

Implements javax.xml.crypto.dsig.XMLSignature.getKeyInfo.

Doc from javax.xml.crypto.dsig.XMLSignature.getKeyInfo.

Returns the key info of this XMLSignature.

Returns:KeyInfo

the key info (may be null if not specified)

Annotations
@Override
getKeySelectorResultback to summary
public KeySelectorResult getKeySelectorResult()

Implements javax.xml.crypto.dsig.XMLSignature.getKeySelectorResult.

Doc from javax.xml.crypto.dsig.XMLSignature.getKeySelectorResult.

Returns the result of the KeySelector, if specified, after this XMLSignature has been signed or validated.

Returns:KeySelectorResult

the key selector result, or null if a key selector has not been specified or this XMLSignature has not been signed or validated

Annotations
@Override
getObjectsback to summary
public List<XMLObject> getObjects()

Implements javax.xml.crypto.dsig.XMLSignature.getObjects.

Doc from javax.xml.crypto.dsig.XMLSignature.getObjects.

Returns an unmodifiable list of XMLObjects contained in this XMLSignature.

Returns:List<XMLObject>

an unmodifiable list of XMLObjects (may be empty but never null)

Annotations
@Override
getSignatureValueback to summary
public XMLSignature.SignatureValue getSignatureValue()

Implements javax.xml.crypto.dsig.XMLSignature.getSignatureValue.

Doc from javax.xml.crypto.dsig.XMLSignature.getSignatureValue.

Returns the signature value of this XMLSignature.

Returns:XMLSignature.SignatureValue

the signature value

Annotations
@Override
getSignedInfoback to summary
public SignedInfo getSignedInfo()

Implements javax.xml.crypto.dsig.XMLSignature.getSignedInfo.

Doc from javax.xml.crypto.dsig.XMLSignature.getSignedInfo.

Returns the signed info of this XMLSignature.

Returns:SignedInfo

the signed info (never null)

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
marshalback to summary
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException

Implements abstract org.jcp.xml.dsig.internal.dom.DOMStructure.marshal.

Annotations
@Override
marshalback to summary
public void marshal(Node parent, Node nextSibling, String dsPrefix, DOMCryptoContext context) throws MarshalException
signback to summary
public void sign(XMLSignContext signContext) throws MarshalException, XMLSignatureException

Implements javax.xml.crypto.dsig.XMLSignature.sign.

Doc from javax.xml.crypto.dsig.XMLSignature.sign.

Signs this XMLSignature.

If this method throws an exception, this XMLSignature and the signContext parameter will be left in the state that it was in prior to the invocation.

Parameters
signContext:XMLSignContext

the signing context

Annotations
@Override
Exceptions
MarshalException:
if an exception occurs while marshalling
XMLSignatureException:
if an unexpected exception occurs while generating the signature
validateback to summary
public boolean validate(XMLValidateContext vc) throws XMLSignatureException

Implements javax.xml.crypto.dsig.XMLSignature.validate.

Doc from javax.xml.crypto.dsig.XMLSignature.validate.

Validates the signature according to the core validation processing rules. This method validates the signature using the existing state, it does not unmarshal and reinitialize the contents of the XMLSignature using the location information specified in the context.

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

Parameters
vc:XMLValidateContext

the validating context

Returns:boolean

true if the signature passed core validation, otherwise false

Annotations
@Override
Exceptions
XMLSignatureException:
if an unexpected error occurs during validation that prevented the validation operation from completing
org.jcp.xml.dsig.internal.dom back to summary

public Class DOMXMLSignature.DOMSignatureValue

extends DOMStructure
implements SignatureValue
Class Inheritance
All Implemented Interfaces
javax.xml.crypto.dsig.XMLSignature.SignatureValue, javax.xml.crypto.XMLStructure

Field Summary

Modifier and TypeField and Description
private String
private Element
private boolean
private boolean
private byte[]
private String

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
DOMSignatureValue(Element sigValueElem)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public String
public String
getId()

Implements javax.xml.crypto.dsig.XMLSignature.SignatureValue.getId.

Returns the optional Id attribute of this SignatureValue, which permits this element to be referenced from elsewhere.
public byte[]
getValue()

Implements javax.xml.crypto.dsig.XMLSignature.SignatureValue.getValue.

Returns the signature value of this SignatureValue.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public void
pack-priv void
setValue(byte[] value)

public boolean
validate(XMLValidateContext
the validating context
validateContext
)

Implements javax.xml.crypto.dsig.XMLSignature.SignatureValue.validate.

Validates the signature value.
Inherited from org.jcp.xml.dsig.internal.dom.DOMStructure:
equalsContentisFeatureSupported

Field Detail

idback to summary
private String id
sigValueElemback to summary
private Element sigValueElem
validatedback to summary
private boolean validated
validationStatusback to summary
private boolean validationStatus
valueback to summary
private byte[] value
valueBase64back to summary
private String valueBase64

Constructor Detail

DOMSignatureValueback to summary
pack-priv DOMSignatureValue(String id)
DOMSignatureValueback to summary
pack-priv DOMSignatureValue(Element sigValueElem) throws MarshalException

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getEncodedValueback to summary
public String getEncodedValue()
getIdback to summary
public String getId()

Implements javax.xml.crypto.dsig.XMLSignature.SignatureValue.getId.

Doc from javax.xml.crypto.dsig.XMLSignature.SignatureValue.getId.

Returns the optional Id attribute of this SignatureValue, which permits this element to be referenced from elsewhere.

Returns:String

the Id attribute (may be null if not specified)

Annotations
@Override
getValueback to summary
public byte[] getValue()

Implements javax.xml.crypto.dsig.XMLSignature.SignatureValue.getValue.

Doc from javax.xml.crypto.dsig.XMLSignature.SignatureValue.getValue.

Returns the signature value of this SignatureValue.

Returns:byte[]

the signature value (may be null if the XMLSignature has not been signed yet). Each invocation of this method returns a new clone of the array to prevent subsequent modification.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
marshalback to summary
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException

Implements abstract org.jcp.xml.dsig.internal.dom.DOMStructure.marshal.

Annotations
@Override
setValueback to summary
pack-priv void setValue(byte[] value)
validateback to summary
public boolean validate(XMLValidateContext validateContext) throws XMLSignatureException

Implements javax.xml.crypto.dsig.XMLSignature.SignatureValue.validate.

Doc from javax.xml.crypto.dsig.XMLSignature.SignatureValue.validate.

Validates the signature value. This method performs a cryptographic validation of the signature calculated over the SignedInfo of the XMLSignature.

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

Parameters
validateContext:XMLValidateContext

the validating context

Returns:boolean

true if the signature was validated successfully; false otherwise

Annotations
@Override
Exceptions
XMLSignatureException:
if an unexpected exception occurs while validating the signature