Module org.apache.santuario.xmlsec
Class DOMSignatureMethod
- java.lang.Object
-
- org.apache.jcp.xml.dsig.internal.dom.DOMStructure
-
- org.apache.jcp.xml.dsig.internal.dom.AbstractDOMSignatureMethod
-
- org.apache.jcp.xml.dsig.internal.dom.DOMSignatureMethod
-
- All Implemented Interfaces:
javax.xml.crypto.AlgorithmMethod,javax.xml.crypto.dsig.SignatureMethod,javax.xml.crypto.XMLStructure
- Direct Known Subclasses:
DOMSignatureMethod.AbstractEDDSASignatureMethod,DOMSignatureMethod.AbstractP1363FormatSignatureMethod,DOMSignatureMethod.AbstractRSASignatureMethod
public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod
DOM-based abstract implementation of SignatureMethod.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.jcp.xml.dsig.internal.dom.AbstractDOMSignatureMethod
AbstractDOMSignatureMethod.Type
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDOM_SIGNATURE_PROVIDER(package private) static java.lang.StringDSA_SHA256(package private) static java.lang.StringECDSA_RIPEMD160(package private) static java.lang.StringECDSA_SHA1(package private) static java.lang.StringECDSA_SHA224(package private) static java.lang.StringECDSA_SHA256(package private) static java.lang.StringECDSA_SHA3_224(package private) static java.lang.StringECDSA_SHA3_256(package private) static java.lang.StringECDSA_SHA3_384(package private) static java.lang.StringECDSA_SHA3_512(package private) static java.lang.StringECDSA_SHA384(package private) static java.lang.StringECDSA_SHA512(package private) static java.lang.StringED25519(package private) static java.lang.StringED448private static java.lang.System.LoggerLOGprivate javax.xml.crypto.dsig.spec.SignatureMethodParameterSpecparams(package private) static java.lang.StringRSA_RIPEMD160(package private) static java.lang.StringRSA_RIPEMD160_MGF1(package private) static java.lang.StringRSA_SHA1_MGF1(package private) static java.lang.StringRSA_SHA224(package private) static java.lang.StringRSA_SHA224_MGF1(package private) static java.lang.StringRSA_SHA256(package private) static java.lang.StringRSA_SHA256_MGF1(package private) static java.lang.StringRSA_SHA3_224_MGF1(package private) static java.lang.StringRSA_SHA3_256_MGF1(package private) static java.lang.StringRSA_SHA3_384_MGF1(package private) static java.lang.StringRSA_SHA3_512_MGF1(package private) static java.lang.StringRSA_SHA384(package private) static java.lang.StringRSA_SHA384_MGF1(package private) static java.lang.StringRSA_SHA512(package private) static java.lang.StringRSA_SHA512_MGF1private java.security.Signaturesignature
-
Constructor Summary
Constructors Constructor Description DOMSignatureMethod(java.security.spec.AlgorithmParameterSpec params)Creates aDOMSignatureMethod.DOMSignatureMethod(org.w3c.dom.Element smElem)Creates aDOMSignatureMethodfrom an element.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.security.spec.AlgorithmParameterSpecgetParameterSpec()(package private) java.security.SignaturegetSignature(java.security.Provider p)Returns an instance of Signature from the specified Provider.(package private) abstract byte[]postSignFormat(java.security.Key key, byte[] sig)Returns the signature bytes with any additional formatting necessary for the signature algorithm used.(package private) abstract byte[]preVerifyFormat(java.security.Key key, byte[] sig)Returns the signature bytes with any conversions that are necessary before the signature can be verified.(package private) byte[]sign(java.security.Key key, javax.xml.crypto.dsig.SignedInfo si, javax.xml.crypto.dsig.XMLSignContext context)Signs the bytes with the specified key, using the underlying Signature or Mac algorithm.(package private) static javax.xml.crypto.dsig.SignatureMethodunmarshal(org.w3c.dom.Element smElem)(package private) booleanverify(java.security.Key key, javax.xml.crypto.dsig.SignedInfo si, byte[] sig, javax.xml.crypto.dsig.XMLValidateContext context)Verifies the passed-in signature with the specified key, using the underlying Signature or Mac algorithm.-
Methods inherited from class org.apache.jcp.xml.dsig.internal.dom.AbstractDOMSignatureMethod
checkParams, equals, getAlgorithmType, getJCAAlgorithm, hashCode, marshal, marshalParams, paramsEqual, unmarshalParams
-
Methods inherited from class org.apache.jcp.xml.dsig.internal.dom.DOMStructure
equalsContent, isFeatureSupported
-
-
-
-
Field Detail
-
DOM_SIGNATURE_PROVIDER
private static final java.lang.String DOM_SIGNATURE_PROVIDER
- See Also:
- Constant Field Values
-
LOG
private static final java.lang.System.Logger LOG
-
params
private javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec params
-
signature
private java.security.Signature signature
-
RSA_SHA224
static final java.lang.String RSA_SHA224
- See Also:
- Constant Field Values
-
RSA_SHA256
static final java.lang.String RSA_SHA256
- See Also:
- Constant Field Values
-
RSA_SHA384
static final java.lang.String RSA_SHA384
- See Also:
- Constant Field Values
-
RSA_SHA512
static final java.lang.String RSA_SHA512
- See Also:
- Constant Field Values
-
RSA_RIPEMD160
static final java.lang.String RSA_RIPEMD160
- See Also:
- Constant Field Values
-
ECDSA_SHA1
static final java.lang.String ECDSA_SHA1
- See Also:
- Constant Field Values
-
ECDSA_SHA224
static final java.lang.String ECDSA_SHA224
- See Also:
- Constant Field Values
-
ECDSA_SHA256
static final java.lang.String ECDSA_SHA256
- See Also:
- Constant Field Values
-
ECDSA_SHA384
static final java.lang.String ECDSA_SHA384
- See Also:
- Constant Field Values
-
ECDSA_SHA512
static final java.lang.String ECDSA_SHA512
- See Also:
- Constant Field Values
-
DSA_SHA256
static final java.lang.String DSA_SHA256
- See Also:
- Constant Field Values
-
ED25519
static final java.lang.String ED25519
- See Also:
- Constant Field Values
-
ED448
static final java.lang.String ED448
- See Also:
- Constant Field Values
-
ECDSA_SHA3_224
static final java.lang.String ECDSA_SHA3_224
- See Also:
- Constant Field Values
-
ECDSA_SHA3_256
static final java.lang.String ECDSA_SHA3_256
- See Also:
- Constant Field Values
-
ECDSA_SHA3_384
static final java.lang.String ECDSA_SHA3_384
- See Also:
- Constant Field Values
-
ECDSA_SHA3_512
static final java.lang.String ECDSA_SHA3_512
- See Also:
- Constant Field Values
-
ECDSA_RIPEMD160
static final java.lang.String ECDSA_RIPEMD160
- See Also:
- Constant Field Values
-
RSA_SHA1_MGF1
static final java.lang.String RSA_SHA1_MGF1
- See Also:
- Constant Field Values
-
RSA_SHA224_MGF1
static final java.lang.String RSA_SHA224_MGF1
- See Also:
- Constant Field Values
-
RSA_SHA256_MGF1
static final java.lang.String RSA_SHA256_MGF1
- See Also:
- Constant Field Values
-
RSA_SHA384_MGF1
static final java.lang.String RSA_SHA384_MGF1
- See Also:
- Constant Field Values
-
RSA_SHA512_MGF1
static final java.lang.String RSA_SHA512_MGF1
- See Also:
- Constant Field Values
-
RSA_RIPEMD160_MGF1
static final java.lang.String RSA_RIPEMD160_MGF1
- See Also:
- Constant Field Values
-
RSA_SHA3_224_MGF1
static final java.lang.String RSA_SHA3_224_MGF1
- See Also:
- Constant Field Values
-
RSA_SHA3_256_MGF1
static final java.lang.String RSA_SHA3_256_MGF1
- See Also:
- Constant Field Values
-
RSA_SHA3_384_MGF1
static final java.lang.String RSA_SHA3_384_MGF1
- See Also:
- Constant Field Values
-
RSA_SHA3_512_MGF1
static final java.lang.String RSA_SHA3_512_MGF1
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DOMSignatureMethod
DOMSignatureMethod(java.security.spec.AlgorithmParameterSpec params) throws java.security.InvalidAlgorithmParameterExceptionCreates aDOMSignatureMethod.- Parameters:
params- the algorithm-specific params (may benull)- Throws:
java.security.InvalidAlgorithmParameterException- if the parameters are not appropriate for this signature method
-
DOMSignatureMethod
DOMSignatureMethod(org.w3c.dom.Element smElem) throws javax.xml.crypto.MarshalExceptionCreates aDOMSignatureMethodfrom an element. This ctor invokes theunmarshalParamsmethod to unmarshal any algorithm-specific input parameters.- Parameters:
smElem- a SignatureMethod element- Throws:
javax.xml.crypto.MarshalException
-
-
Method Detail
-
postSignFormat
abstract byte[] postSignFormat(java.security.Key key, byte[] sig) throws java.io.IOExceptionReturns the signature bytes with any additional formatting necessary for the signature algorithm used. For RSA signatures, no changes are required, and this method should simply return backsig. For DSA and ECDSA, this method should return the signature in the IEEE P1363 format, the concatenation of r and s.- Parameters:
key- the key used to signsig- the signature returned bySignature.sign()- Returns:
- the formatted signature
- Throws:
java.io.IOException
-
preVerifyFormat
abstract byte[] preVerifyFormat(java.security.Key key, byte[] sig) throws java.io.IOExceptionReturns the signature bytes with any conversions that are necessary before the signature can be verified. For RSA signatures, no changes are required, and this method should simply return backsig. For DSA and ECDSA, this method should return the signature in the DER-encoded ASN.1 format.- Parameters:
key- the key used to signsig- the signature- Returns:
- the formatted signature
- Throws:
java.io.IOException
-
unmarshal
static javax.xml.crypto.dsig.SignatureMethod unmarshal(org.w3c.dom.Element smElem) throws javax.xml.crypto.MarshalException- Throws:
javax.xml.crypto.MarshalException
-
getParameterSpec
public final java.security.spec.AlgorithmParameterSpec getParameterSpec()
-
getSignature
java.security.Signature getSignature(java.security.Provider p) throws java.security.NoSuchAlgorithmExceptionReturns an instance of Signature from the specified Provider. The algorithm is specified by thegetJCAAlgorithm()method.- Parameters:
p- the Provider to use- Returns:
- an instance of Signature implementing the algorithm
specified by
getJCAAlgorithm() - Throws:
java.security.NoSuchAlgorithmException- if the Provider does not support the signature algorithm
-
verify
boolean verify(java.security.Key key, javax.xml.crypto.dsig.SignedInfo si, byte[] sig, javax.xml.crypto.dsig.XMLValidateContext context) throws java.security.InvalidKeyException, java.security.SignatureException, javax.xml.crypto.dsig.XMLSignatureExceptionDescription copied from class:AbstractDOMSignatureMethodVerifies the passed-in signature with the specified key, using the underlying Signature or Mac algorithm.- Specified by:
verifyin classAbstractDOMSignatureMethod- Parameters:
key- the verification keysi- the SignedInfosig- the signature bytes to be verifiedcontext- the XMLValidateContext- Returns:
trueif the signature verified successfully,falseif not- Throws:
java.security.InvalidKeyException- if the key is improperly encoded, of the wrong type, or parameters are missing, etcjava.security.SignatureException- if an unexpected error occurs, such as the passed in signature is improperly encodedjavax.xml.crypto.dsig.XMLSignatureException- if an unexpected error occurs
-
sign
byte[] sign(java.security.Key key, javax.xml.crypto.dsig.SignedInfo si, javax.xml.crypto.dsig.XMLSignContext context) throws java.security.InvalidKeyException, javax.xml.crypto.dsig.XMLSignatureExceptionDescription copied from class:AbstractDOMSignatureMethodSigns the bytes with the specified key, using the underlying Signature or Mac algorithm.- Specified by:
signin classAbstractDOMSignatureMethod- Parameters:
key- the signing keysi- the SignedInfocontext- the XMLSignContext- Returns:
- the signature
- Throws:
java.security.InvalidKeyException- if the key is improperly encoded, of the wrong type, or parameters are missing, etcjavax.xml.crypto.dsig.XMLSignatureException- if an unexpected error occurs
-
-