mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8295953: Use enhanced-for cycle instead of Enumeration in sun.security
Reviewed-by: weijun
This commit is contained in:
parent
ba303c048e
commit
3baad069a6
6 changed files with 14 additions and 32 deletions
|
@ -483,9 +483,9 @@ public abstract sealed class JavaKeyStore extends KeyStoreSpi {
|
||||||
public String engineGetCertificateAlias(Certificate cert) {
|
public String engineGetCertificateAlias(Certificate cert) {
|
||||||
Certificate certElem;
|
Certificate certElem;
|
||||||
|
|
||||||
for (Enumeration<String> e = entries.keys(); e.hasMoreElements(); ) {
|
for (Map.Entry<String, Object> e : entries.entrySet()) {
|
||||||
String alias = e.nextElement();
|
String alias = e.getKey();
|
||||||
Object entry = entries.get(alias);
|
Object entry = e.getValue();
|
||||||
if (entry instanceof TrustedCertEntry) {
|
if (entry instanceof TrustedCertEntry) {
|
||||||
certElem = ((TrustedCertEntry)entry).cert;
|
certElem = ((TrustedCertEntry)entry).cert;
|
||||||
} else if (((KeyEntry)entry).chain != null) {
|
} else if (((KeyEntry)entry).chain != null) {
|
||||||
|
@ -566,10 +566,9 @@ public abstract sealed class JavaKeyStore extends KeyStoreSpi {
|
||||||
|
|
||||||
dos.writeInt(entries.size());
|
dos.writeInt(entries.size());
|
||||||
|
|
||||||
for (Enumeration<String> e = entries.keys(); e.hasMoreElements();) {
|
for (Map.Entry<String, Object> e : entries.entrySet()) {
|
||||||
|
String alias = e.getKey();
|
||||||
String alias = e.nextElement();
|
Object entry = e.getValue();
|
||||||
Object entry = entries.get(alias);
|
|
||||||
|
|
||||||
if (entry instanceof KeyEntry) {
|
if (entry instanceof KeyEntry) {
|
||||||
|
|
||||||
|
|
|
@ -316,8 +316,6 @@ public class PolicyParser {
|
||||||
{
|
{
|
||||||
PrintWriter out = new PrintWriter(new BufferedWriter(policy));
|
PrintWriter out = new PrintWriter(new BufferedWriter(policy));
|
||||||
|
|
||||||
Enumeration<GrantEntry> enum_ = grantElements();
|
|
||||||
|
|
||||||
out.println("/* AUTOMATICALLY GENERATED ON "+
|
out.println("/* AUTOMATICALLY GENERATED ON "+
|
||||||
(new java.util.Date()) + "*/");
|
(new java.util.Date()) + "*/");
|
||||||
out.println("/* DO NOT EDIT */");
|
out.println("/* DO NOT EDIT */");
|
||||||
|
@ -333,8 +331,7 @@ public class PolicyParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write "grant" entries
|
// write "grant" entries
|
||||||
while (enum_.hasMoreElements()) {
|
for (GrantEntry ge : grantEntries) {
|
||||||
GrantEntry ge = enum_.nextElement();
|
|
||||||
ge.write(out);
|
ge.write(out);
|
||||||
out.println();
|
out.println();
|
||||||
}
|
}
|
||||||
|
@ -938,9 +935,7 @@ public class PolicyParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.println(" {");
|
out.println(" {");
|
||||||
Enumeration<PermissionEntry> enum_ = permissionEntries.elements();
|
for (PermissionEntry pe : permissionEntries) {
|
||||||
while (enum_.hasMoreElements()) {
|
|
||||||
PermissionEntry pe = enum_.nextElement();
|
|
||||||
out.write(" ");
|
out.write(" ");
|
||||||
pe.write(out);
|
pe.write(out);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1311,9 +1311,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
|
||||||
public String[] getValueNames() {
|
public String[] getValueNames() {
|
||||||
ArrayList<Object> v = new ArrayList<>();
|
ArrayList<Object> v = new ArrayList<>();
|
||||||
Object securityCtx = SecureKey.getCurrentSecurityContext();
|
Object securityCtx = SecureKey.getCurrentSecurityContext();
|
||||||
for (Enumeration<SecureKey> e = boundValues.keys();
|
for (SecureKey key : boundValues.keySet()) {
|
||||||
e.hasMoreElements(); ) {
|
|
||||||
SecureKey key = e.nextElement();
|
|
||||||
if (securityCtx.equals(key.getSecurityContext())) {
|
if (securityCtx.equals(key.getSecurityContext())) {
|
||||||
v.add(key.getAppKey());
|
v.add(key.getAppKey());
|
||||||
}
|
}
|
||||||
|
|
|
@ -4177,9 +4177,7 @@ public final class Main {
|
||||||
// Try out each certificate in the vector, until we find one
|
// Try out each certificate in the vector, until we find one
|
||||||
// whose public key verifies the signature of the certificate
|
// whose public key verifies the signature of the certificate
|
||||||
// in question.
|
// in question.
|
||||||
for (Enumeration<Pair<String,X509Certificate>> issuerCerts = vec.elements();
|
for (Pair<String, X509Certificate> issuerCert : vec) {
|
||||||
issuerCerts.hasMoreElements(); ) {
|
|
||||||
Pair<String,X509Certificate> issuerCert = issuerCerts.nextElement();
|
|
||||||
PublicKey issuerPubKey = issuerCert.snd.getPublicKey();
|
PublicKey issuerPubKey = issuerCert.snd.getPublicKey();
|
||||||
try {
|
try {
|
||||||
certToVerify.snd.verify(issuerPubKey);
|
certToVerify.snd.verify(issuerPubKey);
|
||||||
|
|
|
@ -408,12 +408,8 @@ public class X509CRLEntryImpl extends X509CRLEntry
|
||||||
|
|
||||||
if (extAlias == null) { // may be unknown
|
if (extAlias == null) { // may be unknown
|
||||||
ObjectIdentifier findOID = ObjectIdentifier.of(oid);
|
ObjectIdentifier findOID = ObjectIdentifier.of(oid);
|
||||||
Extension ex;
|
for (Extension ex : extensions.getAllExtensions()) {
|
||||||
ObjectIdentifier inCertOID;
|
ObjectIdentifier inCertOID = ex.getExtensionId();
|
||||||
for (Enumeration<Extension> e = extensions.getElements();
|
|
||||||
e.hasMoreElements();) {
|
|
||||||
ex = e.nextElement();
|
|
||||||
inCertOID = ex.getExtensionId();
|
|
||||||
if (inCertOID.equals(findOID)) {
|
if (inCertOID.equals(findOID)) {
|
||||||
crlExt = ex;
|
crlExt = ex;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1014,12 +1014,8 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
|
||||||
|
|
||||||
if (extAlias == null) { // may be unknown
|
if (extAlias == null) { // may be unknown
|
||||||
ObjectIdentifier findOID = ObjectIdentifier.of(oid);
|
ObjectIdentifier findOID = ObjectIdentifier.of(oid);
|
||||||
Extension ex;
|
for (Extension ex : extensions.getAllExtensions()) {
|
||||||
ObjectIdentifier inCertOID;
|
ObjectIdentifier inCertOID = ex.getExtensionId();
|
||||||
for (Enumeration<Extension> e = extensions.getElements();
|
|
||||||
e.hasMoreElements();) {
|
|
||||||
ex = e.nextElement();
|
|
||||||
inCertOID = ex.getExtensionId();
|
|
||||||
if (inCertOID.equals(findOID)) {
|
if (inCertOID.equals(findOID)) {
|
||||||
crlExt = ex;
|
crlExt = ex;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue