XML Security, 1.6

com.ibm.xml.crypto.dsig.dom
Class AlgorithmFactory

java.lang.Object
  extended by com.ibm.xml.crypto.dsig.dom.AlgorithmFactory
All Implemented Interfaces:
Constants, EngineFactory

public class AlgorithmFactory
extends java.lang.Object
implements Constants, EngineFactory


Field Summary
protected  java.lang.String certProvider
           
protected  java.security.Provider digestProvider
           
(package private) static boolean ENABLE_CACHE
           
protected  java.lang.String keyProvider
           
protected  java.security.Provider macProvider
           
protected  java.security.Provider signatureProvider
           
protected  java.util.Set supportedDataEncryptions
           
protected  java.util.Set<java.lang.String> supportedDigests
           
protected  java.util.Set supportedKeyEncryptions
           
protected  java.util.Set supportedSignatures
           
 
Fields inherited from interface com.ibm.xml.crypto.dsig.Constants
ALG_ECDSA_SHA1, ALG_ESIGN_SHA1, ALG_GSSMIC, ALG_HMAC_MD5, ALG_HMAC_RIPEMD160, ALG_HMAC_SHA1, ALG_HMAC_SHA224, ALG_HMAC_SHA246, ALG_HMAC_SHA384, ALG_HMAC_SHA512, ALG_MD5, ALG_RSA_MD5, ALG_RSA_RIPEMD160, ALG_RSA_SHA256, ALG_RSA_SHA384, ALG_RSA_SHA512, ALG_SHA384, AT_ALGORITHM, AT_ENCODING, AT_ID, AT_MIMETYPE, AT_PREFIXLIST, AT_TARGET, AT_TYPE, AT_URI, AT_URN, AT_VALUE, AT_XPATH2_FILTER, EL_C14NMETHOD, EL_DIGESTMETHOD, EL_DIGESTVALUE, EL_DOMAINPARAMETERS, EL_DSA_G, EL_DSA_J, EL_DSA_P, EL_DSA_PGENCOUNTER, EL_DSA_Q, EL_DSA_SEED, EL_DSA_Y, EL_DSAKEYVALUE, EL_ECDSA_PUBLICKEY, EL_ECDSA_X, EL_ECDSA_Y, EL_ECDSAKEYVALUE, EL_EXPONENT, EL_HMACOUTPUTLENGTH, EL_INCLUSIVENAMESPACES, EL_KEYINFO, EL_KEYNAME, EL_KEYVALUE, EL_MANIFEST, EL_MODULUS, EL_NAMEDCURVE, EL_OBJECT, EL_PGPDATA, EL_PGPKEYID, EL_PGPKEYPACKET, EL_REFERENCE, EL_RETRIEVALMETHOD, EL_RSAKEYVALUE, EL_SIGNATURE, EL_SIGNATUREMETHOD, EL_SIGNATUREPROPERTIES, EL_SIGNATUREPROPERTY, EL_SIGNATUREVALUE, EL_SIGNEDINFO, EL_STYLESHEET, EL_TRANSFORM, EL_TRANSFORMS, EL_X509CERTIFICATE, EL_X509CRL, EL_X509DATA, EL_X509ISSUERNAME, EL_X509ISSUERSERIAL, EL_X509SERIALNUMBER, EL_X509SKI, EL_X509SUBJECTNAME, EL_XPATH, EL_XPATH2_XPATH, NS_DSIG, NS_DSIG_MORE, NS_GSS, NS_INCLUSIVENAMESPACES, NS_XML, NS_XMLNS, NS_XPATH2, NS_XSLT, PREFIX_DSIG, PREFIX_INCLUSIVE, PREFIX_XPATH2, PROP_EMPTY_DIGEST, PROP_INDENT, PROP_INDENT_START, PROP_INDENT_UNIT, XPATH2_FILTER_INTERSECT, XPATH2_FILTER_SUBTRACT, XPATH2_FILTER_UNION
 
