summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/gnu/java/security/x509
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/java/security/x509')
-rw-r--r--libjava/classpath/gnu/java/security/x509/Util.java4
-rw-r--r--libjava/classpath/gnu/java/security/x509/X509CRL.java73
-rw-r--r--libjava/classpath/gnu/java/security/x509/X509CRLEntry.java41
-rw-r--r--libjava/classpath/gnu/java/security/x509/X509Certificate.java16
-rw-r--r--libjava/classpath/gnu/java/security/x509/ext/Extension.java26
-rw-r--r--libjava/classpath/gnu/java/security/x509/ext/GeneralNames.java5
6 files changed, 82 insertions, 83 deletions
diff --git a/libjava/classpath/gnu/java/security/x509/Util.java b/libjava/classpath/gnu/java/security/x509/Util.java
index d27392026f8..1bd268a51e2 100644
--- a/libjava/classpath/gnu/java/security/x509/Util.java
+++ b/libjava/classpath/gnu/java/security/x509/Util.java
@@ -1,5 +1,5 @@
/* Util.java -- Miscellaneous utility methods.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -155,7 +155,7 @@ public final class Util
}
/**
- * See {@link #hexDump(byte[],int,int)}.
+ * See {@link #hexDump(byte[],int,int,String)}.
*/
public static String hexDump(byte[] buf, String prefix)
{
diff --git a/libjava/classpath/gnu/java/security/x509/X509CRL.java b/libjava/classpath/gnu/java/security/x509/X509CRL.java
index 5b2d3b14130..7c471c97284 100644
--- a/libjava/classpath/gnu/java/security/x509/X509CRL.java
+++ b/libjava/classpath/gnu/java/security/x509/X509CRL.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.x509;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.der.BitString;
import gnu.java.security.der.DER;
@@ -64,6 +65,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.util.logging.Logger;
import javax.security.auth.x500.X500Principal;
@@ -75,20 +77,7 @@ import javax.security.auth.x500.X500Principal;
public class X509CRL extends java.security.cert.X509CRL
implements GnuPKIExtension
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
- private static void debug(String msg)
- {
- if (DEBUG)
- {
- System.err.print(">> X509CRL: ");
- System.err.println(msg);
- }
- }
-
+ private static final Logger log = Logger.getLogger(X509CRL.class.getName());
private static final OID ID_DSA = new OID("1.2.840.10040.4.1");
private static final OID ID_DSA_WITH_SHA1 = new OID("1.2.840.10040.4.3");
private static final OID ID_RSA = new OID("1.2.840.113549.1.1.1");
@@ -350,7 +339,8 @@ public class X509CRL extends java.security.cert.X509CRL
// CertificateList ::= SEQUENCE {
DERReader der = new DERReader(in);
DERValue val = der.read();
- debug("start CertificateList len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start CertificateList len == " + val.getLength());
if (!val.isConstructed())
throw new IOException("malformed CertificateList");
encoded = val.getEncoded();
@@ -359,7 +349,8 @@ public class X509CRL extends java.security.cert.X509CRL
val = der.read();
if (!val.isConstructed())
throw new IOException("malformed TBSCertList");
- debug("start tbsCertList len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start tbsCertList len == " + val.getLength());
tbsCRLBytes = val.getEncoded();
// version Version OPTIONAL,
@@ -372,19 +363,23 @@ public class X509CRL extends java.security.cert.X509CRL
}
else
version = 1;
- debug("read version == " + version);
+ if (Configuration.DEBUG)
+ log.fine("read version == " + version);
// signature AlgorithmIdentifier,
- debug("start AlgorithmIdentifier len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start AlgorithmIdentifier len == " + val.getLength());
if (!val.isConstructed())
throw new IOException("malformed AlgorithmIdentifier");
DERValue algIdVal = der.read();
algId = (OID) algIdVal.getValue();
- debug("read object identifier == " + algId);
+ if (Configuration.DEBUG)
+ log.fine("read object identifier == " + algId);
if (val.getLength() > algIdVal.getEncodedLength())
{
val = der.read();
- debug("read parameters len == " + val.getEncodedLength());
+ if (Configuration.DEBUG)
+ log.fine("read parameters len == " + val.getEncodedLength());
algParams = val.getEncoded();
if (val.isConstructed())
in.skip(val.getLength());
@@ -394,18 +389,21 @@ public class X509CRL extends java.security.cert.X509CRL
val = der.read();
issuerDN = new X500DistinguishedName(val.getEncoded());
der.skip(val.getLength());
- debug("read issuer == " + issuerDN);
+ if (Configuration.DEBUG)
+ log.fine("read issuer == " + issuerDN);
// thisUpdate Time,
thisUpdate = (Date) der.read().getValue();
- debug("read thisUpdate == " + thisUpdate);
+ if (Configuration.DEBUG)
+ log.fine("read thisUpdate == " + thisUpdate);
// nextUpdate Time OPTIONAL,
val = der.read();
if (val.getValue() instanceof Date)
{
nextUpdate = (Date) val.getValue();
- debug("read nextUpdate == " + nextUpdate);
+ if (Configuration.DEBUG)
+ log.fine("read nextUpdate == " + nextUpdate);
val = der.read();
}
@@ -433,7 +431,8 @@ public class X509CRL extends java.security.cert.X509CRL
DERValue exts = der.read();
if (!exts.isConstructed())
throw new IOException("malformed Extensions");
- debug("start Extensions len == " + exts.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start Extensions len == " + exts.getLength());
int len = 0;
while (len < exts.getLength())
{
@@ -444,32 +443,42 @@ public class X509CRL extends java.security.cert.X509CRL
extensions.put(e.getOid(), e);
der.skip(ext.getLength());
len += ext.getEncodedLength();
- debug("current count == " + len);
+ if (Configuration.DEBUG)
+ log.fine("current count == " + len);
}
val = der.read();
}
- debug("read tag == " + val.getTag());
+ if (Configuration.DEBUG)
+ log.fine("read tag == " + val.getTag());
if (!val.isConstructed())
throw new IOException("malformed AlgorithmIdentifier");
- debug("start AlgorithmIdentifier len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start AlgorithmIdentifier len == " + val.getLength());
DERValue sigAlgVal = der.read();
- debug("read tag == " + sigAlgVal.getTag());
+ if (Configuration.DEBUG)
+ log.fine("read tag == " + sigAlgVal.getTag());
if (sigAlgVal.getTag() != DER.OBJECT_IDENTIFIER)
throw new IOException("malformed AlgorithmIdentifier");
sigAlg = (OID) sigAlgVal.getValue();
- debug("signature id == " + sigAlg);
- debug("sigAlgVal length == " + sigAlgVal.getEncodedLength());
+ if (Configuration.DEBUG)
+ {
+ log.fine("signature id == " + sigAlg);
+ log.fine("sigAlgVal length == " + sigAlgVal.getEncodedLength());
+ }
if (val.getLength() > sigAlgVal.getEncodedLength())
{
val = der.read();
- debug("sig params tag = " + val.getTag() + " len == " + val.getEncodedLength());
+ if (Configuration.DEBUG)
+ log.fine("sig params tag = " + val.getTag() + " len == "
+ + val.getEncodedLength());
sigAlgParams = (byte[]) val.getEncoded();
if (val.isConstructed())
in.skip(val.getLength());
}
val = der.read();
- debug("read tag = " + val.getTag());
+ if (Configuration.DEBUG)
+ log.fine("read tag = " + val.getTag());
rawSig = val.getEncoded();
signature = ((BitString) val.getValue()).toByteArray();
}
diff --git a/libjava/classpath/gnu/java/security/x509/X509CRLEntry.java b/libjava/classpath/gnu/java/security/x509/X509CRLEntry.java
index a3bcfdea823..26b40363c35 100644
--- a/libjava/classpath/gnu/java/security/x509/X509CRLEntry.java
+++ b/libjava/classpath/gnu/java/security/x509/X509CRLEntry.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.x509;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.der.DERReader;
import gnu.java.security.der.DERValue;
@@ -53,6 +54,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.util.logging.Logger;
/**
* A single entry in a X.509 certificate revocation list.
@@ -63,20 +65,7 @@ import java.util.Set;
class X509CRLEntry extends java.security.cert.X509CRLEntry
implements GnuPKIExtension
{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
- private static void debug(String msg)
- {
- if (DEBUG)
- {
- System.err.print(">> X509CRLEntry: ");
- System.err.println(msg);
- }
- }
-
+ private static final Logger log = Logger.getLogger(X509CRLEntry.class.getName());
/** The DER encoded form of this CRL entry. */
private byte[] encoded;
@@ -230,26 +219,29 @@ class X509CRLEntry extends java.security.cert.X509CRLEntry
{
// RevokedCertificate ::= SEQUENCE {
DERValue entry = der.read();
- debug("start CRL entry len == " + entry.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start CRL entry len == " + entry.getLength());
if (!entry.isConstructed())
throw new IOException("malformed revokedCertificate");
encoded = entry.getEncoded();
int len = 0;
-
- debug("encoded entry:\n" + Util.hexDump(encoded, ">>>> "));
+ if (Configuration.DEBUG)
+ log.fine("encoded entry:\n" + Util.hexDump(encoded, ">>>> "));
// userCertificate CertificateSerialNumber,
DERValue val = der.read();
serialNo = (BigInteger) val.getValue();
len += val.getEncodedLength();
- debug("userCertificate == " + serialNo + " current count == " + len);
+ if (Configuration.DEBUG)
+ log.fine("userCertificate == " + serialNo + " current count == " + len);
// revocationDate Time,
val = der.read();
revocationDate = (Date) val.getValue();
len += val.getEncodedLength();
- debug("revocationDate == " + revocationDate + " current count == " + len);
-
+ if (Configuration.DEBUG)
+ log.fine("revocationDate == " + revocationDate + " current count == "
+ + len);
// crlEntryExtensions Extensions OPTIONAL
// -- if present MUST be v2
if (len < entry.getLength())
@@ -259,19 +251,22 @@ class X509CRLEntry extends java.security.cert.X509CRLEntry
DERValue exts = der.read();
if (!exts.isConstructed())
throw new IOException("malformed Extensions");
- debug("start Extensions len == " + exts.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start Extensions len == " + exts.getLength());
len = 0;
while (len < exts.getLength())
{
val = der.read();
if (!val.isConstructed())
throw new IOException("malformed Extension");
- debug("start Extension len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("start Extension len == " + val.getLength());
Extension e = new Extension(val.getEncoded());
extensions.put(e.getOid(), e);
der.skip(val.getLength());
len += val.getEncodedLength();
- debug("current count == " + len);
+ if (Configuration.DEBUG)
+ log.fine("current count == " + len);
}
}
}
diff --git a/libjava/classpath/gnu/java/security/x509/X509Certificate.java b/libjava/classpath/gnu/java/security/x509/X509Certificate.java
index cf0161701cc..b3f8a696a85 100644
--- a/libjava/classpath/gnu/java/security/x509/X509Certificate.java
+++ b/libjava/classpath/gnu/java/security/x509/X509Certificate.java
@@ -552,7 +552,7 @@ public class X509Certificate extends java.security.cert.X509Certificate
// Certificate ::= SEQUENCE {
DERValue cert = der.read();
logger.log (Component.X509, "start Certificate len == {0}",
- new Integer (cert.getLength()));
+ Integer.valueOf(cert.getLength()));
this.encoded = cert.getEncoded();
if (!cert.isConstructed())
@@ -568,7 +568,7 @@ public class X509Certificate extends java.security.cert.X509Certificate
}
tbsCertBytes = tbsCert.getEncoded();
logger.log (Component.X509, "start TBSCertificate len == {0}",
- new Integer (tbsCert.getLength()));
+ Integer.valueOf(tbsCert.getLength()));
// Version ::= INTEGER [0] { v1(0), v2(1), v3(2) }
DERValue val = der.read();
@@ -582,7 +582,7 @@ public class X509Certificate extends java.security.cert.X509Certificate
version = 1;
}
logger.log (Component.X509, "read version == {0}",
- new Integer (version));
+ Integer.valueOf(version));
// SerialNumber ::= INTEGER
serialNo = (BigInteger) val.getValue();
@@ -596,7 +596,7 @@ public class X509Certificate extends java.security.cert.X509Certificate
}
int certAlgLen = val.getLength();
logger.log (Component.X509, "start AlgorithmIdentifier len == {0}",
- new Integer (certAlgLen));
+ Integer.valueOf(certAlgLen));
val = der.read();
// algorithm OBJECT IDENTIFIER,
@@ -677,20 +677,20 @@ public class X509Certificate extends java.security.cert.X509Certificate
{
val = der.read();
logger.log (Component.X509, "start Extensions len == {0}",
- new Integer (val.getLength()));
+ Integer.valueOf(val.getLength()));
int len = 0;
while (len < val.getLength())
{
DERValue ext = der.read();
logger.log (Component.X509, "start extension len == {0}",
- new Integer (ext.getLength()));
+ Integer.valueOf(ext.getLength()));
Extension e = new Extension(ext.getEncoded());
extensions.put(e.getOid(), e);
der.skip(ext.getLength());
len += ext.getEncodedLength();
logger.log (Component.X509, "read extension {0} == {1}",
new Object[] { e.getOid (), e });
- logger.log (Component.X509, "count == {0}", new Integer (len));
+ logger.log (Component.X509, "count == {0}", Integer.valueOf(len));
}
val = der.read ();
@@ -703,7 +703,7 @@ public class X509Certificate extends java.security.cert.X509Certificate
}
int sigAlgLen = val.getLength();
logger.log (Component.X509, "start AlgorithmIdentifier len == {0}",
- new Integer (sigAlgLen));
+ Integer.valueOf(sigAlgLen));
val = der.read();
sigAlgId = (OID) val.getValue();
logger.log (Component.X509, "read algorithm id == {0}", sigAlgId);
diff --git a/libjava/classpath/gnu/java/security/x509/ext/Extension.java b/libjava/classpath/gnu/java/security/x509/ext/Extension.java
index 97097a2f380..69251987ec9 100644
--- a/libjava/classpath/gnu/java/security/x509/ext/Extension.java
+++ b/libjava/classpath/gnu/java/security/x509/ext/Extension.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.x509.ext;
+import gnu.java.security.Configuration;
import gnu.java.security.OID;
import gnu.java.security.der.DER;
import gnu.java.security.der.DERReader;
@@ -48,20 +49,11 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.logging.Logger;
public class Extension
{
-
- // Fields.
- // -------------------------------------------------------------------------
-
- private static final boolean DEBUG = false;
- private static void debug(String msg)
- {
- System.err.print(">> Extension: ");
- System.err.println(msg);
- }
-
+ private static final Logger log = Logger.getLogger(Extension.class.getName());
/**
* This extension's object identifier.
*/
@@ -97,7 +89,8 @@ public class Extension
// Extension ::= SEQUENCE {
DERValue val = der.read();
- if (DEBUG) debug("read val tag == " + val.getTag() + " len == " + val.getLength());
+ if (Configuration.DEBUG)
+ log.fine("read val tag == " + val.getTag() + " len == " + val.getLength());
if (!val.isConstructed())
throw new IOException("malformed Extension");
@@ -106,7 +99,8 @@ public class Extension
if (val.getTag() != DER.OBJECT_IDENTIFIER)
throw new IOException("expecting OBJECT IDENTIFIER");
oid = (OID) val.getValue();
- if (DEBUG) debug("read oid == " + oid);
+ if (Configuration.DEBUG)
+ log.fine("read oid == " + oid);
// critical BOOLEAN DEFAULT FALSE,
val = der.read();
@@ -117,7 +111,8 @@ public class Extension
}
else
critical = false;
- if (DEBUG) debug("is critical == " + critical);
+ if (Configuration.DEBUG)
+ log.fine("is critical == " + critical);
// extnValue OCTET STRING }
if (val.getTag() != DER.OCTET_STRING)
@@ -181,7 +176,8 @@ public class Extension
value = new Value(encval);
isSupported = false;
}
- if (DEBUG) debug("read value == " + value);
+ if (Configuration.DEBUG)
+ log.fine("read value == " + value);
}
public Extension (final OID oid, final Value value, final boolean critical)
diff --git a/libjava/classpath/gnu/java/security/x509/ext/GeneralNames.java b/libjava/classpath/gnu/java/security/x509/ext/GeneralNames.java
index dae94cd9f35..b342cbd5f2e 100644
--- a/libjava/classpath/gnu/java/security/x509/ext/GeneralNames.java
+++ b/libjava/classpath/gnu/java/security/x509/ext/GeneralNames.java
@@ -1,5 +1,5 @@
/* GeneralNames.java -- the GeneralNames object
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,6 @@ import gnu.java.security.OID;
import gnu.java.security.der.DER;
import gnu.java.security.der.DERReader;
import gnu.java.security.der.DERValue;
-import gnu.java.security.x509.X500DistinguishedName;
import java.io.IOException;
import java.net.InetAddress;
@@ -91,7 +90,7 @@ public class GeneralNames
int tagClass = name.getTagClass();
if (tagClass != DER.CONTEXT)
throw new IOException("malformed GeneralName: Tag class is " + tagClass);
- namePair.add(new Integer(name.getTag()));
+ namePair.add(Integer.valueOf(name.getTag()));
DERValue val = null;
switch (name.getTag())
{
OpenPOWER on IntegriCloud