javax.xml.crypto.NoSuchMechanismException Java Examples

The following examples show how to use javax.xml.crypto.NoSuchMechanismException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLSignatureFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 {@extLink security_guide_xmldsig_provider
 *    Service Providers} 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");
    }

    Service s = provider.getService("XMLSignatureFactory", mechanismType);
    if (s != null) {
        Object obj = null;
        try {
            obj = s.newInstance(null);
        } catch (NoSuchAlgorithmException nsae) {
            throw new NoSuchMechanismException(nsae);
        }

        if (obj instanceof XMLSignatureFactory) {
            XMLSignatureFactory factory = (XMLSignatureFactory) obj;
            factory.mechanismType = mechanismType;
            factory.provider = provider;
            return factory;
        }
    }
    throw new NoSuchMechanismException
        ("Mechanism " + mechanismType + " not available from " +
         provider.getName());
}
 
Example #2
Source File: XMLSignatureFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 {@extLink security_guide_xmldsig_provider
 *    Service Providers} 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();
    }

    Provider p = Security.getProvider(provider);
    if (p == null) {
        throw new NoSuchProviderException("No such provider: " +
                                          provider);
    }
    Service s = p.getService("XMLSignatureFactory", mechanismType);
    if (s != null) {
        Object obj = null;
        try {
            obj = s.newInstance(null);
        } catch (NoSuchAlgorithmException nsae) {
            throw new NoSuchMechanismException(nsae);
        }
        if (obj instanceof XMLSignatureFactory) {
            XMLSignatureFactory factory = (XMLSignatureFactory) obj;
            factory.mechanismType = mechanismType;
            factory.provider = p;
            return factory;
        }
    }
    throw new NoSuchMechanismException
        ("Mechanism " + mechanismType + " not available from " + provider);
}
 
Example #3
Source File: KeyInfoFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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=
 *    "{@docRoot}/../specs/security/standard-names.html#xml-signature-xmlsignaturefactorykeyinfofactorytransformservice-mechanisms">
 *    Java Security Standard Algorithm Names</a> document
 *    for more information.
 * @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");
    }

    Service s = provider.getService("KeyInfoFactory", mechanismType);
    if (s != null) {
        Object obj = null;
        try {
            obj = s.newInstance(null);
        } catch (NoSuchAlgorithmException nsae) {
            throw new NoSuchMechanismException(nsae);
        }

        if (obj instanceof KeyInfoFactory) {
            KeyInfoFactory factory = (KeyInfoFactory) obj;
            factory.mechanismType = mechanismType;
            factory.provider = provider;
            return factory;
        }
    }
    throw new NoSuchMechanismException
        ("Mechanism " + mechanismType + " not available from " + provider.getName());
}
 
Example #4
Source File: KeyInfoFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a <code>KeyInfoFactory</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=
 *    "{@docRoot}/../specs/security/standard-names.html#xml-signature-xmlsignaturefactorykeyinfofactorytransformservice-mechanisms">
 *    Java Security Standard Algorithm Names</a> document
 *    for more information.
 * @param provider the string name of the provider
 * @return a new <code>KeyInfoFactory</code>
 * @throws NoSuchProviderException if the specified provider is not
 *    registered in the security provider list
 * @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 provider
 * @see Provider
 */
public static KeyInfoFactory 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();
    }
    Provider p = Security.getProvider(provider);
    if (p == null) {
        throw new NoSuchProviderException("No such provider: " +
                                          provider);
    }
    Service s = p.getService("KeyInfoFactory", mechanismType);
    if (s != null) {
        Object obj = null;
        try {
            obj = s.newInstance(null);
        } catch (NoSuchAlgorithmException nsae) {
            throw new NoSuchMechanismException(nsae);
        }
        if (obj instanceof KeyInfoFactory) {
            KeyInfoFactory factory = (KeyInfoFactory) obj;
            factory.mechanismType = mechanismType;
            factory.provider = p;
            return factory;
        }
    }
    throw new NoSuchMechanismException
        ("Mechanism " + mechanismType + " not available from " + provider);
}
 
Example #5
Source File: XMLSignatureFactory.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: KeyInfoFactory.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #7
Source File: KeyInfoFactory.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a <code>KeyInfoFactory</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>KeyInfoFactory</code>
 * @throws NoSuchProviderException if the specified provider is not
 *    registered in the security provider list
 * @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 provider
 * @see Provider
 */
public static KeyInfoFactory 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
            ("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;
}
 
Example #8
Source File: KeyInfoFactory.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: KeyInfoFactory.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a <code>KeyInfoFactory</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>KeyInfoFactory</code>
 * @throws NoSuchProviderException if the specified provider is not
 *    registered in the security provider list
 * @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 provider
 * @see Provider
 */
public static KeyInfoFactory 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
            ("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;
}
 
