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

@ -39,13 +39,9 @@ import sun.security.util.*;
* @see CertAttrSet
*/
public class CRLReasonCodeExtension extends Extension
implements CertAttrSet<String> {
implements CertAttrSet {
/**
* Attribute name
*/
public static final String NAME = "CRLReasonCode";
public static final String REASON = "reason";
private static final CRLReason[] values = CRLReason.values();
@ -102,35 +98,6 @@ public class CRLReasonCodeExtension extends Extension
this.reasonCode = val.getEnumerated();
}
/**
* Set the attribute value.
*/
public void set(String name, Object obj) throws IOException {
if (!(obj instanceof Integer)) {
throw new IOException("Attribute must be of type Integer.");
}
if (name.equalsIgnoreCase(REASON)) {
reasonCode = ((Integer)obj).intValue();
} else {
throw new IOException
("Name not supported by CRLReasonCodeExtension");
}
encodeThis();
}
/**
* Get the attribute value.
*/
public Integer get(String name) throws IOException {
if (name.equalsIgnoreCase(REASON)) {
return reasonCode;
} else {
throw new IOException
("Name not supported by CRLReasonCodeExtension");
}
}
/**
* Returns a printable representation of the Reason code.
*/
@ -156,7 +123,7 @@ public class CRLReasonCodeExtension extends Extension
/**
* Return the name of this attribute.
* Return the name of this extension.
*/
@Override
public String getName() {
@ -174,4 +141,8 @@ public class CRLReasonCodeExtension extends Extension
return CRLReason.UNSPECIFIED;
}
}
public int getReason() {
return reasonCode;
}
}