Constructor Summary
protected AlgorithmFactory()
           
 
Method Summary
 boolean checkPGPKeyId(byte[] keyId)
           
 boolean checkPGPKeyPacket(byte[] keyPacket)
           
 boolean checkURI(java.lang.String uri)
          Called by URIReferenceImpl()
static boolean checkURI(java.lang.String uri, boolean verbose)
           
 java.security.spec.AlgorithmParameterSpec convertParameter(java.lang.String uri, java.util.Map properties)
          Convert algorithm parameters from properties form to AlgorithmParameterSpec form.
 java.security.cert.Certificate generateCertificate(java.io.InputStream is)
           
 java.security.cert.CRL generateCRL(java.io.InputStream is)
           
 java.security.PublicKey generatePublic(java.security.spec.KeySpec spec)
           
 java.util.Set getDataEncryptionAlgorithms()
          Return a set of the supported data encryption algorithms by a factory implementation.
 java.util.Set getDigestAlgorithms()
          Return a set of the supported digest algorithms by a factory implementation.
 javax.xml.parsers.DocumentBuilder getDocumentBuilder()
           
 EncryptionEngine getEncryptionEngine(java.lang.String uri)
          Return an instance of EncryptionEngine implementation which handles the algorithm specified by uri.
static AlgorithmFactory getInstance()
           
 java.util.Set getKeyEncryptionAlgorithms()
          Return a set of the supported key encryption algorithms by a factory implementation.
 KeyGenerationEngine getKeyGenerationEngine(java.lang.String uri, java.lang.String type)
          Return an instance of KeyGenerationEngine implementation which handles the algorithm specified by uri.
 java.security.MessageDigest getMessageDigest(java.lang.String uri, java.security.spec.AlgorithmParameterSpec spec)
          Return an instance of MessageDigest implementation which handles the algorithm specified by uri.
 java.util.Set getSignatureAlgorithms()
          Return a set of the supported signature algorithms by a factory implementation.
 SignatureEngine getSignatureEngine(java.lang.String alg)
          Return an instance of SignatureEngine implementation which handles the algorithm specified by uri.
 void marshalParameter(java.lang.String uri, java.security.spec.AlgorithmParameterSpec spec, org.w3c.dom.Element el)
          Marshal the specified spec under the el element.
(package private)  void marshalParameter(java.lang.String uri, java.security.spec.AlgorithmParameterSpec spec, org.w3c.dom.Element el, Marshalling m)
           
 org.w3c.dom.Document parse(java.io.InputStream stream)
           
 org.w3c.dom.Document parse(java.lang.String uri)
           
 void releaseDocumentBuilder(javax.xml.parsers.DocumentBuilder builder)
           
 boolean releaseEncryptionEngine(EncryptionEngine eng)
          This method is called when XML-Signature/XML-Encryption processors finish to use the specified engine instance.
 boolean releaseKeyGenerationEngine(KeyGenerationEngine eng)
          This method is called when XML-Signature/XML-Encryption processors finish to use the specified engine instance.
 boolean releaseMessageDigest(java.lang.String alg, java.security.MessageDigest d)
          This method is called when XML-Signature/XML-Encryption processors finish to use the specified engine instance.
 boolean releaseSignatureEngine(SignatureEngine eng)
          This method is called when XML-Signature/XML-Encryption processors finish to use the specified engine instance.
 java.security.spec.AlgorithmParameterSpec unmarshalParameter(java.lang.String uri, org.w3c.dom.Element el)
          Generate AlgorithmParameterSpec for uri from specified DOM element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENABLE_CACHE

static final boolean ENABLE_CACHE
See Also:
Constant Field Values

digestProvider

protected java.security.Provider digestProvider

signatureProvider

protected java.security.Provider signatureProvider

macProvider

protected java.security.Provider macProvider

certProvider

protected java.lang.String certProvider

