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, 65 insertions, 62 deletions
diff --git a/pki/base/util/src/netscape/security/x509/SubjectKeyIdentifierExtension.java b/pki/base/util/src/netscape/security/x509/SubjectKeyIdentifierExtension.java index fc65ec31..9a2288b1 100644 --- a/pki/base/util/src/netscape/security/x509/SubjectKeyIdentifierExtension.java +++ b/pki/base/util/src/netscape/security/x509/SubjectKeyIdentifierExtension.java @@ -29,38 +29,39 @@ 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. */ @@ -78,20 +79,21 @@ implements CertAttrSet { } /** - * 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; @@ -101,21 +103,21 @@ implements CertAttrSet { /** * 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); @@ -125,15 +127,16 @@ implements CertAttrSet { * 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. */ @@ -145,12 +148,12 @@ implements CertAttrSet { 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. */ @@ -162,58 +165,58 @@ implements CertAttrSet { * 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); } } |