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


Java Instance类代码示例

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


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

示例1: getInstanceRSA

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
private static Signature getInstanceRSA(Provider p)
        throws NoSuchAlgorithmException {
    // try Signature first
    Service s = p.getService("Signature", RSA_SIGNATURE);
    if (s != null) {
        Instance instance = GetInstance.getInstance(s, SignatureSpi.class);
        return getInstance(instance, RSA_SIGNATURE);
    }
    // check Cipher
    try {
        Cipher c = Cipher.getInstance(RSA_CIPHER, p);
        return new Delegate(new CipherAdapter(c), RSA_SIGNATURE);
    } catch (GeneralSecurityException e) {
        // throw Signature style exception message to avoid confusion,
        // but append Cipher exception as cause
        throw new NoSuchAlgorithmException("no such algorithm: "
            + RSA_SIGNATURE + " for provider " + p.getName(), e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Signature.java

示例2: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
private static KeyPairGenerator getInstance(Instance instance,
        String algorithm) {
    KeyPairGenerator kpg;
    if (instance.impl instanceof KeyPairGenerator) {
        kpg = (KeyPairGenerator)instance.impl;
    } else {
        KeyPairGeneratorSpi spi = (KeyPairGeneratorSpi)instance.impl;
        kpg = new Delegate(spi, algorithm);
    }
    kpg.provider = instance.provider;

    if (!skipDebug && pdebug != null) {
        pdebug.println("KeyPairGenerator." + algorithm +
            " algorithm from: " + kpg.provider.getName());
    }

    return kpg;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:KeyPairGenerator.java

示例3: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
static Instance getInstance(String type, Class<?> clazz, String algorithm)
        throws NoSuchAlgorithmException {
    List<Service> services = GetInstance.getServices(type, algorithm);
    NoSuchAlgorithmException failure = null;
    for (Service s : services) {
        if (canUseProvider(s.getProvider()) == false) {
            // allow only signed providers
            continue;
        }
        try {
            Instance instance = GetInstance.getInstance(s, clazz);
            return instance;
        } catch (NoSuchAlgorithmException e) {
            failure = e;
        }
    }
    throw new NoSuchAlgorithmException("Algorithm " + algorithm
            + " not available", failure);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:JceSecurity.java

示例4: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
/**
 * Returns a Signature object that implements the specified signature
 * algorithm.
 *
 * <p> This method traverses the list of registered security Providers,
 * starting with the most preferred Provider.
 * A new Signature object encapsulating the
 * SignatureSpi implementation from the first
 * Provider that supports the specified algorithm is returned.
 *
 * <p> Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the standard name of the algorithm requested.
 * See the Signature section in the <a href=
 * "{@docRoot}/../technotes/guides/security/StandardNames.html#Signature">
 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 * for information about standard algorithm names.
 *
 * @return the new Signature object.
 *
 * @exception NoSuchAlgorithmException if no Provider supports a
 *          Signature implementation for the
 *          specified algorithm.
 *
 * @see Provider
 */
public static Signature getInstance(String algorithm)
        throws NoSuchAlgorithmException {
    List<Service> list;
    if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
        list = GetInstance.getServices(rsaIds);
    } else {
        list = GetInstance.getServices("Signature", algorithm);
    }
    Iterator<Service> t = list.iterator();
    if (t.hasNext() == false) {
        throw new NoSuchAlgorithmException
            (algorithm + " Signature not available");
    }
    // try services until we find an Spi or a working Signature subclass
    NoSuchAlgorithmException failure;
    do {
        Service s = t.next();
        if (isSpi(s)) {
            return new Delegate(s, t, algorithm);
        } else {
            // must be a subclass of Signature, disable dynamic selection
            try {
                Instance instance =
                    GetInstance.getInstance(s, SignatureSpi.class);
                return getInstance(instance, algorithm);
            } catch (NoSuchAlgorithmException e) {
                failure = e;
            }
        }
    } while (t.hasNext());
    throw failure;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:60,代码来源:Signature.java

示例5: Delegate

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
Delegate(Instance instance, Iterator<Service> serviceIterator,
        String algorithm) {
    super(algorithm);
    spi = (KeyPairGeneratorSpi)instance.impl;
    provider = instance.provider;
    this.serviceIterator = serviceIterator;
    initType = I_NONE;

    if (!skipDebug && pdebug != null) {
        pdebug.println("KeyPairGenerator." + algorithm +
            " algorithm from: " + provider.getName());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:KeyPairGenerator.java

示例6: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
private static Signature getInstance(Instance instance, String algorithm) {
    Signature sig;
    if (instance.impl instanceof Signature) {
        sig = (Signature)instance.impl;
        sig.algorithm = algorithm;
    } else {
        SignatureSpi spi = (SignatureSpi)instance.impl;
        sig = new Delegate(spi, algorithm);
    }
    sig.provider = instance.provider;
    return sig;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:Signature.java

示例7: if

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
/**
 * Returns a <code>TransformService</code> that supports the specified
 * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
 * (ex: DOM).
 *
 * <p>This method uses the standard JCA provider lookup mechanism to
 * locate and instantiate a <code>TransformService</code> implementation
 * of the desired algorithm and <code>MechanismType</code> service
 * attribute. It traverses the list of registered security
 * <code>Provider</code>s, starting with the most preferred
 * <code>Provider</code>. A new <code>TransformService</code> object
 * from the first <code>Provider</code> that supports the specified
 * algorithm and mechanism type is returned.
 *
 * <p> Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the URI of the algorithm
 * @param mechanismType the type of the XML processing mechanism and
 *   representation
 * @return a new <code>TransformService</code>
 * @throws NullPointerException if <code>algorithm</code> or
 *   <code>mechanismType</code> is  <code>null</code>
 * @throws NoSuchAlgorithmException if no <code>Provider</code> supports a
 *   <code>TransformService</code> implementation for the specified
 *   algorithm and mechanism type
 * @see Provider
 */
public static TransformService getInstance
    (String algorithm, String mechanismType)
    throws NoSuchAlgorithmException {
    if (mechanismType == null || algorithm == null) {
        throw new NullPointerException();
    }
    boolean dom = false;
    if (mechanismType.equals("DOM")) {
        dom = true;
    }
    List<Service> services = GetInstance.getServices("TransformService", algorithm);
    for (Iterator<Service> t = services.iterator(); t.hasNext(); ) {
        Service s = t.next();
        String value = s.getAttribute("MechanismType");
        if ((value == null && dom) ||
            (value != null && value.equals(mechanismType))) {
            Instance instance = GetInstance.getInstance(s, null);
            TransformService ts = (TransformService) instance.impl;
            ts.algorithm = algorithm;
            ts.mechanism = mechanismType;
            ts.provider = instance.provider;
            return ts;
        }
    }
    throw new NoSuchAlgorithmException
        (algorithm + " algorithm and " + mechanismType
             + " mechanism not available");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:57,代码来源:TransformService.java

示例8: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的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

示例9: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的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

示例10: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
/**
 * Returns a Signature object that implements the specified signature
 * algorithm.
 *
 * <p> A new Signature object encapsulating the
 * SignatureSpi implementation from the specified provider
 * is returned.  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 algorithm the name of the algorithm requested.
 * See the Signature section in the <a href=
 * "{@docRoot}/../technotes/guides/security/StandardNames.html#Signature">
 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 * for information about standard algorithm names.
 *
 * @param provider the name of the provider.
 *
 * @return the new Signature object.
 *
 * @exception NoSuchAlgorithmException if a SignatureSpi
 *          implementation for the specified algorithm is not
 *          available from the specified provider.
 *
 * @exception NoSuchProviderException if the specified provider is not
 *          registered in the security provider list.
 *
 * @exception IllegalArgumentException if the provider name is null
 *          or empty.
 *
 * @see Provider
 */
public static Signature getInstance(String algorithm, String provider)
        throws NoSuchAlgorithmException, NoSuchProviderException {
    if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
        // exception compatibility with existing code
        if ((provider == null) || (provider.length() == 0)) {
            throw new IllegalArgumentException("missing provider");
        }
        Provider p = Security.getProvider(provider);
        if (p == null) {
            throw new NoSuchProviderException
                ("no such provider: " + provider);
        }
        return getInstanceRSA(p);
    }
    Instance instance = GetInstance.getInstance
            ("Signature", SignatureSpi.class, algorithm, provider);
    return getInstance(instance, algorithm);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:53,代码来源:Signature.java

示例11: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
/**
 * Returns a {@code CertPathValidator} object that implements the
 * specified algorithm.
 *
 * <p> This method traverses the list of registered security Providers,
 * starting with the most preferred Provider.
 * A new CertPathValidator object encapsulating the
 * CertPathValidatorSpi implementation from the first
 * Provider that supports the specified algorithm is returned.
 *
 * <p> Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the name of the requested {@code CertPathValidator}
 *  algorithm. See the CertPathValidator section in the <a href=
 *  "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathValidator">
 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 * for information about standard algorithm names.
 *
 * @return a {@code CertPathValidator} object that implements the
 *          specified algorithm.
 *
 * @exception NoSuchAlgorithmException if no Provider supports a
 *          CertPathValidatorSpi implementation for the
 *          specified algorithm.
 *
 * @see java.security.Provider
 */
public static CertPathValidator getInstance(String algorithm)
        throws NoSuchAlgorithmException {
    Instance instance = GetInstance.getInstance("CertPathValidator",
        CertPathValidatorSpi.class, algorithm);
    return new CertPathValidator((CertPathValidatorSpi)instance.impl,
        instance.provider, algorithm);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:CertPathValidator.java

示例12: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
/**
 * Returns a {@code SecureRandom} object that implements the specified
 * Random Number Generator (RNG) algorithm and supports the specified
 * {@code SecureRandomParameters} request.
 *
 * <p> A new {@code SecureRandom} object encapsulating the
 * {@code SecureRandomSpi} implementation from the specified provider
 * is returned.  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 algorithm the name of the RNG algorithm.
 * See the {@code SecureRandom} section in the <a href=
 * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms">
 * Java Security Standard Algorithm Names Specification</a>
 * for information about standard RNG algorithm names.
 *
 * @param params the {@code SecureRandomParameters}
 *               the newly created {@code SecureRandom} object must support.
 *
 * @param provider the name of the provider.
 *
 * @return the new {@code SecureRandom} object
 *
 * @throws IllegalArgumentException if the provider name is {@code null}
 *         or empty, or params is {@code null}
 *
 * @throws NoSuchAlgorithmException if the specified provider does not
 *         support a {@code SecureRandomSpi} implementation for the
 *         specified algorithm and parameters
 *
 * @throws NoSuchProviderException if the specified provider is not
 *         registered in the security provider list
 *
 * @throws NullPointerException if {@code algorithm} is {@code null}
 *
 * @see Provider
 *
 * @since 9
 */
public static SecureRandom getInstance(String algorithm,
        SecureRandomParameters params, String provider)
        throws NoSuchAlgorithmException, NoSuchProviderException {
    Objects.requireNonNull(algorithm, "null algorithm name");
    if (params == null) {
        throw new IllegalArgumentException("params cannot be null");
    }
    Instance instance = GetInstance.getInstance("SecureRandom",
            SecureRandomSpi.class, algorithm, params, provider);
    return new SecureRandom((SecureRandomSpi)instance.impl,
            instance.provider, algorithm);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:55,代码来源:SecureRandom.java

示例13: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
/**
 * Returns a {@code CertStore} object that implements the specified
 * {@code CertStore} type.
 *
 * <p> A new CertStore object encapsulating the
 * CertStoreSpi implementation from the specified provider
 * is returned.  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.
 *
 * <p>The {@code CertStore} that is returned is initialized with the
 * specified {@code CertStoreParameters}. The type of parameters
 * needed may vary between different types of {@code CertStore}s.
 * Note that the specified {@code CertStoreParameters} object is
 * cloned.
 *
 * @param type the requested {@code CertStore} type.
 * See the CertStore section in the <a href=
 * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertStore">
 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 * for information about standard types.
 *
 * @param params the initialization parameters (may be {@code null}).
 *
 * @param provider the name of the provider.
 *
 * @return a {@code CertStore} object that implements the
 *          specified type.
 *
 * @throws NoSuchAlgorithmException if a CertStoreSpi
 *          implementation for the specified type is not
 *          available from the specified provider.
 *
 * @throws InvalidAlgorithmParameterException if the specified
 *          initialization parameters are inappropriate for this
 *          {@code CertStore}.
 *
 * @throws NoSuchProviderException if the specified provider is not
 *          registered in the security provider list.
 *
 * @exception IllegalArgumentException if the {@code provider} is
 *          null or empty.
 *
 * @see java.security.Provider
 */
public static CertStore getInstance(String type,
        CertStoreParameters params, String provider)
        throws InvalidAlgorithmParameterException,
        NoSuchAlgorithmException, NoSuchProviderException {
    try {
        Instance instance = GetInstance.getInstance("CertStore",
            CertStoreSpi.class, type, params, provider);
        return new CertStore((CertStoreSpi)instance.impl,
            instance.provider, type, params);
    } catch (NoSuchAlgorithmException e) {
        return handleException(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:61,代码来源:CertStore.java

示例14: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
/**
 * Returns a certificate factory object that implements the
 * specified certificate type.
 *
 * <p> This method traverses the list of registered security Providers,
 * starting with the most preferred Provider.
 * A new CertificateFactory object encapsulating the
 * CertificateFactorySpi implementation from the first
 * Provider that supports the specified type is returned.
 *
 * <p> Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param type the name of the requested certificate type.
 * See the CertificateFactory section in the <a href=
 * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertificateFactory">
 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 * for information about standard certificate types.
 *
 * @return a certificate factory object for the specified type.
 *
 * @exception CertificateException if no Provider supports a
 *          CertificateFactorySpi implementation for the
 *          specified type.
 *
 * @see java.security.Provider
 */
public static final CertificateFactory getInstance(String type)
        throws CertificateException {
    try {
        Instance instance = GetInstance.getInstance("CertificateFactory",
            CertificateFactorySpi.class, type);
        return new CertificateFactory((CertificateFactorySpi)instance.impl,
            instance.provider, type);
    } catch (NoSuchAlgorithmException e) {
        throw new CertificateException(type + " not found", e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:CertificateFactory.java

示例15: getInstance

import sun.security.jca.GetInstance.Instance; //导入依赖的package包/类
/**
 * Returns a {@code CertPathBuilder} object that implements the
 * specified algorithm.
 *
 * <p> This method traverses the list of registered security Providers,
 * starting with the most preferred Provider.
 * A new CertPathBuilder object encapsulating the
 * CertPathBuilderSpi implementation from the first
 * Provider that supports the specified algorithm is returned.
 *
 * <p> Note that the list of registered providers may be retrieved via
 * the {@link Security#getProviders() Security.getProviders()} method.
 *
 * @param algorithm the name of the requested {@code CertPathBuilder}
 *  algorithm.  See the CertPathBuilder section in the <a href=
 *  "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 * for information about standard algorithm names.
 *
 * @return a {@code CertPathBuilder} object that implements the
 *          specified algorithm.
 *
 * @throws NoSuchAlgorithmException if no Provider supports a
 *          CertPathBuilderSpi implementation for the
 *          specified algorithm.
 *
 * @see java.security.Provider
 */
public static CertPathBuilder getInstance(String algorithm)
        throws NoSuchAlgorithmException {
    Instance instance = GetInstance.getInstance("CertPathBuilder",
        CertPathBuilderSpi.class, algorithm);
    return new CertPathBuilder((CertPathBuilderSpi)instance.impl,
        instance.provider, algorithm);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:CertPathBuilder.java


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