keyProvider

protected java.lang.String keyProvider

supportedSignatures

protected java.util.Set supportedSignatures

supportedDigests

protected java.util.Set<java.lang.String> supportedDigests

supportedDataEncryptions

protected java.util.Set supportedDataEncryptions

supportedKeyEncryptions

protected java.util.Set supportedKeyEncryptions
Constructor Detail

AlgorithmFactory

protected AlgorithmFactory()
Method Detail

getInstance

public static AlgorithmFactory getInstance()

getDigestAlgorithms

public java.util.Set getDigestAlgorithms()
Description copied from interface: EngineFactory
Return a set of the supported digest algorithms by a factory implementation.

Specified by:
getDigestAlgorithms in interface EngineFactory
Returns:
A set of Strings representing the supported digest algorithms. If there is no algorithms to be supported, return null.

getMessageDigest

public java.security.MessageDigest getMessageDigest(java.lang.String uri,
                                                    java.security.spec.AlgorithmParameterSpec spec)
                                             throws java.security.NoSuchAlgorithmException,
                                                    java.security.InvalidAlgorithmParameterException
Description copied from interface: EngineFactory
Return an instance of MessageDigest implementation which handles the algorithm specified by uri. A factory implementation may return a cached MessageDigest instance.

Specified by:
getMessageDigest in interface EngineFactory
Parameters:
uri - Algorithm identifier
spec - An isntance of algorithm-specific sub-class of AlgorithmParameterSpec. It may be null.
Returns:
An instance of implementation class of MessageDigest interface. It supports the algorithm specified by uri
Throws:
java.security.NoSuchAlgorithmException - This factory implementation does not support the specified URI.
java.security.InvalidAlgorithmParameterException - Invalid AlgorithmParameterSpec is specified.

releaseMessageDigest

public boolean releaseMessageDigest(java.lang.String alg,
                                    java.security.MessageDigest d)
Description copied from interface: EngineFactory
This method is called when XML-Signature/XML-Encryption processors finish to use the specified engine instance. A factory implementation may pool the speficied instance.

Specified by:
releaseMessageDigest in interface EngineFactory
Parameters:
alg - Algorithm identifier
Returns:
true if specified instance is generated by this EngineFactory.

getSignatureAlgorithms

public java.util.Set getSignatureAlgorithms()
Description copied from interface: EngineFactory
Return a set of the supported signature algorithms by a factory implementation.

Specified by:
getSignatureAlgorithms in interface EngineFactory
Returns:
A set of Strings representing the supported signature algorithms. If there is no algorithms to be supported, return null.

getSignatureEngine

public SignatureEngine getSignatureEngine(java.lang.String alg)
                                   throws java.security.NoSuchAlgorithmException
Description copied from interface: EngineFactory
Return an instance of SignatureEngine implementation which handles the algorithm specified by uri. A factory implementation may return a cached SignatureEngine instance, and MUST call SignatureEngine.setParameter().

Specified by:
getSignatureEngine in interface EngineFactory
Parameters:
alg - Algorithm identifier
Returns:
An instance of implementation class of SignatureEngine interface. It supports the algorithm specified by uri
Throws:
java.security.NoSuchAlgorithmException - This factory implementation does not support the specified URI.

releaseSignatureEngine

public boolean releaseSignatureEngine(SignatureEngine eng)
Description copied from interface: EngineFactory
This method is called when XML-Signature/XML-Encryption processors finish to use the specified engine instance. A factory implementation may pool the speficied instance.

Specified by:
releaseSignatureEngine in interface EngineFactory
Parameters:
eng - An instance which is not used anymore.
Returns:
true if specified instance is generated by this EngineFactory.

getDataEncryptionAlgorithms

public java.util.Set getDataEncryptionAlgorithms()
Description copied from interface: EngineFactory
Return a set of the supported data encryption algorithms by a factory implementation.

