summaryrefslogtreecommitdiffstats
path: root/pki/base/util/src/netscape/security/x509/Extensions.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/util/src/netscape/security/x509/Extensions.java')
-rw-r--r--pki/base/util/src/netscape/security/x509/Extensions.java66
1 files changed, 33 insertions, 33 deletions
diff --git a/pki/base/util/src/netscape/security/x509/Extensions.java b/pki/base/util/src/netscape/security/x509/Extensions.java
index befce89b8..1e728a0a8 100644
--- a/pki/base/util/src/netscape/security/x509/Extensions.java
+++ b/pki/base/util/src/netscape/security/x509/Extensions.java
@@ -34,21 +34,22 @@ import netscape.security.util.DerValue;
/**
* This class defines the Extensions attribute for the Certificate.
- *
+ *
* @author Amit Kapoor
* @author Hemma Prafullchandra
* @version 1.11
* @see CertAttrSet
*/
-public class Extensions extends Vector implements CertAttrSet {
+public class Extensions extends Vector
+implements CertAttrSet {
/**
*
*/
private static final long serialVersionUID = 4597917347772057433L;
/**
- * Identifier for this attribute, to be used with the get, set, delete
- * methods of Certificate, x509 type.
- */
+ * 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";
/**
* name
@@ -61,10 +62,10 @@ public class Extensions extends Vector implements CertAttrSet {
public void parseExtension(Extension ext) throws IOException {
try {
Class extClass = OIDMap.getClass(ext.getExtensionId());
- if (extClass == null) { // Unsupported extension
+ if (extClass == null) { // Unsupported extension
if (ext.isCritical()) {
throw new IOException("Unsupported CRITICAL extension: "
- + ext.getExtensionId());
+ + ext.getExtensionId());
} else {
map.put(ext.getExtensionId().toString(), ext);
addElement(ext);
@@ -76,23 +77,23 @@ public class Extensions extends Vector implements CertAttrSet {
byte[] extData = ext.getExtensionValue();
int extLen = extData.length;
- Object value = Array.newInstance(byte.class, extLen);
-
- for (int i = 0; i < extLen; i++) {
- Array.setByte(value, i, extData[i]);
- }
- Object[] passed = new Object[] { new Boolean(ext.isCritical()),
- value };
- CertAttrSet certExt = (CertAttrSet) cons.newInstance(passed);
- map.put(certExt.getName(), certExt);
+ Object value = Array.newInstance(byte.class, extLen);
+
+ for (int i = 0; i < extLen; i++) {
+ Array.setByte(value, i, extData[i]);
+ }
+ Object[] passed = new Object[] {new Boolean(ext.isCritical()),
+ value};
+ CertAttrSet certExt = (CertAttrSet)cons.newInstance(passed);
+ map.put(certExt.getName(), certExt);
addElement(certExt);
} catch (NoSuchMethodException nosuch) {
throw new IOException(nosuch.toString());
} catch (InvocationTargetException invk) {
throw new IOException(invk.getTargetException().toString());
- } catch (Exception e) {
- throw new IOException(e.toString());
+ } catch (Exception e) {
+ throw new IOException(e.toString());
}
}
@@ -105,11 +106,12 @@ public class Extensions extends Vector implements CertAttrSet {
/**
* Create the object, decoding the values from the passed DER stream.
- *
+ *
* @param in the DerInputStream to read the Extension from.
* @exception IOException on decoding errors.
*/
- public Extensions(DerInputStream in) throws IOException {
+ public Extensions(DerInputStream in)
+ throws IOException {
map = new Hashtable();
DerValue[] exts = in.getSequence(5);
@@ -122,7 +124,7 @@ public class Extensions extends Vector implements CertAttrSet {
/**
* Decode the extensions from the InputStream.
- *
+ *
* @param in the InputStream to unmarshal the contents from.
* @exception IOException on decoding or validity errors.
*/
@@ -141,45 +143,44 @@ public class Extensions extends Vector implements CertAttrSet {
/**
* Encode the extensions in DER form to the stream.
- *
+ *
* @param out the DerOutputStream to marshal the contents to.
* @exception CertificateException on encoding errors.
* @exception IOException on errors.
*/
- public void encode(OutputStream out) throws CertificateException,
- IOException {
+ public void encode(OutputStream out)
+ throws CertificateException, IOException {
DerOutputStream extOut = new DerOutputStream();
for (int i = 0; i < size(); i++) {
Object thisOne = elementAt(i);
if (thisOne instanceof CertAttrSet)
- ((CertAttrSet) thisOne).encode(extOut);
+ ((CertAttrSet)thisOne).encode(extOut);
else if (thisOne instanceof Extension)
- ((Extension) thisOne).encode(extOut);
+ ((Extension)thisOne).encode(extOut);
else
throw new CertificateException("Invalid extension object");
}
DerOutputStream seq = new DerOutputStream();
- seq.write(DerValue.tag_Sequence, extOut);
+ seq.write(DerValue.tag_Sequence,extOut);
+
out.write(seq.toByteArray());
}
/**
* Set the attribute value.
- *
* @param name the extension name used in the cache.
* @param obj the object to set.
* @exception IOException if the object could not be cached.
*/
public void set(String name, Object obj) throws IOException {
- map.put(name, obj);
+ map.put(name,obj);
addElement(obj);
}
/**
* Get the attribute value.
- *
* @param name the extension name used in the lookup.
* @exception IOException if named extension is not found.
*/
@@ -193,7 +194,6 @@ public class Extensions extends Vector implements CertAttrSet {
/**
* Delete the attribute value.
- *
* @param name the extension name used in the lookup.
* @exception IOException if named extension is not found.
*/
@@ -210,14 +210,14 @@ public class Extensions extends Vector implements CertAttrSet {
* Return an enumeration of names of attributes existing within this
* attribute.
*/
- public Enumeration getElements() {
+ public Enumeration getElements () {
return (map.elements());
}
/**
* Return the name of this attribute.
*/
- public String getName() {
+ public String getName () {
return (NAME);
}
}