Methods Summary |
---|
public static java.security.Provider | getProvider(java.lang.String name)Returns the provider with the specified name
if (name == null) {
return null;
}
return providersNames.get(name);
|
public static java.security.Provider[] | getProviders()Returns registered providers
return providers.toArray(new Provider[providers.size()]);
|
public static java.util.List | getProvidersList()Returns registered providers as List
return new ArrayList<Provider>(providers);
|
public static java.security.Provider$Service | getService(java.lang.String key)Returns service description.
Call refresh() before.
return services.get(key);
|
public static void | initServiceInfo(java.security.Provider p)Adds information about provider services into HashMap.
Provider.Service serv;
String key;
String type;
String alias;
StringBuffer sb = new StringBuffer(128);
for (Iterator<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$
serv.getAlgorithm().toUpperCase()).toString();
if (!services.containsKey(key)) {
services.put(key, serv);
}
for (Iterator<String> it2 = Engine.door.getAliases(serv); it2.hasNext();) {
alias = it2.next();
sb.delete(0, sb.length());
key = sb.append(type).append(".").append(alias.toUpperCase()) //$NON-NLS-1$
.toString();
if (!services.containsKey(key)) {
services.put(key, serv);
}
}
}
|
public static int | insertProviderAt(java.security.Provider provider, int position)Inserts a provider at a specified 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;
|
public static boolean | isEmpty()Returns true if services contain any provider information
return services.isEmpty();
|
private static void | loadProviders()
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
loadProviders();
return null;
}
});
String providerClassName = null;
int i = 1;
ClassLoader cl = ClassLoader.getSystemClassLoader();
Provider p;
while ((providerClassName = Security.getProperty("security.provider." //$NON-NLS-1$
+ i++)) != null) {
try {
p = (Provider) Class
.forName(providerClassName.trim(), true, cl)
.newInstance();
providers.add(p);
providersNames.put(p.getName(), p);
initServiceInfo(p);
} catch (Exception e) { // ignore
}
}
Engine.door.renumProviders();
|
public static void | printServices()Prints Services content
refresh();
Set<String> s = services.keySet();
for (Iterator<String> i = s.iterator(); i.hasNext();) {
String key = i.next();
System.out.println(key + "=" + services.get(key)); //$NON-NLS-1$
}
|
public static void | refresh()Refresh services info
if (needRefresh) {
refreshNumber++;
updateServiceInfo();
}
|
public static void | removeProvider(int providerNumber)Removes the provider
Provider p = providers.remove(providerNumber - 1);
providersNames.remove(p.getName());
setNeedRefresh();
|
public static void | setNeedRefresh()Set flag needRefresh
needRefresh = true;
|
public static void | updateServiceInfo()Updates services hashtable for all registered providers
services.clear();
for (Iterator<Provider> it = providers.iterator(); it.hasNext();) {
initServiceInfo(it.next());
}
needRefresh = false;
|