Class SignatureAlgorithm
- java.lang.Object
-
- org.apache.xml.security.utils.ElementProxy
-
- org.apache.xml.security.utils.SignatureElementProxy
-
- org.apache.xml.security.algorithms.Algorithm
-
- org.apache.xml.security.algorithms.SignatureAlgorithm
-
public class SignatureAlgorithm extends Algorithm
Allows selection of digital signature's algorithm, private keys, other security parameters, and algorithm's ID.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,java.lang.Class<? extends SignatureAlgorithmSpi>>
algorithmHash
All available algorithm classes are registered hereprivate java.lang.String
algorithmURI
private static org.slf4j.Logger
LOG
private SignatureAlgorithmSpi
signatureAlgorithm
Field signatureAlgorithm-
Fields inherited from class org.apache.xml.security.utils.ElementProxy
baseURI
-
-
Constructor Summary
Constructors Constructor Description SignatureAlgorithm(org.w3c.dom.Document doc, java.lang.String algorithmURI)
Constructor SignatureAlgorithmSignatureAlgorithm(org.w3c.dom.Document doc, java.lang.String algorithmURI, int hmacOutputLength)
Constructor SignatureAlgorithmSignatureAlgorithm(org.w3c.dom.Element element, java.lang.String baseURI)
Constructor SignatureAlgorithmSignatureAlgorithm(org.w3c.dom.Element element, java.lang.String baseURI, boolean secureValidation)
Constructor SignatureAlgorithm
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getBaseLocalName()
Method getBaseLocalNamejava.lang.String
getBaseNamespace()
Method getBaseNamespacejava.lang.String
getJCEAlgorithmString()
Proxy method forSignature.getAlgorithm()
which is executed on the internalSignature
object.java.lang.String
getJCEProviderName()
Method getJCEProviderNameprivate static SignatureAlgorithmSpi
getSignatureAlgorithmSpi(java.lang.String algorithmURI)
Get a SignatureAlgorithmSpi object corresponding to the algorithmURI argumentjava.lang.String
getURI()
Returns the URI representation of Transformation algorithmvoid
initSign(java.security.Key signingKey)
Proxy method forSignature.initSign(java.security.PrivateKey)
which is executed on the internalSignature
object.void
initSign(java.security.Key signingKey, java.security.SecureRandom secureRandom)
Proxy method forSignature.initSign(java.security.PrivateKey, java.security.SecureRandom)
which is executed on the internalSignature
object.void
initSign(java.security.Key signingKey, java.security.spec.AlgorithmParameterSpec algorithmParameterSpec)
Proxy method forSignature.initSign(java.security.PrivateKey)
which is executed on the internalSignature
object.void
initVerify(java.security.Key verificationKey)
Proxy method forSignature.initVerify(java.security.PublicKey)
which is executed on the internalSignature
object.static void
register(java.lang.String algorithmURI, java.lang.Class<? extends SignatureAlgorithmSpi> implementingClass)
Registers implementing class of the SignatureAlgorithm with algorithmURIstatic void
register(java.lang.String algorithmURI, java.lang.String implementingClass)
Registers implementing class of the SignatureAlgorithm with algorithmURIstatic void
registerDefaultAlgorithms()
This method registers the default algorithms.void
setParameter(java.security.spec.AlgorithmParameterSpec params)
Proxy method forSignature.setParameter( java.security.spec.AlgorithmParameterSpec)
which is executed on the internalSignature
object.byte[]
sign()
Proxy method forSignature.sign()
which is executed on the internalSignature
object.void
update(byte input)
Proxy method forSignature.update(byte)
which is executed on the internalSignature
object.void
update(byte[] input)
Proxy method forSignature.update(byte[])
which is executed on the internalSignature
object.void
update(byte[] buf, int offset, int len)
Proxy method forSignature.update(byte[], int, int)
which is executed on the internalSignature
object.boolean
verify(byte[] signature)
Proxy method forSignature.verify(byte[])
which is executed on the internalSignature
object.-
Methods inherited from class org.apache.xml.security.algorithms.Algorithm
getAlgorithmURI, setAlgorithmURI
-
Methods inherited from class org.apache.xml.security.utils.ElementProxy
addBase64Element, addBase64Text, addBigIntegerElement, addReturnToSelf, addText, addTextElement, appendOther, appendSelf, appendSelf, createElementForFamily, createElementForFamilyLocal, createText, getBaseURI, getBigIntegerFromChildElement, getBytesFromTextChild, getDefaultPrefix, getDocument, getElement, getElementPlusReturns, getFirstChild, getLocalAttribute, getTextFromChildElement, getTextFromTextChild, length, registerDefaultPrefixes, setDefaultPrefix, setDocument, setElement, setElement, setLocalAttribute, setLocalIdAttribute, setXPathNamespaceContext
-
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
algorithmHash
private static java.util.Map<java.lang.String,java.lang.Class<? extends SignatureAlgorithmSpi>> algorithmHash
All available algorithm classes are registered here
-
signatureAlgorithm
private final SignatureAlgorithmSpi signatureAlgorithm
Field signatureAlgorithm
-
algorithmURI
private final java.lang.String algorithmURI
-
-
Constructor Detail
-
SignatureAlgorithm
public SignatureAlgorithm(org.w3c.dom.Document doc, java.lang.String algorithmURI) throws XMLSecurityException
Constructor SignatureAlgorithm- Parameters:
doc
-algorithmURI
-- Throws:
XMLSecurityException
-
SignatureAlgorithm
public SignatureAlgorithm(org.w3c.dom.Document doc, java.lang.String algorithmURI, int hmacOutputLength) throws XMLSecurityException
Constructor SignatureAlgorithm- Parameters:
doc
-algorithmURI
-hmacOutputLength
-- Throws:
XMLSecurityException
-
SignatureAlgorithm
public SignatureAlgorithm(org.w3c.dom.Element element, java.lang.String baseURI) throws XMLSecurityException
Constructor SignatureAlgorithm- Parameters:
element
-baseURI
-- Throws:
XMLSecurityException
-
SignatureAlgorithm
public SignatureAlgorithm(org.w3c.dom.Element element, java.lang.String baseURI, boolean secureValidation) throws XMLSecurityException
Constructor SignatureAlgorithm- Parameters:
element
-baseURI
-secureValidation
-- Throws:
XMLSecurityException
-
-
Method Detail
-
getSignatureAlgorithmSpi
private static SignatureAlgorithmSpi getSignatureAlgorithmSpi(java.lang.String algorithmURI) throws XMLSignatureException
Get a SignatureAlgorithmSpi object corresponding to the algorithmURI argument- Throws:
XMLSignatureException
-
sign
public byte[] sign() throws XMLSignatureException
Proxy method forSignature.sign()
which is executed on the internalSignature
object.- Returns:
- the result of the
Signature.sign()
method - Throws:
XMLSignatureException
-
getJCEAlgorithmString
public java.lang.String getJCEAlgorithmString()
Proxy method forSignature.getAlgorithm()
which is executed on the internalSignature
object.- Returns:
- the result of the
Signature.getAlgorithm()
method
-
getJCEProviderName
public java.lang.String getJCEProviderName()
Method getJCEProviderName- Returns:
- The Provider of this Signature Algorithm
-
update
public void update(byte[] input) throws XMLSignatureException
Proxy method forSignature.update(byte[])
which is executed on the internalSignature
object.- Parameters:
input
-- Throws:
XMLSignatureException
-
update
public void update(byte input) throws XMLSignatureException
Proxy method forSignature.update(byte)
which is executed on the internalSignature
object.- Parameters:
input
-- Throws:
XMLSignatureException
-
update
public void update(byte[] buf, int offset, int len) throws XMLSignatureException
Proxy method forSignature.update(byte[], int, int)
which is executed on the internalSignature
object.- Parameters:
buf
-offset
-len
-- Throws:
XMLSignatureException
-
initSign
public void initSign(java.security.Key signingKey) throws XMLSignatureException
Proxy method forSignature.initSign(java.security.PrivateKey)
which is executed on the internalSignature
object.- Parameters:
signingKey
-- Throws:
XMLSignatureException
-
initSign
public void initSign(java.security.Key signingKey, java.security.SecureRandom secureRandom) throws XMLSignatureException
Proxy method forSignature.initSign(java.security.PrivateKey, java.security.SecureRandom)
which is executed on the internalSignature
object.- Parameters:
signingKey
-secureRandom
-- Throws:
XMLSignatureException
-
initSign
public void initSign(java.security.Key signingKey, java.security.spec.AlgorithmParameterSpec algorithmParameterSpec) throws XMLSignatureException
Proxy method forSignature.initSign(java.security.PrivateKey)
which is executed on the internalSignature
object.- Parameters:
signingKey
-algorithmParameterSpec
-- Throws:
XMLSignatureException
-
setParameter
public void setParameter(java.security.spec.AlgorithmParameterSpec params) throws XMLSignatureException
Proxy method forSignature.setParameter( java.security.spec.AlgorithmParameterSpec)
which is executed on the internalSignature
object.- Parameters:
params
-- Throws:
XMLSignatureException
-
initVerify
public void initVerify(java.security.Key verificationKey) throws XMLSignatureException
Proxy method forSignature.initVerify(java.security.PublicKey)
which is executed on the internalSignature
object.- Parameters:
verificationKey
-- Throws:
XMLSignatureException
-
verify
public boolean verify(byte[] signature) throws XMLSignatureException
Proxy method forSignature.verify(byte[])
which is executed on the internalSignature
object.- Parameters:
signature
-- Returns:
- true if the signature is valid.
- Throws:
XMLSignatureException
-
getURI
public final java.lang.String getURI()
Returns the URI representation of Transformation algorithm- Returns:
- the URI representation of Transformation algorithm
-
register
public static void register(java.lang.String algorithmURI, java.lang.String implementingClass) throws AlgorithmAlreadyRegisteredException, java.lang.ClassNotFoundException, XMLSignatureException
Registers implementing class of the SignatureAlgorithm with algorithmURI- Parameters:
algorithmURI
- algorithmURI URI representation ofSignatureAlgorithm
.implementingClass
-implementingClass
the implementing class ofSignatureAlgorithmSpi
- Throws:
AlgorithmAlreadyRegisteredException
- if specified algorithmURI is already registeredXMLSignatureException
java.lang.SecurityException
- if a security manager is installed and the caller does not have permission to register the signature algorithmjava.lang.ClassNotFoundException
-
register
public static void register(java.lang.String algorithmURI, java.lang.Class<? extends SignatureAlgorithmSpi> implementingClass) throws AlgorithmAlreadyRegisteredException, java.lang.ClassNotFoundException, XMLSignatureException
Registers implementing class of the SignatureAlgorithm with algorithmURI- Parameters:
algorithmURI
- algorithmURI URI representation ofSignatureAlgorithm
.implementingClass
-implementingClass
the implementing class ofSignatureAlgorithmSpi
- Throws:
AlgorithmAlreadyRegisteredException
- if specified algorithmURI is already registeredXMLSignatureException
java.lang.SecurityException
- if a security manager is installed and the caller does not have permission to register the signature algorithmjava.lang.ClassNotFoundException
-
registerDefaultAlgorithms
public static void registerDefaultAlgorithms()
This method registers the default algorithms.
-
getBaseNamespace
public java.lang.String getBaseNamespace()
Method getBaseNamespace- Overrides:
getBaseNamespace
in classSignatureElementProxy
- Returns:
- URI of this element
-
getBaseLocalName
public java.lang.String getBaseLocalName()
Method getBaseLocalName- Specified by:
getBaseLocalName
in classElementProxy
- Returns:
- Local name
-
-