mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8296143: CertAttrSet's set/get mechanism is not type-safe
Reviewed-by: mullan
This commit is contained in:
parent
d04d6566b0
commit
671f84bd86
66 changed files with 643 additions and 2902 deletions
|
@ -66,17 +66,9 @@ import sun.security.util.DerOutputStream;
|
|||
* @see CertAttrSet
|
||||
*/
|
||||
public class CertificatePoliciesExtension extends Extension
|
||||
implements CertAttrSet<String> {
|
||||
/**
|
||||
* Identifier for this attribute, to be used with the
|
||||
* get, set, delete methods of Certificate, x509 type.
|
||||
*/
|
||||
public static final String IDENT = "x509.info.extensions.CertificatePolicies";
|
||||
/**
|
||||
* Attribute names.
|
||||
*/
|
||||
implements CertAttrSet {
|
||||
|
||||
public static final String NAME = "CertificatePolicies";
|
||||
public static final String POLICIES = "policies";
|
||||
|
||||
/**
|
||||
* List of PolicyInformation for this object.
|
||||
|
@ -187,44 +179,19 @@ implements CertAttrSet<String> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the attribute value.
|
||||
* Get the PolicyInformation value.
|
||||
*/
|
||||
@SuppressWarnings("unchecked") // Checked with an instanceof check
|
||||
public void set(String name, Object obj) throws IOException {
|
||||
if (name.equalsIgnoreCase(POLICIES)) {
|
||||
if (!(obj instanceof List)) {
|
||||
throw new IOException("Attribute value should be of type List.");
|
||||
}
|
||||
certPolicies = (List<PolicyInformation>)obj;
|
||||
} else {
|
||||
throw new IOException("Attribute name [" + name +
|
||||
"] not recognized by " +
|
||||
"CertAttrSet:CertificatePoliciesExtension.");
|
||||
}
|
||||
encodeThis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attribute value.
|
||||
*/
|
||||
public List<PolicyInformation> get(String name) throws IOException {
|
||||
if (name.equalsIgnoreCase(POLICIES)) {
|
||||
//XXXX May want to consider cloning this
|
||||
return certPolicies;
|
||||
} else {
|
||||
throw new IOException("Attribute name [" + name +
|
||||
"] not recognized by " +
|
||||
"CertAttrSet:CertificatePoliciesExtension.");
|
||||
}
|
||||
public List<PolicyInformation> getCertPolicies() {
|
||||
return certPolicies;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of this attribute.
|
||||
* Return the name of this extension.
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return (NAME);
|
||||
return NAME;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue