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

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.DOMXMLSignature
All Implemented Interfaces:
XMLSignature, XMLStructure

public final class DOMXMLSignature
extends DOMStructure
implements XMLSignature

DOM-based implementation of XMLSignature.

Author:
Sean Mullan, Joyce Leung

Nested Class Summary
 class DOMXMLSignature.DOMSignatureValue
           
 
Nested classes/interfaces inherited from interface javax.xml.crypto.dsig.XMLSignature
XMLSignature.SignatureValue
 
Field Summary
 
Fields inherited from interface javax.xml.crypto.dsig.XMLSignature
XMLNS
 
Constructor Summary
DOMXMLSignature(Element sigElem, XMLCryptoContext context, Provider provider)
          Creates a DOMXMLSignature from XML.
DOMXMLSignature(SignedInfo si, KeyInfo ki, List<? extends XMLObject> objs, String id, String signatureValueId)
          Creates a DOMXMLSignature from the specified components.
 
Method Summary
 boolean equals(Object o)
           
 String getId()
          Returns the optional Id of this XMLSignature.
 KeyInfo getKeyInfo()
          Returns the key info of this XMLSignature.
 KeySelectorResult getKeySelectorResult()
          Returns the result of the KeySelector, if specified, after this XMLSignature has been signed or validated.
 List<XMLObject> getObjects()
          Returns an unmodifiable list of XMLObjects contained in this XMLSignature.
 XMLSignature.SignatureValue getSignatureValue()
          Returns the signature value of this XMLSignature.
 SignedInfo getSignedInfo()
          Returns the signed info of this XMLSignature.
 int hashCode()
           
 void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context)
           
 void sign(XMLSignContext signContext)
          Signs this XMLSignature.
 boolean validate(XMLValidateContext vc)
          Validates the signature according to the core validation processing rules.
 
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
 

Constructor Detail

DOMXMLSignature

public DOMXMLSignature(SignedInfo si,
                       KeyInfo ki,
                       List<? extends XMLObject> objs,
                       String id,
                       String signatureValueId)
Creates a DOMXMLSignature from the specified components.

Parameters:
si - the SignedInfo
ki - the KeyInfo, or null if not specified
objs - a list of XMLObjects or null if not specified. The list is copied to protect against subsequent modification.
id - an optional id (specify null to omit)
signatureValueId - an optional id (specify null to omit)
Throws:
NullPointerException - if si is null

DOMXMLSignature

public DOMXMLSignature(Element sigElem,
                       XMLCryptoContext context,
                       Provider provider)
                throws MarshalException
Creates a DOMXMLSignature from XML.

Parameters:
sigElem - Signature element
Throws:
MarshalException - if XMLSignature cannot be unmarshalled
Method Detail

getId

public String getId()
Description copied from interface: XMLSignature
Returns the optional Id of this XMLSignature.

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

getKeyInfo

public KeyInfo getKeyInfo()
Description copied from interface: XMLSignature
Returns the key info of this XMLSignature.

Specified by:
getKeyInfo in interface XMLSignature
Returns:
the key info (may be null if not specified)

getSignedInfo

public SignedInfo getSignedInfo()
Description copied from interface: XMLSignature
Returns the signed info of this XMLSignature.

Specified by:
getSignedInfo in interface XMLSignature
Returns:
the signed info (never null)

getObjects

public List<XMLObject> getObjects()
Description copied from interface: XMLSignature
Returns an unmodifiable list of XMLObjects contained in this XMLSignature.

Specified by:
getObjects in interface XMLSignature
Returns:
an unmodifiable list of XMLObjects (may be empty but never null)

getSignatureValue

public XMLSignature.SignatureValue getSignatureValue()
Description copied from interface: XMLSignature
Returns the signature value of this XMLSignature.

Specified by:
getSignatureValue in interface XMLSignature
Returns:
the signature value

getKeySelectorResult

public KeySelectorResult getKeySelectorResult()
Description copied from interface: XMLSignature
Returns the result of the KeySelector, if specified, after this XMLSignature has been signed or validated.

Specified by:
getKeySelectorResult in interface XMLSignature
Returns:
the key selector result, or null if a key selector has not been specified or this XMLSignature has not been signed or validated

marshal

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

validate

public boolean validate(XMLValidateContext vc)
                 throws XMLSignatureException
Description copied from interface: XMLSignature
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.

Specified by:
validate in interface XMLSignature
Parameters:
vc - the validating context
Returns:
true if the signature passed core validation, otherwise false
Throws:
XMLSignatureException - if an unexpected error occurs during validation that prevented the validation operation from completing

sign

public void sign(XMLSignContext signContext)
          throws MarshalException,
                 XMLSignatureException
Description copied from interface: XMLSignature
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.

Specified by:
sign in interface XMLSignature
Parameters:
signContext - the signing context
Throws:
MarshalException - if an exception occurs while marshalling
XMLSignatureException - if an unexpected exception occurs while generating the signature

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.