XMLSignature (Java Platform SE 6) (original) (raw)



javax.xml.crypto.dsig

Interface XMLSignature

All Superinterfaces:

XMLStructure


public interface XMLSignature

extends XMLStructure

A representation of the XML Signature element as defined in the W3C Recommendation for XML-Signature Syntax and Processing. This class contains methods for signing and validating XML signatures with behavior as defined by the W3C specification. The XML Schema Definition is defined as:


 <element name="Signature" type="ds:SignatureType"/>
 <complexType name="SignatureType">
    <sequence> 
      <element ref="ds:SignedInfo"/> 
      <element ref="ds:SignatureValue"/> 
      <element ref="ds:KeyInfo" minOccurs="0"/> 
      <element ref="ds:Object" minOccurs="0" maxOccurs="unbounded"/> 
    </sequence>  
    <attribute name="Id" type="ID" use="optional"/>
 </complexType>
 

An XMLSignature instance may be created by invoking one of the[newXMLSignature](../../../../javax/xml/crypto/dsig/XMLSignatureFactory.html#newXMLSignature%28javax.xml.crypto.dsig.SignedInfo, javax.xml.crypto.dsig.keyinfo.KeyInfo%29) methods of theXMLSignatureFactory class.

If the contents of the underlying document containing the XMLSignature are subsequently modified, the behavior is undefined.

Note that this class is named XMLSignature rather thanSignature to avoid naming clashes with the existingjava.security.Signature class.

Since:

1.6

See Also:

[XMLSignatureFactory.newXMLSignature(SignedInfo, KeyInfo)](../../../../javax/xml/crypto/dsig/XMLSignatureFactory.html#newXMLSignature%28javax.xml.crypto.dsig.SignedInfo, javax.xml.crypto.dsig.keyinfo.KeyInfo%29), [XMLSignatureFactory.newXMLSignature(SignedInfo, KeyInfo, List, String, String)](../../../../javax/xml/crypto/dsig/XMLSignatureFactory.html#newXMLSignature%28javax.xml.crypto.dsig.SignedInfo, javax.xml.crypto.dsig.keyinfo.KeyInfo, java.util.List, java.lang.String, java.lang.String%29)


Nested Class Summary
static interface XMLSignature.SignatureValue A representation of the XML SignatureValue element as defined in the W3C Recommendation for XML-Signature Syntax and Processing.
Field Summary
static String XMLNS The XML Namespace URI of the W3C Recommendation for XML-Signature Syntax and Processing.
Method Summary
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 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.
void sign(XMLSignContext signContext) Signs this XMLSignature.
boolean validate(XMLValidateContext validateContext) Validates the signature according to the core validation processing rules.
Methods inherited from interface javax.xml.crypto.XMLStructure
isFeatureSupported
Field Detail

XMLNS

static final String XMLNS

The XML Namespace URI of the W3C Recommendation for XML-Signature Syntax and Processing.

See Also:

Constant Field Values

Method Detail

validate

boolean validate(XMLValidateContext validateContext) throws XMLSignatureException

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:

validateContext - the validating context

Returns:

true if the signature passed core validation, otherwise false

Throws:

[ClassCastException](../../../../java/lang/ClassCastException.html "class in java.lang") - if the type of validateContext is not compatible with this XMLSignature

[NullPointerException](../../../../java/lang/NullPointerException.html "class in java.lang") - if validateContext is null

[XMLSignatureException](../../../../javax/xml/crypto/dsig/XMLSignatureException.html "class in javax.xml.crypto.dsig") - if an unexpected error occurs during validation that prevented the validation operation from completing


getKeyInfo

KeyInfo getKeyInfo()

Returns the key info of this XMLSignature.

Returns:

the key info (may be null if not specified)


getSignedInfo

SignedInfo getSignedInfo()

Returns the signed info of this XMLSignature.

Returns:

the signed info (never null)


getObjects

List getObjects()

Returns an unmodifiable list of XMLObjects contained in this XMLSignature.

Returns:

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


getId

String getId()

Returns the optional Id of this XMLSignature.

Returns:

the Id (may be null if not specified)


getSignatureValue

XMLSignature.SignatureValue getSignatureValue()

Returns the signature value of this XMLSignature.

Returns:

the signature value


sign

void sign(XMLSignContext signContext) throws MarshalException, XMLSignatureException

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 - the signing context

Throws:

[ClassCastException](../../../../java/lang/ClassCastException.html "class in java.lang") - if the type of signContext is not compatible with this XMLSignature

[NullPointerException](../../../../java/lang/NullPointerException.html "class in java.lang") - if signContext is null

[MarshalException](../../../../javax/xml/crypto/MarshalException.html "class in javax.xml.crypto") - if an exception occurs while marshalling

[XMLSignatureException](../../../../javax/xml/crypto/dsig/XMLSignatureException.html "class in javax.xml.crypto.dsig") - if an unexpected exception occurs while generating the signature


getKeySelectorResult

KeySelectorResult getKeySelectorResult()

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

Returns:

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



Submit a bug or feature
For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Scripting on this page tracks web page traffic, but does not change the content in any way.