Specified by:
getDataEncryptionAlgorithms in interface EngineFactory
Returns:
A set of Strings representing the supported data encryption algorithms. If there is no algorithms to be supported, return null.

getEncryptionEngine

public EncryptionEngine getEncryptionEngine(java.lang.String uri)
                                     throws java.security.NoSuchAlgorithmException
Description copied from interface: EngineFactory
Return an instance of EncryptionEngine implementation which handles the algorithm specified by uri. A factory implementation may return a cached EncryptionEngine instance.

Specified by:
getEncryptionEngine in interface EngineFactory
Parameters:
uri - Algorithm identifier
Returns:
An instance of implementation class of EncryptionEngine interface. It supports the algorithm specified by uri
Throws:
java.security.NoSuchAlgorithmException - This factory implementation does not support the specified URI.

releaseEncryptionEngine

public boolean releaseEncryptionEngine(EncryptionEngine eng)
Description copied from interface: EngineFactory
This method is called when XML-Signature/XML-Encryption processors finish to use the specified engine instance. A factory implementation may pool the speficied instance.

Specified by:
releaseEncryptionEngine in interface EngineFactory
Parameters:
eng - An instance which is not used anymore.
Returns:
true if specified instance is generated by this EngineFactory.

getKeyEncryptionAlgorithms

public java.util.Set getKeyEncryptionAlgorithms()
Description copied from interface: EngineFactory
Return a set of the supported key encryption algorithms by a factory implementation.

Specified by:
getKeyEncryptionAlgorithms in interface EngineFactory
Returns:
A set of Strings representing the supported key encryption algorithms. If there is no algorithms to be supported, return null.

getKeyGenerationEngine

public KeyGenerationEngine getKeyGenerationEngine(java.lang.String uri,
                                                  java.lang.String type)
                                           throws java.security.NoSuchAlgorithmException
Description copied from interface: EngineFactory
Return an instance of KeyGenerationEngine implementation which handles the algorithm specified by uri. A factory implementation may return a cached KeyGenerationEngine instance.

Specified by:
getKeyGenerationEngine in interface EngineFactory
Parameters:
uri - Algorithm identifier
type - Type identifier specified as enc:EncryptedKey/@Type. This may be null.
Returns:
An instance of implementation class of KeyGenerationEngine interface. It supports the algorithm specified by uri
Throws:
java.security.NoSuchAlgorithmException - This factory implementation does not support the specified URI.

releaseKeyGenerationEngine

public boolean releaseKeyGenerationEngine(KeyGenerationEngine eng)
Description copied from interface: EngineFactory
This method is called when XML-Signature/XML-Encryption processors finish to use the specified engine instance. A factory implementation may pool the speficied instance.

Specified by:
releaseKeyGenerationEngine in interface EngineFactory
Parameters:
eng - An instance which is not used anymore.
Returns:
true if specified instance is generated by this EngineFactory.

unmarshalParameter

public java.security.spec.AlgorithmParameterSpec unmarshalParameter(java.lang.String uri,
                                                                    org.w3c.dom.Element el)
                                                             throws java.security.NoSuchAlgorithmException,
                                                                    java.security.InvalidAlgorithmParameterException
Description copied from interface: EngineFactory
Generate AlgorithmParameterSpec for uri from specified DOM element.

Specified by:
unmarshalParameter in interface EngineFactory
Parameters:
uri - Algorithm identifier
el - An element representing <ds:SingatureMethod>, <ds:DigestMethod>, or <enc:EncryptionMethod>.
Throws:
java.security.NoSuchAlgorithmException - This factory implementation does not support the specified URI.
java.security.InvalidAlgorithmParameterException - Parameters in el is invalid.

convertParameter

public java.security.spec.AlgorithmParameterSpec convertParameter(java.lang.String uri,
                                                                  java.util.Map properties)
                                                           throws java.security.NoSuchAlgorithmException,
                                                                  java.security.InvalidAlgorithmParameterException
