org.apache.xml.security.algorithms
Class SignatureAlgorithm

java.lang.Object
  extended by org.apache.xml.security.utils.ElementProxy
      extended by org.apache.xml.security.utils.SignatureElementProxy
          extended by org.apache.xml.security.algorithms.Algorithm
              extended by 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.

Author:
Christian Geuer-Pollmann

Field Summary
 
Fields inherited from class org.apache.xml.security.utils.ElementProxy
baseURI
 
Constructor Summary
SignatureAlgorithm(Document doc, String algorithmURI)
          Constructor SignatureAlgorithm
SignatureAlgorithm(Document doc, String algorithmURI, int hmacOutputLength)
          Constructor SignatureAlgorithm
SignatureAlgorithm(Element element, String baseURI)
          Constructor SignatureAlgorithm
SignatureAlgorithm(Element element, String baseURI, boolean secureValidation)
          Constructor SignatureAlgorithm
 
Method Summary
 String getBaseLocalName()
          Method getBaseLocalName
 String getBaseNamespace()
          Method getBaseNamespace
 String getJCEAlgorithmString()
          Proxy method for Signature.getAlgorithm() which is executed on the internal Signature object.
 String getJCEProviderName()
          Method getJCEProviderName
 String getURI()
          Returns the URI representation of Transformation algorithm
 void initSign(Key signingKey)
          Proxy method for Signature.initSign(java.security.PrivateKey) which is executed on the internal Signature object.
 void initSign(Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
          Proxy method for Signature.initSign(java.security.PrivateKey) which is executed on the internal Signature object.
 void initSign(Key signingKey, SecureRandom secureRandom)
          Proxy method for Signature.initSign(java.security.PrivateKey, java.security.SecureRandom) which is executed on the internal Signature object.
 void initVerify(Key verificationKey)
          Proxy method for Signature.initVerify(java.security.PublicKey) which is executed on the internal Signature object.
static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass)
          Registers implementing class of the Transform algorithm with algorithmURI
static void register(String algorithmURI, String implementingClass)
          Registers implementing class of the Transform algorithm with algorithmURI
static void registerDefaultAlgorithms()
          This method registers the default algorithms.
 void setParameter(AlgorithmParameterSpec params)
          Proxy method for Signature.setParameter( java.security.spec.AlgorithmParameterSpec) which is executed on the internal Signature object.
 byte[] sign()
          Proxy method for Signature.sign() which is executed on the internal Signature object.
 void update(byte input)
          Proxy method for Signature.update(byte) which is executed on the internal Signature object.
 void update(byte[] input)
          Proxy method for Signature.update(byte[]) which is executed on the internal Signature object.
 void update(byte[] buf, int offset, int len)
          Proxy method for Signature.update(byte[], int, int) which is executed on the internal Signature object.
 boolean verify(byte[] signature)
          Proxy method for Signature.verify(byte[]) which is executed on the internal Signature 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SignatureAlgorithm

public SignatureAlgorithm(Document doc,
                          String algorithmURI)
                   throws XMLSecurityException
Constructor SignatureAlgorithm

Parameters:
doc -
algorithmURI -
Throws:
XMLSecurityException

SignatureAlgorithm

public SignatureAlgorithm(Document doc,
                          String algorithmURI,
                          int hmacOutputLength)
                   throws XMLSecurityException
Constructor SignatureAlgorithm

Parameters:
doc -
algorithmURI -
hmacOutputLength -
Throws:
XMLSecurityException

SignatureAlgorithm

public SignatureAlgorithm(Element element,
                          String baseURI)
                   throws XMLSecurityException
Constructor SignatureAlgorithm

Parameters:
element -
baseURI -
Throws:
XMLSecurityException

SignatureAlgorithm

public SignatureAlgorithm(Element element,
                          String baseURI,
                          boolean secureValidation)
                   throws XMLSecurityException
Constructor SignatureAlgorithm

Parameters:
element -
baseURI -
secureValidation -
Throws:
XMLSecurityException
Method Detail

sign

public byte[] sign()
            throws XMLSignatureException
Proxy method for Signature.sign() which is executed on the internal Signature object.

Returns:
the result of the Signature.sign() method
Throws:
XMLSignatureException

getJCEAlgorithmString

public String getJCEAlgorithmString()
Proxy method for Signature.getAlgorithm() which is executed on the internal Signature object.

