8242151: Improve OID mapping and reuse among JDK security providers for aliases registration

Use sun.security.util.KnownOIDs enum instead of hardcoding oid strings everywhere

Reviewed-by: weijun
This commit is contained in:
Valerie Peng 2020-05-19 04:05:03 +00:00
parent a97932d8fc
commit 080b3b83eb
79 changed files with 2016 additions and 2080 deletions

View file

@ -76,7 +76,7 @@ public final class PKCS12Attribute implements KeyStore.Entry.Attribute {
// Validate name
ObjectIdentifier type;
try {
type = new ObjectIdentifier(name);
type = ObjectIdentifier.of(name);
} catch (IOException e) {
throw new IllegalArgumentException("Incorrect format: name", e);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -246,7 +246,7 @@ public class CertificateRevokedException extends CertificateException {
boolean critical = ois.readBoolean();
byte[] extVal = IOUtils.readExactlyNBytes(ois, ois.readInt());
Extension ext = sun.security.x509.Extension.newExtension
(new ObjectIdentifier(oid), critical, extVal);
(ObjectIdentifier.of(oid), critical, extVal);
extensions.put(oid, ext);
}
}

View file

@ -31,11 +31,7 @@ import java.security.PublicKey;
import java.util.*;
import javax.security.auth.x500.X500Principal;
import sun.security.util.HexDumpEncoder;
import sun.security.util.Debug;
import sun.security.util.DerInputStream;
import sun.security.util.DerValue;
import sun.security.util.ObjectIdentifier;
import sun.security.util.*;
import sun.security.x509.*;
/**
@ -88,7 +84,7 @@ public class X509CertSelector implements CertSelector {
private static final Debug debug = Debug.getInstance("certpath");
private static final ObjectIdentifier ANY_EXTENDED_KEY_USAGE =
ObjectIdentifier.of("2.5.29.37.0");
ObjectIdentifier.of(KnownOIDs.anyExtendedKeyUsage);
static {
CertPathHelperImpl.initialize();
@ -506,7 +502,7 @@ public class X509CertSelector implements CertSelector {
if (oid == null) {
subjectPublicKeyAlgID = null;
} else {
subjectPublicKeyAlgID = new ObjectIdentifier(oid);
subjectPublicKeyAlgID = ObjectIdentifier.of(oid);
}
}
@ -622,7 +618,7 @@ public class X509CertSelector implements CertSelector {
Collections.unmodifiableSet(new HashSet<>(keyPurposeSet));
keyPurposeOIDSet = new HashSet<>();
for (String s : this.keyPurposeSet) {
keyPurposeOIDSet.add(new ObjectIdentifier(s));
keyPurposeOIDSet.add(ObjectIdentifier.of(s));
}
}
}
@ -1105,8 +1101,8 @@ public class X509CertSelector implements CertSelector {
if (!(o instanceof String)) {
throw new IOException("non String in certPolicySet");
}
polIdVector.add(new CertificatePolicyId(new ObjectIdentifier(
(String)o)));
polIdVector.add(new CertificatePolicyId
(ObjectIdentifier.of((String)o)));
}
// If everything went OK, make the changes
policySet = tempSet;