Example #10
Source File: XMLSignatureFactory.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns an <code>XMLSignatureFactory</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 an <code>XMLSignatureFactory</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>XMLSignatureFactory</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>XMLSignatureFactory</code>
 * @throws NullPointerException if <code>mechanismType</code> is
 *    <code>null</code>
 * @throws NoSuchMechanismException if no <code>Provider</code> supports an
 *    <code>XMLSignatureFactory</code> implementation for the specified
 *    mechanism
 * @see Provider
 */
public static XMLSignatureFactory getInstance(String mechanismType) {
    if (mechanismType == null) {
        throw new NullPointerException("mechanismType cannot be null");
    }
    Instance instance;
    try {
        instance = GetInstance.getInstance
            ("XMLSignatureFactory", null, mechanismType);
    } catch (NoSuchAlgorithmException nsae) {
        throw new NoSuchMechanismException(nsae);
    }
    XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
    factory.mechanismType = mechanismType;
    factory.provider = instance.provider;
    return factory;
}
 
Example #11
Source File: XMLSignatureFactory.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: XMLSignatureFactory.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source File: KeyInfoFactory.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a <code>KeyInfoFactory</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>KeyInfoFactory</code>
 * @throws NoSuchProviderException if the specified provider is not
 *    registered in the security provider list
 * @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 provider
 * @see Provider
 */
public static KeyInfoFactory 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
            ("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;
}
 
Example #14
Source File: XMLSignatureFactory.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #15
Source File: XMLSignatureFactory.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns an <code>XMLSignatureFactory</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 an <code>XMLSignatureFactory</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>XMLSignatureFactory</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>XMLSignatureFactory</code>
 * @throws NullPointerException if <code>mechanismType</code> is
 *    <code>null</code>
 * @throws NoSuchMechanismException if no <code>Provider</code> supports an
 *    <code>XMLSignatureFactory</code> implementation for the specified
 *    mechanism
 * @see Provider
 */
public static XMLSignatureFactory getInstance(String mechanismType) {
    if (mechanismType == null) {
        throw new NullPointerException("mechanismType cannot be null");
    }
    Instance instance;
    try {
        instance = GetInstance.getInstance
            ("XMLSignatureFactory", null, mechanismType);
    } catch (NoSuchAlgorithmException nsae) {
        throw new NoSuchMechanismException(nsae);
    }
    XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
    factory.mechanismType = mechanismType;
    factory.provider = instance.provider;
    return factory;
}
 
Example #16
Source File: KeyInfoFactory.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #17
Source File: KeyInfoFactory.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #18
Source File: KeyInfoFactory.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #19
Source File: XMLSignatureFactory.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source File: XMLSignatureFactory.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns an <code>XMLSignatureFactory</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 an <code>XMLSignatureFactory</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>XMLSignatureFactory</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>XMLSignatureFactory</code>
 * @throws NullPointerException if <code>mechanismType</code> is
 *    <code>null</code>
 * @throws NoSuchMechanismException if no <code>Provider</code> supports an
 *    <code>XMLSignatureFactory</code> implementation for the specified
 *    mechanism
 * @see Provider
 */
public static XMLSignatureFactory getInstance(String mechanismType) {
    if (mechanismType == null) {
        throw new NullPointerException("mechanismType cannot be null");
    }
    Instance instance;
    try {
        instance = GetInstance.getInstance
            ("XMLSignatureFactory", null, mechanismType);
    } catch (NoSuchAlgorithmException nsae) {
        throw new NoSuchMechanismException(nsae);
    }
    XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
    factory.mechanismType = mechanismType;
    factory.provider = instance.provider;
    return factory;
}
 
Example #21
Source File: XMLSignatureFactory.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an <code>XMLSignatureFactory</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 an <code>XMLSignatureFactory</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>XMLSignatureFactory</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>XMLSignatureFactory</code>
 * @throws NullPointerException if <code>mechanismType</code> is
 *    <code>null</code>
 * @throws NoSuchMechanismException if no <code>Provider</code> supports an
 *    <code>XMLSignatureFactory</code> implementation for the specified
 *    mechanism
 * @see Provider
 */
public static XMLSignatureFactory getInstance(String mechanismType) {
    if (mechanismType == null) {
        throw new NullPointerException("mechanismType cannot be null");
    }
    Instance instance;
    try {
        instance = GetInstance.getInstance
            ("XMLSignatureFactory", null, mechanismType);
    } catch (NoSuchAlgorithmException nsae) {
        throw new NoSuchMechanismException(nsae);
    }
    XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
    factory.mechanismType = mechanismType;
    factory.provider = instance.provider;
    return factory;
}
 
Example #22
Source File: KeyInfoFactory.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a <code>KeyInfoFactory</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>KeyInfoFactory</code>
 * @throws NoSuchProviderException if the specified provider is not
 *    registered in the security provider list
 * @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 provider
 * @see Provider
 */
