当前位置: 首页>>代码示例>>Java>>正文


Java NoSuchMechanismException类代码示例

本文整理汇总了Java中javax.xml.crypto.NoSuchMechanismException的典型用法代码示例。如果您正苦于以下问题:Java NoSuchMechanismException类的具体用法?Java NoSuchMechanismException怎么用?Java NoSuchMechanismException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NoSuchMechanismException类属于javax.xml.crypto包,在下文中一共展示了NoSuchMechanismException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstance

import javax.xml.crypto.NoSuchMechanismException; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:49,代码来源:XMLSignatureFactory.java

示例2: getInstance

import javax.xml.crypto.NoSuchMechanismException; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:61,代码来源:KeyInfoFactory.java

示例3: getInstance

import javax.xml.crypto.NoSuchMechanismException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:45,代码来源:XMLSignatureFactory.java

示例4: getInstance

import javax.xml.crypto.NoSuchMechanismException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:44,代码来源:KeyInfoFactory.java

示例5: getInstance

import javax.xml.crypto.NoSuchMechanismException; //导入依赖的package包/类
/**
 * 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 <a
 *    href="../../../../../technotes/guides/security/xmldsig/overview.html#Service%20Provider">
 *    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;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:53,代码来源:XMLSignatureFactory.java

示例6: getInstance

import javax.xml.crypto.NoSuchMechanismException; //导入依赖的package包/类
/**
 * 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="../../../../../../technotes/guides/security/xmldsig/overview.html#Service%20Provider">
 *    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;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:52,代码来源:KeyInfoFactory.java


注:本文中的javax.xml.crypto.NoSuchMechanismException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。