Search in sources :

Example 1 with NoSuchMechanismException

use of javax.xml.crypto.NoSuchMechanismException in project jdk8u_jdk by JetBrains.

the class KeyInfoFactory method getInstance.

/**
     * Returns a <code>KeyInfoFactory</code> that supports the
     * requested XML processing mechanism and representation type (ex: "DOM"),
     * as supplied by the specified provider. Note that the specified
     * <code>Provider</code> object does not have to be registered in the
     * provider list.
     *
     * @param mechanismType the type of the XML processing mechanism and
     *    representation. See the <a
     *    href="../../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
     *    Service Providers</a> section of the API overview for a list of
     *    standard mechanism types.
     * @param provider the <code>Provider</code> object
     * @return a new <code>KeyInfoFactory</code>
     * @throws NullPointerException if <code>mechanismType</code> or
     *    <code>provider</code> are <code>null</code>
     * @throws NoSuchMechanismException if a <code>KeyInfoFactory</code>
     *    implementation for the specified mechanism is not available from the
     *    specified <code>Provider</code> object
     * @see Provider
     */
public static KeyInfoFactory getInstance(String mechanismType, Provider provider) {
    if (mechanismType == null) {
        throw new NullPointerException("mechanismType cannot be null");
    } else if (provider == null) {
        throw new NullPointerException("provider cannot be null");
    }
    Instance instance;
    try {
        instance = GetInstance.getInstance("KeyInfoFactory", null, mechanismType, provider);
    } catch (NoSuchAlgorithmException nsae) {
        throw new NoSuchMechanismException(nsae);
    }
    KeyInfoFactory factory = (KeyInfoFactory) instance.impl;
    factory.mechanismType = mechanismType;
    factory.provider = instance.provider;
    return factory;
}
Also used : Instance(sun.security.jca.GetInstance.Instance) NoSuchMechanismException(javax.xml.crypto.NoSuchMechanismException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 2 with NoSuchMechanismException

use of javax.xml.crypto.NoSuchMechanismException in project jdk8u_jdk by JetBrains.

the class KeyInfoFactory method getInstance.

/**
     * Returns a <code>KeyInfoFactory</code> that supports the
     * specified XML processing mechanism and representation type (ex: "DOM").
     *
     * <p>This method uses the standard JCA provider lookup mechanism to
     * locate and instantiate a <code>KeyInfoFactory</code> implementation of
     * the desired mechanism type. It traverses the list of registered security
     * <code>Provider</code>s, starting with the most preferred
     * <code>Provider</code>. A new <code>KeyInfoFactory</code> object
     * from the first <code>Provider</code> that supports the specified
     * mechanism is returned.
     *
     * <p> Note that the list of registered providers may be retrieved via
     * the {@link Security#getProviders() Security.getProviders()} method.
     *
     * @param mechanismType the type of the XML processing mechanism and
     *    representation. See the <a
     *    href="../../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
     *    Service Providers</a> section of the API overview for a list of
     *    standard mechanism types.
     * @return a new <code>KeyInfoFactory</code>
     * @throws NullPointerException if <code>mechanismType</code> is
     *    <code>null</code>
     * @throws NoSuchMechanismException if no <code>Provider</code> supports a
     *    <code>KeyInfoFactory</code> implementation for the specified mechanism
     * @see Provider
     */
public static KeyInfoFactory getInstance(String mechanismType) {
    if (mechanismType == null) {
        throw new NullPointerException("mechanismType cannot be null");
    }
    Instance instance;
    try {
        instance = GetInstance.getInstance("KeyInfoFactory", null, mechanismType);
    } catch (NoSuchAlgorithmException nsae) {
        throw new NoSuchMechanismException(nsae);
    }
    KeyInfoFactory factory = (KeyInfoFactory) instance.impl;
    factory.mechanismType = mechanismType;
    factory.provider = instance.provider;
    return factory;
}
Also used : Instance(sun.security.jca.GetInstance.Instance) NoSuchMechanismException(javax.xml.crypto.NoSuchMechanismException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 3 with NoSuchMechanismException

use of javax.xml.crypto.NoSuchMechanismException in project jdk8u_jdk by JetBrains.

the class XMLSignatureFactory method getInstance.

/**
     * Returns an <code>XMLSignatureFactory</code> that supports the
     * requested XML processing mechanism and representation type (ex: "DOM"),
     * as supplied by the specified provider. Note that the specified
     * <code>Provider</code> object does not have to be registered in the
     * provider list.
     *
     * @param mechanismType the type of the XML processing mechanism and
     *    representation. See the <a
     *    href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
     *    Service Providers</a> section of the API overview for a list of
     *    standard mechanism types.
     * @param provider the <code>Provider</code> object
     * @return a new <code>XMLSignatureFactory</code>
     * @throws NullPointerException if <code>provider</code> or
     *    <code>mechanismType</code> is <code>null</code>
     * @throws NoSuchMechanismException if an <code>XMLSignatureFactory</code>
     *   implementation for the specified mechanism is not available
     *   from the specified <code>Provider</code> object
     * @see Provider
     */
public static XMLSignatureFactory getInstance(String mechanismType, Provider provider) {
    if (mechanismType == null) {
        throw new NullPointerException("mechanismType cannot be null");
    } else if (provider == null) {
        throw new NullPointerException("provider cannot be null");
    }
    Instance instance;
    try {
        instance = GetInstance.getInstance("XMLSignatureFactory", null, mechanismType, provider);
    } catch (NoSuchAlgorithmException nsae) {
        throw new NoSuchMechanismException(nsae);
    }
    XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
    factory.mechanismType = mechanismType;
    factory.provider = instance.provider;
    return factory;
}
Also used : Instance(sun.security.jca.GetInstance.Instance) NoSuchMechanismException(javax.xml.crypto.NoSuchMechanismException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 4 with NoSuchMechanismException

use of javax.xml.crypto.NoSuchMechanismException in project jdk8u_jdk by JetBrains.

the class XMLSignatureFactory method getInstance.

/**
     * Returns an <code>XMLSignatureFactory</code> that supports the
     * requested XML processing mechanism and representation type (ex: "DOM"),
     * as supplied by the specified provider. The specified provider must be
     * registered in the security provider list.
     *
     * <p>Note that the list of registered providers may be retrieved via
     * the {@link Security#getProviders() Security.getProviders()} method.
     *
     * @param mechanismType the type of the XML processing mechanism and
     *    representation. See the <a
     *    href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
     *    Service Providers</a> section of the API overview for a list of
     *    standard mechanism types.
     * @param provider the string name of the provider
     * @return a new <code>XMLSignatureFactory</code>
     * @throws NoSuchProviderException if the specified provider is not
     *    registered in the security provider list
     * @throws NullPointerException if <code>provider</code> or
     *    <code>mechanismType</code> is <code>null</code>
     * @throws NoSuchMechanismException if an <code>XMLSignatureFactory</code>
     *    implementation for the specified mechanism is not
     *    available from the specified provider
     * @see Provider
     */
public static XMLSignatureFactory getInstance(String mechanismType, String provider) throws NoSuchProviderException {
    if (mechanismType == null) {
        throw new NullPointerException("mechanismType cannot be null");
    } else if (provider == null) {
        throw new NullPointerException("provider cannot be null");
    } else if (provider.length() == 0) {
        throw new NoSuchProviderException();
    }
    Instance instance;
    try {
        instance = GetInstance.getInstance("XMLSignatureFactory", null, mechanismType, provider);
    } catch (NoSuchAlgorithmException nsae) {
        throw new NoSuchMechanismException(nsae);
    }
    XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
    factory.mechanismType = mechanismType;
    factory.provider = instance.provider;
    return factory;
}
Also used : Instance(sun.security.jca.GetInstance.Instance) NoSuchMechanismException(javax.xml.crypto.NoSuchMechanismException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoSuchProviderException(java.security.NoSuchProviderException)

Aggregations

NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 NoSuchMechanismException (javax.xml.crypto.NoSuchMechanismException)4 Instance (sun.security.jca.GetInstance.Instance)4 NoSuchProviderException (java.security.NoSuchProviderException)1