summaryrefslogtreecommitdiffstats
path: root/pki/base/util/src/netscape/security/x509/OtherName.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/util/src/netscape/security/x509/OtherName.java')
-rw-r--r--pki/base/util/src/netscape/security/x509/OtherName.java149
1 files changed, 75 insertions, 74 deletions
diff --git a/pki/base/util/src/netscape/security/x509/OtherName.java b/pki/base/util/src/netscape/security/x509/OtherName.java
index f2195d1f8..c4815bb21 100644
--- a/pki/base/util/src/netscape/security/x509/OtherName.java
+++ b/pki/base/util/src/netscape/security/x509/OtherName.java
@@ -25,18 +25,20 @@ import netscape.security.util.DerValue;
import netscape.security.util.ObjectIdentifier;
/**
- * This class implements the OtherName as required by the GeneralNames ASN.1
- * object.
- *
- * OtherName ::= SEQUENCE { type-id OBJECT IDENTIFIER, value [0] EXPLICIT ANY
- * DEFINED BY type-id }
- *
+ * This class implements the OtherName as required by the GeneralNames
+ * ASN.1 object.
+ *
+ * OtherName ::= SEQUENCE {
+ * type-id OBJECT IDENTIFIER,
+ * value [0] EXPLICIT ANY DEFINED BY type-id
+ * }
+ *
* @see GeneralName
* @see GeneralNameInterface
* @see GeneralNames
- *
+ *
* @version 1.2
- *
+ *
* @author Amit Kapoor
* @author Hemma Prafullchandra
*/
@@ -50,7 +52,7 @@ public class OtherName implements GeneralNameInterface {
/**
* Create the IPAddressName object from the passed encoded Der value.
- *
+ *
* @param derValue the encoded DER IPAddressName.
* @exception IOException on error.
*/
@@ -59,60 +61,61 @@ public class OtherName implements GeneralNameInterface {
}
public OtherName(ObjectIdentifier oid, byte data[]) {
- mOID = oid;
- DerOutputStream dos = new DerOutputStream();
- try {
- dos.putDerValue(new DerValue(data));
- } catch (IOException e) {
- }
- mData = dos.toByteArray();
+ mOID = oid;
+ DerOutputStream dos = new DerOutputStream();
+ try {
+ dos.putDerValue(new DerValue(data));
+ } catch (IOException e) {
+ }
+ mData = dos.toByteArray();
}
/**
* Constructs a string-based other name.
*/
public OtherName(ObjectIdentifier oid, byte tag, String value) {
- mOID = oid;
- DerOutputStream dos = new DerOutputStream();
- try {
- if (tag == DerValue.tag_PrintableString) {
- dos.putPrintableString(value);
- } else if (tag == DerValue.tag_IA5String) {
- dos.putIA5String(value);
- } else if (tag == DerValue.tag_BMPString) {
- dos.putBMPString(value);
- } else if (tag == DerValue.tag_UTF8String) {
- dos.putUTF8String(value);
- }
- } catch (IOException e) {
+ mOID = oid;
+ DerOutputStream dos = new DerOutputStream();
+ try {
+ if (tag == DerValue.tag_PrintableString) {
+ dos.putPrintableString(value);
+ } else if (tag == DerValue.tag_IA5String) {
+ dos.putIA5String(value);
+ } else if (tag == DerValue.tag_BMPString) {
+ dos.putBMPString(value);
+ } else if (tag == DerValue.tag_UTF8String) {
+ dos.putUTF8String(value);
}
- mData = dos.toByteArray();
+ } catch (IOException e) {
+ }
+ mData = dos.toByteArray();
}
public OtherName(ObjectIdentifier oid, String value) {
- mOID = oid;
- DerOutputStream dos = new DerOutputStream();
- try {
- dos.putPrintableString(value);
- } catch (IOException e) {
- }
- mData = dos.toByteArray();
+ mOID = oid;
+ DerOutputStream dos = new DerOutputStream();
+ try {
+ dos.putPrintableString(value);
+ } catch (IOException e) {
+ }
+ mData = dos.toByteArray();
}
/**
* Create the IPAddressName object with the specified name.
- *
+ *
* @param name the IPAddressName.
*/
public OtherName(byte[] data) {
try {
- decodeThis(new DerValue(data));
+ decodeThis(new DerValue(data));
} catch (IOException e) {
}
}
- public ObjectIdentifier getOID() {
- return mOID;
+ public ObjectIdentifier getOID()
+ {
+ return mOID;
}
/**
@@ -124,19 +127,19 @@ public class OtherName implements GeneralNameInterface {
/**
* Encode the IPAddress name into the DerOutputStream.
- *
+ *
* @param out the DER stream to encode the IPAddressName to.
* @exception IOException on encoding errors.
*/
public void encode(DerOutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
- // encoding the attributes
+ //encoding the attributes
tmp.putOID(mOID);
DerOutputStream tmp1 = new DerOutputStream();
tmp1.write(mData);
- tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x80),
- tmp1);
+ tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true,
+ (byte)0x80), tmp1);
out.write(DerValue.tag_SequenceOf, tmp);
}
@@ -149,15 +152,16 @@ public class OtherName implements GeneralNameInterface {
// Decode this extension value
private void decodeThis(DerValue derVal) throws IOException {
- // if (derVal.tag != DerValue.tag_Sequence) {
- // throw new IOException("Invalid encoding for other name");
- // }
+ // if (derVal.tag != DerValue.tag_Sequence) {
+ // throw new IOException("Invalid encoding for other name");
+ // }
+
// Decode all the Attributes
mOID = derVal.data.getOID();
- // skip tag
+ // skip tag
DerValue tag = derVal.data.getDerValue();
- // read data
+ // read data
DerValue data = tag.data.getDerValue();
mData = data.toByteArray();
}
@@ -172,26 +176,21 @@ public class OtherName implements GeneralNameInterface {
public String toString() {
if (mData != null) {
try {
- DerValue data = new DerValue(mData);
- if (data.tag == DerValue.tag_PrintableString) {
- return "OtherName: (PrintableString)" + mOID + ","
- + data.getPrintableString();
- } else if (data.tag == DerValue.tag_IA5String) {
- return "OtherName: (IA5String)" + mOID + ","
- + data.getIA5String();
- } else if (data.tag == DerValue.tag_BMPString) {
- return "OtherName: (BMPString)" + mOID + ","
- + data.getIA5String();
- } else if (data.tag == DerValue.tag_UTF8String) {
- return "OtherName: (UTF8String)" + mOID + ","
- + data.getUTF8String();
- } else {
- return "OtherName: (Any)" + mOID + ","
- + toStr(data.toByteArray());
- }
- } catch (IOException e) {
-
- return "OtherName: (Any)" + mOID + "," + toStr(mData);
+ DerValue data = new DerValue(mData);
+ if (data.tag == DerValue.tag_PrintableString) {
+ return "OtherName: (PrintableString)" + mOID + "," + data.getPrintableString();
+ } else if (data.tag == DerValue.tag_IA5String) {
+ return "OtherName: (IA5String)" + mOID + "," + data.getIA5String();
+ } else if (data.tag == DerValue.tag_BMPString) {
+ return "OtherName: (BMPString)" + mOID + "," + data.getIA5String();
+ } else if (data.tag == DerValue.tag_UTF8String) {
+ return "OtherName: (UTF8String)" + mOID + "," + data.getUTF8String();
+ } else {
+ return "OtherName: (Any)" + mOID + "," + toStr(data.toByteArray());
+ }
+ } catch (IOException e) {
+
+ return "OtherName: (Any)" + mOID + "," + toStr(mData);
}
} else {
return "OtherName: ";
@@ -201,11 +200,13 @@ public class OtherName implements GeneralNameInterface {
public String toStr(byte data[]) {
StringBuffer b = new StringBuffer();
for (int i = 0; i < data.length; i++) {
- if ((data[i] & 0xff) < 16) {
- b.append("0");
- }
- b.append(Integer.toString((int) (data[i] & 0xff), 0x10));
+ if ((data[i] & 0xff) < 16) {
+ b.append("0");
+ }
+ b.append(Integer.toString((int)(data[i] & 0xff), 0x10));
}
return b.toString();
}
}
+
+