8296143: CertAttrSet's set/get mechanism is not type-safe

Reviewed-by: mullan
This commit is contained in:
Weijun Wang 2022-11-08 22:35:29 +00:00
parent d04d6566b0
commit 671f84bd86
66 changed files with 643 additions and 2902 deletions

View file

@ -44,13 +44,9 @@ import sun.security.util.*;
* @see CertAttrSet
*/
public class CRLNumberExtension extends Extension
implements CertAttrSet<String> {
implements CertAttrSet {
/**
* Attribute name.
*/
public static final String NAME = "CRLNumber";
public static final String NUMBER = "value";
private static final String LABEL = "CRL Number";
@ -135,31 +131,10 @@ implements CertAttrSet<String> {
}
/**
* Set the attribute value.
* Get the crlNumber value.
*/
public void set(String name, Object obj) throws IOException {
if (name.equalsIgnoreCase(NUMBER)) {
if (!(obj instanceof BigInteger)) {
throw new IOException("Attribute must be of type BigInteger.");
}
crlNumber = (BigInteger)obj;
} else {
throw new IOException("Attribute name not recognized by" +
" CertAttrSet:" + extensionName + '.');
}
encodeThis();
}
/**
* Get the attribute value.
*/
public BigInteger get(String name) throws IOException {
if (name.equalsIgnoreCase(NUMBER)) {
return crlNumber;
} else {
throw new IOException("Attribute name not recognized by" +
" CertAttrSet:" + extensionName + '.');
}
public BigInteger getCrlNumber() {
return crlNumber;
}
@ -206,10 +181,10 @@ implements CertAttrSet<String> {
/**
* Return the name of this attribute.
* Return the name of this extension.
*/
@Override
public String getName() {
return (extensionName);
return extensionName;
}
}