+2001-10-18 Tom Tromey <tromey@redhat.com>
+
+ * java/security/Security.java (loadProviders): Removed unused
+ `pname' variable. Don't create `File' object. Don't update
+ `providerCount'.
+ (providerCount): Removed.
+ (insertProviderAt): Don't use `providerCount'.
+ (addProvider(Provider,int)): Likewise.
+ (removeProvider): Likewise.
+ (addProvider(Provider)): Rewrote.
+ (getProviders): Rewrote.
+ (getProvider): Don't use `providerCount'.
+
2001-10-17 Tom Tromey <tromey@redhat.com>
* gnu/java/security/provider/SHA1PRNG.java (engineNextBytes):
public final class Security extends Object
{
private static Vector providers = new Vector();
- private static int providerCount = 0;
private static Properties secprops;
static
separator + "security" +
separator + vendor + ".security");
- providerCount = 0;
try
{
- File secFile = new File(secfilestr);
- FileInputStream fin = new FileInputStream(secFile);
+ FileInputStream fin = new FileInputStream(secfilestr);
secprops = new Properties();
secprops.load(fin);
int i = 1;
String name;
- StringBuffer pname = new StringBuffer("security.provider.");
while ((name = secprops.getProperty("security.provider." + i++)) !=
null)
try
{
providers.addElement(Class.forName(name).newInstance());
- providerCount++;
i++;
}
catch (ClassNotFoundException x)
if (sm != null)
sm.checkSecurityAccess("insertProvider." + provider.getName());
- for (int i = 0; i < providerCount; i++)
+ int max = providers.size ();
+ for (int i = 0; i < max; i++)
{
if (((Provider) providers.elementAt(i)).getName() ==
provider.getName())
}
if (position < 0)
- position = 0;
- if (position > providerCount)
- position = providerCount;
+ position = 0;
+ if (position > max)
+ position = max;
providers.insertElementAt(provider, position);
- providerCount++;
return position;
}
*/
public static int addProvider(Provider provider)
{
- SecurityManager sm = System.getSecurityManager();
-
- if (sm != null)
- sm.checkSecurityAccess("insertProvider." + provider.getName());
-
- for (int i = 0; i < providerCount; i++)
- {
- if (((Provider) providers.elementAt(i)).getName() ==
- provider.getName())
- return -1;
- }
-
- providers.addElement(provider);
- providerCount++;
-
- return providerCount - 1;
+ return insertProviderAt (provider, providers.size ());
}
/**
sm.checkSecurityAccess("removeProvider." + name);
Provider p = null;
- for (int i = 0; i < providerCount; i++)
+ int max = providers.size ();
+ for (int i = 0; i < max; i++)
{
if (((Provider) providers.elementAt(i)).getName() == name)
{
- p = (Provider) providers.elementAt(i);
+ providers.remove(i);
break;
}
}
-
- if (p != null)
- if (providers.removeElement(p))
- providerCount--;
-
}
/**
*/
public static Provider[] getProviders()
{
- Provider array[] = new Provider[providerCount];
- for (int i = 0; i < providerCount; i++)
- array[i] = (Provider) providers.elementAt(i);
+ Provider array[] = new Provider[providers.size ()];
+ providers.copyInto (array);
return array;
}
public static Provider getProvider(String name)
{
Provider p = null;
- for (int i = 0; i < providerCount; i++)
+ int max = providers.size ();
+ for (int i = 0; i < max; i++)
{
p = (Provider) providers.elementAt(i);
if (p.getName() == name)