Description copied from interface: EngineFactory
Convert algorithm parameters from properties form to AlgorithmParameterSpec form.

Specified by:
convertParameter in interface EngineFactory
Parameters:
uri - Algorithm identifier
properties - String => String map specified in a configuration. It may be null.
Returns:
An isntance of algorithm-specific sub-class of AlgorithmParameterSpec. It may be null.
Throws:
java.security.NoSuchAlgorithmException - This factory implementation does not support the specified URI.
java.security.InvalidAlgorithmParameterException - Invalid AlgorithmParameterSpec is specified.

marshalParameter

public void marshalParameter(java.lang.String uri,
                             java.security.spec.AlgorithmParameterSpec spec,
                             org.w3c.dom.Element el)
                      throws java.security.NoSuchAlgorithmException,
                             java.security.InvalidAlgorithmParameterException
Description copied from interface: EngineFactory
Marshal the specified spec under the el element.

Specified by:
marshalParameter in interface EngineFactory
Parameters:
uri - Algorithm identifier
spec - Algorithm parameter to be marshalled. It may be null.
el - An element representing <ds:SingatureMethod>, <ds:DigestMethod>, or <enc:EncryptionMethod>.
Throws:
java.security.NoSuchAlgorithmException - This factory implementation does not support the specified URI.
java.security.InvalidAlgorithmParameterException - Invalid AlgorithmParameterSpec is specified.

marshalParameter

void marshalParameter(java.lang.String uri,
                      java.security.spec.AlgorithmParameterSpec spec,
                      org.w3c.dom.Element el,
                      Marshalling m)
                throws java.security.NoSuchAlgorithmException,
                       java.security.InvalidAlgorithmParameterException
Parameters:
c - may be null
Throws:
java.security.NoSuchAlgorithmException
java.security.InvalidAlgorithmParameterException

generatePublic

public java.security.PublicKey generatePublic(java.security.spec.KeySpec spec)
                                       throws java.security.NoSuchAlgorithmException,
                                              java.security.spec.InvalidKeySpecException,
                                              java.security.NoSuchProviderException
Throws:
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
java.security.NoSuchProviderException

generateCertificate

public java.security.cert.Certificate generateCertificate(java.io.InputStream is)
                                                   throws java.security.cert.CertificateException,
                                                          java.security.NoSuchProviderException
Throws:
java.security.cert.CertificateException
java.security.NoSuchProviderException

generateCRL

public java.security.cert.CRL generateCRL(java.io.InputStream is)
                                   throws java.security.cert.CertificateException,
                                          java.security.NoSuchProviderException,
                                          java.security.cert.CRLException
Throws:
java.security.cert.CertificateException
java.security.NoSuchProviderException
java.security.cert.CRLException

getDocumentBuilder

public javax.xml.parsers.DocumentBuilder getDocumentBuilder()
                                                     throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException

releaseDocumentBuilder

public void releaseDocumentBuilder(javax.xml.parsers.DocumentBuilder builder)

parse

public org.w3c.dom.Document parse(java.lang.String uri)
                           throws javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException,
                                  java.io.IOException
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException

parse

public org.w3c.dom.Document parse(java.io.InputStream stream)
                           throws javax.xml.parsers.ParserConfigurationException,
                                  org.xml.sax.SAXException,
                                  java.io.IOException
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException

checkURI

public boolean checkURI(java.lang.String uri)
Called by URIReferenceImpl()


checkURI

public static boolean checkURI(java.lang.String uri,
                               boolean verbose)

checkPGPKeyId

public boolean checkPGPKeyId(byte[] keyId)

checkPGPKeyPacket

public boolean checkPGPKeyPacket(byte[] keyPacket)
                          throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

XML Security, 1.6

Portions Copyright 2003, 2012 IBM Corporation.
Portions Copyright 2003, 2012 Oracle and/or its affiliates.