/** * Returns a new instance of {@code SecureRandom} that utilizes the * specified algorithm. * * @param algorithm * the name of the algorithm to use. * @return a new instance of {@code SecureRandom} that utilizes the * specified algorithm. * @throws NoSuchAlgorithmException * if the specified algorithm is not available. * @throws NullPointerException * if {@code algorithm} is {@code null}. */ public static SecureRandom getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new SecureRandom((SecureRandomSpi) sap.spi, sap.provider, algorithm); }
private static Signature getSignatureInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException { Object spi = ENGINE.getInstance(algorithm, provider, null); if (spi instanceof Signature) { Signature result = (Signature) spi; result.algorithm = algorithm; result.provider = provider; return result; } return new SignatureImpl((SignatureSpi) spi, provider, algorithm); }
/** * Returns a new certification path validator for the specified algorithm. * * @param algorithm * the algorithm name. * @return a certification path validator for the requested algorithm. * @throws NoSuchAlgorithmException * if no installed provider provides the specified algorithm. * @throws NullPointerException * if algorithm is {@code null}. */ public static CertPathValidator getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new CertPathValidator((CertPathValidatorSpi) sap.spi, sap.provider, algorithm); }
/** * Returns a new instance of {@code KeyFactory} that utilizes the specified * algorithm. * * @param algorithm * the name of the algorithm. * @return a new instance of {@code KeyFactory} that utilizes the specified * algorithm. * @throws NoSuchAlgorithmException * if no provider provides the requested algorithm. */ public static KeyFactory getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new KeyFactory((KeyFactorySpi) sap.spi, sap.provider, algorithm); }
/** * Creates a new {@code SSLContext} instance for the specified protocol. * * @param protocol * the requested protocol to create a context for. * @return the created {@code SSLContext} instance. * @throws NoSuchAlgorithmException * if no installed provider can provide the requested protocol * @throws NullPointerException * if {@code protocol} is {@code null} (instead of * NoSuchAlgorithmException as in 1.4 release) */ public static SSLContext getInstance(String protocol) throws NoSuchAlgorithmException { if (protocol == null) { throw new NullPointerException("protocol == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(protocol, null); return new SSLContext((SSLContextSpi) sap.spi, sap.provider, protocol); }
/** * Creates a new {@code CertPathBuilder} instance with the specified * algorithm. * * @param algorithm * the name of the algorithm. * @return a builder for the requested algorithm. * @throws NullPointerException * if the algorithm is {@code null}. * @throws NoSuchAlgorithmException * if no installed provider can provide the algorithm. */ public static CertPathBuilder getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new CertPathBuilder((CertPathBuilderSpi) sap.spi, sap.provider, algorithm); }
/** * Creates a new {@code KeyAgreement} for the specified algorithm. * * @param algorithm * the name of the key agreement algorithm to create. * @return a key agreement for the specified algorithm. * @throws NoSuchAlgorithmException * if no installed provider can provide the requested algorithm. * @throws NullPointerException * if the specified algorithm is {@code null}. */ public static final KeyAgreement getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new KeyAgreement((KeyAgreementSpi) sap.spi, sap.provider, algorithm); }
/** * Creates a new {@code KeyGenerator} instance that provides the specified * key algorithm, * * @param algorithm * the name of the requested key algorithm * @return the new {@code KeyGenerator} instance. * @throws NoSuchAlgorithmException * if the specified algorithm is not available by any provider. * @throws NullPointerException * if {@code algorithm} is {@code null}. */ public static final KeyGenerator getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new KeyGenerator((KeyGeneratorSpi) sap.spi, sap.provider, algorithm); }
/** * Creates a new {@code SecretKeyFactory} instance for the specified key * algorithm. * * @param algorithm * the name of the key algorithm. * @return a secret key factory for the specified key algorithm. * @throws NoSuchAlgorithmException * if no installed provider can provide the requested algorithm. * @throws NullPointerException * if the specified algorithm is {@code null}. */ public static final SecretKeyFactory getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new SecretKeyFactory((SecretKeyFactorySpi) sap.spi, sap.provider, algorithm); }
/** * Creates a new {@code KeyManagerFactory} instance for the specified key * management algorithm. * * @param algorithm * the name of the requested key management algorithm. * @return a key manager factory for the requested algorithm. * @throws NoSuchAlgorithmException * if no installed provider can provide the requested algorithm. * @throws NullPointerException * if {@code algorithm} is {@code null} (instead of * NoSuchAlgorithmException as in 1.4 release) */ public static final KeyManagerFactory getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new KeyManagerFactory((KeyManagerFactorySpi) sap.spi, sap.provider, algorithm); }
/** * Returns a new {@code ExemptionMechanism} instance that provides the * specified exemption mechanism algorithm. * * @param algorithm * the name of the requested exemption mechanism. * @return the new {@code ExemptionMechanism} instance. * @throws NoSuchAlgorithmException * if the specified algorithm is not available by any provider. * @throws NullPointerException * if the algorithm parameter is {@code null}. */ public static final ExemptionMechanism getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new ExemptionMechanism((ExemptionMechanismSpi) sap.spi, sap.provider, algorithm); }
/** * Creates a new {@code Mac} instance that provides the specified MAC * algorithm. * * @param algorithm * the name of the requested MAC algorithm. * @return the new {@code Mac} instance. * @throws NoSuchAlgorithmException * if the specified algorithm is not available by any provider. * @throws NullPointerException * if {@code algorithm} is {@code null} (instead of * NoSuchAlgorithmException as in 1.4 release). */ public static final Mac getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new Mac((MacSpi) sap.spi, sap.provider, algorithm); }
/** * Returns a new instance of {@code AlgorithmParameterGenerator} for the * specified algorithm. * * @param algorithm * the name of the algorithm to use. * @return a new instance of {@code AlgorithmParameterGenerator} for the * specified algorithm. * @throws NoSuchAlgorithmException * if the specified algorithm is not available. * @throws NullPointerException * if {@code algorithm} is {@code null}. */ public static AlgorithmParameterGenerator getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new AlgorithmParameterGenerator((AlgorithmParameterGeneratorSpi) sap.spi, sap.provider, algorithm); }
/** * Returns a new instance of {@code AlgorithmParameters} for the specified * algorithm. * * @param algorithm * the name of the algorithm to use. * @return a new instance of {@code AlgorithmParameters} for the specified * algorithm. * @throws NoSuchAlgorithmException * if the specified algorithm is not available. * @throws NullPointerException * if {@code algorithm} is {@code null}. */ public static AlgorithmParameters getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new AlgorithmParameters((AlgorithmParametersSpi) sap.spi, sap.provider, algorithm); }
/** * Creates a new {@code TrustManagerFactory} instance for the specified * trust management algorithm. * * @param algorithm * the name of the requested trust management algorithm. * @return a trust manager factory for the requested algorithm. * @throws NoSuchAlgorithmException * if no installed provider can provide the requested algorithm. * @throws NullPointerException * if {@code algorithm} is {@code null} (instead of * NoSuchAlgorithmException as in 1.4 release) */ public static final TrustManagerFactory getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Engine.SpiAndProvider sap = ENGINE.getInstance(algorithm, null); return new TrustManagerFactory((TrustManagerFactorySpi) sap.spi, sap.provider, algorithm); }
/** * Returns a new instance of {@code KeyFactory} that utilizes the specified * algorithm from the specified provider. * * @param algorithm * the name of the algorithm. * @param provider * the security provider. * @return a new instance of {@code KeyFactory} that utilizes the specified * algorithm from the specified provider. * @throws NoSuchAlgorithmException * if the provider does not provide the requested algorithm. * @throws IllegalArgumentException if {@code provider == null} */ public static KeyFactory getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException { if (provider == null) { throw new IllegalArgumentException("provider == null"); } if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Object spi = ENGINE.getInstance(algorithm, provider, null); return new KeyFactory((KeyFactorySpi) spi, provider, algorithm); }
/** * Creates a new {@code CertificateFactory} instance that provides the * requested certificate type. * * @param type * the certificate type. * @return the new {@code CertificateFactory} instance. * @throws CertificateException * if the specified certificate type is not available at any * installed provider. * @throws NullPointerException if {@code type == null} */ public static final CertificateFactory getInstance(String type) throws CertificateException { if (type == null) { throw new NullPointerException("type == null"); } try { Engine.SpiAndProvider sap = ENGINE.getInstance(type, null); return new CertificateFactory((CertificateFactorySpi) sap.spi, sap.provider, type); } catch (NoSuchAlgorithmException e) { throw new CertificateException(e); } }
/** * Returns a new certification path validator for the specified algorithm * from the specified provider. * * @param algorithm * the algorithm name. * @param provider * the security provider name. * @return a certification path validator for the requested algorithm. * @throws NoSuchAlgorithmException * if the specified provider cannot provide the requested * algorithm. * @throws IllegalArgumentException if {@code provider == null} * @throws NullPointerException * if algorithm is {@code null}. */ public static CertPathValidator getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException { if (provider == null) { throw new IllegalArgumentException("provider == null"); } if (algorithm == null) { throw new NullPointerException("algorithm == null"); } Object spi = ENGINE.getInstance(algorithm, provider, null); return new CertPathValidator((CertPathValidatorSpi) spi, provider, algorithm); }
/** * Creates a new {@code SSLContext} instance for the specified protocol from * the specified provider. * * @param protocol * the requested protocol to create a context for * @param provider * the provider that provides the requested protocol. * @return an {@code SSLContext} for the requested protocol. * @throws NoSuchAlgorithmException * if the specified provider cannot provide the requested * protocol. * @throws NullPointerException * if {@code protocol} is {@code null} (instead of * NoSuchAlgorithmException as in 1.4 release) */ public static SSLContext getInstance(String protocol, Provider provider) throws NoSuchAlgorithmException { if (provider == null) { throw new IllegalArgumentException("provider is null"); } if (protocol == null) { throw new NullPointerException("protocol == null"); } Object spi = ENGINE.getInstance(protocol, provider, null); return new SSLContext((SSLContextSpi) spi, provider, protocol); }
/** * Returns a new instance of {@code KeyStore} with the specified type. * * @param type * the type of the returned {@code KeyStore}. * @return a new instance of {@code KeyStore} with the specified type. * @throws KeyStoreException * if an error occurred during the creation of the new {@code * KeyStore}. * @throws NullPointerException if {@code type == null} * @see #getDefaultType */ public static KeyStore getInstance(String type) throws KeyStoreException { if (type == null) { throw new NullPointerException("type == null"); } try { Engine.SpiAndProvider sap = ENGINE.getInstance(type, null); return new KeyStore((KeyStoreSpi) sap.spi, sap.provider, type); } catch (NoSuchAlgorithmException e) { throw new KeyStoreException(e); } }