public static final CertificateFactory getInstance(String type) throws CertificateException { if (type == null) { throw new NullPointerException("type == null"); } try { SpiAndProvider sap = ENGINE.getInstance(type, null); return new CertificateFactory((CertificateFactorySpi) sap.spi, sap.provider, type); } catch (Throwable e) { throw new CertificateException(e); } }
public static final CertificateFactory getInstance(String type, Provider provider) throws CertificateException { if (provider == null) { throw new IllegalArgumentException("provider == null"); } else if (type == null) { throw new NullPointerException("type == null"); } else { try { return new CertificateFactory( (CertificateFactorySpi) ENGINE.getInstance(type, provider, null), provider, type); } catch (Throwable e) { throw new CertificateException(e); } } }
/** * Returns a new instance of {@code MessageDigest} that utilizes the specified algorithm. * * @param algorithm the name of the algorithm to use * @return a new instance of {@code MessageDigest} that utilizes the specified algorithm * @throws NoSuchAlgorithmException if the specified algorithm is not available * @throws NullPointerException if {@code algorithm} is {@code null} */ public static MessageDigest getInstance(String algorithm) throws NoSuchAlgorithmException { if (algorithm == null) { throw new NullPointerException(); } MessageDigest result; synchronized (engine) { engine.getInstance(algorithm, null); if (engine.spi instanceof MessageDigest) { result = (MessageDigest) engine.spi; result.algorithm = algorithm; result.provider = engine.provider; return result; } return new MessageDigestImpl((MessageDigestSpi) engine.spi, engine.provider, algorithm); } }
private static Engine.SpiAndProvider tryAlgorithmWithProvider(Key key, Provider.Service service) { try { if (key != null && !service.supportsParameter(key)) { return null; } Engine.SpiAndProvider sap = ENGINE.getInstance(service, null); if (sap.spi == null || sap.provider == null) { return null; } if (!(sap.spi instanceof SignatureSpi)) { return null; } return sap; } catch (NoSuchAlgorithmException ignored) { } return null; }