public static KeyInfoFactory 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
            ("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;
}
 
Example #23
Source File: KeyInfoFactory.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #24
Source File: KeyInfoFactory.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #25
Source File: XMLSignatureFactory.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #26
Source File: XMLSignatureFactory.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #27
Source File: XMLSignatureFactory.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns an <code>XMLSignatureFactory</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 an <code>XMLSignatureFactory</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>XMLSignatureFactory</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>XMLSignatureFactory</code>
 * @throws NullPointerException if <code>mechanismType</code> is
 *    <code>null</code>
 * @throws NoSuchMechanismException if no <code>Provider</code> supports an
 *    <code>XMLSignatureFactory</code> implementation for the specified
 *    mechanism
 * @see Provider
 */
public static XMLSignatureFactory getInstance(String mechanismType) {
    if (mechanismType == null) {
        throw new NullPointerException("mechanismType cannot be null");
    }
    Instance instance;
    try {
        instance = GetInstance.getInstance
            ("XMLSignatureFactory", null, mechanismType);
    } catch (NoSuchAlgorithmException nsae) {
        throw new NoSuchMechanismException(nsae);
    }
    XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
    factory.mechanismType = mechanismType;
    factory.provider = instance.provider;
    return factory;
}
 
Example #28
Source File: KeyInfoFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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.
 *
 * @implNote
 * The JDK Reference Implementation additionally uses the
 * {@code jdk.security.provider.preferred}
 * {@link Security#getProperty(String) Security} property to determine
 * the preferred provider order for the specified algorithm. This
 * may be different than the order of providers returned by
 * {@link Security#getProviders() Security.getProviders()}.
 *
 * @param mechanismType the type of the XML processing mechanism and
 *    representation.  See the <a href=
 *    "{@docRoot}/../specs/security/standard-names.html#xml-signature-xmlsignaturefactorykeyinfofactorytransformservice-mechanisms">
 *    Java Security Standard Algorithm Names</a> document
 * for more information.
 * @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");
    }
    Provider[] provs = Security.getProviders();
    for (Provider p : provs) {
        Service s = p.getService("KeyInfoFactory", mechanismType);
        if (s != null) {
            Object obj = null;
            try {
                obj = s.newInstance(null);
            } catch (NoSuchAlgorithmException nsae) {
                throw new NoSuchMechanismException(nsae);
            }
            if (obj instanceof KeyInfoFactory) {
                KeyInfoFactory factory = (KeyInfoFactory) obj;
                factory.mechanismType = mechanismType;
                factory.provider = p;
                return factory;
            }
        }
    }
    throw new NoSuchMechanismException
        ("Mechanism " + mechanismType + " not available");
}
 
Example #29
Source File: XMLSignatureFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns an <code>XMLSignatureFactory</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 an <code>XMLSignatureFactory</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>XMLSignatureFactory</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.
 *
 * @implNote
 * The JDK Reference Implementation additionally uses the
 * {@code jdk.security.provider.preferred}
 * {@link Security#getProperty(String) Security} property to determine
 * the preferred provider order for the specified algorithm. This
 * may be different than the order of providers returned by
 * {@link Security#getProviders() Security.getProviders()}.
 *
 * @param mechanismType the type of the XML processing mechanism and
 *    representation. See the {@extLink security_guide_xmldsig_provider
 *    Service Providers} section of the API overview for a list of
 *    standard mechanism types.
 * @return a new <code>XMLSignatureFactory</code>
 * @throws NullPointerException if <code>mechanismType</code> is
 *    <code>null</code>
 * @throws NoSuchMechanismException if no <code>Provider</code> supports an
 *    <code>XMLSignatureFactory</code> implementation for the specified
 *    mechanism
 * @see Provider
 */
public static XMLSignatureFactory getInstance(String mechanismType) {
    if (mechanismType == null) {
        throw new NullPointerException("mechanismType cannot be null");
    }
    Provider[] provs = Security.getProviders();
    for (Provider p : provs) {
        Service s = p.getService("XMLSignatureFactory", mechanismType);
        if (s != null) {
            Object obj = null;
            try {
                obj = s.newInstance(null);
            } catch (NoSuchAlgorithmException nsae) {
                throw new NoSuchMechanismException(nsae);
            }
            if (obj instanceof XMLSignatureFactory) {
                XMLSignatureFactory factory = (XMLSignatureFactory) obj;
                factory.mechanismType = mechanismType;
                factory.provider = p;
                return factory;
            }
        }
    }
    throw new NoSuchMechanismException
        ("Mechanism " + mechanismType + " not available");
}
 
Example #30
Source File: KeyInfoFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a <code>KeyInfoFactory</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>KeyInfoFactory</code>
 * @throws NoSuchProviderException if the specified provider is not
 *    registered in the security provider list
 * @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 provider
 * @see Provider
 */
public static KeyInfoFactory 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
            ("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;
}