mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +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
|
@ -44,16 +44,8 @@ import sun.security.util.*;
|
|||
* @see CertAttrSet
|
||||
*/
|
||||
public class KeyUsageExtension extends Extension
|
||||
implements CertAttrSet<String> {
|
||||
implements CertAttrSet {
|
||||
|
||||
/**
|
||||
* 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.KeyUsage";
|
||||
/**
|
||||
* Attribute names.
|
||||
*/
|
||||
public static final String NAME = "KeyUsage";
|
||||
public static final String DIGITAL_SIGNATURE = "digital_signature";
|
||||
public static final String NON_REPUDIATION = "non_repudiation";
|
||||
|
@ -183,11 +175,7 @@ implements CertAttrSet<String> {
|
|||
/**
|
||||
* Set the attribute value.
|
||||
*/
|
||||
public void set(String name, Object obj) throws IOException {
|
||||
if (!(obj instanceof Boolean)) {
|
||||
throw new IOException("Attribute must be of type Boolean.");
|
||||
}
|
||||
boolean val = ((Boolean)obj).booleanValue();
|
||||
public void set(String name, boolean val) throws IOException {
|
||||
if (name.equalsIgnoreCase(DIGITAL_SIGNATURE)) {
|
||||
set(0,val);
|
||||
} else if (name.equalsIgnoreCase(NON_REPUDIATION)) {
|
||||
|
@ -216,25 +204,25 @@ implements CertAttrSet<String> {
|
|||
/**
|
||||
* Get the attribute value.
|
||||
*/
|
||||
public Boolean get(String name) throws IOException {
|
||||
public boolean get(String name) throws IOException {
|
||||
if (name.equalsIgnoreCase(DIGITAL_SIGNATURE)) {
|
||||
return Boolean.valueOf(isSet(0));
|
||||
return isSet(0);
|
||||
} else if (name.equalsIgnoreCase(NON_REPUDIATION)) {
|
||||
return Boolean.valueOf(isSet(1));
|
||||
return isSet(1);
|
||||
} else if (name.equalsIgnoreCase(KEY_ENCIPHERMENT)) {
|
||||
return Boolean.valueOf(isSet(2));
|
||||
return isSet(2);
|
||||
} else if (name.equalsIgnoreCase(DATA_ENCIPHERMENT)) {
|
||||
return Boolean.valueOf(isSet(3));
|
||||
return isSet(3);
|
||||
} else if (name.equalsIgnoreCase(KEY_AGREEMENT)) {
|
||||
return Boolean.valueOf(isSet(4));
|
||||
return isSet(4);
|
||||
} else if (name.equalsIgnoreCase(KEY_CERTSIGN)) {
|
||||
return Boolean.valueOf(isSet(5));
|
||||
return isSet(5);
|
||||
} else if (name.equalsIgnoreCase(CRL_SIGN)) {
|
||||
return Boolean.valueOf(isSet(6));
|
||||
return isSet(6);
|
||||
} else if (name.equalsIgnoreCase(ENCIPHER_ONLY)) {
|
||||
return Boolean.valueOf(isSet(7));
|
||||
return isSet(7);
|
||||
} else if (name.equalsIgnoreCase(DECIPHER_ONLY)) {
|
||||
return Boolean.valueOf(isSet(8));
|
||||
return isSet(8);
|
||||
} else {
|
||||
throw new IOException("Attribute name not recognized by"
|
||||
+ " CertAttrSet:KeyUsage.");
|
||||
|
@ -305,10 +293,10 @@ implements CertAttrSet<String> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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