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