summaryrefslogtreecommitdiffstats
path: root/pki/base/util/src/netscape/security/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/util/src/netscape/security/extensions')
-rw-r--r--pki/base/util/src/netscape/security/extensions/AccessDescription.java17
-rw-r--r--pki/base/util/src/netscape/security/extensions/AuthInfoAccessExtension.java78
-rw-r--r--pki/base/util/src/netscape/security/extensions/CertInfo.java44
-rw-r--r--pki/base/util/src/netscape/security/extensions/CertificateRenewalWindowExtension.java36
-rw-r--r--pki/base/util/src/netscape/security/extensions/CertificateScopeEntry.java17
-rw-r--r--pki/base/util/src/netscape/security/extensions/CertificateScopeOfUseExtension.java51
-rw-r--r--pki/base/util/src/netscape/security/extensions/ExtendedKeyUsageExtension.java67
-rw-r--r--pki/base/util/src/netscape/security/extensions/GenericASN1Extension.java381
-rw-r--r--pki/base/util/src/netscape/security/extensions/InhibitAnyPolicyExtension.java61
-rw-r--r--pki/base/util/src/netscape/security/extensions/KerberosName.java83
-rw-r--r--pki/base/util/src/netscape/security/extensions/NSCertTypeExtension.java134
-rw-r--r--pki/base/util/src/netscape/security/extensions/OCSPNoCheckExtension.java35
-rw-r--r--pki/base/util/src/netscape/security/extensions/PresenceServerExtension.java393
-rw-r--r--pki/base/util/src/netscape/security/extensions/SubjectInfoAccessExtension.java57
14 files changed, 775 insertions, 679 deletions
diff --git a/pki/base/util/src/netscape/security/extensions/AccessDescription.java b/pki/base/util/src/netscape/security/extensions/AccessDescription.java
index a6c94fdd..89b4d829 100644
--- a/pki/base/util/src/netscape/security/extensions/AccessDescription.java
+++ b/pki/base/util/src/netscape/security/extensions/AccessDescription.java
@@ -25,6 +25,7 @@ import netscape.security.util.DerValue;
import netscape.security.util.ObjectIdentifier;
import netscape.security.x509.GeneralName;
+
public class AccessDescription implements Serializable {
ObjectIdentifier mOID = null;
GeneralName mLocation = null;
@@ -43,10 +44,12 @@ public class AccessDescription implements Serializable {
}
/**
- * For serialization: Note that GeneralName is not serializable. That is why
- * we need to define our own serialization method.
+ * For serialization:
+ * Note that GeneralName is not serializable. That is
+ * why we need to define our own serialization method.
*/
- private void writeObject(java.io.ObjectOutputStream out) throws IOException {
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws IOException {
DerOutputStream seq = new DerOutputStream();
DerOutputStream tmp = new DerOutputStream();
@@ -57,10 +60,12 @@ public class AccessDescription implements Serializable {
}
/**
- * For serialization Note that GeneralName is not serializable. That is why
- * we need to define our own serialization method.
+ * For serialization
+ * Note that GeneralName is not serializable. That is
+ * why we need to define our own serialization method.
*/
- private void readObject(java.io.ObjectInputStream in) throws IOException {
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException {
DerValue val = new DerValue(in);
DerValue seq = val.data.getDerValue();
diff --git a/pki/base/util/src/netscape/security/extensions/AuthInfoAccessExtension.java b/pki/base/util/src/netscape/security/extensions/AuthInfoAccessExtension.java
index ff017a7d..108dab07 100644
--- a/pki/base/util/src/netscape/security/extensions/AuthInfoAccessExtension.java
+++ b/pki/base/util/src/netscape/security/extensions/AuthInfoAccessExtension.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package netscape.security.extensions;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -36,24 +37,29 @@ import netscape.security.x509.Extension;
import netscape.security.x509.GeneralName;
import netscape.security.x509.URIName;
+
/**
- * This represents the authority information access extension as defined in
- * RFC2459.
- *
+ * This represents the authority information access extension
+ * as defined in RFC2459.
+ *
* id-pkix OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) dod(6)
- * internet(1) security(5) mechanisms(5) pkix(7) } } id-pe OBJECT IDENTIFIER ::=
- * { id-pkix 1 } id-pe-authorityInfoAccess OBJECT IDENTIFIER ::= { id-pe 1 }
+ * internet(1) security(5) mechanisms(5)
+ * pkix(7) } }
+ * id-pe OBJECT IDENTIFIER ::= { id-pkix 1 }
+ * id-pe-authorityInfoAccess OBJECT IDENTIFIER ::= { id-pe 1 }
* AuthorityInfoAccessSyntax ::= SEQUENCE SIZE (1..MAX) OF AccessDescription
- * AccessDescription ::= SEQUENCE { accessMethod OBJECT IDENTIFIER,
- * accessLocation GeneralName } id-ad OBJECT IDENTIFIER ::= { id-pkix 48 }
- * id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 } id-ad-caIssuers OBJECT
- * IDENTIFIER ::= { id-ad 2 }
- *
+ * AccessDescription ::= SEQUENCE {
+ * accessMethod OBJECT IDENTIFIER,
+ * accessLocation GeneralName
+ * }
+ * id-ad OBJECT IDENTIFIER ::= { id-pkix 48 }
+ * id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 }
+ * id-ad-caIssuers OBJECT IDENTIFIER ::= { id-ad 2 }
+ *
* Need to make sure the following is added to CMS.cfg:
- * oidmap.auth_info_access.class
- * =com.netscape.certsrv.cert.AuthInfoAccessExtension
+ * oidmap.auth_info_access.class=com.netscape.certsrv.cert.AuthInfoAccessExtension
* oidmap.auth_info_access.oid=1.3.6.1.5.5.7.1.1
- *
+ *
* @author thomask
* @version $Revision$, $Date$
*/
@@ -66,12 +72,12 @@ public class AuthInfoAccessExtension extends Extension implements CertAttrSet {
public static final String NAME2 = "AuthorityInformationAccess";
public static final int OID_OCSP[] = { 1, 3, 6, 1, 5, 5, 7, 48, 1 };
- public static final ObjectIdentifier METHOD_OCSP = new ObjectIdentifier(
- OID_OCSP);
+ public static final ObjectIdentifier METHOD_OCSP = new
+ ObjectIdentifier(OID_OCSP);
public static final int OID_CA_ISSUERS[] = { 1, 3, 6, 1, 5, 5, 7, 48, 2 };
- public static final ObjectIdentifier METHOD_CA_ISSUERS = new ObjectIdentifier(
- OID_CA_ISSUERS);
+ public static final ObjectIdentifier METHOD_CA_ISSUERS = new
+ ObjectIdentifier(OID_CA_ISSUERS);
public static final int OID[] = { 1, 3, 6, 1, 5, 5, 7, 1, 1 };
public static final ObjectIdentifier ID = new ObjectIdentifier(OID);
@@ -80,7 +86,7 @@ public class AuthInfoAccessExtension extends Extension implements CertAttrSet {
/**
* Create the extension from the passed DER encoded value of the same.
- *
+ *
* @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.
@@ -91,8 +97,8 @@ public class AuthInfoAccessExtension extends Extension implements CertAttrSet {
this.extensionValue = null; // build this when encodeThis() is called
}
- public AuthInfoAccessExtension(Boolean critical, Object value)
- throws IOException {
+ public AuthInfoAccessExtension(Boolean critical, Object value)
+ throws IOException {
this.extensionId = ID;
this.critical = critical.booleanValue();
this.extensionValue = (byte[]) ((byte[]) value).clone();
@@ -147,8 +153,10 @@ public class AuthInfoAccessExtension extends Extension implements CertAttrSet {
/**
* Adds Access Description.
*/
- public void addAccessDescription(ObjectIdentifier method, GeneralName gn) {
- clearValue();
+ public void addAccessDescription(
+ ObjectIdentifier method,
+ GeneralName gn) {
+ clearValue();
mDesc.addElement(new AccessDescription(method, gn));
}
@@ -167,8 +175,7 @@ public class AuthInfoAccessExtension extends Extension implements CertAttrSet {
DerValue val = new DerValue(this.extensionValue);
if (val.tag != DerValue.tag_Sequence) {
- throw new IOException(
- "Invalid encoding of AuthInfoAccess extension");
+ throw new IOException("Invalid encoding of AuthInfoAccess extension");
}
while (val.data.available() != 0) {
DerValue seq = val.data.getDerValue();
@@ -179,7 +186,7 @@ public class AuthInfoAccessExtension extends Extension implements CertAttrSet {
}
}
- private void encodeThis() throws IOException {
+ private void encodeThis() throws IOException {
DerOutputStream seq = new DerOutputStream();
DerOutputStream tmp = new DerOutputStream();
@@ -194,10 +201,10 @@ public class AuthInfoAccessExtension extends Extension implements CertAttrSet {
seq.write(DerValue.tag_Sequence, tmp);
this.extensionValue = seq.toByteArray();
}
-
+
/**
* Write the extension to the DerOutputStream.
- *
+ *
* @param out the DerOutputStream to write the extension to.
* @exception IOException on encoding errors.
*/
@@ -229,21 +236,20 @@ public class AuthInfoAccessExtension extends Extension implements CertAttrSet {
public static void main(String[] argv) {
AuthInfoAccessExtension aia = new AuthInfoAccessExtension(false);
- GeneralName ocspName = new GeneralName(new URIName(
- "http://ocsp.netscape.com"));
+ GeneralName ocspName = new GeneralName(new
+ URIName("http://ocsp.netscape.com"));
aia.addAccessDescription(METHOD_OCSP, ocspName);
- GeneralName caIssuersName = new GeneralName(new URIName(
- "http://ocsp.netscape.com"));
+ GeneralName caIssuersName = new GeneralName(new
+ URIName("http://ocsp.netscape.com"));
- aia.addAccessDescription(METHOD_CA_ISSUERS, caIssuersName);
+ aia.addAccessDescription(METHOD_CA_ISSUERS, caIssuersName);
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
aia.encode(os);
- System.out
- .println(com.netscape.osutil.OSUtil.BtoA(os.toByteArray()));
+ System.out.println(com.netscape.osutil.OSUtil.BtoA(os.toByteArray()));
} catch (IOException e) {
System.out.println(e.toString());
}
@@ -258,8 +264,8 @@ public class AuthInfoAccessExtension extends Extension implements CertAttrSet {
ByteArrayInputStream bis = new ByteArrayInputStream(
bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
- AuthInfoAccessExtension clone = (AuthInfoAccessExtension) ois
- .readObject();
+ AuthInfoAccessExtension clone = (AuthInfoAccessExtension)
+ ois.readObject();
System.out.println(clone);
} catch (Exception e) {
diff --git a/pki/base/util/src/netscape/security/extensions/CertInfo.java b/pki/base/util/src/netscape/security/extensions/CertInfo.java
index 145f8926..548a60f6 100644
--- a/pki/base/util/src/netscape/security/extensions/CertInfo.java
+++ b/pki/base/util/src/netscape/security/extensions/CertInfo.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package netscape.security.extensions;
+
import java.io.IOException;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
@@ -33,9 +34,10 @@ import netscape.security.x509.CertificateVersion;
import netscape.security.x509.X500Name;
import netscape.security.x509.X509CertInfo;
+
/**
- * Extends X509CertInfo class so that minimal fields are initialized at creation
- * time so an object of this type is always serializable.
+ * Extends X509CertInfo class so that minimal fields are initialized at
+ * creation time so an object of this type is always serializable.
*/
public class CertInfo extends X509CertInfo {
/**
@@ -52,31 +54,35 @@ public class CertInfo extends X509CertInfo {
static {
try {
// force version 3
- FORCE_VERSION_3 = new CertificateVersion(CertificateVersion.V3);
- SERIALIZE_SUBJECT = new CertificateSubjectName(new X500Name(
- "cn=uninitialized"));
- SERIALIZE_ISSUER = new CertificateIssuerName(new X500Name(
- "cn=uninitialized"));
- SERIALIZE_VALIDITY = new CertificateValidity(new Date(0), new Date(
- 0));
- SERIALIZE_SERIALNO = new CertificateSerialNumber(
- new BigInteger("0"));
- SERIALIZE_ALGOR = new CertificateAlgorithmId(
- AlgorithmId.getAlgorithmId("MD5withRSA"));
+ FORCE_VERSION_3 =
+ new CertificateVersion(CertificateVersion.V3);
+ SERIALIZE_SUBJECT =
+ new CertificateSubjectName(
+ new X500Name("cn=uninitialized"));
+ SERIALIZE_ISSUER =
+ new CertificateIssuerName(
+ new X500Name("cn=uninitialized"));
+ SERIALIZE_VALIDITY =
+ new CertificateValidity(new Date(0), new Date(0));
+ SERIALIZE_SERIALNO =
+ new CertificateSerialNumber(new BigInteger("0"));
+ SERIALIZE_ALGOR =
+ new CertificateAlgorithmId(
+ AlgorithmId.getAlgorithmId("MD5withRSA"));
} catch (IOException e) {
- // should never happen. If does, system is hosed.
+ // should never happen. If does, system is hosed.
System.out.println("**** Impossible Error encountered ****");
throw new RuntimeException(e.toString());
} catch (NoSuchAlgorithmException e) {
- // should never happen. If does, system is hosed.
+ // should never happen. If does, system is hosed.
System.out.println("**** Impossible Error encountered ****");
throw new RuntimeException(e.toString());
}
}
/**
- * Initializes most fields required by der encoding so object will serialize
- * properly.
+ * Initializes most fields required by der encoding so object will
+ * serialize properly.
*/
// XXX should write a class to use something else for serialization
// but this is faster and done now for the time crunch.
@@ -107,8 +113,8 @@ public class CertInfo extends X509CertInfo {
certinfo.set(X509CertInfo.SUBJECT, SERIALIZE_SUBJECT);
}
// key is set later in the request.
- } // these exceptions shouldn't happen here unless the
- // whole process is hosed.
+ } // these exceptions shouldn't happen here unless the
+ // whole process is hosed.
catch (CertificateException e) {
} catch (IOException e) {
}
diff --git a/pki/base/util/src/netscape/security/extensions/CertificateRenewalWindowExtension.java b/pki/base/util/src/netscape/security/extensions/CertificateRenewalWindowExtension.java
index 1d0b5ba7..634e2d57 100644
--- a/pki/base/util/src/netscape/security/extensions/CertificateRenewalWindowExtension.java
+++ b/pki/base/util/src/netscape/security/extensions/CertificateRenewalWindowExtension.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package netscape.security.extensions;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -30,31 +31,33 @@ import netscape.security.util.ObjectIdentifier;
import netscape.security.x509.CertAttrSet;
import netscape.security.x509.Extension;
+
/**
- * This represents the CertificateRenewalWindow extension as defined in
- * draft-thayes-cert-renewal-00
- *
- * CertificateRenewalWindow ::= SEQUENCE { beginTime GeneralizedTime, endTime
- * GeneralizedTime OPTIONAL }
- *
+ * This represents the CertificateRenewalWindow extension
+ * as defined in draft-thayes-cert-renewal-00
+ *
+ * CertificateRenewalWindow ::= SEQUENCE {
+ * beginTime GeneralizedTime,
+ * endTime GeneralizedTime OPTIONAL }
+ *
* @author thomask
* @version $Revision$, $Date$
*/
-public class CertificateRenewalWindowExtension extends Extension implements
- CertAttrSet {
+public class CertificateRenewalWindowExtension extends Extension
+ implements CertAttrSet {
/**
*
*/
private static final long serialVersionUID = 4470220533545299271L;
public static final String NAME = "CertificateRenewalWindow";
- public static final int OID[] = { 2, 16, 840, 1, 113730, 1, 15 };
+ public static final int OID[] = { 2, 16, 840, 1, 113730, 1, 15};
public static final ObjectIdentifier ID = new ObjectIdentifier(OID);
private Date mBeginTime = null;
private Date mEndTime = null; // optional
public CertificateRenewalWindowExtension(boolean critical, Date beginTime,
- Date endTime) throws IOException {
+ Date endTime) throws IOException {
this.extensionId = ID;
this.critical = critical;
mBeginTime = beginTime;
@@ -68,8 +71,8 @@ public class CertificateRenewalWindowExtension extends Extension implements
this.extensionValue = null; // build this when encodeThis() is called
}
- public CertificateRenewalWindowExtension(Boolean critical, Object value)
- throws IOException {
+ public CertificateRenewalWindowExtension(Boolean critical, Object value)
+ throws IOException {
this.extensionId = ID;
this.critical = critical.booleanValue();
this.extensionValue = (byte[]) ((byte[]) value).clone();
@@ -138,8 +141,7 @@ public class CertificateRenewalWindowExtension extends Extension implements
DerValue val = new DerValue(this.extensionValue);
if (val.tag != DerValue.tag_Sequence) {
- throw new IOException(
- "Invalid encoding of CertificateWindow extension");
+ throw new IOException("Invalid encoding of CertificateWindow extension");
}
while (val.data.available() != 0) {
if (mBeginTime == null) {
@@ -150,7 +152,7 @@ public class CertificateRenewalWindowExtension extends Extension implements
}
}
- private void encodeThis() throws IOException {
+ private void encodeThis() throws IOException {
DerOutputStream seq = new DerOutputStream();
DerOutputStream tmp = new DerOutputStream();
@@ -161,10 +163,10 @@ public class CertificateRenewalWindowExtension extends Extension implements
seq.write(DerValue.tag_Sequence, tmp);
this.extensionValue = seq.toByteArray();
}
-
+
/**
* Write the extension to the DerOutputStream.
- *
+ *
* @param out the DerOutputStream to write the extension to.
* @exception IOException on encoding errors.
*/
diff --git a/pki/base/util/src/netscape/security/extensions/CertificateScopeEntry.java b/pki/base/util/src/netscape/security/extensions/CertificateScopeEntry.java
index 553df897..39c87407 100644
--- a/pki/base/util/src/netscape/security/extensions/CertificateScopeEntry.java
+++ b/pki/base/util/src/netscape/security/extensions/CertificateScopeEntry.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package netscape.security.extensions;
+
import java.io.IOException;
import netscape.security.util.BigInt;
@@ -25,13 +26,15 @@ import netscape.security.util.DerValue;
import netscape.security.x509.GeneralName;
/**
- * This represents the CertificateScopeOfUse extension as defined in
- * draft-thayes-cert-scope-00
- *
- * CertificateScopeEntry ::= SEQUENCE { name GeneralName, -- pattern, as for
- * NameConstraints portNumber INTEGER OPTIONAL } CertificateScopeOfUse ::=
- * SEQUENCE OF CertificateScopeEntry
- *
+ * This represents the CertificateScopeOfUse extension
+ * as defined in draft-thayes-cert-scope-00
+ *
+ * CertificateScopeEntry ::= SEQUENCE {
+ * name GeneralName, -- pattern, as for NameConstraints
+ * portNumber INTEGER OPTIONAL
+ * }
+ * CertificateScopeOfUse ::= SEQUENCE OF CertificateScopeEntry
+ *
* @author thomask
* @version $Revision$, $Date$
*/
diff --git a/pki/base/util/src/netscape/security/extensions/CertificateScopeOfUseExtension.java b/pki/base/util/src/netscape/security/extensions/CertificateScopeOfUseExtension.java
index 1e2706cf..b6b8a87a 100644
--- a/pki/base/util/src/netscape/security/extensions/CertificateScopeOfUseExtension.java
+++ b/pki/base/util/src/netscape/security/extensions/CertificateScopeOfUseExtension.java
@@ -32,24 +32,26 @@ import netscape.security.x509.Extension;
import netscape.security.x509.OIDMap;
/**
- * This represents the CertificateScopeOfUse extension as defined in
- * draft-thayes-cert-scope-00
- *
- * CertificateScopeEntry ::= SEQUENCE { name GeneralName, -- pattern, as for
- * NameConstraints portNumber INTEGER OPTIONAL } CertificateScopeOfUse ::=
- * SEQUENCE OF CertificateScopeEntry
- *
+ * This represents the CertificateScopeOfUse extension
+ * as defined in draft-thayes-cert-scope-00
+ *
+ * CertificateScopeEntry ::= SEQUENCE {
+ * name GeneralName, -- pattern, as for NameConstraints
+ * portNumber INTEGER OPTIONAL
+ * }
+ * CertificateScopeOfUse ::= SEQUENCE OF CertificateScopeEntry
+ *
* @author thomask
* @version $Revision$, $Date$
*/
-public class CertificateScopeOfUseExtension extends Extension implements
- CertAttrSet {
+public class CertificateScopeOfUseExtension extends Extension
+ implements CertAttrSet {
/**
*
*/
private static final long serialVersionUID = 2143292831971567770L;
public static final String NAME = "CertificateScopeOfUse";
- public static final int OID[] = { 2, 16, 840, 1, 113730, 1, 17 };
+ public static final int OID[] = { 2, 16, 840, 1, 113730, 1, 17};
public static final ObjectIdentifier ID = new ObjectIdentifier(OID);
private Vector mEntries = null;
@@ -57,13 +59,13 @@ public class CertificateScopeOfUseExtension extends Extension implements
static {
try {
OIDMap.addAttribute(CertificateScopeOfUseExtension.class.getName(),
- ID.toString(), NAME);
+ ID.toString(), NAME);
} catch (CertificateException e) {
}
}
public CertificateScopeOfUseExtension(boolean critical, Vector scopeEntries)
- throws IOException {
+ throws IOException {
this.extensionId = ID;
this.critical = critical;
this.extensionValue = null; // build this when encodeThis() is called
@@ -77,8 +79,8 @@ public class CertificateScopeOfUseExtension extends Extension implements
this.extensionValue = null; // build this when encodeThis() is called
}
- public CertificateScopeOfUseExtension(Boolean critical, Object value)
- throws IOException {
+ public CertificateScopeOfUseExtension(Boolean critical, Object value)
+ throws IOException {
this.extensionId = ID;
this.critical = critical.booleanValue();
this.extensionValue = (byte[]) ((byte[]) value).clone();
@@ -135,17 +137,16 @@ public class CertificateScopeOfUseExtension extends Extension implements
DerValue val = new DerValue(this.extensionValue);
if (val.tag != DerValue.tag_Sequence) {
- throw new IOException(
- "Invalid encoding of CertificateWindow extension");
+ throw new IOException("Invalid encoding of CertificateWindow extension");
}
mEntries = new Vector();
while (val.data.available() != 0) {
- mEntries.addElement(new CertificateScopeEntry(val.data
- .getDerValue()));
+ mEntries.addElement(new CertificateScopeEntry(
+ val.data.getDerValue()));
}
}
- private void encodeThis() throws IOException {
+ private void encodeThis() throws IOException {
DerOutputStream seq = new DerOutputStream();
DerOutputStream tmp = new DerOutputStream();
@@ -153,8 +154,8 @@ public class CertificateScopeOfUseExtension extends Extension implements
throw new IOException("Invalid Scope Entries");
for (int i = 0; i < mEntries.size(); i++) {
- CertificateScopeEntry se = (CertificateScopeEntry) mEntries
- .elementAt(i);
+ CertificateScopeEntry se = (CertificateScopeEntry)
+ mEntries.elementAt(i);
se.encode(tmp);
}
@@ -162,10 +163,10 @@ public class CertificateScopeOfUseExtension extends Extension implements
seq.write(DerValue.tag_Sequence, tmp);
this.extensionValue = seq.toByteArray();
}
-
+
/**
* Write the extension to the DerOutputStream.
- *
+ *
* @param out the DerOutputStream to write the extension to.
* @exception IOException on encoding errors.
*/
@@ -187,8 +188,8 @@ public class CertificateScopeOfUseExtension extends Extension implements
if (mEntries != null) {
for (int i = 0; i < mEntries.size(); i++) {
- CertificateScopeEntry se = (CertificateScopeEntry) mEntries
- .elementAt(i);
+ CertificateScopeEntry se = (CertificateScopeEntry)
+ mEntries.elementAt(i);
s += se.toString();
}
diff --git a/pki/base/util/src/netscape/security/extensions/ExtendedKeyUsageExtension.java b/pki/base/util/src/netscape/security/extensions/ExtendedKeyUsageExtension.java
index 1e69da44..71ff031f 100644
--- a/pki/base/util/src/netscape/security/extensions/ExtendedKeyUsageExtension.java
+++ b/pki/base/util/src/netscape/security/extensions/ExtendedKeyUsageExtension.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package netscape.security.extensions;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -31,6 +32,7 @@ import netscape.security.x509.CertAttrSet;
import netscape.security.x509.Extension;
import netscape.security.x509.OIDMap;
+
/**
* This represents the extended key usage extension.
*/
@@ -45,23 +47,23 @@ public class ExtendedKeyUsageExtension extends Extension implements CertAttrSet
public static final String OID_OCSPSigning = "1.3.6.1.5.5.7.3.9";
public static final String OID_CODESigning = "1.3.6.1.5.5.7.3.3";
- public static final int OID_OCSP_SIGNING_STR[] = { 1, 3, 6, 1, 5, 5, 7, 3,
- 9 };
- public static final ObjectIdentifier OID_OCSP_SIGNING = new ObjectIdentifier(
- OID_OCSP_SIGNING_STR);
+ public static final int OID_OCSP_SIGNING_STR[] =
+ { 1, 3, 6, 1, 5, 5, 7, 3, 9 };
+ public static final ObjectIdentifier OID_OCSP_SIGNING = new
+ ObjectIdentifier(OID_OCSP_SIGNING_STR);
- public static final int OID_CODE_SIGNING_STR[] = { 1, 3, 6, 1, 5, 5, 7, 3,
- 3 };
- public static final ObjectIdentifier OID_CODE_SIGNING = new ObjectIdentifier(
- OID_OCSP_SIGNING_STR);
+ public static final int OID_CODE_SIGNING_STR[] =
+ { 1, 3, 6, 1, 5, 5, 7, 3, 3 };
+ public static final ObjectIdentifier OID_CODE_SIGNING = new
+ ObjectIdentifier(OID_OCSP_SIGNING_STR);
private Vector oidSet = null;
private byte mCached[] = null;
static {
try {
- OIDMap.addAttribute(ExtendedKeyUsageExtension.class.getName(), OID,
- NAME);
+ OIDMap.addAttribute(ExtendedKeyUsageExtension.class.getName(),
+ OID, NAME);
} catch (CertificateException e) {
}
}
@@ -73,7 +75,7 @@ public class ExtendedKeyUsageExtension extends Extension implements CertAttrSet
public ExtendedKeyUsageExtension(boolean crit, Vector oids) {
try {
extensionId = ObjectIdentifier.getObjectIdentifier(OID);
- } catch (IOException e) {
+ } catch (IOException e) {
// never here
}
critical = crit;
@@ -85,8 +87,8 @@ public class ExtendedKeyUsageExtension extends Extension implements CertAttrSet
encodeExtValue();
}
- public ExtendedKeyUsageExtension(Boolean crit, Object byteVal)
- throws IOException {
+ public ExtendedKeyUsageExtension(Boolean crit, Object byteVal)
+ throws IOException {
extensionId = ObjectIdentifier.getObjectIdentifier(OID);
critical = crit.booleanValue();
extensionValue = (byte[]) ((byte[]) byteVal).clone();
@@ -99,7 +101,7 @@ public class ExtendedKeyUsageExtension extends Extension implements CertAttrSet
mCached = null;
}
}
-
+
public Enumeration getOIDs() {
if (oidSet == null)
return null;
@@ -108,25 +110,24 @@ public class ExtendedKeyUsageExtension extends Extension implements CertAttrSet
public void deleteAllOIDs() {
if (oidSet == null)
- return;
- oidSet.clear();
+ return;
+ oidSet.clear();
}
public void addOID(ObjectIdentifier oid) {
if (oidSet == null) {
oidSet = new Vector();
}
-
- if (oidSet.contains(oid))
- return;
+
+ if (oidSet.contains(oid)) return;
oidSet.addElement(oid);
mCached = null;
}
-
+
public void encode(DerOutputStream out) throws IOException {
if (mCached == null) {
encodeExtValue();
- super.encode(out);
+ super.encode(out);
mCached = out.toByteArray();
}
}
@@ -143,16 +144,17 @@ public class ExtendedKeyUsageExtension extends Extension implements CertAttrSet
for (int i = 0; i < extensionValue.length; i++) {
extByteValue += (extensionValue[i] + " ");
}
- presentation += extByteValue;
+ presentation += extByteValue;
}
return presentation;
}
- public void decode(InputStream in) throws CertificateException, IOException {
+ public void decode(InputStream in)
+ throws CertificateException, IOException {
}
- public void encode(OutputStream out) throws CertificateException,
- IOException {
+ public void encode(OutputStream out)
+ throws CertificateException, IOException {
if (mCached == null) {
DerOutputStream temp = new DerOutputStream();
@@ -161,8 +163,8 @@ public class ExtendedKeyUsageExtension extends Extension implements CertAttrSet
out.write(mCached);
}
- public void set(String name, Object obj) throws CertificateException,
- IOException {
+ public void set(String name, Object obj)
+ throws CertificateException, IOException {
// NOT USED
}
@@ -176,10 +178,11 @@ public class ExtendedKeyUsageExtension extends Extension implements CertAttrSet
}
public String getName() {
- return NAME;
+ return NAME;
}
- public void delete(String name) throws CertificateException, IOException {
+ public void delete(String name)
+ throws CertificateException, IOException {
// NOT USED
}
@@ -187,8 +190,8 @@ public class ExtendedKeyUsageExtension extends Extension implements CertAttrSet
DerValue val = new DerValue(this.extensionValue);
if (val.tag != DerValue.tag_Sequence) {
- throw new IOException(
- "Invalid encoding of AuthInfoAccess extension");
+ throw new IOException("Invalid encoding of AuthInfoAccess extension"
+ );
}
if (oidSet == null)
oidSet = new Vector();
@@ -202,7 +205,7 @@ public class ExtendedKeyUsageExtension extends Extension implements CertAttrSet
private void encodeExtValue() {
DerOutputStream out = new DerOutputStream();
DerOutputStream temp = new DerOutputStream();
-
+
if (!oidSet.isEmpty()) {
Enumeration oidList = oidSet.elements();
diff --git a/pki/base/util/src/netscape/security/extensions/GenericASN1Extension.java b/pki/base/util/src/netscape/security/extensions/GenericASN1Extension.java
index fd82598a..bd0fd7e1 100644
--- a/pki/base/util/src/netscape/security/extensions/GenericASN1Extension.java
+++ b/pki/base/util/src/netscape/security/extensions/GenericASN1Extension.java
@@ -39,10 +39,13 @@ import netscape.security.x509.CertAttrSet;
import netscape.security.x509.Extension;
import netscape.security.x509.OIDMap;
+
+
/**
* Represent the AsnInteger Extension.
*/
-public class GenericASN1Extension extends Extension implements CertAttrSet {
+public class GenericASN1Extension extends Extension
+implements CertAttrSet {
/**
*
*/
@@ -50,19 +53,28 @@ public class GenericASN1Extension extends Extension implements CertAttrSet {
protected static final int MAX_ATTR = 10;
- protected static final String PROP_CRITICAL = "critical";
- protected static final String PROP_NAME = "name";
- protected static final String PROP_OID = "oid";
- protected static final String PROP_PATTERN = "pattern";
- protected static final String PROP_ATTRIBUTE = "attribute";
- protected static final String PROP_TYPE = "type";
- protected static final String PROP_SOURCE = "source";
- protected static final String PROP_VALUE = "value";
- protected static final String PROP_PREDICATE = "predicate";
+ protected static final String PROP_CRITICAL =
+ "critical";
+ protected static final String PROP_NAME =
+ "name";
+ protected static final String PROP_OID =
+ "oid";
+ protected static final String PROP_PATTERN =
+ "pattern";
+ protected static final String PROP_ATTRIBUTE =
+ "attribute";
+ protected static final String PROP_TYPE =
+ "type";
+ protected static final String PROP_SOURCE =
+ "source";
+ protected static final String PROP_VALUE =
+ "value";
+ protected static final String PROP_PREDICATE =
+ "predicate";
/**
- * 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 String NAME = null;
public static String OID = null;
public static Hashtable mConfig = null;
@@ -70,12 +82,16 @@ public class GenericASN1Extension extends Extension implements CertAttrSet {
private int index = 0;
// Encode this value
- private void encodeThis() throws IOException, ParseException {
+ private void encodeThis()
+ throws IOException, ParseException
+ {
this.extensionValue = encodePattern();
}
-
+
// Encode pattern
- private byte[] encodePattern() throws IOException, ParseException {
+ private byte[] encodePattern()
+ throws IOException, ParseException
+ {
DerOutputStream os = new DerOutputStream();
DerOutputStream tmp = new DerOutputStream();
String type = null;
@@ -84,118 +100,110 @@ public class GenericASN1Extension extends Extension implements CertAttrSet {
while (index < pattern.length()) {
char ch = pattern.charAt(index);
switch (ch) {
- case '{':
- index++;
- byte[] buff = encodePattern();
- tmp.putDerValue(new DerValue(buff));
- break;
- case '}':
- os.write(DerValue.tag_Sequence, tmp);
- return os.toByteArray();
- default:
- type = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch + "."
- + PROP_TYPE);
- if (type.equalsIgnoreCase("integer")) {
- int num = Integer.parseInt((String) mConfig
- .get(PROP_ATTRIBUTE + "." + ch + "." + PROP_VALUE));
- PutInteger(tmp, num);
- } else if (type.equalsIgnoreCase("ia5string")) {
- source = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_SOURCE);
- value = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_VALUE);
- if (source.equalsIgnoreCase("file"))
- PutIA5String(tmp, getFromFile(value));
- else
- PutIA5String(tmp, value);
- } else if (type.equalsIgnoreCase("octetstring")) {
- source = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_SOURCE);
- value = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_VALUE);
- // It should be colon seperated ASCII Hexdecimal String
- if (source.equalsIgnoreCase("file"))
- PutOctetString(tmp, getFromFile(value));
- else
- PutOctetString(tmp, value);
- } else if (type.equalsIgnoreCase("bmpstring")) {
- source = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_SOURCE);
- value = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_VALUE);
- if (source.equalsIgnoreCase("file"))
- PutBMPString(tmp, getFromFile(value));
- else
- PutBMPString(tmp, value);
- } else if (type.equalsIgnoreCase("printablestring")) {
- source = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_SOURCE);
- value = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_VALUE);
- if (source.equalsIgnoreCase("file"))
- PutPrintableString(tmp, getFromFile(value));
- else
- PutPrintableString(tmp, value);
- } else if (type.equalsIgnoreCase("visiblestring")) {
- source = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_SOURCE);
- value = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_VALUE);
- if (source.equalsIgnoreCase("file"))
- PutVisibleString(tmp, getFromFile(value));
- else
- PutVisibleString(tmp, value);
- } else if (type.equalsIgnoreCase("utctime")) {
- value = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_VALUE);
- PutUTCtime(tmp, value);
- } else if (type.equalsIgnoreCase("oid")) {
- value = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_VALUE);
- PutOID(tmp, value);
- } else if (type.equalsIgnoreCase("boolean")) {
- boolean bool = false;
- String b = (String) mConfig.get(PROP_ATTRIBUTE + "." + ch
- + "." + PROP_VALUE);
- if (b.equalsIgnoreCase("true"))
- bool = true;
- else
- bool = false;
- PutBoolean(tmp, bool);
- } else if (type.equalsIgnoreCase("null")) {
- tmp.putNull();
- } else {
- throw new ParseException("Unknown Attribute Type", 0);
- }
+ case '{' :
+ index++;
+ byte[] buff = encodePattern();
+ tmp.putDerValue(new DerValue(buff));
+ break;
+ case '}' :
+ os.write(DerValue.tag_Sequence, tmp);
+ return os.toByteArray();
+ default :
+ type = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_TYPE);
+ if (type.equalsIgnoreCase("integer")) {
+ int num = Integer.parseInt((String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_VALUE));
+ PutInteger(tmp, num);
+ }
+ else if (type.equalsIgnoreCase("ia5string")) {
+ source = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_SOURCE);
+ value = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_VALUE);
+ if (source.equalsIgnoreCase("file"))
+ PutIA5String(tmp, getFromFile(value));
+ else
+ PutIA5String(tmp, value);
+ }
+ else if (type.equalsIgnoreCase("octetstring")) {
+ source = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_SOURCE);
+ value = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_VALUE);
+ // It should be colon seperated ASCII Hexdecimal String
+ if (source.equalsIgnoreCase("file"))
+ PutOctetString(tmp, getFromFile(value));
+ else
+ PutOctetString(tmp, value);
+ }
+ else if (type.equalsIgnoreCase("bmpstring")) {
+ source = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_SOURCE);
+ value = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_VALUE);
+ if (source.equalsIgnoreCase("file"))
+ PutBMPString(tmp, getFromFile(value));
+ else
+ PutBMPString(tmp, value);
+ }
+ else if (type.equalsIgnoreCase("printablestring")) {
+ source = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_SOURCE);
+ value = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_VALUE);
+ if (source.equalsIgnoreCase("file"))
+ PutPrintableString(tmp, getFromFile(value));
+ else
+ PutPrintableString(tmp, value);
+ }
+ else if (type.equalsIgnoreCase("visiblestring")) {
+ source = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_SOURCE);
+ value = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_VALUE);
+ if (source.equalsIgnoreCase("file"))
+ PutVisibleString(tmp, getFromFile(value));
+ else
+ PutVisibleString(tmp, value);
+ }
+ else if (type.equalsIgnoreCase("utctime")) {
+ value = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_VALUE);
+ PutUTCtime(tmp, value);
+ }
+ else if (type.equalsIgnoreCase("oid")) {
+ value = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_VALUE);
+ PutOID(tmp, value);
+ }
+ else if (type.equalsIgnoreCase("boolean")) {
+ boolean bool = false;
+ String b = (String)mConfig.get(PROP_ATTRIBUTE+"."+ch+"."+PROP_VALUE);
+ if (b.equalsIgnoreCase("true"))
+ bool = true;
+ else
+ bool = false;
+ PutBoolean(tmp, bool);
+ }
+ else if (type.equalsIgnoreCase("null")) {
+ tmp.putNull();
+ }
+ else {
+ throw new ParseException("Unknown Attribute Type", 0);
+ }
}
index++;
- }
+ }
return tmp.toByteArray();
}
/**
- * Create a GenericASN1Extension with the value and oid. The criticality is
- * set to false.
- *
+ * Create a GenericASN1Extension with the value and oid.
+ * The criticality is set to false.
+ *
* @param the values to be set for the extension.
*/
- public GenericASN1Extension(String name, String oid, String pattern,
- boolean critical, Hashtable config) throws IOException,
- ParseException {
+ public GenericASN1Extension(String name, String oid, String pattern, boolean critical, Hashtable config)
+ throws IOException, ParseException
+ {
ObjectIdentifier tmpid = new ObjectIdentifier(oid);
NAME = name;
OID = oid;
mConfig = config;
this.pattern = pattern;
-
+
try {
if (OIDMap.getName(tmpid) == null)
- OIDMap.addAttribute(
- "netscape.security.x509.GenericASN1Extension", oid,
- name);
- } catch (CertificateException e) {
- }
+ OIDMap.addAttribute("netscape.security.x509.GenericASN1Extension", oid, name);
+ } catch (CertificateException e) {}
this.extensionId = tmpid;
this.critical = critical;
@@ -203,53 +211,53 @@ public class GenericASN1Extension extends Extension implements CertAttrSet {
}
/**
- * Create a GenericASN1Extension with the value and oid. The criticality is
- * set to false.
- *
+ * Create a GenericASN1Extension with the value and oid.
+ * The criticality is set to false.
+ *
* @param the values to be set for the extension.
*/
- public GenericASN1Extension(Hashtable config) throws IOException,
- ParseException {
+ public GenericASN1Extension(Hashtable config)
+ throws IOException, ParseException
+ {
mConfig = config;
- ObjectIdentifier tmpid = new ObjectIdentifier(
- (String) mConfig.get(PROP_OID));
- NAME = (String) mConfig.get(PROP_NAME);
- OID = (String) mConfig.get(PROP_OID);
- pattern = (String) mConfig.get(PROP_PATTERN);
-
+ ObjectIdentifier tmpid = new ObjectIdentifier((String)mConfig.get(PROP_OID));
+ NAME = (String)mConfig.get(PROP_NAME);
+ OID = (String)mConfig.get(PROP_OID);
+ pattern = (String)mConfig.get(PROP_PATTERN);
+
try {
if (OIDMap.getName(tmpid) == null)
OIDMap.addAttribute("GenericASN1Extension", OID, NAME);
- } catch (CertificateException e) {
- }
+ } catch (CertificateException e) {}
this.extensionId = tmpid;
this.critical = false;
- String b = (String) mConfig.get(PROP_CRITICAL);
- if (b.equalsIgnoreCase("true"))
- this.critical = true;
- else
- this.critical = false;
+ String b = (String)mConfig.get(PROP_CRITICAL);
+ if (b.equalsIgnoreCase("true"))
+ this.critical = true;
+ else
+ this.critical = false;
encodeThis();
}
/**
* Create the extension from the passed DER encoded value of the same.
- *
+ *
* @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 GenericASN1Extension(Boolean critical, Object value)
- throws IOException {
+ throws IOException
+ {
this.extensionId = new ObjectIdentifier(OID);
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;
}
@@ -283,7 +291,7 @@ public class GenericASN1Extension extends Extension implements CertAttrSet {
/**
* Decode the extension from the InputStream.
- *
+ *
* @param in the InputStream to unmarshal the contents from.
* @exception IOException on decoding or validity errors.
*/
@@ -293,12 +301,14 @@ public class GenericASN1Extension extends Extension implements CertAttrSet {
/**
* Write the extension to the DerOutputStream.
- *
+ *
* @param out the DerOutputStream to write the extension to.
* @exception IOException on encoding errors.
*/
- public void encode(OutputStream out) throws IOException {
- DerOutputStream tmp = new DerOutputStream();
+ public void encode(OutputStream out)
+ throws IOException
+ {
+ DerOutputStream tmp = new DerOutputStream();
try {
if (this.extensionValue == null) {
@@ -306,9 +316,9 @@ public class GenericASN1Extension extends Extension implements CertAttrSet {
this.critical = true;
encodeThis();
}
- } catch (ParseException e) {
}
-
+ catch (ParseException e) {}
+
super.encode(tmp);
out.write(tmp.toByteArray());
}
@@ -316,104 +326,100 @@ public class GenericASN1Extension extends Extension implements CertAttrSet {
/**
* Return the name of this attribute.
*/
- public String getName() {
+ public String getName () {
return (NAME);
}
-
/**
* Set the name of this attribute.
*/
- public void setName(String name) {
+ public void setName (String name) {
NAME = name;
}
-
/**
* Return the OID of this attribute.
*/
- public String getOID() {
+ public String getOID () {
return (OID);
}
-
/**
* Set the OID of this attribute.
*/
- public void setOID(String oid) {
+ public void setOID (String oid) {
OID = oid;
}
-
/**
* Return an enumeration of names of attributes existing within this
* attribute.
*/
- public Enumeration getElements() {
+ public Enumeration getElements () {
Vector<String> elements = new Vector<String>();
elements.addElement("octet");
- return (elements.elements());
+ return (elements.elements());
}
-
- private void PutInteger(DerOutputStream os, int number) throws IOException,
- ParseException {
+
+ private void PutInteger(DerOutputStream os, int number)
+ throws IOException, ParseException {
os.putInteger(new BigInt(number));
return;
}
-
- private void PutIA5String(DerOutputStream os, String value)
- throws IOException, ParseException {
+
+ private void PutIA5String(DerOutputStream os, String value)
+ throws IOException, ParseException {
os.putIA5String(value);
return;
}
- private void PutOctetString(DerOutputStream os, String value)
- throws IOException, ParseException {
+ private void PutOctetString(DerOutputStream os, String value)
+ throws IOException, ParseException {
StringTokenizer token = new StringTokenizer(value, ":");
byte[] octets = new byte[token.countTokens()];
for (int i = 0; token.hasMoreElements(); i++) {
- String num = (String) token.nextElement();
+ String num = (String)token.nextElement();
octets[i] = (byte) Integer.parseInt(num, 16);
}
-
+
os.putOctetString(octets);
return;
}
- private void PutBMPString(DerOutputStream os, String value)
- throws IOException, ParseException {
+ private void PutBMPString(DerOutputStream os, String value)
+ throws IOException, ParseException {
os.putBMPString(value);
return;
}
- private void PutPrintableString(DerOutputStream os, String value)
- throws IOException, ParseException {
+ private void PutPrintableString(DerOutputStream os, String value)
+ throws IOException, ParseException {
os.putPrintableString(value);
return;
}
- private void PutVisibleString(DerOutputStream os, String value)
- throws IOException, ParseException {
+ private void PutVisibleString(DerOutputStream os, String value)
+ throws IOException, ParseException {
os.putVisibleString(value);
return;
}
- private void PutUTCtime(DerOutputStream os, String value)
- throws IOException, ParseException {
+ private void PutUTCtime(DerOutputStream os, String value)
+ throws IOException, ParseException {
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
os.putUTCTime(df.parse(value));
return;
}
- private void PutOID(DerOutputStream os, String value) throws IOException,
- ParseException {
+ private void PutOID(DerOutputStream os, String value)
+ throws IOException, ParseException {
os.putOID(new ObjectIdentifier(value));
return;
}
private void PutBoolean(DerOutputStream os, boolean value)
- throws IOException, ParseException {
+ throws IOException, ParseException {
os.putBoolean(value);
return;
}
-
+
private String getFromFile(String fname) throws IOException {
String s = null;
byte[] buff = null;
@@ -421,34 +427,33 @@ public class GenericASN1Extension extends Extension implements CertAttrSet {
int j = 0;
if ((fname == null) || (fname.equals(""))) {
throw new IOException("File name is not provided.");
- }
-
+ }
+
FileInputStream fis = new FileInputStream(fname);
int n = 0;
while ((n = fis.available()) > 0) {
buff = new byte[n];
int result = fis.read(buff);
- if (result == -1)
- break;
+ if (result == -1) break;
s = new String(buff);
}
-
+
for (i = 0, j = 0; j < s.length(); j++) {
- int ch = (int) s.charAt(j);
+ int ch = (int)s.charAt(j);
if (ch == 10 || ch == 13 || ch == 9)
continue;
i++;
- }
+ }
buff = new byte[i];
for (i = 0, j = 0; j < s.length(); j++) {
- int ch = (int) s.charAt(j);
+ int ch = (int)s.charAt(j);
if (ch == 10 || ch == 13 || ch == 9)
continue;
- buff[i++] = (byte) ch;
- }
-
+ buff[i++] = (byte)ch;
+ }
+
s = new String(buff);
-
- return s;
- }
+
+ return s;
+ }
}
diff --git a/pki/base/util/src/netscape/security/extensions/InhibitAnyPolicyExtension.java b/pki/base/util/src/netscape/security/extensions/InhibitAnyPolicyExtension.java
index 23592e1e..626d126b 100644
--- a/pki/base/util/src/netscape/security/extensions/InhibitAnyPolicyExtension.java
+++ b/pki/base/util/src/netscape/security/extensions/InhibitAnyPolicyExtension.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package netscape.security.extensions;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -33,15 +34,17 @@ import netscape.security.x509.Extension;
import netscape.security.x509.OIDMap;
/**
- * RFC3280:
- *
- * id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 }
+ * RFC3280:
+ *
+ * id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 }
*
- * InhibitAnyPolicy ::= SkipCerts
+ * InhibitAnyPolicy ::= SkipCerts
*
- * SkipCerts ::= INTEGER (0..MAX)
+ * SkipCerts ::= INTEGER (0..MAX)
*/
-public class InhibitAnyPolicyExtension extends Extension implements CertAttrSet {
+public class InhibitAnyPolicyExtension
+ extends Extension implements CertAttrSet
+{
/**
*
@@ -54,8 +57,8 @@ public class InhibitAnyPolicyExtension extends Extension implements CertAttrSet
static {
try {
- OIDMap.addAttribute(InhibitAnyPolicyExtension.class.getName(), OID,
- NAME);
+ OIDMap.addAttribute(InhibitAnyPolicyExtension.class.getName(),
+ OID, NAME);
} catch (CertificateException e) {
}
}
@@ -67,23 +70,23 @@ public class InhibitAnyPolicyExtension extends Extension implements CertAttrSet
public InhibitAnyPolicyExtension(boolean crit, BigInt skipCerts) {
try {
extensionId = ObjectIdentifier.getObjectIdentifier(OID);
- } catch (IOException e) {
+ } catch (IOException e) {
// never here
}
critical = crit;
- mSkipCerts = skipCerts;
+ mSkipCerts = skipCerts;
encodeExtValue();
}
- public InhibitAnyPolicyExtension(Boolean crit, Object value)
- throws IOException {
+ public InhibitAnyPolicyExtension(Boolean crit, Object value)
+ throws IOException {
extensionId = ObjectIdentifier.getObjectIdentifier(OID);
critical = crit.booleanValue();
- // extensionValue = (byte[]) ((byte[]) byteVal).clone();
+ //extensionValue = (byte[]) ((byte[]) byteVal).clone();
int len = Array.getLength(value);
byte[] extValue = new byte[len];
for (int i = 0; i < len; i++) {
- extValue[i] = Array.getByte(value, i);
+ extValue[i] = Array.getByte(value, i);
}
extensionValue = extValue;
@@ -95,7 +98,7 @@ public class InhibitAnyPolicyExtension extends Extension implements CertAttrSet
critical = newValue;
}
}
-
+
public BigInt getSkipCerts() {
return mSkipCerts;
}
@@ -111,16 +114,17 @@ public class InhibitAnyPolicyExtension extends Extension implements CertAttrSet
if (extensionValue != null) {
String extByteValue = new String(" skipCerts=" + mSkipCerts);
- presentation += extByteValue;
+ presentation += extByteValue;
}
return presentation;
}
- public void decode(InputStream in) throws CertificateException, IOException {
+ public void decode(InputStream in)
+ throws CertificateException, IOException {
}
- public void set(String name, Object obj) throws CertificateException,
- IOException {
+ public void set(String name, Object obj)
+ throws CertificateException, IOException {
// NOT USED
}
@@ -134,10 +138,11 @@ public class InhibitAnyPolicyExtension extends Extension implements CertAttrSet
}
public String getName() {
- return NAME;
+ return NAME;
}
- public void delete(String name) throws CertificateException, IOException {
+ public void delete(String name)
+ throws CertificateException, IOException {
// NOT USED
}
@@ -148,27 +153,27 @@ public class InhibitAnyPolicyExtension extends Extension implements CertAttrSet
}
public void encode(OutputStream out) throws IOException {
- DerOutputStream tmp = new DerOutputStream();
+ DerOutputStream tmp = new DerOutputStream();
- if (this.extensionValue == null) {
+ if (this.extensionValue == null) {
try {
extensionId = ObjectIdentifier.getObjectIdentifier(OID);
- } catch (IOException e) {
+ } catch (IOException e) {
// never here
}
DerOutputStream os = new DerOutputStream();
os.putInteger(mSkipCerts);
this.extensionValue = os.toByteArray();
- }
+ }
- super.encode(tmp);
- out.write(tmp.toByteArray());
+ super.encode(tmp);
+ out.write(tmp.toByteArray());
}
private void encodeExtValue() {
DerOutputStream out = new DerOutputStream();
try {
- out.putInteger(mSkipCerts);
+ out.putInteger(mSkipCerts);
} catch (IOException e) {
}
extensionValue = out.toByteArray();
diff --git a/pki/base/util/src/netscape/security/extensions/KerberosName.java b/pki/base/util/src/netscape/security/extensions/KerberosName.java
index 2b8b85a0..c60ceb0d 100644
--- a/pki/base/util/src/netscape/security/extensions/KerberosName.java
+++ b/pki/base/util/src/netscape/security/extensions/KerberosName.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package netscape.security.extensions;
+
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -29,23 +30,28 @@ import netscape.security.util.DerValue;
import netscape.security.util.ObjectIdentifier;
/**
- * This represents a KerberosName as defined in RFC 1510.
- *
- * KerberosName ::= SEQUENCE { realm [0] Realm, principalName [1]
- * CertPrincipalName -- defined above }
- *
- * CertPrincipalName ::= SEQUENCE { name-type[0] INTEGER, name-string[1]
- * SEQUENCE OF UTF8String }
- *
+ * This represents a KerberosName as defined in
+ * RFC 1510.
+ *
+ * KerberosName ::= SEQUENCE {
+ * realm [0] Realm,
+ * principalName [1] CertPrincipalName -- defined above
+ * }
+ *
+ * CertPrincipalName ::= SEQUENCE {
+ * name-type[0] INTEGER,
+ * name-string[1] SEQUENCE OF UTF8String
+ * }
+ *
* @author thomask
* @version $Revision$, $Date$
*/
public class KerberosName {
public static final int OID[] = { 1, 3, 6, 1, 5, 2, 2 };
- public static final ObjectIdentifier KRB5_PRINCIPAL_NAME = new ObjectIdentifier(
- OID);
-
+ public static final ObjectIdentifier KRB5_PRINCIPAL_NAME = new
+ ObjectIdentifier(OID);
+
private String m_realm = null;
private int m_name_type = 0;
private Vector m_name_strings = null;
@@ -58,7 +64,7 @@ public class KerberosName {
/**
* Write the extension to the DerOutputStream.
- *
+ *
* @param out the DerOutputStream to write the extension to.
* @exception IOException on encoding errors.
*/
@@ -68,50 +74,49 @@ public class KerberosName {
DerOutputStream tmp = new DerOutputStream();
DerOutputStream realm = new DerOutputStream();
realm.putGeneralString(m_realm);
- tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0),
- realm);
+ tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT,
+ true, (byte)0), realm);
DerOutputStream seq1 = new DerOutputStream();
DerOutputStream tmp1 = new DerOutputStream();
DerOutputStream name_type = new DerOutputStream();
name_type.putInteger(new BigInt(m_name_type));
- tmp1.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0),
- name_type);
+ tmp1.write(DerValue.createTag(DerValue.TAG_CONTEXT,
+ true, (byte)0), name_type);
DerOutputStream name_strings = new DerOutputStream();
DerOutputStream name_string = new DerOutputStream();
for (int i = 0; i < m_name_strings.size(); i++) {
- name_string.putGeneralString((String) m_name_strings.elementAt(i));
+ name_string.putGeneralString((String)m_name_strings.elementAt(i));
}
name_strings.write(DerValue.tag_SequenceOf, name_string);
- tmp1.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 1),
- name_strings);
+ tmp1.write(DerValue.createTag(DerValue.TAG_CONTEXT,
+ true, (byte)1), name_strings);
seq1.write(DerValue.tag_Sequence, tmp1);
- tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 1),
- seq1);
+ tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT,
+ true, (byte)1), seq1);
seq.write(DerValue.tag_Sequence, tmp);
out.write(seq.toByteArray());
}
public byte[] toByteArray() throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- encode(bos);
- return bos.toByteArray();
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ encode(bos);
+ return bos.toByteArray();
}
public String toString() {
- String strings = null;
- for (int i = 0; i < m_name_strings.size(); i++) {
- if (strings == null) {
- strings = (String) m_name_strings.elementAt(i);
- } else {
- strings += ",";
- strings += (String) m_name_strings.elementAt(i);
- }
- }
- return "Realm: " + m_realm + " Name Type: " + m_name_type
- + " Name String(s):" + strings;
+ String strings = null;
+ for (int i = 0; i < m_name_strings.size(); i++) {
+ if (strings == null) {
+ strings = (String)m_name_strings.elementAt(i);
+ } else {
+ strings += ",";
+ strings += (String)m_name_strings.elementAt(i);
+ }
+ }
+ return "Realm: " + m_realm + " Name Type: " + m_name_type + " Name String(s):" + strings;
}
public static void main(String[] argv) {
@@ -121,11 +126,11 @@ public class KerberosName {
System.out.println(k.toString());
try {
- FileOutputStream os = new FileOutputStream("/tmp/out.der");
- k.encode(os);
- os.close();
+ FileOutputStream os = new FileOutputStream("/tmp/out.der");
+ k.encode(os);
+ os.close();
} catch (Exception e) {
- System.out.println(e.toString());
+ System.out.println(e.toString());
}
}
}
diff --git a/pki/base/util/src/netscape/security/extensions/NSCertTypeExtension.java b/pki/base/util/src/netscape/security/extensions/NSCertTypeExtension.java
index 0d337f50..e470d4dc 100644
--- a/pki/base/util/src/netscape/security/extensions/NSCertTypeExtension.java
+++ b/pki/base/util/src/netscape/security/extensions/NSCertTypeExtension.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package netscape.security.extensions;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -31,13 +32,14 @@ import netscape.security.x509.CertAttrSet;
import netscape.security.x509.Extension;
/**
- * NSCertTypeExtension Represents Netscape Certificate Type Extension
- *
- * <p>
- * This deprecated extension, if present, defines both the purpose (e.g.,
- * encipherment, signature, certificate signing) and the application (e.g., SSL,
- * S/Mime or Object Signing of the key contained in the certificate.
- *
+ * NSCertTypeExtension
+ * Represents Netscape Certificate Type Extension
+ *
+ * <p>This deprecated extension, if present, defines both the purpose
+ * (e.g., encipherment, signature, certificate signing) and the application
+ * (e.g., SSL, S/Mime or Object Signing of the key contained in the
+ * certificate.
+ *
* @author galperin
* @version $Revision$, $Date$
*/
@@ -54,38 +56,38 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
/**
* Identifies the particular public key used to sign the certificate.
*/
- public static final ObjectIdentifier CertType_Id = new ObjectIdentifier(
- CertType_data);
-
- /**
- * Attribute names.
- */
- public static final String NAME = "NSCertType";
- public static final String SSL_CLIENT = "ssl_client";
- public static final String SSL_SERVER = "ssl_server";
- public static final String EMAIL = "email";
- public static final String OBJECT_SIGNING = "object_signing";
- public static final String SSL_CA = "ssl_ca";
- public static final String EMAIL_CA = "email_ca";
- public static final String OBJECT_SIGNING_CA = "object_signing_ca";
-
- /**
- * Attribute names.
- */
- public static final int SSL_CLIENT_BIT = 0;
- public static final int SSL_SERVER_BIT = 1;
- public static final int EMAIL_BIT = 2;
- public static final int OBJECT_SIGNING_BIT = 3;
- // 4 is reserved.
- public static final int SSL_CA_BIT = 5;
- public static final int EMAIL_CA_BIT = 6;
- public static final int OBJECT_SIGNING_CA_BIT = 7;
-
- public static final int NBITS = 8;
+ public static final ObjectIdentifier CertType_Id = new
+ ObjectIdentifier(CertType_data);
+
+ /**
+ * Attribute names.
+ */
+ public static final String NAME = "NSCertType";
+ public static final String SSL_CLIENT = "ssl_client";
+ public static final String SSL_SERVER = "ssl_server";
+ public static final String EMAIL = "email";
+ public static final String OBJECT_SIGNING = "object_signing";
+ public static final String SSL_CA = "ssl_ca";
+ public static final String EMAIL_CA = "email_ca";
+ public static final String OBJECT_SIGNING_CA = "object_signing_ca";
+
+ /**
+ * Attribute names.
+ */
+ public static final int SSL_CLIENT_BIT = 0;
+ public static final int SSL_SERVER_BIT = 1;
+ public static final int EMAIL_BIT = 2;
+ public static final int OBJECT_SIGNING_BIT = 3;
+ // 4 is reserved.
+ public static final int SSL_CA_BIT = 5;
+ public static final int EMAIL_CA_BIT = 6;
+ public static final int OBJECT_SIGNING_CA_BIT = 7;
+
+ public static final int NBITS = 8;
/**
- * 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.NSCertType";
@@ -102,12 +104,17 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
}
}
- private static MapEntry[] mMapData = { new MapEntry(SSL_CLIENT, 0),
- new MapEntry(SSL_SERVER, 1), new MapEntry(EMAIL, 2),
+ private static MapEntry[] mMapData =
+ {
+ new MapEntry(SSL_CLIENT, 0),
+ new MapEntry(SSL_SERVER, 1),
+ new MapEntry(EMAIL, 2),
new MapEntry(OBJECT_SIGNING, 3),
// note that bit 4 is reserved
- new MapEntry(SSL_CA, 5), new MapEntry(EMAIL_CA, 6),
- new MapEntry(OBJECT_SIGNING_CA, 7), };
+ new MapEntry(SSL_CA, 5),
+ new MapEntry(EMAIL_CA, 6),
+ new MapEntry(OBJECT_SIGNING_CA, 7),
+ };
private static Vector mAttributeNames = new Vector();
@@ -123,7 +130,8 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
return mMapData[i].mPosition;
}
throw new CertificateException("Attribute name [" + name
- + "] not recognized by" + " CertAttrSet:NSCertType.");
+ + "] not recognized by"
+ + " CertAttrSet:NSCertType.");
}
// Encode this extension value
@@ -136,7 +144,7 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
/**
* Check if bit is set.
- *
+ *
* @param position the position in the bit string to check.
*/
public boolean isSet(int position) {
@@ -169,8 +177,8 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
}
/**
- * Create NSCertTypeExtension from boolean array. The criticality is set to
- * false.
+ * Create NSCertTypeExtension from boolean array.
+ * The criticality is set to false.
*/
public NSCertTypeExtension(boolean critical, boolean[] bits) {
this.extensionId = CertType_Id;
@@ -193,13 +201,12 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
}
/**
- * Create a NSCertTypeExtension with the passed bit settings. The
- * criticality is set to false.
- *
+ * Create a NSCertTypeExtension with the passed bit settings.
+ * The criticality is set to false.
+ *
* @param bitString the bits to be set for the extension.
*/
- public NSCertTypeExtension(boolean critical, byte[] bitString)
- throws IOException {
+ public NSCertTypeExtension(boolean critical, byte[] bitString) throws IOException {
this.mBitString = bitString;
this.extensionId = CertType_Id;
this.critical = critical;
@@ -215,17 +222,19 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
/**
* Create the extension from the passed DER encoded value of the same.
- *
+ *
* @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 NSCertTypeExtension(Boolean critical, Object value)
- throws IOException {
+ throws IOException {
/**
- * Debug.trace("NSCertTypeExtension"); this.mBitString = new byte[1];
- * this.mBitString[0] = (byte)0x00; return;
+ Debug.trace("NSCertTypeExtension");
+ this.mBitString = new byte[1];
+ this.mBitString[0] = (byte)0x00;
+ return;
**/
this.extensionId = CertType_Id;
@@ -245,10 +254,10 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
this.extensionId = CertType_Id;
this.critical = false;
this.mBitString = new byte[0];
- try {
- encodeThis();
- } catch (Exception e) {
- }
+ try {
+ encodeThis();
+ } catch (Exception e) {
+ }
}
/**
@@ -256,7 +265,8 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
*/
public void set(String name, Object obj) throws CertificateException {
if (!(obj instanceof Boolean)) {
- throw new CertificateException("Attribute must be of type Boolean.");
+ throw new CertificateException
+ ("Attribute must be of type Boolean.");
}
boolean val = ((Boolean) obj).booleanValue();
@@ -324,7 +334,7 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
/**
* Decode the extension from the InputStream.
- *
+ *
* @param in the InputStream to unmarshal the contents from.
* @exception IOException on decoding or validity errors.
*/
@@ -334,12 +344,12 @@ public class NSCertTypeExtension extends Extension implements CertAttrSet {
/**
* Write the extension to the DerOutputStream.
- *
+ *
* @param out the DerOutputStream to write the extension to.
* @exception IOException on encoding errors.
*/
public void encode(OutputStream out) throws IOException {
- DerOutputStream tmp = new DerOutputStream();
+ DerOutputStream tmp = new DerOutputStream();
encodeThis();
if (this.extensionValue == null) {
diff --git a/pki/base/util/src/netscape/security/extensions/OCSPNoCheckExtension.java b/pki/base/util/src/netscape/security/extensions/OCSPNoCheckExtension.java
index ceb7819d..68d0e8a3 100644
--- a/pki/base/util/src/netscape/security/extensions/OCSPNoCheckExtension.java
+++ b/pki/base/util/src/netscape/security/extensions/OCSPNoCheckExtension.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package netscape.security.extensions;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -29,6 +30,7 @@ import netscape.security.x509.CertAttrSet;
import netscape.security.x509.Extension;
import netscape.security.x509.OIDMap;
+
/**
* This represents the OCSPNoCheck extension.
*/
@@ -45,7 +47,8 @@ public class OCSPNoCheckExtension extends Extension implements CertAttrSet {
static {
try {
- OIDMap.addAttribute(OCSPNoCheckExtension.class.getName(), OID, NAME);
+ OIDMap.addAttribute(OCSPNoCheckExtension.class.getName(),
+ OID, NAME);
} catch (CertificateException e) {
}
}
@@ -56,8 +59,7 @@ public class OCSPNoCheckExtension extends Extension implements CertAttrSet {
public OCSPNoCheckExtension(Boolean crit) {
try {
- extensionId = ObjectIdentifier
- .getObjectIdentifier(OCSPNoCheckExtension.OID);
+ extensionId = ObjectIdentifier.getObjectIdentifier(OCSPNoCheckExtension.OID);
} catch (IOException e) {
// never here
}
@@ -73,15 +75,14 @@ public class OCSPNoCheckExtension extends Extension implements CertAttrSet {
public OCSPNoCheckExtension(Boolean crit, Object byteVal) {
try {
- extensionId = ObjectIdentifier
- .getObjectIdentifier(OCSPNoCheckExtension.OID);
+ extensionId = ObjectIdentifier.getObjectIdentifier(OCSPNoCheckExtension.OID);
} catch (IOException e) {
// never here
}
critical = crit.booleanValue();
extensionValue = (byte[]) ((byte[]) byteVal).clone();
}
-
+
public void setCritical(boolean newValue) {
if (critical != newValue) {
critical = newValue;
@@ -95,14 +96,14 @@ public class OCSPNoCheckExtension extends Extension implements CertAttrSet {
mCached = out.toByteArray();
}
}
-
+
private void encodeThis(DerOutputStream out) throws IOException {
if (mCached == null) {
super.encode(out);
mCached = out.toByteArray();
}
}
-
+
public String toString() {
String presentation = "oid=" + OID + " ";
@@ -115,17 +116,18 @@ public class OCSPNoCheckExtension extends Extension implements CertAttrSet {
for (int i = 0; i < extensionValue.length; i++) {
extByteValue += (extensionValue[i] + " ");
}
- presentation += extByteValue;
+ presentation += extByteValue;
}
return presentation;
}
- public void decode(InputStream in) throws CertificateException, IOException {
+ public void decode(InputStream in)
+ throws CertificateException, IOException {
// NOT USED
}
- public void encode(OutputStream out) throws CertificateException,
- IOException {
+ public void encode(OutputStream out)
+ throws CertificateException, IOException {
if (mCached == null) {
DerOutputStream temp = new DerOutputStream();
@@ -134,8 +136,8 @@ public class OCSPNoCheckExtension extends Extension implements CertAttrSet {
out.write(mCached);
}
- public void set(String name, Object obj) throws CertificateException,
- IOException {
+ public void set(String name, Object obj)
+ throws CertificateException, IOException {
// NOT USED
}
@@ -150,10 +152,11 @@ public class OCSPNoCheckExtension extends Extension implements CertAttrSet {
}
public String getName() {
- return NAME;
+ return NAME;
}
- public void delete(String name) throws CertificateException, IOException {
+ public void delete(String name)
+ throws CertificateException, IOException {
// NOT USED
}
}
diff --git a/pki/base/util/src/netscape/security/extensions/PresenceServerExtension.java b/pki/base/util/src/netscape/security/extensions/PresenceServerExtension.java
index 52b0cbd1..084e1d69 100644
--- a/pki/base/util/src/netscape/security/extensions/PresenceServerExtension.java
+++ b/pki/base/util/src/netscape/security/extensions/PresenceServerExtension.java
@@ -33,7 +33,8 @@ import netscape.security.util.ObjectIdentifier;
import netscape.security.x509.CertAttrSet;
import netscape.security.x509.Extension;
-public class PresenceServerExtension extends Extension implements CertAttrSet {
+public class PresenceServerExtension extends Extension implements CertAttrSet
+{
/**
*
*/
@@ -52,150 +53,173 @@ public class PresenceServerExtension extends Extension implements CertAttrSet {
public static final String OID = "2.16.840.1.113730.1.18";
- /*
- * public PresenceServerExtension() { }
- */
-
- public PresenceServerExtension(Boolean critical, Object value)
- throws IOException {
- this.extensionId = new ObjectIdentifier(OID);
- this.critical = critical.booleanValue();
- this.extensionValue = (byte[]) ((byte[]) value).clone();
- decodeThis();
- }
-
- public PresenceServerExtension(boolean critical, int version,
- String streetAddress, String telephoneNumber, String rfc822Name,
- String ID, String hostName, int portNumber, int maxUsers,
- int serviceLevel) throws IOException {
- mCritical = critical;
- mVersion = version;
- mStreetAddress = streetAddress;
- mTelephoneNumber = telephoneNumber;
- mRFC822Name = rfc822Name;
- mID = ID;
- mHostName = hostName;
- mPortNumber = portNumber;
- mMaxUsers = maxUsers;
- mServiceLevel = serviceLevel;
-
- this.extensionId = new ObjectIdentifier(OID);
- this.critical = mCritical;
- encodeThis();
- }
-
- public int getVersion() {
- return mVersion;
- }
-
- public String getStreetAddress() {
- return mStreetAddress;
+/*
+ public PresenceServerExtension()
+ {
}
+*/
- public String getTelephoneNumber() {
- return mTelephoneNumber;
- }
-
- public String getRFC822() {
- return mRFC822Name;
- }
-
- public String getID() {
- return mID;
- }
-
- public String getHostName() {
- return mHostName;
- }
-
- public int getPortNumber() {
- return mPortNumber;
- }
-
- public int getMaxUsers() {
- return mMaxUsers;
- }
-
- public int getServiceLevel() {
- return mServiceLevel;
+ public PresenceServerExtension(Boolean critical, Object value)
+ throws IOException {
+ this.extensionId = new ObjectIdentifier(OID);
+ this.critical = critical.booleanValue();
+ this.extensionValue = (byte[]) ((byte[]) value).clone();
+ decodeThis();
+ }
+
+ public PresenceServerExtension(
+ boolean critical,
+ int version,
+ String streetAddress,
+ String telephoneNumber,
+ String rfc822Name,
+ String ID,
+ String hostName,
+ int portNumber,
+ int maxUsers,
+ int serviceLevel)
+ throws IOException
+ {
+ mCritical = critical;
+ mVersion = version;
+ mStreetAddress = streetAddress;
+ mTelephoneNumber = telephoneNumber;
+ mRFC822Name = rfc822Name;
+ mID = ID;
+ mHostName = hostName;
+ mPortNumber = portNumber;
+ mMaxUsers = maxUsers;
+ mServiceLevel = serviceLevel;
+
+ this.extensionId = new ObjectIdentifier(OID);
+ this.critical = mCritical;
+ encodeThis();
}
- public void encodeThis() throws IOException {
- DerOutputStream out = new DerOutputStream();
- DerOutputStream temp = new DerOutputStream();
- temp.putInteger(new BigInt(mVersion));
- temp.putOctetString(mStreetAddress.getBytes());
- temp.putOctetString(mTelephoneNumber.getBytes());
- temp.putOctetString(mRFC822Name.getBytes());
- temp.putOctetString(mID.getBytes());
- temp.putOctetString(mHostName.getBytes());
- temp.putInteger(new BigInt(mPortNumber));
- temp.putInteger(new BigInt(mMaxUsers));
- temp.putInteger(new BigInt(mServiceLevel));
- out.write(DerValue.tag_Sequence, temp);
- this.extensionValue = out.toByteArray();
+ public int getVersion()
+ {
+ return mVersion;
+ }
+
+ public String getStreetAddress()
+ {
+ return mStreetAddress;
+ }
+
+ public String getTelephoneNumber()
+ {
+ return mTelephoneNumber;
+ }
+
+ public String getRFC822()
+ {
+ return mRFC822Name;
+ }
+
+ public String getID()
+ {
+ return mID;
+ }
+
+ public String getHostName()
+ {
+ return mHostName;
+ }
+
+ public int getPortNumber()
+ {
+ return mPortNumber;
+ }
+
+ public int getMaxUsers()
+ {
+ return mMaxUsers;
+ }
+
+ public int getServiceLevel()
+ {
+ return mServiceLevel;
+ }
+
+ public void encodeThis() throws IOException
+ {
+ DerOutputStream out = new DerOutputStream();
+ DerOutputStream temp = new DerOutputStream();
+ temp.putInteger(new BigInt(mVersion));
+ temp.putOctetString(mStreetAddress.getBytes());
+ temp.putOctetString(mTelephoneNumber.getBytes());
+ temp.putOctetString(mRFC822Name.getBytes());
+ temp.putOctetString(mID.getBytes());
+ temp.putOctetString(mHostName.getBytes());
+ temp.putInteger(new BigInt(mPortNumber));
+ temp.putInteger(new BigInt(mMaxUsers));
+ temp.putInteger(new BigInt(mServiceLevel));
+ out.write(DerValue.tag_Sequence, temp);
+ this.extensionValue = out.toByteArray();
}
- public void decodeThis() throws IOException {
- DerInputStream val = new DerInputStream(this.extensionValue);
- byte data[] = null;
- DerValue seq[] = val.getSequence(0);
+ public void decodeThis() throws IOException
+ {
+ DerInputStream val = new DerInputStream(this.extensionValue);
+ byte data[] = null;
+ DerValue seq[] = val.getSequence(0);
mVersion = seq[0].getInteger().toInt();
- data = null;
- if (seq[1].length() > 0) {
- data = seq[1].getOctetString();
- }
- if (data == null) {
- mStreetAddress = "";
- } else {
- mStreetAddress = new String(data);
- }
- data = null;
- if (seq[2].length() > 0)
- data = seq[2].getOctetString();
- if (data == null) {
- mTelephoneNumber = "";
- } else {
- mTelephoneNumber = new String(data);
- }
- data = null;
- if (seq[3].length() > 0)
- data = seq[3].getOctetString();
- if (data == null) {
- mRFC822Name = "";
- } else {
- mRFC822Name = new String(data);
- }
- data = null;
- if (seq[4].length() > 0)
- data = seq[4].getOctetString();
- if (data == null) {
- mID = "";
- } else {
- mID = new String(data);
- }
- data = null;
- if (seq[5].length() > 0)
- data = seq[5].getOctetString();
- if (data == null) {
- mHostName = "";
- } else {
- mHostName = new String(data);
- }
+ data = null;
+ if (seq[1].length() > 0) {
+ data = seq[1].getOctetString();
+ }
+ if (data == null) {
+ mStreetAddress = "";
+ } else {
+ mStreetAddress = new String(data);
+ }
+ data = null;
+ if (seq[2].length() > 0)
+ data = seq[2].getOctetString();
+ if (data == null) {
+ mTelephoneNumber = "";
+ } else {
+ mTelephoneNumber = new String(data);
+ }
+ data = null;
+ if (seq[3].length() > 0)
+ data = seq[3].getOctetString();
+ if (data == null) {
+ mRFC822Name = "";
+ } else {
+ mRFC822Name = new String(data);
+ }
+ data = null;
+ if (seq[4].length() > 0)
+ data = seq[4].getOctetString();
+ if (data == null) {
+ mID = "";
+ } else {
+ mID = new String(data);
+ }
+ data = null;
+ if (seq[5].length() > 0)
+ data = seq[5].getOctetString();
+ if (data == null) {
+ mHostName = "";
+ } else {
+ mHostName = new String(data);
+ }
mPortNumber = seq[6].getInteger().toInt();
mMaxUsers = seq[7].getInteger().toInt();
mServiceLevel = seq[8].getInteger().toInt();
}
- public void decode(InputStream in) throws CertificateException, IOException {
+ public void decode(InputStream in)
+ throws CertificateException, IOException {
}
- public void encode(OutputStream out) throws CertificateException,
- IOException {
- DerOutputStream dos = new DerOutputStream();
- super.encode(dos);
- out.write(dos.toByteArray());
+ public void encode(OutputStream out)
+ throws CertificateException, IOException {
+ DerOutputStream dos = new DerOutputStream();
+ super.encode(dos);
+ out.write(dos.toByteArray());
}
/**
@@ -219,74 +243,91 @@ public class PresenceServerExtension extends Extension implements CertAttrSet {
throw new IOException("Method not to be called directly.");
}
- public Enumeration getElements() {
- return null;
+ public Enumeration getElements () {
+ return null;
}
/**
* Return the name of this attribute.
*/
- public String getName() {
- return "PresenceServerExtension";
+ public String getName () {
+ return "PresenceServerExtension";
}
/**
* Set the name of this attribute.
*/
- public void setName(String name) {
+ public void setName (String name) {
}
/**
* Return the OID of this attribute.
*/
- public String getOID() {
- return OID;
+ public String getOID () {
+ return OID;
}
/**
* Set the OID of this attribute.
*/
- public void setOID(String oid) {
+ public void setOID (String oid) {
}
- public static void main(String args[]) throws Exception {
- /*
- * 0 30 115: SEQUENCE { 2 06 9: OBJECT IDENTIFIER '2 16 840 1 113730 1
- * 100' 13 04 102: OCTET STRING, encapsulates { 15 30 100: SEQUENCE { 17
- * 02 1: INTEGER 0 20 04 31: OCTET STRING : 34 30 31 45 20 4D 69 64 64
- * 6C 65 66 69 65 6C 64 : 20 52 64 2E 2C 4D 56 2C 43 41 39 34 30 34 31
- * 53 04 12: OCTET STRING : 36 35 30 2D 31 31 31 2D 31 31 31 31 67 04
- * 18: OCTET STRING : 61 64 6D 69 6E 40 6E 65 74 73 63 61 70 65 2E 63 :
- * 6F 6D 87 04 10: OCTET STRING : 70 73 2D 63 61 70 69 74 6F 6C 99 04 7:
- * OCTET STRING : 63 61 70 69 74 6F 6C 108 02 1: INTEGER 80 111 02 1:
- * INTEGER 10 114 02 1: INTEGER 1 : } : } : }
- */
- boolean critical = false;
- int version = 1;
- String streetAddress = "401E Middlefield Rd.,MV,CA94041";
- String telephoneNumber = "650-111-1111";
- String rfc822Name = "admin@netscape.com";
- String ID = "ps-capitol";
- String hostName = "capitol";
- int portNumber = 80;
- int maxUsers = 10;
- int serviceLevel = 1;
-
- PresenceServerExtension ext = new PresenceServerExtension(critical,
- version, streetAddress, telephoneNumber, rfc822Name, ID,
- hostName, portNumber, maxUsers, serviceLevel);
-
- // encode
-
- ByteArrayOutputStream dos = new ByteArrayOutputStream();
- ext.encode(dos);
- FileOutputStream fos = new FileOutputStream("pse.der");
- fos.write(dos.toByteArray());
- fos.close();
-
- Extension ext1 = new Extension(new DerValue(dos.toByteArray()));
- PresenceServerExtension ext2 = new PresenceServerExtension(new Boolean(
- false), ext1.getExtensionValue());
+ public static void main(String args[]) throws Exception
+ {
+/*
+ 0 30 115: SEQUENCE {
+ 2 06 9: OBJECT IDENTIFIER '2 16 840 1 113730 1 100'
+ 13 04 102: OCTET STRING, encapsulates {
+ 15 30 100: SEQUENCE {
+ 17 02 1: INTEGER 0
+ 20 04 31: OCTET STRING
+ : 34 30 31 45 20 4D 69 64 64 6C 65 66 69 65 6C 64
+ : 20 52 64 2E 2C 4D 56 2C 43 41 39 34 30 34 31
+ 53 04 12: OCTET STRING
+ : 36 35 30 2D 31 31 31 2D 31 31 31 31
+ 67 04 18: OCTET STRING
+ : 61 64 6D 69 6E 40 6E 65 74 73 63 61 70 65 2E 63
+ : 6F 6D
+ 87 04 10: OCTET STRING
+ : 70 73 2D 63 61 70 69 74 6F 6C
+ 99 04 7: OCTET STRING
+ : 63 61 70 69 74 6F 6C
+ 108 02 1: INTEGER 80
+ 111 02 1: INTEGER 10
+ 114 02 1: INTEGER 1
+ : }
+ : }
+ : }
+ */
+ boolean critical = false;
+ int version = 1;
+ String streetAddress = "401E Middlefield Rd.,MV,CA94041";
+ String telephoneNumber = "650-111-1111";
+ String rfc822Name = "admin@netscape.com";
+ String ID = "ps-capitol";
+ String hostName = "capitol";
+ int portNumber = 80;
+ int maxUsers = 10;
+ int serviceLevel = 1;
+
+ PresenceServerExtension ext = new PresenceServerExtension(
+ critical,
+ version, streetAddress, telephoneNumber,
+ rfc822Name, ID, hostName, portNumber,
+ maxUsers, serviceLevel);
+
+ // encode
+
+ ByteArrayOutputStream dos = new ByteArrayOutputStream();
+ ext.encode(dos);
+ FileOutputStream fos = new FileOutputStream("pse.der");
+ fos.write(dos.toByteArray());
+ fos.close();
+
+ Extension ext1 = new Extension(new DerValue(dos.toByteArray()));
+ PresenceServerExtension ext2 = new PresenceServerExtension(
+ new Boolean(false), ext1.getExtensionValue());
}
}
diff --git a/pki/base/util/src/netscape/security/extensions/SubjectInfoAccessExtension.java b/pki/base/util/src/netscape/security/extensions/SubjectInfoAccessExtension.java
index 25eb254a..26d048dc 100644
--- a/pki/base/util/src/netscape/security/extensions/SubjectInfoAccessExtension.java
+++ b/pki/base/util/src/netscape/security/extensions/SubjectInfoAccessExtension.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package netscape.security.extensions;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -36,15 +37,15 @@ import netscape.security.x509.Extension;
import netscape.security.x509.GeneralName;
import netscape.security.x509.URIName;
+
/**
- * This represents the subject information access extension as defined in
- * RFC3280.
- *
+ * This represents the subject information access extension
+ * as defined in RFC3280.
+ *
* @author thomask
* @version $Revision$, $Date$
*/
-public class SubjectInfoAccessExtension extends Extension implements
- CertAttrSet {
+public class SubjectInfoAccessExtension extends Extension implements CertAttrSet {
/**
*
*/
@@ -53,12 +54,12 @@ public class SubjectInfoAccessExtension extends Extension implements
public static final String NAME = "SubjectInfoAccessExtension";
public static final int OID_OCSP[] = { 1, 3, 6, 1, 5, 5, 7, 48, 1 };
- public static final ObjectIdentifier METHOD_OCSP = new ObjectIdentifier(
- OID_OCSP);
+ public static final ObjectIdentifier METHOD_OCSP = new
+ ObjectIdentifier(OID_OCSP);
public static final int OID_CA_ISSUERS[] = { 1, 3, 6, 1, 5, 5, 7, 48, 2 };
- public static final ObjectIdentifier METHOD_CA_ISSUERS = new ObjectIdentifier(
- OID_CA_ISSUERS);
+ public static final ObjectIdentifier METHOD_CA_ISSUERS = new
+ ObjectIdentifier(OID_CA_ISSUERS);
public static final int OID[] = { 1, 3, 6, 1, 5, 5, 7, 1, 11 };
public static final ObjectIdentifier ID = new ObjectIdentifier(OID);
@@ -67,7 +68,7 @@ public class SubjectInfoAccessExtension extends Extension implements
/**
* Create the extension from the passed DER encoded value of the same.
- *
+ *
* @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.
@@ -78,8 +79,8 @@ public class SubjectInfoAccessExtension extends Extension implements
this.extensionValue = null; // build this when encodeThis() is called
}
- public SubjectInfoAccessExtension(Boolean critical, Object value)
- throws IOException {
+ public SubjectInfoAccessExtension(Boolean critical, Object value)
+ throws IOException {
this.extensionId = ID;
this.critical = critical.booleanValue();
this.extensionValue = (byte[]) ((byte[]) value).clone();
@@ -134,8 +135,10 @@ public class SubjectInfoAccessExtension extends Extension implements
/**
* Adds Access Description.
*/
- public void addAccessDescription(ObjectIdentifier method, GeneralName gn) {
- clearValue();
+ public void addAccessDescription(
+ ObjectIdentifier method,
+ GeneralName gn) {
+ clearValue();
mDesc.addElement(new AccessDescription(method, gn));
}
@@ -154,8 +157,7 @@ public class SubjectInfoAccessExtension extends Extension implements
DerValue val = new DerValue(this.extensionValue);
if (val.tag != DerValue.tag_Sequence) {
- throw new IOException(
- "Invalid encoding of AuthInfoAccess extension");
+ throw new IOException("Invalid encoding of AuthInfoAccess extension");
}
while (val.data.available() != 0) {
DerValue seq = val.data.getDerValue();
@@ -166,7 +168,7 @@ public class SubjectInfoAccessExtension extends Extension implements
}
}
- private void encodeThis() throws IOException {
+ private void encodeThis() throws IOException {
DerOutputStream seq = new DerOutputStream();
DerOutputStream tmp = new DerOutputStream();
@@ -181,10 +183,10 @@ public class SubjectInfoAccessExtension extends Extension implements
seq.write(DerValue.tag_Sequence, tmp);
this.extensionValue = seq.toByteArray();
}
-
+
/**
* Write the extension to the DerOutputStream.
- *
+ *
* @param out the DerOutputStream to write the extension to.
* @exception IOException on encoding errors.
*/
@@ -216,21 +218,20 @@ public class SubjectInfoAccessExtension extends Extension implements
public static void main(String[] argv) {
AuthInfoAccessExtension aia = new AuthInfoAccessExtension(false);
- GeneralName ocspName = new GeneralName(new URIName(
- "http://ocsp.netscape.com"));
+ GeneralName ocspName = new GeneralName(new
+ URIName("http://ocsp.netscape.com"));
aia.addAccessDescription(METHOD_OCSP, ocspName);
- GeneralName caIssuersName = new GeneralName(new URIName(
- "http://ocsp.netscape.com"));
+ GeneralName caIssuersName = new GeneralName(new
+ URIName("http://ocsp.netscape.com"));
- aia.addAccessDescription(METHOD_CA_ISSUERS, caIssuersName);
+ aia.addAccessDescription(METHOD_CA_ISSUERS, caIssuersName);
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
aia.encode(os);
- System.out
- .println(com.netscape.osutil.OSUtil.BtoA(os.toByteArray()));
+ System.out.println(com.netscape.osutil.OSUtil.BtoA(os.toByteArray()));
} catch (IOException e) {
System.out.println(e.toString());
}
@@ -245,8 +246,8 @@ public class SubjectInfoAccessExtension extends Extension implements
ByteArrayInputStream bis = new ByteArrayInputStream(
bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
- AuthInfoAccessExtension clone = (AuthInfoAccessExtension) ois
- .readObject();
+ AuthInfoAccessExtension clone = (AuthInfoAccessExtension)
+ ois.readObject();
System.out.println(clone);
} catch (Exception e) {