On Thu, 21 Dec 2023 16:27:43 GMT, Weijun Wang <wei...@openjdk.org> wrote:
>> Refactored PKCS9Attribute to use a hash map instead of multiple arrays. The >> key for the hash map is an `ObjectIdentifier` and the values are a record >> `AttributeInfo` that stores the information previously contained in the >> arrays `PKCS9_VALUE_TAGS`, `VALUE_CLASSES`, and `SINGLE_VALUED`. >> >> It seems as though we should be able to get rid of constants such as >> `EMAIL_ADDRESS_OID` since they aren't heavily used with the hash map >> approach, but since the values are public it might cause compatibility >> issues. >> >> Another question is how to handle `RSA DSI`, `S/MIME`, >> `Extended-certificate`, and `Issuer Serial Number` OIDs. The prior version >> threw an error but in this refactor they are treated as an "unknown OID" and >> only throw a debug warning. This was addressed in >> https://bugs.openjdk.org/browse/JDK-8011867 but prior to this refactor the >> aforementioned OIDs were treated differently than unknown OIDs. > > src/java.base/share/classes/sun/security/pkcs/PKCS9Attribute.java line 186: > >> 184: /** >> 185: * Array of attribute OIDs defined in PKCS9, by number. >> 186: */ > > I don't think `PKCS9_OIDS` is useful now. It's used in > `PKCS9Attributes.getAttributes()` but this method is used nowhere. It's also > used in `PKCS9Attributes.toString` but we can just iterate through > `attributes` there. I don't see a reason to print the attributes in this > order. If we want to print them in the order they appear in the data, we can > use `LinkedHashMap` to in `PKCS9Attributes`. `Hashtable` is a little stale. Do you think we can remove `PKCS9Attributes.getAttributes()` entirely or should we just modify it to not use `PKCS9_OIDS` anymore? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/17132#discussion_r1439704152