Returns:
the result of the Signature.getAlgorithm() method

getJCEProviderName

public String getJCEProviderName()
Method getJCEProviderName

Returns:
The Provider of this Signature Algorithm

update

public void update(byte[] input)
            throws XMLSignatureException
Proxy method for Signature.update(byte[]) which is executed on the internal Signature object.

Parameters:
input -
Throws:
XMLSignatureException

update

public void update(byte input)
            throws XMLSignatureException
Proxy method for Signature.update(byte) which is executed on the internal Signature object.

Parameters:
input -
Throws:
XMLSignatureException

update

public void update(byte[] buf,
                   int offset,
                   int len)
            throws XMLSignatureException
Proxy method for Signature.update(byte[], int, int) which is executed on the internal Signature object.

Parameters:
buf -
offset -
len -
Throws:
XMLSignatureException

initSign

public void initSign(Key signingKey)
              throws XMLSignatureException
Proxy method for Signature.initSign(java.security.PrivateKey) which is executed on the internal Signature object.

Parameters:
signingKey -
Throws:
XMLSignatureException

initSign

public void initSign(Key signingKey,
                     SecureRandom secureRandom)
              throws XMLSignatureException
Proxy method for Signature.initSign(java.security.PrivateKey, java.security.SecureRandom) which is executed on the internal Signature object.

Parameters:
signingKey -
secureRandom -
Throws:
XMLSignatureException

initSign

public void initSign(Key signingKey,
                     AlgorithmParameterSpec algorithmParameterSpec)
              throws XMLSignatureException
Proxy method for Signature.initSign(java.security.PrivateKey) which is executed on the internal Signature object.

Parameters:
signingKey -
algorithmParameterSpec -
Throws:
XMLSignatureException

setParameter

public void setParameter(AlgorithmParameterSpec params)
                  throws XMLSignatureException
Proxy method for Signature.setParameter( java.security.spec.AlgorithmParameterSpec) which is executed on the internal Signature object.

Parameters:
params -
Throws:
XMLSignatureException

initVerify

public void initVerify(Key verificationKey)
                throws XMLSignatureException
Proxy method for Signature.initVerify(java.security.PublicKey) which is executed on the internal Signature object.

Parameters:
verificationKey -
Throws:
XMLSignatureException

verify

public boolean verify(byte[] signature)
               throws XMLSignatureException
Proxy method for Signature.verify(byte[]) which is executed on the internal Signature object.

Parameters:
signature -
Returns:
true if if the signature is valid.
Throws:
XMLSignatureException

getURI

public final String getURI()
Returns the URI representation of Transformation algorithm

Returns:
the URI representation of Transformation algorithm

register

public static void register(String algorithmURI,
                            String implementingClass)
                     throws AlgorithmAlreadyRegisteredException,
                            ClassNotFoundException,
                            XMLSignatureException
Registers implementing class of the Transform algorithm with algorithmURI

Parameters:
algorithmURI - algorithmURI URI representation of Transform algorithm.
implementingClass - implementingClass the implementing class of SignatureAlgorithmSpi
Throws:
AlgorithmAlreadyRegisteredException - if specified algorithmURI is already registered
XMLSignatureException
ClassNotFoundException

register

public static void register(String algorithmURI,
                            Class<? extends SignatureAlgorithmSpi> implementingClass)
                     throws AlgorithmAlreadyRegisteredException,
                            ClassNotFoundException,
                            XMLSignatureException
Registers implementing class of the Transform algorithm with algorithmURI

Parameters:
algorithmURI - algorithmURI URI representation of Transform algorithm.
implementingClass - implementingClass the implementing class of SignatureAlgorithmSpi
Throws:
AlgorithmAlreadyRegisteredException - if specified algorithmURI is already registered
XMLSignatureException
ClassNotFoundException

registerDefaultAlgorithms

public static void registerDefaultAlgorithms()
This method registers the default algorithms.


getBaseNamespace

public String getBaseNamespace()
Method getBaseNamespace

Overrides:
getBaseNamespace in class SignatureElementProxy
Returns:
URI of this element

getBaseLocalName

public String getBaseLocalName()
Method getBaseLocalName

Specified by:
getBaseLocalName in class ElementProxy
Returns:
Local name


Copyright © 2000–2014 The Apache Software Foundation. All rights reserved.