8297683: Use enhanced-for cycle instead of Enumeration in java.security.jgss
Reviewed-by: weijun
This commit is contained in:
parent
c67166f120
commit
0edb5d0805
@ -134,10 +134,7 @@ public class GSSCredentialImpl implements GSSCredential {
|
||||
|
||||
public void dispose() throws GSSException {
|
||||
if (!destroyed) {
|
||||
GSSCredentialSpi element;
|
||||
Enumeration<GSSCredentialSpi> values = hashtable.elements();
|
||||
while (values.hasMoreElements()) {
|
||||
element = values.nextElement();
|
||||
for (GSSCredentialSpi element : hashtable.values()) {
|
||||
element.dispose();
|
||||
}
|
||||
destroyed = true;
|
||||
@ -211,14 +208,11 @@ public class GSSCredentialImpl implements GSSCredential {
|
||||
"no longer valid");
|
||||
}
|
||||
|
||||
SearchKey tempKey;
|
||||
GSSCredentialSpi tempCred;
|
||||
int tempLife, tempInitLife, tempAcceptLife;
|
||||
int min = INDEFINITE_LIFETIME;
|
||||
|
||||
for (Enumeration<SearchKey> e = hashtable.keys();
|
||||
e.hasMoreElements(); ) {
|
||||
tempKey = e.nextElement();
|
||||
for (SearchKey tempKey : hashtable.keySet()) {
|
||||
tempCred = hashtable.get(tempKey);
|
||||
if (tempKey.getUsage() == INITIATE_ONLY)
|
||||
tempLife = tempCred.getInitLifetime();
|
||||
@ -329,13 +323,10 @@ public class GSSCredentialImpl implements GSSCredential {
|
||||
"no longer valid");
|
||||
}
|
||||
|
||||
SearchKey tempKey;
|
||||
boolean initiate = false;
|
||||
boolean accept = false;
|
||||
|
||||
for (Enumeration<SearchKey> e = hashtable.keys();
|
||||
e.hasMoreElements(); ) {
|
||||
tempKey = e.nextElement();
|
||||
for (SearchKey tempKey : hashtable.keySet()) {
|
||||
if (tempKey.getUsage() == INITIATE_ONLY)
|
||||
initiate = true;
|
||||
else if (tempKey.getUsage() == ACCEPT_ONLY)
|
||||
@ -406,10 +397,7 @@ public class GSSCredentialImpl implements GSSCredential {
|
||||
"no longer valid");
|
||||
}
|
||||
ArrayList<Oid> result = new ArrayList<Oid>(hashtable.size());
|
||||
|
||||
for (Enumeration<SearchKey> e = hashtable.keys();
|
||||
e.hasMoreElements(); ) {
|
||||
SearchKey tempKey = e.nextElement();
|
||||
for (SearchKey tempKey : hashtable.keySet()) {
|
||||
result.add(tempKey.getMech());
|
||||
}
|
||||
return result.toArray(new Oid[0]);
|
||||
@ -615,14 +603,7 @@ public class GSSCredentialImpl implements GSSCredential {
|
||||
}
|
||||
|
||||
Set<GSSCredentialSpi> getElements() {
|
||||
HashSet<GSSCredentialSpi> retVal =
|
||||
new HashSet<>(hashtable.size());
|
||||
Enumeration<GSSCredentialSpi> values = hashtable.elements();
|
||||
while (values.hasMoreElements()) {
|
||||
GSSCredentialSpi o = values.nextElement();
|
||||
retVal.add(o);
|
||||
}
|
||||
return retVal;
|
||||
return new HashSet<>(hashtable.values());
|
||||
}
|
||||
|
||||
private static String getElementStr(Oid mechOid, int usage) {
|
||||
|
@ -32,7 +32,6 @@ import java.security.Security;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import sun.security.jgss.spi.*;
|
||||
import sun.security.jgss.wrapper.NativeGSSFactory;
|
||||
@ -408,12 +407,9 @@ public final class ProviderList {
|
||||
String prop;
|
||||
boolean retVal = false;
|
||||
|
||||
// Get all props for this provider
|
||||
Enumeration<Object> props = p.keys();
|
||||
|
||||
// See if there are any GSS prop's
|
||||
while (props.hasMoreElements()) {
|
||||
prop = (String) props.nextElement();
|
||||
for (Object o : p.keySet()) {
|
||||
prop = (String) o;
|
||||
if (isMechFactoryProperty(prop)) {
|
||||
// Ok! This is a GSS provider!
|
||||
try {
|
||||
@ -428,7 +424,7 @@ public final class ProviderList {
|
||||
}
|
||||
}
|
||||
} // Processed GSS property
|
||||
} // while loop
|
||||
} // for loop
|
||||
|
||||
return retVal;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user