diff options
Diffstat (limited to 'pki/base/util/src/netscape/security/x509/SubjectKeyIdentifierExtension.java')
-rw-r--r-- | pki/base/util/src/netscape/security/x509/SubjectKeyIdentifierExtension.java | 127 |
1 files changed, 62 insertions, 65 deletions
diff --git a/pki/base/util/src/netscape/security/x509/SubjectKeyIdentifierExtension.java b/pki/base/util/src/netscape/security/x509/SubjectKeyIdentifierExtension.java index 9a2288b1a..fc65ec31e 100644 --- a/pki/base/util/src/netscape/security/x509/SubjectKeyIdentifierExtension.java +++ b/pki/base/util/src/netscape/security/x509/SubjectKeyIdentifierExtension.java @@ -29,39 +29,38 @@ import netscape.security.util.DerValue; /** * Represent the Subject Key Identifier Extension. - * + * * This extension, if present, provides a means of identifying the particular - * public key used in an application. This extension by default is marked + * public key used in an application. This extension by default is marked * non-critical. - * - * <p> - * Extensions are addiitonal attributes which can be inserted in a X509 v3 - * certificate. For example a "Driving License Certificate" could have the - * driving license number as a extension. - * - * <p> - * Extensions are represented as a sequence of the extension identifier (Object - * Identifier), a boolean flag stating whether the extension is to be treated as - * being critical and the extension value itself (this is again a DER encoding - * of the extension value). - * + * + * <p>Extensions are addiitonal attributes which can be inserted in a X509 + * v3 certificate. For example a "Driving License Certificate" could have + * the driving license number as a extension. + * + * <p>Extensions are represented as a sequence of the extension identifier + * (Object Identifier), a boolean flag stating whether the extension is to + * be treated as being critical and the extension value itself (this is again + * a DER encoding of the extension value). + * * @author Amit Kapoor * @author Hemma Prafullchandra * @version 1.7 * @see Extension * @see CertAttrSet */ -public class SubjectKeyIdentifierExtension extends Extension implements - CertAttrSet { +public class SubjectKeyIdentifierExtension extends Extension +implements CertAttrSet { /** * */ private static final long serialVersionUID = 2457721262590880939L; /** - * 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.SubjectKeyIdentifier"; + * 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.SubjectKeyIdentifier"; /** * Attribute names. */ @@ -79,21 +78,20 @@ public class SubjectKeyIdentifierExtension extends Extension implements } /** - * Create a SubjectKeyIdentifierExtension with the passed octet string. The - * criticality is set to False. - * + * Create a SubjectKeyIdentifierExtension with the passed octet string. + * The criticality is set to False. * @param octetString the octet string identifying the key identifier. */ - public SubjectKeyIdentifierExtension(boolean critical, byte[] octetString) - throws IOException { + public SubjectKeyIdentifierExtension (boolean critical, byte[] octetString) + throws IOException { id = new KeyIdentifier(octetString); this.extensionId = PKIXExtensions.SubjectKey_Id; this.critical = critical; encodeThis(); } - - public SubjectKeyIdentifierExtension(byte[] octetString) throws IOException { + public SubjectKeyIdentifierExtension (byte[] octetString) + throws IOException { id = new KeyIdentifier(octetString); this.extensionId = PKIXExtensions.SubjectKey_Id; @@ -103,21 +101,21 @@ public class SubjectKeyIdentifierExtension extends Extension implements /** * Create the extension from the passed DER encoded value. - * + * * @param critical true if the extension is to be treated as critical. * @param value Array of DER encoded bytes of the actual value. * @exception IOException on error. */ public SubjectKeyIdentifierExtension(Boolean critical, Object value) - throws IOException { + throws IOException { this.extensionId = PKIXExtensions.SubjectKey_Id; this.critical = critical.booleanValue(); int len = Array.getLength(value); - byte[] extValue = new byte[len]; - for (int i = 0; i < len; i++) { - extValue[i] = Array.getByte(value, i); - } + byte[] extValue = new byte[len]; + for (int i = 0; i < len; i++) { + extValue[i] = Array.getByte(value,i); + } this.extensionValue = extValue; DerValue val = new DerValue(extValue); this.id = new KeyIdentifier(val); @@ -127,16 +125,15 @@ public class SubjectKeyIdentifierExtension extends Extension implements * Returns a printable representation. */ public String toString() { - if (id == null) - return ""; + if (id == null) return ""; String s = super.toString() + "SubjectKeyIdentifier [\n" - + id.toString() + "]\n"; + + id.toString() + "]\n"; return (s); } /** * Write the extension to the OutputStream. - * + * * @param out the OutputStream to write the extension to. * @exception IOException on encoding errors. */ @@ -148,12 +145,12 @@ public class SubjectKeyIdentifierExtension extends Extension implements encodeThis(); } super.encode(tmp); - out.write(tmp.toByteArray()); + out.write(tmp.toByteArray()); } /** * Decode the extension from the InputStream. - * + * * @param in the InputStream to unmarshal the contents from. * @exception IOException on decoding or validity errors. */ @@ -165,58 +162,58 @@ public class SubjectKeyIdentifierExtension extends Extension implements * Set the attribute value. */ public void set(String name, Object obj) throws IOException { - clearValue(); - if (name.equalsIgnoreCase(KEY_ID)) { - if (!(obj instanceof KeyIdentifier)) { - throw new IOException("Attribute value should be of" - + " type KeyIdentifier."); - } - id = (KeyIdentifier) obj; - } else { - throw new IOException("Attribute name not recognized by " - + "CertAttrSet:SubjectKeyIdentifierExtension."); - } + clearValue(); + if (name.equalsIgnoreCase(KEY_ID)) { + if (!(obj instanceof KeyIdentifier)) { + throw new IOException("Attribute value should be of" + + " type KeyIdentifier."); + } + id = (KeyIdentifier)obj; + } else { + throw new IOException("Attribute name not recognized by " + + "CertAttrSet:SubjectKeyIdentifierExtension."); + } } /** * Get the attribute value. */ public Object get(String name) throws IOException { - if (name.equalsIgnoreCase(KEY_ID)) { - return (id); - } else { - throw new IOException("Attribute name not recognized by " - + "CertAttrSet:SubjectKeyIdentifierExtension."); - } + if (name.equalsIgnoreCase(KEY_ID)) { + return (id); + } else { + throw new IOException("Attribute name not recognized by " + + "CertAttrSet:SubjectKeyIdentifierExtension."); + } } /** * Delete the attribute value. */ public void delete(String name) throws IOException { - if (name.equalsIgnoreCase(KEY_ID)) { - id = null; - } else { - throw new IOException("Attribute name not recognized by " - + "CertAttrSet:SubjectKeyIdentifierExtension."); - } + if (name.equalsIgnoreCase(KEY_ID)) { + id = null; + } else { + throw new IOException("Attribute name not recognized by " + + "CertAttrSet:SubjectKeyIdentifierExtension."); + } } /** * Return an enumeration of names of attributes existing within this * attribute. */ - public Enumeration<String> getElements() { + public Enumeration<String> getElements () { Vector<String> elements = new Vector<String>(); elements.addElement(KEY_ID); - return (elements.elements()); + return (elements.elements()); } /** * Return the name of this attribute. */ - public String getName() { + public String getName () { return (NAME); } } |