/* * * Adds information about provider services into HashMap. * * @param p */ public static void initServiceInfo(java.security.Provider p) { java.security.Provider.Service serv; String key; String type; String alias; java.lang.StringBuilder sb = new java.lang.StringBuilder(128); for (java.util.Iterator <java.security.Provider.Service> it1 = p.getServices().iterator(); it1.hasNext();) { serv = it1.next(); type = serv.getType(); sb.delete(0, sb.length()); key = sb.append(type).append(".").append( //$NON-NLS-1$ Util.toUpperCase(serv.getAlgorithm())).toString(); if (!services.containsKey(key)) { services.put(key, serv); } for (java.util.Iterator <String> it2 = Engine.door.getAliases(serv); it2.hasNext();) { alias = it2.next(); sb.delete(0, sb.length()); key = sb.append(type).append(".").append(Util.toUpperCase(alias)) //$NON-NLS-1$ .toString(); if (!services.containsKey(key)) { services.put(key, serv); } } } }
/** * Returns a <code>TransformService</code> that supports the specified * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism 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 algorithm the URI of the algorithm * @param mechanismType the type of the XML processing mechanism and * representation * @param provider the <code>Provider</code> object * @return a new <code>TransformService</code> * @throws NullPointerException if <code>provider</code>, * <code>algorithm</code>, or <code>mechanismType</code> is * <code>null</code> * @throws NoSuchAlgorithmException if a <code>TransformService</code> * implementation for the specified algorithm and mechanism type is not * available from the specified <code>Provider</code> object * @see Provider */ public static TransformService getInstance (String algorithm, String mechanismType, java.security.Provider provider) {//throws NoSuchAlgorithmException { if (mechanismType == null || algorithm == null || provider == null) { throw new java.lang.NullPointerException(); } return(findInstance(algorithm, mechanismType, provider)); }
/* * Inserts a provider at a specified position * * @param provider * @param position * @return */ public static int insertProviderAt(java.security.Provider provider, int position) { int size = providers.size(); if ((position < 1) || (position > size)) { position = size + 1; } providers.add(position - 1, provider); providersNames.put(provider.getName(), provider); setNeedRefresh(); return(position); }
/* * Returns a <code>KeyInfoFactory</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 <a * href="../../../../../overview-summary.html#Service Provider">Service * Providers</a> section of the API overview for a list of standard * mechanism types. * @param provider the <code>Provider</code> object * @return a new <code>KeyInfoFactory</code> * @throws NullPointerException if <code>mechanismType</code> or * <code>provider</code> are <code>null</code> * @throws NoSuchMechanismException if a <code>KeyInfoFactory</code> * implementation for the specified mechanism is not available from the * specified <code>Provider</code> object * @see Provider */ public static KeyInfoFactory getInstance(String mechanismType, java.security.Provider provider) { if (mechanismType == null) { throw new java.lang.NullPointerException("mechanismType cannot be null"); } else if (provider == null) { throw new java.lang.NullPointerException("provider cannot be null"); } return(findInstance(mechanismType, provider)); }
/** * Returns a <code>TransformService</code> that supports the specified * algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type * (ex: DOM) as supplied by the specified provider. 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 URI of the algorithm * @param mechanismType the type of the XML processing mechanism and * representation * @param provider the string name of the provider * @return a new <code>TransformService</code> * @throws NoSuchProviderException if the specified provider is not * registered in the security provider list * @throws NullPointerException if <code>provider</code>, * <code>mechanismType</code>, or <code>algorithm</code> is * <code>null</code> * @throws NoSuchAlgorithmException if a <code>TransformService</code> * implementation for the specified algorithm and mechanism type is not * available from the specified provider * @see Provider */ public static TransformService getInstance (String algorithm, String mechanismType, String provider) {//throws NoSuchAlgorithmException, NoSuchProviderException { if (mechanismType == null || algorithm == null || provider == null) { throw new java.lang.NullPointerException(); } java.security.Provider prov = java.security.Security.getProvider(provider); if (prov == null) { throw new java.security.NoSuchProviderException("cannot find provider named " + provider); } return(findInstance(algorithm, mechanismType, prov)); }
/** * * 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; } }
/* * Returns a <code>KeyInfoFactory</code> that supports the * requested XML processing mechanism and representation type (ex: "DOM"), * as supplied by the specified provider. 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 mechanismType the type of the XML processing mechanism and * representation. See the <a * href="../../../../../overview-summary.html#Service Provider">Service * Providers</a> section of the API overview for a list of standard * mechanism types. * @param provider the string name of the provider * @return a new <code>KeyInfoFactory</code> * @throws NoSuchProviderException if the specified provider is not * registered in the security provider list * @throws NullPointerException if <code>mechanismType</code> or * <code>provider</code> are <code>null</code> * @throws NoSuchMechanismException if a <code>KeyInfoFactory</code> * implementation for the specified mechanism is not available from the * specified provider * @see Provider */ public static KeyInfoFactory getInstance(String mechanismType, String provider)// throws NoSuchProviderException { { if (mechanismType == null) { throw new java.lang.NullPointerException("mechanismType cannot be null"); } else if (provider == null) { throw new java.lang.NullPointerException("provider cannot be null"); } java.security.Provider prov = java.security.Security.getProvider(provider); if (prov == null) { throw new java.security.NoSuchProviderException("cannot find provider named " + provider); } return(findInstance(mechanismType, prov)); }
/** * * Finds the appropriate service implementation and creates instance of the * class that implements corresponding Service Provider Interface. * * @param algorithm * @param service * @throws NoSuchAlgorithmException */ public void getInstance(String algorithm, Object param) {// throws NoSuchAlgorithmException { lock (this) { java.security.Provider.Service serv; if (algorithm == null) { throw new java.security.NoSuchAlgorithmException("Null algorithm name"); //$NON-NLS-1$ } Services.refresh(); if (returnedService != null && Util.equalsIgnoreCase(algorithm, lastAlgorithm) && refreshNumber == Services.refreshNumber) { serv = returnedService; } else { if (Services.isEmpty()) { throw new java.security.NoSuchAlgorithmException(serviceName + " " + algorithm + " implementation not found"); } serv = Services.getService(new java.lang.StringBuilder(128) .append(serviceName).append(".").append( //$NON-NLS-1$ Util.toUpperCase(algorithm)).toString()); if (serv == null) { throw new java.security.NoSuchAlgorithmException(serviceName + " " + algorithm + " implementation not found"); } returnedService = serv; lastAlgorithm = algorithm; refreshNumber = Services.refreshNumber; } spi = serv.newInstance(param); this.provider = serv.getProvider(); } }
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); } }
/* * Removes the provider * * @param providerNumber */ public static void removeProvider(int providerNumber) { java.security.Provider p = providers.remove(providerNumber - 1); providersNames.remove(p.getName()); setNeedRefresh(); }
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); } }
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; }