/** * * Finds the appropriate service implementation and creates instance of the * class that implements corresponding Service Provider Interface. * * @param algorithm * @param service * @param provider * @throws NoSuchAlgorithmException */ public void getInstance(String algorithm, java.security.Provider provider, Object param) {//throws NoSuchAlgorithmException { lock (this) { java.security.Provider.Service serv = null; if (algorithm == null) { throw new java.security.NoSuchAlgorithmException(serviceName + " , algorithm is null"); //$NON-NLS-1$ } serv = provider.getService(serviceName, algorithm); if (serv == null) { throw new java.security.NoSuchAlgorithmException(serviceName + " " + algorithm + " implementation not found"); } spi = serv.newInstance(param); this.provider = provider; } }
private static TransformService findInstance(String algorithm, String mechanismType, java.security.Provider provider) {// throws NoSuchAlgorithmException { if (provider == null) { provider = getProvider("TransformService", algorithm, mechanismType); } java.security.Provider.Service ps = provider.getService("TransformService", algorithm); if (ps == null) { throw new java.security.NoSuchAlgorithmException("no such algorithm: " + algorithm + " for provider " + provider.getName()); } TransformService ts = (TransformService)ps.newInstance(null); ts.algorithm = algorithm; ts.mechanism = mechanismType; ts.provider = provider; return(ts); }
private static KeyInfoFactory findInstance(String mechanismType, java.security.Provider provider) { if (provider == null) { provider = getProvider("KeyInfoFactory", mechanismType); } java.security.Provider.Service ps = provider.getService("KeyInfoFactory", mechanismType); if (ps == null) { throw new NoSuchMechanismException("Cannot find " + mechanismType + " mechanism type"); } try { KeyInfoFactory fac = (KeyInfoFactory)ps.newInstance(null); fac.mechanismType = mechanismType; fac.provider = provider; return(fac); } catch (java.security.NoSuchAlgorithmException nsae) { throw new NoSuchMechanismException("Cannot find " + mechanismType + " mechanism type", nsae); } }