diff options
author | Tom Tromey <tromey@redhat.com> | 2001-10-18 17:51:47 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2001-10-18 17:51:47 +0000 |
commit | c586d12794533da0614e70b7d17cd01ab8ebf049 (patch) | |
tree | 7e68460c1cc2f879087bb6b55871dcd3bedee149 /libjava/java/security/Security.java | |
parent | bf911a9a73fcb85470695f17360b0d9df24a59b5 (diff) | |
download | gcc-c586d12794533da0614e70b7d17cd01ab8ebf049.zip gcc-c586d12794533da0614e70b7d17cd01ab8ebf049.tar.gz gcc-c586d12794533da0614e70b7d17cd01ab8ebf049.tar.bz2 |
Security.java (loadProviders): Removed unused `pname' variable.
* 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'.
From-SVN: r46332
Diffstat (limited to 'libjava/java/security/Security.java')
-rw-r--r-- | libjava/java/security/Security.java | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/libjava/java/security/Security.java b/libjava/java/security/Security.java index 373637a..eba476d 100644 --- a/libjava/java/security/Security.java +++ b/libjava/java/security/Security.java @@ -44,7 +44,6 @@ import java.util.Properties; public final class Security extends Object { private static Vector providers = new Vector(); - private static int providerCount = 0; private static Properties secprops; static @@ -69,17 +68,14 @@ public final class Security extends Object 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) @@ -89,7 +85,6 @@ public final class Security extends Object try { providers.addElement(Class.forName(name).newInstance()); - providerCount++; i++; } catch (ClassNotFoundException x) @@ -162,7 +157,8 @@ public final class Security extends Object 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()) @@ -170,12 +166,11 @@ public final class Security extends Object } if (position < 0) - position = 0; - if (position > providerCount) - position = providerCount; + position = 0; + if (position > max) + position = max; providers.insertElementAt(provider, position); - providerCount++; return position; } @@ -199,22 +194,7 @@ public final class Security extends Object */ 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 ()); } /** @@ -238,19 +218,15 @@ public final class Security extends Object 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--; - } /** @@ -261,9 +237,8 @@ public final class Security extends Object */ 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; } @@ -278,7 +253,8 @@ public final class Security extends Object 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) |