8234037: Improve Object Identifier Processing

Reviewed-by: weijun, mschoene, ssahoo
This commit is contained in:
Xue-Lei Andrew Fan 2019-11-25 07:24:17 -08:00
parent 796f3ba8be
commit 02cc064144
2 changed files with 62 additions and 84 deletions

View file

@ -599,7 +599,7 @@ public class AVA implements DerEncoder {
if (derval.tag != DerValue.tag_Sequence) { if (derval.tag != DerValue.tag_Sequence) {
throw new IOException("AVA not a sequence"); throw new IOException("AVA not a sequence");
} }
oid = X500Name.intern(derval.data.getOID()); oid = derval.data.getOID();
value = derval.data.getDerValue(); value = derval.data.getDerValue();
if (derval.data.available() != 0) { if (derval.data.available() != 0) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -1097,18 +1097,6 @@ public class X500Name implements GeneralNameInterface, Principal {
/****************************************************************/ /****************************************************************/
/*
* Maybe return a preallocated OID, to reduce storage costs
* and speed recognition of common X.500 attributes.
*/
static ObjectIdentifier intern(ObjectIdentifier oid) {
ObjectIdentifier interned = internedOIDs.putIfAbsent(oid, oid);
return (interned == null) ? oid : interned;
}
private static final Map<ObjectIdentifier,ObjectIdentifier> internedOIDs
= new HashMap<ObjectIdentifier,ObjectIdentifier>();
/* /*
* Selected OIDs from X.520 * Selected OIDs from X.520
* Includes all those specified in RFC 5280 as MUST or SHOULD * Includes all those specified in RFC 5280 as MUST or SHOULD
@ -1136,92 +1124,82 @@ public class X500Name implements GeneralNameInterface, Principal {
{ 0, 9, 2342, 19200300, 100, 1, 1 }; { 0, 9, 2342, 19200300, 100, 1, 1 };
public static final ObjectIdentifier commonName_oid; // OID for the "CN=" attribute, denoting a person's common name.
public static final ObjectIdentifier countryName_oid; public static final ObjectIdentifier commonName_oid =
public static final ObjectIdentifier localityName_oid; ObjectIdentifier.newInternal(commonName_data);
public static final ObjectIdentifier orgName_oid;
public static final ObjectIdentifier orgUnitName_oid;
public static final ObjectIdentifier stateName_oid;
public static final ObjectIdentifier streetAddress_oid;
public static final ObjectIdentifier title_oid;
public static final ObjectIdentifier DNQUALIFIER_OID;
public static final ObjectIdentifier SURNAME_OID;
public static final ObjectIdentifier GIVENNAME_OID;
public static final ObjectIdentifier INITIALS_OID;
public static final ObjectIdentifier GENERATIONQUALIFIER_OID;
public static final ObjectIdentifier ipAddress_oid;
public static final ObjectIdentifier DOMAIN_COMPONENT_OID;
public static final ObjectIdentifier userid_oid;
public static final ObjectIdentifier SERIALNUMBER_OID;
static { // OID for the "SERIALNUMBER=" attribute, denoting a serial number for.
/** OID for the "CN=" attribute, denoting a person's common name. */ // a name. Do not confuse with PKCS#9 issuerAndSerialNumber or the
commonName_oid = intern(ObjectIdentifier.newInternal(commonName_data)); // certificate serial number.
public static final ObjectIdentifier SERIALNUMBER_OID =
ObjectIdentifier.newInternal(SERIALNUMBER_DATA);
/** OID for the "SERIALNUMBER=" attribute, denoting a serial number for. // OID for the "C=" attribute, denoting a country.
a name. Do not confuse with PKCS#9 issuerAndSerialNumber or the public static final ObjectIdentifier countryName_oid =
certificate serial number. */ ObjectIdentifier.newInternal(countryName_data);
SERIALNUMBER_OID = intern(ObjectIdentifier.newInternal(SERIALNUMBER_DATA));
/** OID for the "C=" attribute, denoting a country. */ // OID for the "L=" attribute, denoting a locality (such as a city).
countryName_oid = intern(ObjectIdentifier.newInternal(countryName_data)); public static final ObjectIdentifier localityName_oid =
ObjectIdentifier.newInternal(localityName_data);
/** OID for the "L=" attribute, denoting a locality (such as a city) */ // OID for the "O=" attribute, denoting an organization name.
localityName_oid = intern(ObjectIdentifier.newInternal(localityName_data)); public static final ObjectIdentifier orgName_oid =
ObjectIdentifier.newInternal(orgName_data);
/** OID for the "O=" attribute, denoting an organization name */ // OID for the "OU=" attribute, denoting an organizational unit name.
orgName_oid = intern(ObjectIdentifier.newInternal(orgName_data)); public static final ObjectIdentifier orgUnitName_oid =
ObjectIdentifier.newInternal(orgUnitName_data);
/** OID for the "OU=" attribute, denoting an organizational unit name */ // OID for the "S=" attribute, denoting a state (such as Delaware).
orgUnitName_oid = intern(ObjectIdentifier.newInternal(orgUnitName_data)); public static final ObjectIdentifier stateName_oid =
ObjectIdentifier.newInternal(stateName_data);
/** OID for the "S=" attribute, denoting a state (such as Delaware) */ // OID for the "STREET=" attribute, denoting a street address.
stateName_oid = intern(ObjectIdentifier.newInternal(stateName_data)); public static final ObjectIdentifier streetAddress_oid =
ObjectIdentifier.newInternal(streetAddress_data);
/** OID for the "STREET=" attribute, denoting a street address. */ // OID for the "T=" attribute, denoting a person's title.
streetAddress_oid = intern(ObjectIdentifier.newInternal(streetAddress_data)); public static final ObjectIdentifier title_oid =
ObjectIdentifier.newInternal(title_data);
/** OID for the "T=" attribute, denoting a person's title. */ // OID for the "DNQUALIFIER=" or "DNQ=" attribute, denoting DN
title_oid = intern(ObjectIdentifier.newInternal(title_data)); // disambiguating information.
public static final ObjectIdentifier DNQUALIFIER_OID =
ObjectIdentifier.newInternal(DNQUALIFIER_DATA);
/** OID for the "DNQUALIFIER=" or "DNQ=" attribute, denoting DN // OID for the "SURNAME=" attribute, denoting a person's surname.
disambiguating information.*/ public static final ObjectIdentifier SURNAME_OID =
DNQUALIFIER_OID = intern(ObjectIdentifier.newInternal(DNQUALIFIER_DATA)); ObjectIdentifier.newInternal(SURNAME_DATA);
/** OID for the "SURNAME=" attribute, denoting a person's surname.*/ // OID for the "GIVENNAME=" attribute, denoting a person's given name.
SURNAME_OID = intern(ObjectIdentifier.newInternal(SURNAME_DATA)); public static final ObjectIdentifier GIVENNAME_OID =
ObjectIdentifier.newInternal(GIVENNAME_DATA);
/** OID for the "GIVENNAME=" attribute, denoting a person's given name.*/ // OID for the "INITIALS=" attribute, denoting a person's initials.
GIVENNAME_OID = intern(ObjectIdentifier.newInternal(GIVENNAME_DATA)); public static final ObjectIdentifier INITIALS_OID =
ObjectIdentifier.newInternal(INITIALS_DATA);
/** OID for the "INITIALS=" attribute, denoting a person's initials.*/ // OID for the "GENERATION=" attribute, denoting Jr., II, etc.
INITIALS_OID = intern(ObjectIdentifier.newInternal(INITIALS_DATA)); public static final ObjectIdentifier GENERATIONQUALIFIER_OID =
ObjectIdentifier.newInternal(GENERATIONQUALIFIER_DATA);
/** OID for the "GENERATION=" attribute, denoting Jr., II, etc.*/ // OIDs from other sources which show up in X.500 names we
GENERATIONQUALIFIER_OID = // expect to deal with often.
intern(ObjectIdentifier.newInternal(GENERATIONQUALIFIER_DATA)); //
// OID for "IP=" IP address attributes, used with SKIP.
public static final ObjectIdentifier ipAddress_oid =
ObjectIdentifier.newInternal(ipAddress_data);
/* // Domain component OID from RFC 1274, RFC 2247, RFC 5280.
* OIDs from other sources which show up in X.500 names we //
* expect to deal with often // OID for "DC=" domain component attributes, used with DNSNames in DN
*/ // format.
/** OID for "IP=" IP address attributes, used with SKIP. */ public static final ObjectIdentifier DOMAIN_COMPONENT_OID =
ipAddress_oid = intern(ObjectIdentifier.newInternal(ipAddress_data)); ObjectIdentifier.newInternal(DOMAIN_COMPONENT_DATA);
/* // OID for "UID=" denoting a user id, defined in RFCs 1274 & 2798.
* Domain component OID from RFC 1274, RFC 2247, RFC 5280 public static final ObjectIdentifier userid_oid =
*/ ObjectIdentifier.newInternal(userid_data);
/*
* OID for "DC=" domain component attributes, used with DNSNames in DN
* format
*/
DOMAIN_COMPONENT_OID =
intern(ObjectIdentifier.newInternal(DOMAIN_COMPONENT_DATA));
/** OID for "UID=" denoting a user id, defined in RFCs 1274 & 2798. */
userid_oid = intern(ObjectIdentifier.newInternal(userid_data));
}
/** /**
* Return constraint type:<ul> * Return constraint type:<ul>