diff options
| author | Raif S. Naffah <raif@swiftdsl.com.au> | 2006-06-11 12:14:43 +0000 |
|---|---|---|
| committer | Raif S. Naffah <raif@swiftdsl.com.au> | 2006-06-11 12:14:43 +0000 |
| commit | 8ace3af577b4314374a3cc74fdeae04a0733f7de (patch) | |
| tree | 3849fb63506a60f82f4c1cb244b3181b5cd89931 /gnu/java/security | |
| parent | b911a80084bcdaf3c58728a4b97f8672e4f415c1 (diff) | |
| download | classpath-8ace3af577b4314374a3cc74fdeae04a0733f7de.tar.gz | |
2006-06-11 Raif S. Naffah <raif@swiftdsl.com.au>generics-merge-20060611
PR Classpath/26065
* gnu/javax/security/auth/login/GnuConfiguration.java: Condition all trace/
debug code based on Configuration.DEBUG.
Use logger instead of STDOUT and ot STDERR.
* gnu/javax/security/auth/login/ConfigFileParser.java: Likewise.
* gnu/javax/crypto/sasl/SaslOutputStream.java: Likewise.
* gnu/javax/crypto/sasl/SaslInputStream.java: Likewise.
* gnu/javax/crypto/sasl/srp/SRPServer.java: Likewise.
* gnu/javax/crypto/sasl/srp/SRPClient.java: Likewise.
* gnu/javax/crypto/prng/CSPRNG.java: Likewise.
* gnu/javax/crypto/pad/TBC.java: Likewise.
* gnu/javax/crypto/pad/PKCS7.java: Likewise.
* gnu/javax/crypto/pad/PKCS1_V1_5.java: Likewise.
* gnu/javax/crypto/pad/BasePad.java: Likewise.
* gnu/javax/crypto/mac/OMAC.java: Likewise.
* gnu/javax/crypto/keyring/PasswordEncryptedEntry.java: Likewise.
* gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java: Likewise.
* gnu/javax/crypto/keyring/GnuPublicKeyring.java: Likewise.
* gnu/javax/crypto/keyring/GnuPrivateKeyring.java: Likewise.
* gnu/javax/crypto/keyring/EnvelopeEntry.java: Likewise.
* gnu/javax/crypto/keyring/Entry.java: Likewise.
* gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java: Likewise.
* gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java: Likewise.
* gnu/javax/crypto/jce/prng/UMacRandomSpi.java: Likewise.
* gnu/javax/crypto/jce/prng/ICMRandomSpi.java: Likewise.
* gnu/javax/crypto/jce/keyring/GnuKeyring.java: Likewise.
* gnu/javax/crypto/cipher/Twofish.java: Likewise.
* gnu/javax/crypto/cipher/Khazad.java: Likewise.
* gnu/javax/crypto/cipher/Rijndael.java: Likewise.
* gnu/javax/crypto/cipher/BaseCipher.java: Likewise.
* gnu/javax/crypto/cipher/Anubis.java: Likewise.
* gnu/java/security/Properties.java: Likewise.
* gnu/java/security/x509/X509CRLEntry.java: Likewise.
* gnu/java/security/x509/X509CRL.java: Likewise.
* gnu/java/security/x509/ext/Extension.java: Likewise.
* gnu/java/security/util/Prime2.java: Likewise.
* gnu/java/security/util/Base64.java: Likewise.
* gnu/java/security/sig/rsa/RSAPSSSignature.java: Likewise.
* gnu/java/security/sig/rsa/EMSA_PSS.java: Likewise.
* gnu/java/security/provider/PKIXCertPathValidatorImpl.java: Likewise.
* gnu/java/security/pkcs/SignerInfo.java: Likewise.
* gnu/java/security/pkcs/PKCS7SignedData.java: Likewise.
* gnu/java/security/key/rsa/RSAKeyPairX509Codec.java: Likewise.
* gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java: Likewise.
* gnu/java/security/key/rsa/RSAKeyPairGenerator.java: Likewise.
* gnu/java/security/key/rsa/GnuRSAPrivateKey.java: Likewise.
* gnu/java/security/key/dss/DSSPrivateKey.java: Likewise.
* gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java: Likewise.
* gnu/java/security/key/dss/DSSKeyPairGenerator.java: Likewise.
* gnu/java/security/jce/sig/SignatureAdapter.java: Likewise.
* gnu/java/security/jce/sig/EncodedKeyFactory.java: Likewise.
* gnu/java/security/hash/Whirlpool.java: Likewise.
Diffstat (limited to 'gnu/java/security')
21 files changed, 399 insertions, 491 deletions
diff --git a/gnu/java/security/Properties.java b/gnu/java/security/Properties.java index 860b7d928..4e8bc01ea 100644 --- a/gnu/java/security/Properties.java +++ b/gnu/java/security/Properties.java @@ -38,13 +38,15 @@ exception statement from your version. */ package gnu.java.security; +import gnu.classpath.Configuration; + import java.io.FileInputStream; import java.io.IOException; -import java.io.PrintWriter; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; import java.util.PropertyPermission; +import java.util.logging.Logger; /** * <p>A global object containing build-specific properties that affect the @@ -52,25 +54,7 @@ import java.util.PropertyPermission; */ public final class Properties { - - // Debugging methods and variables - // ------------------------------------------------------------------------- - - private static final String NAME = "Properties"; - - private static final boolean DEBUG = false; - - // private static final int debuglevel = 9; - private static final PrintWriter err = new PrintWriter(System.out, true); - - private static void debug(final String s) - { - err.println(">>> " + NAME + ": " + s); - } - - // Constants and variables - // ------------------------------------------------------------------------- - + private static final Logger log = Logger.getLogger(Properties.class.getName()); public static final String VERSION = "gnu.crypto.version"; public static final String PROPERTIES_FILE = "gnu.crypto.properties.file"; @@ -300,9 +284,8 @@ public final class Properties } catch (SecurityException se) { - if (DEBUG) - debug("Reading property " + PROPERTIES_FILE - + " not allowed. Ignored."); + if (Configuration.DEBUG) + log.fine("Reading property " + PROPERTIES_FILE + " not allowed. Ignored."); } if (propFile != null) { @@ -316,14 +299,14 @@ public final class Properties } catch (IOException ioe) { - if (DEBUG) - debug("IO error reading " + propFile + ": " + ioe.getMessage()); + if (Configuration.DEBUG) + log.fine("IO error reading " + propFile + ": " + ioe.getMessage()); } catch (SecurityException se) { - if (DEBUG) - debug("Security error reading " + propFile + ": " - + se.getMessage()); + if (Configuration.DEBUG) + log.fine("Security error reading " + propFile + ": " + + se.getMessage()); } } @@ -350,8 +333,8 @@ public final class Properties } catch (SecurityException x) { - if (DEBUG) - debug("SecurityManager forbids reading system properties. Ignored"); + if (Configuration.DEBUG) + log.fine("SecurityManager forbids reading system properties. Ignored"); } if (s != null) { @@ -360,14 +343,14 @@ public final class Properties // hide valid value set previously if (s.equals(TRUE) || s.equals(FALSE)) { - if (DEBUG) - debug("Setting " + name + " to '" + s + "'"); + if (Configuration.DEBUG) + log.fine("Setting " + name + " to '" + s + "'"); props.put(name, s); } else { - if (DEBUG) - debug("Invalid value for -D" + name + ": " + s + ". Ignored"); + if (Configuration.DEBUG) + log.fine("Invalid value for -D" + name + ": " + s + ". Ignored"); } } } diff --git a/gnu/java/security/hash/Whirlpool.java b/gnu/java/security/hash/Whirlpool.java index b10fa53cd..ee40d92b3 100644 --- a/gnu/java/security/hash/Whirlpool.java +++ b/gnu/java/security/hash/Whirlpool.java @@ -38,9 +38,12 @@ exception statement from your version. */ package gnu.java.security.hash; +import gnu.classpath.Configuration; import gnu.java.security.Registry; import gnu.java.security.util.Util; +import java.util.logging.Logger; + /** * Whirlpool, a new 512-bit hashing function operating on messages less than * 2 ** 256 bits in length. The function structure is designed according to the @@ -61,16 +64,7 @@ import gnu.java.security.util.Util; */ public final class Whirlpool extends BaseHash { - // Debugging methods and variables - // ------------------------------------------------------------------------- - - private static final boolean DEBUG = false; - - private static final int debuglevel = 3; - - // Constants and variables - // ------------------------------------------------------------------------- - + private static final Logger log = Logger.getLogger(Whirlpool.class.getName()); private static final int BLOCK_SIZE = 64; // inner block size in bytes /** The digest of the 0-bit long message. */ @@ -183,95 +177,87 @@ public final class Whirlpool extends BaseHash ^ (T7[i++] & 0x00000000000000FFL); time = System.currentTimeMillis() - time; - if (DEBUG && debuglevel > 8) + if (Configuration.DEBUG) { - System.out.println("=========="); - System.out.println(); - System.out.println("Static data"); - System.out.println(); - - System.out.println(); - System.out.println("T0[]:"); + log.fine("Static data"); + log.fine("T0[]:"); + StringBuilder sb; for (i = 0; i < 64; i++) { + sb = new StringBuilder(); for (j = 0; j < 4; j++) - System.out.print("0x" + Util.toString(T0[i * 4 + j]) + ", "); + sb.append("0x").append(Util.toString(T0[i * 4 + j])).append(", "); - System.out.println(); + log.fine(sb.toString()); } - System.out.println(); - System.out.println("T1[]:"); + log.fine("T1[]:"); for (i = 0; i < 64; i++) { + sb = new StringBuilder(); for (j = 0; j < 4; j++) - System.out.print("0x" + Util.toString(T1[i * 4 + j]) + ", "); + sb.append("0x").append(Util.toString(T1[i * 4 + j])).append(", "); - System.out.println(); + log.fine(sb.toString()); } - System.out.println(); - System.out.println("T2[]:"); + log.fine("T2[]:"); for (i = 0; i < 64; i++) { + sb = new StringBuilder(); for (j = 0; j < 4; j++) - System.out.print("0x" + Util.toString(T2[i * 4 + j]) + ", "); + sb.append("0x").append(Util.toString(T2[i * 4 + j])).append(", "); - System.out.println(); + log.fine(sb.toString()); } - System.out.println(); - System.out.println("T3[]:"); + log.fine("T3[]:"); for (i = 0; i < 64; i++) { + sb = new StringBuilder(); for (j = 0; j < 4; j++) - System.out.print("0x" + Util.toString(T3[i * 4 + j]) + ", "); + sb.append("0x").append(Util.toString(T3[i * 4 + j])).append(", "); - System.out.println(); + log.fine(sb.toString()); } - System.out.println(); - System.out.println("T4[]:"); + log.fine("\nT4[]:"); for (i = 0; i < 64; i++) { + sb = new StringBuilder(); for (j = 0; j < 4; j++) - System.out.print("0x" + Util.toString(T4[i * 4 + j]) + ", "); + sb.append("0x").append(Util.toString(T4[i * 4 + j])).append(", "); - System.out.println(); + log.fine(sb.toString()); } - System.out.println(); - System.out.println("T5[]:"); + log.fine("T5[]:"); for (i = 0; i < 64; i++) { + sb = new StringBuilder(); for (j = 0; j < 4; j++) - System.out.print("0x" + Util.toString(T5[i * 4 + j]) + ", "); + sb.append("0x").append(Util.toString(T5[i * 4 + j])).append(", "); - System.out.println(); + log.fine(sb.toString()); } - System.out.println(); - System.out.println("T6[]:"); + log.fine("T6[]:"); for (i = 0; i < 64; i++) { + sb = new StringBuilder(); for (j = 0; j < 4; j++) - System.out.print("0x" + Util.toString(T5[i * 4 + j]) + ", "); + sb.append("0x").append(Util.toString(T5[i * 4 + j])).append(", "); - System.out.println(); + log.fine(sb.toString()); } - System.out.println(); - System.out.println("T7[]:"); + log.fine("T7[]:"); for (i = 0; i < 64; i++) { + sb = new StringBuilder(); for (j = 0; j < 4; j++) - System.out.print("0x" + Util.toString(T5[i * 4 + j]) + ", "); + sb.append("0x").append(Util.toString(T5[i * 4 + j])).append(", "); - System.out.println(); + log.fine(sb.toString()); } - System.out.println(); - System.out.println("rc[]:"); + log.fine("rc[]:"); for (i = 0; i < R; i++) - System.out.println("0x" + Util.toString(rc[i])); - - System.out.println(); + log.fine("0x" + Util.toString(rc[i])); - System.out.println(); - System.out.println("Total initialization time: " + time + " ms."); - System.out.println(); + log.fine("Total initialization time: " + time + " ms."); } } diff --git a/gnu/java/security/jce/sig/EncodedKeyFactory.java b/gnu/java/security/jce/sig/EncodedKeyFactory.java index 60152c279..bfee6cc76 100644 --- a/gnu/java/security/jce/sig/EncodedKeyFactory.java +++ b/gnu/java/security/jce/sig/EncodedKeyFactory.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.jce.sig; +import gnu.classpath.Configuration; import gnu.java.security.Registry; import gnu.java.security.key.dss.DSSPrivateKey; import gnu.java.security.key.dss.DSSPublicKey; @@ -196,7 +197,8 @@ public class EncodedKeyFactory protected PublicKey engineGeneratePublic(KeySpec keySpec) throws InvalidKeySpecException { - log.entering(this.getClass().getName(), "engineGeneratePublic()", keySpec); + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "engineGeneratePublic()", keySpec); PublicKey result = null; if (keySpec instanceof DSAPublicKeySpec) @@ -220,8 +222,9 @@ public class EncodedKeyFactory } catch (InvalidParameterException ignored) { - log.log(Level.FINE, "Exception in DSSPublicKey.valueOf(). Ignore", - ignored); + if (Configuration.DEBUG) + log.log(Level.FINE, "Exception in DSSPublicKey.valueOf(). Ignore", + ignored); } if (! ok) // try RSA @@ -232,23 +235,25 @@ public class EncodedKeyFactory } catch (InvalidParameterException ignored) { - log.log(Level.FINE, - "Exception in GnuRSAPublicKey.valueOf(). Ignore", - ignored); + if (Configuration.DEBUG) + log.log(Level.FINE, + "Exception in GnuRSAPublicKey.valueOf(). Ignore", + ignored); } if (! ok) // try DH result = decodeDHPublicKey(input); } - - log.exiting(this.getClass().getName(), "engineGeneratePublic()", result); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "engineGeneratePublic()", result); return result; } protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { - log.entering(this.getClass().getName(), "engineGeneratePrivate()", keySpec); + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "engineGeneratePrivate()", keySpec); PrivateKey result = null; if (keySpec instanceof DSAPrivateKeySpec) @@ -272,8 +277,9 @@ public class EncodedKeyFactory } catch (InvalidParameterException ignored) { - log.log(Level.FINE, "Exception in DSSPrivateKey.valueOf(). Ignore", - ignored); + if (Configuration.DEBUG) + log.log(Level.FINE, "Exception in DSSPrivateKey.valueOf(). Ignore", + ignored); } if (! ok) // try RSA @@ -284,16 +290,17 @@ public class EncodedKeyFactory } catch (InvalidParameterException ignored) { - log.log(Level.FINE, - "Exception in GnuRSAPrivateKey.valueOf(). Ignore", - ignored); + if (Configuration.DEBUG) + log.log(Level.FINE, + "Exception in GnuRSAPrivateKey.valueOf(). Ignore", + ignored); } if (! ok) // try DH result = decodeDHPrivateKey(input); } - - log.exiting(this.getClass().getName(), "engineGeneratePrivate()", result); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "engineGeneratePrivate()", result); return result; } diff --git a/gnu/java/security/jce/sig/SignatureAdapter.java b/gnu/java/security/jce/sig/SignatureAdapter.java index 4dcbe78e5..724cc260e 100644 --- a/gnu/java/security/jce/sig/SignatureAdapter.java +++ b/gnu/java/security/jce/sig/SignatureAdapter.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.jce.sig; +import gnu.classpath.Configuration; import gnu.java.security.sig.BaseSignature; import gnu.java.security.sig.ISignature; import gnu.java.security.sig.ISignatureCodec; @@ -223,7 +224,8 @@ class SignatureAdapter extends SignatureSpi implements Cloneable public boolean engineVerify(byte[] sigBytes) throws SignatureException { - log.entering("SignatureAdapter", "engineVerify"); + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "engineVerify"); Object signature = codec.decodeSignature(sigBytes); boolean result = false; @@ -235,8 +237,8 @@ class SignatureAdapter extends SignatureSpi implements Cloneable { throw new SignatureException(String.valueOf(x)); } - - log.exiting("SignatureAdapter", "engineVerify", new Boolean(result)); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "engineVerify", Boolean.valueOf(result)); return result; } diff --git a/gnu/java/security/key/dss/DSSKeyPairGenerator.java b/gnu/java/security/key/dss/DSSKeyPairGenerator.java index 5aa746147..ca24f36c5 100644 --- a/gnu/java/security/key/dss/DSSKeyPairGenerator.java +++ b/gnu/java/security/key/dss/DSSKeyPairGenerator.java @@ -38,12 +38,12 @@ exception statement from your version. */ package gnu.java.security.key.dss; +import gnu.classpath.Configuration; import gnu.java.security.Registry; import gnu.java.security.hash.Sha160; import gnu.java.security.key.IKeyPairGenerator; import gnu.java.security.util.PRNG; -import java.io.PrintWriter; import java.math.BigInteger; import java.security.KeyPair; import java.security.PrivateKey; @@ -51,6 +51,7 @@ import java.security.PublicKey; import java.security.SecureRandom; import java.security.spec.DSAParameterSpec; import java.util.Map; +import java.util.logging.Logger; /** * <p>A key-pair generator for asymetric keys to use in conjunction with the DSS @@ -63,26 +64,7 @@ import java.util.Map; */ public class DSSKeyPairGenerator implements IKeyPairGenerator { - - // Debugging methods and variables - // ------------------------------------------------------------------------- - - private static final String NAME = "dss"; - - private static final boolean DEBUG = false; - - private static final int debuglevel = 5; - - private static final PrintWriter err = new PrintWriter(System.out, true); - - private static void debug(String s) - { - err.println(">>> " + NAME + ": " + s); - } - - // Constants and variables - // ------------------------------------------------------------------------- - + private static final Logger log = Logger.getLogger(DSSKeyPairGenerator.class.getName()); /** The BigInteger constant 2. */ private static final BigInteger TWO = new BigInteger("2"); @@ -361,14 +343,14 @@ public class DSSKeyPairGenerator implements IKeyPairGenerator p = params[FIPS186.DSA_PARAMS_P]; e = params[FIPS186.DSA_PARAMS_E]; g = params[FIPS186.DSA_PARAMS_G]; - if (DEBUG && debuglevel > 0) + if (Configuration.DEBUG) { - debug("seed: " + seed.toString(16)); - debug("counter: " + counter.intValue()); - debug("q: " + q.toString(16)); - debug("p: " + p.toString(16)); - debug("e: " + e.toString(16)); - debug("g: " + g.toString(16)); + log.fine("seed: " + seed.toString(16)); + log.fine("counter: " + counter.intValue()); + log.fine("q: " + q.toString(16)); + log.fine("p: " + p.toString(16)); + log.fine("e: " + e.toString(16)); + log.fine("g: " + g.toString(16)); } } diff --git a/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java b/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java index 3a115b963..166178fe4 100644 --- a/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java +++ b/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.key.dss; +import gnu.classpath.Configuration; import gnu.java.security.OID; import gnu.java.security.Registry; import gnu.java.security.der.DER; @@ -184,7 +185,8 @@ public class DSSKeyPairPKCS8Codec */ public PrivateKey decodePrivateKey(byte[] input) { - log.entering("DSSKeyPairPKCS8Codec", "decodePrivateKey"); + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "decodePrivateKey"); if (input == null) throw new InvalidParameterException("Input bytes MUST NOT be null"); @@ -226,9 +228,11 @@ public class DSSKeyPairPKCS8Codec g = (BigInteger) val.getValue(); val = der.read(); - log.finest("val = " + val); + if (Configuration.DEBUG) + log.fine("val = " + val); byte[] xBytes = (byte[]) val.getValue(); - log.finest(Util.dumpString(xBytes, "xBytes: ")); + if (Configuration.DEBUG) + log.fine(Util.dumpString(xBytes, "xBytes: ")); DERReader der2 = new DERReader(xBytes); val = der2.read(); DerUtil.checkIsBigInteger(val, "Wrong X field"); @@ -240,8 +244,8 @@ public class DSSKeyPairPKCS8Codec y.initCause(e); throw y; } - - log.exiting("DSSKeyPairPKCS8Codec", "decodePrivateKey"); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "decodePrivateKey"); return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x); } } diff --git a/gnu/java/security/key/dss/DSSPrivateKey.java b/gnu/java/security/key/dss/DSSPrivateKey.java index fe59cb6d7..a9374557b 100644 --- a/gnu/java/security/key/dss/DSSPrivateKey.java +++ b/gnu/java/security/key/dss/DSSPrivateKey.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.key.dss; +import gnu.classpath.Configuration; import gnu.classpath.SystemProperties; import gnu.java.security.Registry; import gnu.java.security.key.IKeyPairCodec; @@ -53,11 +54,6 @@ import java.security.interfaces.DSAPrivateKey; */ public class DSSPrivateKey extends DSSKey implements PrivateKey, DSAPrivateKey { - // Constants and variables - // ------------------------------------------------------------------------- - - private static final boolean DEBUG = false; - /** * <p>A randomly or pseudorandomly generated integer with <code>0 < x < * q</code>.</p> @@ -210,7 +206,8 @@ public class DSSPrivateKey extends DSSKey implements PrivateKey, DSAPrivateKey String ls = SystemProperties.getProperty("line.separator"); str = new StringBuilder(this.getClass().getName()).append("(") .append(super.toString()).append(",").append(ls) - .append("x=0x").append(DEBUG ? x.toString(16) : "**...*").append(ls) + .append("x=0x").append(Configuration.DEBUG ? x.toString(16) + : "**...*").append(ls) .append(")").toString(); } diff --git a/gnu/java/security/key/rsa/GnuRSAPrivateKey.java b/gnu/java/security/key/rsa/GnuRSAPrivateKey.java index 920534487..bd39ee657 100644 --- a/gnu/java/security/key/rsa/GnuRSAPrivateKey.java +++ b/gnu/java/security/key/rsa/GnuRSAPrivateKey.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.key.rsa; +import gnu.classpath.Configuration; import gnu.classpath.SystemProperties; import gnu.java.security.Registry; import gnu.java.security.key.IKeyPairCodec; @@ -61,11 +62,6 @@ import java.security.interfaces.RSAPrivateKey; public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey, RSAPrivateCrtKey { - // Constants and variables - // ------------------------------------------------------------------------- - - private static final boolean DEBUG = false; - /** The first prime divisor of the modulus. */ private final BigInteger p; @@ -307,12 +303,18 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey, String ls = SystemProperties.getProperty("line.separator"); str = new StringBuilder(this.getClass().getName()).append("(") .append(super.toString()).append(",").append(ls) - .append("d=0x").append(DEBUG ? d.toString(16) : "**...*").append(ls) - .append("p=0x").append(DEBUG ? p.toString(16) : "**...*").append(ls) - .append("q=0x").append(DEBUG ? q.toString(16) : "**...*").append(ls) - .append("dP=0x").append(DEBUG ? dP.toString(16) : "**...*").append(ls) - .append("dQ=0x").append(DEBUG ? dQ.toString(16) : "**...*").append(ls) - .append("qInv=0x").append(DEBUG ? qInv.toString(16) : "**...*").append(ls) + .append("d=0x").append(Configuration.DEBUG ? d.toString(16) + : "**...*").append(ls) + .append("p=0x").append(Configuration.DEBUG ? p.toString(16) + : "**...*").append(ls) + .append("q=0x").append(Configuration.DEBUG ? q.toString(16) + : "**...*").append(ls) + .append("dP=0x").append(Configuration.DEBUG ? dP.toString(16) + : "**...*").append(ls) + .append("dQ=0x").append(Configuration.DEBUG ? dQ.toString(16) + : "**...*").append(ls) + .append("qInv=0x").append(Configuration.DEBUG ? qInv.toString(16) + : "**...*").append(ls) .append(")").toString(); } return str; diff --git a/gnu/java/security/key/rsa/RSAKeyPairGenerator.java b/gnu/java/security/key/rsa/RSAKeyPairGenerator.java index 39063381f..127b3eac4 100644 --- a/gnu/java/security/key/rsa/RSAKeyPairGenerator.java +++ b/gnu/java/security/key/rsa/RSAKeyPairGenerator.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.key.rsa; +import gnu.classpath.Configuration; import gnu.java.security.Registry; import gnu.java.security.key.IKeyPairGenerator; import gnu.java.security.util.PRNG; @@ -152,8 +153,8 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator */ public void setup(Map attributes) { - log.entering(this.getClass().getName(), "setup", attributes); - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "setup", attributes); // do we have a SecureRandom, or should we use our own? rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS); @@ -181,8 +182,8 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT); preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT : formatID.intValue(); - - log.exiting(this.getClass().getName(), "setup"); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "setup"); } /** @@ -193,7 +194,8 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator */ public KeyPair generate() { - log.entering(this.getClass().getName(), "generate"); + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "generate"); BigInteger p, q, n, d; @@ -243,7 +245,8 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator PrivateKey secK = new GnuRSAPrivateKey(preferredFormat, p, q, e, d); KeyPair result = new KeyPair(pubK, secK); - log.exiting(this.getClass().getName(), "generate", result); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "generate", result); return result; } diff --git a/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java b/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java index 0b9809032..14a0a063c 100644 --- a/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java +++ b/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java @@ -38,15 +38,7 @@ exception statement from your version. */ package gnu.java.security.key.rsa; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.math.BigInteger; -import java.security.InvalidParameterException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.util.ArrayList; -import java.util.logging.Logger; - +import gnu.classpath.Configuration; import gnu.java.security.OID; import gnu.java.security.Registry; import gnu.java.security.der.DER; @@ -56,6 +48,15 @@ import gnu.java.security.der.DERWriter; import gnu.java.security.key.IKeyPairCodec; import gnu.java.security.util.DerUtil; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.math.BigInteger; +import java.security.InvalidParameterException; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.util.ArrayList; +import java.util.logging.Logger; + /** * An implementation of an {@link IKeyPairCodec} that knows how to encode / * decode PKCS#8 ASN.1 external representation of RSA private keys. @@ -122,7 +123,8 @@ public class RSAKeyPairPKCS8Codec */ public byte[] encodePrivateKey(PrivateKey key) { - log.entering(this.getClass().getName(), "encodePrivateKey()", key); + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "encodePrivateKey()", key); if (! (key instanceof GnuRSAPrivateKey)) throw new InvalidParameterException("Wrong key type"); @@ -190,8 +192,8 @@ public class RSAKeyPairPKCS8Codec y.initCause(x); throw y; } - - log.exiting(this.getClass().getName(), "encodePrivateKey()", result); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "encodePrivateKey()", result); return result; } @@ -213,7 +215,8 @@ public class RSAKeyPairPKCS8Codec */ public PrivateKey decodePrivateKey(byte[] input) { - log.entering(this.getClass().getName(), "decodePrivateKey()", input); + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "decodePrivateKey()", input); if (input == null) throw new InvalidParameterException("Input bytes MUST NOT be null"); @@ -287,7 +290,8 @@ public class RSAKeyPairPKCS8Codec PrivateKey result = new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID, n, e, d, p, q, dP, dQ, qInv); - log.exiting(this.getClass().getName(), "decodePrivateKey()", result); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "decodePrivateKey()", result); return result; } } diff --git a/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java b/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java index 882d9c7b2..87c5c3a6d 100644 --- a/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java +++ b/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.key.rsa; +import gnu.classpath.Configuration; import gnu.java.security.OID; import gnu.java.security.Registry; import gnu.java.security.der.BitString; @@ -114,7 +115,8 @@ public class RSAKeyPairX509Codec */ public byte[] encodePublicKey(PublicKey key) { - log.entering(this.getClass().getName(), "encodePublicKey()", key); + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "encodePublicKey()", key); if (! (key instanceof GnuRSAPublicKey)) throw new InvalidParameterException("key"); @@ -160,8 +162,8 @@ public class RSAKeyPairX509Codec y.initCause(x); throw y; } - - log.exiting(this.getClass().getName(), "encodePublicKey()", result); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "encodePublicKey()", result); return result; } @@ -183,7 +185,8 @@ public class RSAKeyPairX509Codec */ public PublicKey decodePublicKey(byte[] input) { - log.entering(this.getClass().getName(), "decodePublicKey()", input); + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "decodePublicKey()", input); if (input == null) throw new InvalidParameterException("Input bytes MUST NOT be null"); @@ -235,7 +238,8 @@ public class RSAKeyPairX509Codec } PublicKey result = new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e); - log.exiting(this.getClass().getName(), "decodePublicKey()", result); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "decodePublicKey()", result); return result; } diff --git a/gnu/java/security/pkcs/PKCS7SignedData.java b/gnu/java/security/pkcs/PKCS7SignedData.java index 0781f4ba9..de2b2f679 100644 --- a/gnu/java/security/pkcs/PKCS7SignedData.java +++ b/gnu/java/security/pkcs/PKCS7SignedData.java @@ -37,6 +37,7 @@ exception statement from your version. */ package gnu.java.security.pkcs; +import gnu.classpath.Configuration; import gnu.java.security.OID; import gnu.java.security.ber.BER; import gnu.java.security.ber.BEREncodingException; @@ -52,9 +53,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; - import java.math.BigInteger; - import java.security.cert.CRL; import java.security.cert.CRLException; import java.security.cert.Certificate; @@ -62,7 +61,6 @@ import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509CRL; - import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -174,21 +172,22 @@ public class PKCS7SignedData if (!val.isConstructed()) throw new BEREncodingException("malformed SignedData"); - log.finest("SignedData: " + val); + if (Configuration.DEBUG) + log.fine("SignedData: " + val); val = ber.read(); if (val.getTag() != BER.INTEGER) throw new BEREncodingException("expecting Version"); version = (BigInteger) val.getValue(); - - log.finest(" Version: " + version); + if (Configuration.DEBUG) + log.fine(" Version: " + version); digestAlgorithms = new HashSet(); val = ber.read(); if (!val.isConstructed()) throw new BEREncodingException("malformed DigestAlgorithmIdentifiers"); - - log.finest(" DigestAlgorithmIdentifiers: " + val); + if (Configuration.DEBUG) + log.fine(" DigestAlgorithmIdentifiers: " + val); int count = 0; DERValue val2 = ber.read(); while (val2 != BER.END_OF_SEQUENCE && @@ -196,14 +195,14 @@ public class PKCS7SignedData { if (!val2.isConstructed()) throw new BEREncodingException("malformed AlgorithmIdentifier"); - - log.finest(" AlgorithmIdentifier: " + val2); + if (Configuration.DEBUG) + log.fine(" AlgorithmIdentifier: " + val2); count += val2.getEncodedLength(); val2 = ber.read(); if (val2.getTag() != BER.OBJECT_IDENTIFIER) throw new BEREncodingException("malformed AlgorithmIdentifier"); - - log.finest(" digestAlgorithmIdentifiers OID: " + val2.getValue()); + if (Configuration.DEBUG) + log.fine(" digestAlgorithmIdentifiers OID: " + val2.getValue()); List algId = new ArrayList(2); algId.add(val2.getValue()); val2 = ber.read(); @@ -224,23 +223,27 @@ public class PKCS7SignedData else algId.add(null); - log.finest(" digestAlgorithmIdentifiers params: "); - log.finest(Util.dumpString((byte[]) algId.get(1), - " digestAlgorithmIdentifiers params: ")); + if (Configuration.DEBUG) + { + log.fine(" digestAlgorithmIdentifiers params: "); + log.fine(Util.dumpString((byte[]) algId.get(1), + " digestAlgorithmIdentifiers params: ")); + } digestAlgorithms.add(algId); } val = ber.read(); if (!val.isConstructed()) throw new BEREncodingException("malformed ContentInfo"); - - log.finest(" ContentInfo: " + val); + if (Configuration.DEBUG) + log.fine(" ContentInfo: " + val); val2 = ber.read(); if (val2.getTag() != BER.OBJECT_IDENTIFIER) throw new BEREncodingException("malformed ContentType"); contentType = (OID) val2.getValue(); - log.finest(" ContentType OID: " + contentType); + if (Configuration.DEBUG) + log.fine(" ContentType OID: " + contentType); if (BERValue.isIndefinite(val) || (val.getLength() > 0 && val.getLength() > val2.getEncodedLength())) { @@ -252,17 +255,18 @@ public class PKCS7SignedData val2 = ber.read(); } } - - log.finest(" Content: "); - log.finest(Util.dumpString(content, " Content: ")); - + if (Configuration.DEBUG) + { + log.fine(" Content: "); + log.fine(Util.dumpString(content, " Content: ")); + } val = ber.read(); if (val.getTag() == 0) { if (!val.isConstructed()) throw new BEREncodingException("malformed ExtendedCertificatesAndCertificates"); - - log.finest(" ExtendedCertificatesAndCertificates: " + val); + if (Configuration.DEBUG) + log.fine(" ExtendedCertificatesAndCertificates: " + val); count = 0; val2 = ber.read(); List certs = new LinkedList(); @@ -271,7 +275,8 @@ public class PKCS7SignedData { Certificate cert = x509.generateCertificate(new ByteArrayInputStream(val2.getEncoded())); - log.finest(" Certificate: " + cert); + if (Configuration.DEBUG) + log.fine(" Certificate: " + cert); certs.add(cert); count += val2.getEncodedLength(); ber.skip(val2.getLength()); @@ -286,8 +291,8 @@ public class PKCS7SignedData { if (!val.isConstructed()) throw new BEREncodingException("malformed CertificateRevocationLists"); - - log.finest(" CertificateRevocationLists: " + val); + if (Configuration.DEBUG) + log.fine(" CertificateRevocationLists: " + val); count = 0; val2 = ber.read(); List crls = new LinkedList(); @@ -295,7 +300,8 @@ public class PKCS7SignedData (val.getLength() > 0 && val.getLength() > count)) { CRL crl = x509.generateCRL(new ByteArrayInputStream(val2.getEncoded())); - log.finest(" CRL: " + crl); + if (Configuration.DEBUG) + log.fine(" CRL: " + crl); crls.add(crl); count += val2.getEncodedLength(); ber.skip(val2.getLength()); @@ -309,8 +315,8 @@ public class PKCS7SignedData signerInfos = new HashSet(); if (!val.isConstructed()) throw new BEREncodingException("malformed SignerInfos"); - - log.finest(" SignerInfos: " + val); + if (Configuration.DEBUG) + log.fine(" SignerInfos: " + val); // FIXME read this more carefully. // Since we are just reading a file (probably) we just read until we diff --git a/gnu/java/security/pkcs/SignerInfo.java b/gnu/java/security/pkcs/SignerInfo.java index 7b38bfefd..662bcc3b7 100644 --- a/gnu/java/security/pkcs/SignerInfo.java +++ b/gnu/java/security/pkcs/SignerInfo.java @@ -37,6 +37,7 @@ exception statement from your version. */ package gnu.java.security.pkcs; +import gnu.classpath.Configuration; import gnu.java.security.OID; import gnu.java.security.ber.BER; import gnu.java.security.ber.BEREncodingException; @@ -50,7 +51,6 @@ import gnu.java.security.util.Util; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; - import java.math.BigInteger; import java.util.ArrayList; import java.util.logging.Logger; @@ -101,7 +101,8 @@ public class SignerInfo public SignerInfo(BERReader ber) throws IOException { DERValue val = ber.read(); - log.finest("SignerInfo: " + val); + if (Configuration.DEBUG) + log.fine("SignerInfo: " + val); if (!val.isConstructed()) throw new BEREncodingException("malformed SignerInfo"); @@ -110,13 +111,13 @@ public class SignerInfo throw new BEREncodingException("malformed Version"); version = (BigInteger) val.getValue(); - log.finest(" Version: " + version); + log.fine(" Version: " + version); val = ber.read(); if (!val.isConstructed()) throw new BEREncodingException("malformed IssuerAndSerialNumber"); - - log.finest(" IssuerAndSerialNumber: " + val); + if (Configuration.DEBUG) + log.fine(" IssuerAndSerialNumber: " + val); val = ber.read(); if (!val.isConstructed()) @@ -124,20 +125,22 @@ public class SignerInfo issuer = new X500Principal(val.getEncoded()); ber.skip(val.getLength()); - log.finest(" Issuer: " + issuer); + if (Configuration.DEBUG) + log.fine(" Issuer: " + issuer); val = ber.read(); if (val.getTag() != BER.INTEGER) throw new BEREncodingException("malformed SerialNumber"); serialNumber = (BigInteger) val.getValue(); - log.finest(" SerialNumber: " + serialNumber); + if (Configuration.DEBUG) + log.fine(" SerialNumber: " + serialNumber); val = ber.read(); if (!val.isConstructed()) throw new BEREncodingException("malformed DigestAlgorithmIdentifier"); - - log.finest(" DigestAlgorithmIdentifier: " + val); + if (Configuration.DEBUG) + log.fine(" DigestAlgorithmIdentifier: " + val); int count = 0; DERValue val2 = ber.read(); @@ -145,7 +148,8 @@ public class SignerInfo throw new BEREncodingException("malformed AlgorithmIdentifier"); digestAlgorithmId = (OID) val2.getValue(); - log.finest(" digestAlgorithm OID: " + digestAlgorithmId); + if (Configuration.DEBUG) + log.fine(" digestAlgorithm OID: " + digestAlgorithmId); if (BERValue.isIndefinite(val)) { @@ -170,10 +174,12 @@ public class SignerInfo else digestAlgorithmParams = null; - log.finest(" digestAlgorithm params: "); - log.finest(Util.dumpString(digestAlgorithmParams, - " digestAlgorithm params: ")); - + if (Configuration.DEBUG) + { + log.fine(" digestAlgorithm params: "); + log.fine(Util.dumpString(digestAlgorithmParams, + " digestAlgorithm params: ")); + } val = ber.read(); if (val.getTag() == 0) { @@ -187,21 +193,24 @@ public class SignerInfo else authenticatedAttributes = null; - log.finest(" AuthenticatedAttributes: "); - log.finest(Util.dumpString(authenticatedAttributes, - " AuthenticatedAttributes: ")); - + if (Configuration.DEBUG) + { + log.fine(" AuthenticatedAttributes: "); + log.fine(Util.dumpString(authenticatedAttributes, + " AuthenticatedAttributes: ")); + } if (!val.isConstructed()) throw new BEREncodingException("malformed DigestEncryptionAlgorithmIdentifier"); - - log.finest(" DigestEncryptionAlgorithmIdentifier: " + val); + if (Configuration.DEBUG) + log.fine(" DigestEncryptionAlgorithmIdentifier: " + val); count = 0; val2 = ber.read(); if (val2.getTag() != BER.OBJECT_IDENTIFIER) throw new BEREncodingException("malformed AlgorithmIdentifier"); digestEncryptionAlgorithmId = (OID) val2.getValue(); - log.finest(" digestEncryptionAlgorithm OID: " + digestEncryptionAlgorithmId); + if (Configuration.DEBUG) + log.fine(" digestEncryptionAlgorithm OID: " + digestEncryptionAlgorithmId); if (BERValue.isIndefinite(val)) { @@ -226,27 +235,33 @@ public class SignerInfo else digestEncryptionAlgorithmParams = null; - log.finest(" digestEncryptionAlgorithm params: "); - log.finest(Util.dumpString(digestEncryptionAlgorithmParams, - " digestEncryptionAlgorithm params: ")); - + if (Configuration.DEBUG) + { + log.fine(" digestEncryptionAlgorithm params: "); + log.fine(Util.dumpString(digestEncryptionAlgorithmParams, + " digestEncryptionAlgorithm params: ")); + } val = ber.read(); if (val.getTag() != BER.OCTET_STRING) throw new BEREncodingException("malformed EncryptedDigest"); encryptedDigest = (byte[]) val.getValue(); - log.finest(" EncryptedDigest: "); - log.finest(Util.dumpString(encryptedDigest, " EncryptedDigest: ")); - + if (Configuration.DEBUG) + { + log.fine(" EncryptedDigest: "); + log.fine(Util.dumpString(encryptedDigest, " EncryptedDigest: ")); + } if (ber.peek() == 1) unauthenticatedAttributes = ber.read().getEncoded(); else unauthenticatedAttributes = null; - log.finest(" UnauthenticatedAttributes: "); - log.finest(Util.dumpString(unauthenticatedAttributes, - " UnauthenticatedAttributes: ")); - + if (Configuration.DEBUG) + { + log.fine(" UnauthenticatedAttributes: "); + log.fine(Util.dumpString(unauthenticatedAttributes, + " UnauthenticatedAttributes: ")); + } if (ber.peek() == 0) ber.read(); } diff --git a/gnu/java/security/provider/PKIXCertPathValidatorImpl.java b/gnu/java/security/provider/PKIXCertPathValidatorImpl.java index 448a609ec..3680f2fae 100644 --- a/gnu/java/security/provider/PKIXCertPathValidatorImpl.java +++ b/gnu/java/security/provider/PKIXCertPathValidatorImpl.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.provider; +import gnu.classpath.Configuration; import gnu.java.security.OID; import gnu.java.security.Registry; import gnu.java.security.key.dss.DSSPublicKey; @@ -81,6 +82,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; +import java.util.logging.Logger; /** * An implementation of the Public Key Infrastructure's X.509 @@ -94,17 +96,7 @@ import java.util.Set; */ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi { - - // Constants. - // ------------------------------------------------------------------------- - - private static final boolean DEBUG = false; - private static void debug (String msg) - { - System.err.print (">> PKIXCertPathValidatorImpl: "); - System.err.println (msg); - } - + private static final Logger log = Logger.getLogger(PKIXCertPathValidatorImpl.class.getName()); public static final String ANY_POLICY = "2.5.29.32.0"; // Constructor. @@ -603,7 +595,8 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi boolean explicitPolicy) throws CertPathValidatorException { - if (DEBUG) debug("updatePolicyTree depth == " + depth); + if (Configuration.DEBUG) + log.fine("updatePolicyTree depth == " + depth); Set nodes = new HashSet(); LinkedList stack = new LinkedList(); Iterator current = null; @@ -614,15 +607,18 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi while (current.hasNext()) { PolicyNodeImpl p = (PolicyNodeImpl) current.next(); - if (DEBUG) debug("visiting node == " + p); + if (Configuration.DEBUG) + log.fine("visiting node == " + p); if (p.getDepth() == depth - 1) { - if (DEBUG) debug("added node"); + if (Configuration.DEBUG) + log.fine("added node"); nodes.add(p); } else { - if (DEBUG) debug("skipped node"); + if (Configuration.DEBUG) + log.fine("skipped node"); stack.addLast(current); current = p.getChildren(); } @@ -646,16 +642,21 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi else cp = Collections.EMPTY_LIST; boolean match = false; - if (DEBUG) debug("nodes are == " + nodes); - if (DEBUG) debug("cert policies are == " + cp); + if (Configuration.DEBUG) + { + log.fine("nodes are == " + nodes); + log.fine("cert policies are == " + cp); + } for (Iterator it = nodes.iterator(); it.hasNext(); ) { PolicyNodeImpl parent = (PolicyNodeImpl) it.next(); - if (DEBUG) debug("adding policies to " + parent); + if (Configuration.DEBUG) + log.fine("adding policies to " + parent); for (Iterator it2 = cp.iterator(); it2.hasNext(); ) { OID policy = (OID) it2.next(); - if (DEBUG) debug("trying to add policy == " + policy); + if (Configuration.DEBUG) + log.fine("trying to add policy == " + policy); if (policy.toString().equals(ANY_POLICY) && params.isAnyPolicyInhibited()) continue; @@ -691,13 +692,15 @@ public class PKIXCertPathValidatorImpl extends CertPathValidatorSpi private boolean checkExplicitPolicy (int depth, List explicitPolicies) { - if (DEBUG) debug ("checkExplicitPolicy depth=" + depth); + if (Configuration.DEBUG) + log.fine("checkExplicitPolicy depth=" + depth); for (Iterator it = explicitPolicies.iterator(); it.hasNext(); ) { int[] i = (int[]) it.next(); int caDepth = i[0]; int limit = i[1]; - if (DEBUG) debug (" caDepth=" + caDepth + " limit=" + limit); + if (Configuration.DEBUG) + log.fine(" caDepth=" + caDepth + " limit=" + limit); if (depth - caDepth >= limit) return true; } diff --git a/gnu/java/security/sig/rsa/EMSA_PSS.java b/gnu/java/security/sig/rsa/EMSA_PSS.java index c1c9760ed..0b93abab7 100644 --- a/gnu/java/security/sig/rsa/EMSA_PSS.java +++ b/gnu/java/security/sig/rsa/EMSA_PSS.java @@ -38,12 +38,13 @@ exception statement from your version. */ package gnu.java.security.sig.rsa; +import gnu.classpath.Configuration; import gnu.java.security.hash.HashFactory; import gnu.java.security.hash.IMessageDigest; import gnu.java.security.util.Util; -import java.io.PrintWriter; import java.util.Arrays; +import java.util.logging.Logger; /** * <p>An implementation of the EMSA-PSS encoding/decoding scheme.</p> @@ -70,26 +71,7 @@ import java.util.Arrays; */ public class EMSA_PSS implements Cloneable { - - // Debugging methods and variables - // ------------------------------------------------------------------------- - - private static final String NAME = "emsa-pss"; - - private static final boolean DEBUG = false; - - private static final int debuglevel = 5; - - private static final PrintWriter err = new PrintWriter(System.out, true); - - private static void debug(String s) - { - err.println(">>> " + NAME + ": " + s); - } - - // Constants and variables - // ------------------------------------------------------------------------- - + private static final Logger log = Logger.getLogger(EMSA_PSS.class.getName()); /** The underlying hash function to use with this instance. */ private IMessageDigest hash; @@ -202,10 +184,10 @@ public class EMSA_PSS implements Cloneable System.arraycopy(salt, 0, DB, emLen - sLen - hLen - 1, sLen); // 9. Let dbMask = MGF(H, emLen - hLen - 1). byte[] dbMask = MGF(H, emLen - hLen - 1); - if (DEBUG && debuglevel > 8) + if (Configuration.DEBUG) { - debug("dbMask (encode): " + Util.toString(dbMask)); - debug("DB (encode): " + Util.toString(DB)); + log.fine("dbMask (encode): " + Util.toString(dbMask)); + log.fine("DB (encode): " + Util.toString(DB)); } // 10. Let maskedDB = DB XOR dbMask. for (i = 0; i < DB.length; i++) @@ -244,12 +226,12 @@ public class EMSA_PSS implements Cloneable */ public boolean decode(byte[] mHash, byte[] EM, int emBits, int sLen) { - if (DEBUG && debuglevel > 8) + if (Configuration.DEBUG) { - debug("mHash: " + Util.toString(mHash)); - debug("EM: " + Util.toString(EM)); - debug("emBits: " + String.valueOf(emBits)); - debug("sLen: " + String.valueOf(sLen)); + log.fine("mHash: " + Util.toString(mHash)); + log.fine("EM: " + Util.toString(EM)); + log.fine("emBits: " + String.valueOf(emBits)); + log.fine("sLen: " + String.valueOf(sLen)); } if (sLen < 0) { @@ -262,19 +244,15 @@ public class EMSA_PSS implements Cloneable // 2. Let mHash = Hash(M), an octet string of length hLen. if (hLen != mHash.length) { - if (DEBUG && debuglevel > 8) - { - debug("hLen != mHash.length; hLen: " + String.valueOf(hLen)); - } + if (Configuration.DEBUG) + log.fine("hLen != mHash.length; hLen: " + String.valueOf(hLen)); throw new IllegalArgumentException("wrong hash"); } // 3. If emBits < 8.hLen + 8.sLen + 9, output 'decoding error' and stop. if (emBits < (8 * hLen + 8 * sLen + 9)) { - if (DEBUG && debuglevel > 8) - { - debug("emBits < (8hLen + 8sLen + 9); sLen: " + String.valueOf(sLen)); - } + if (Configuration.DEBUG) + log.fine("emBits < (8hLen + 8sLen + 9); sLen: " + String.valueOf(sLen)); throw new IllegalArgumentException("decoding error"); } int emLen = (emBits + 7) / 8; @@ -282,10 +260,8 @@ public class EMSA_PSS implements Cloneable // output 'inconsistent' and stop. if ((EM[EM.length - 1] & 0xFF) != 0xBC) { - if (DEBUG && debuglevel > 8) - { - debug("EM does not end with 0xBC"); - } + if (Configuration.DEBUG) + log.fine("EM does not end with 0xBC"); return false; } // 5. Let maskedDB be the leftmost emLen ? hLen ? 1 octets of EM, and let @@ -294,10 +270,8 @@ public class EMSA_PSS implements Cloneable // maskedDB are not all equal to zero, output 'inconsistent' and stop. if ((EM[0] & (0xFF << (8 - (8 * emLen - emBits)))) != 0) { - if (DEBUG && debuglevel > 8) - { - debug("Leftmost 8emLen - emBits bits of EM are not 0s"); - } + if (Configuration.DEBUG) + log.fine("Leftmost 8emLen - emBits bits of EM are not 0s"); return false; } byte[] DB = new byte[emLen - hLen - 1]; @@ -314,10 +288,10 @@ public class EMSA_PSS implements Cloneable } // 9. Set the leftmost 8.emLen ? emBits bits of DB to zero. DB[0] &= (0xFF >>> (8 * emLen - emBits)); - if (DEBUG && debuglevel > 8) + if (Configuration.DEBUG) { - debug("dbMask (decode): " + Util.toString(dbMask)); - debug("DB (decode): " + Util.toString(DB)); + log.fine("dbMask (decode): " + Util.toString(dbMask)); + log.fine("DB (decode): " + Util.toString(DB)); } // 10. If the emLen -hLen -sLen -2 leftmost octets of DB are not zero or // if the octet at position emLen -hLen -sLen -1 is not equal to 0x01, @@ -329,20 +303,16 @@ public class EMSA_PSS implements Cloneable { if (DB[i] != 0) { - if (DEBUG && debuglevel > 8) - { - debug("DB[" + String.valueOf(i) + "] != 0x00"); - } + if (Configuration.DEBUG) + log.fine("DB[" + String.valueOf(i) + "] != 0x00"); return false; } } if (DB[i] != 0x01) { // i == emLen -hLen -sLen -2 - if (DEBUG && debuglevel > 8) - { - debug("DB's byte at position (emLen -hLen -sLen -2); i.e. " - + String.valueOf(i) + " is not 0x01"); - } + if (Configuration.DEBUG) + log.fine("DB's byte at position (emLen -hLen -sLen -2); i.e. " + + String.valueOf(i) + " is not 0x01"); return false; } // 11. Let salt be the last sLen octets of DB. diff --git a/gnu/java/security/sig/rsa/RSAPSSSignature.java b/gnu/java/security/sig/rsa/RSAPSSSignature.java index 7ec62568a..3e9cad452 100644 --- a/gnu/java/security/sig/rsa/RSAPSSSignature.java +++ b/gnu/java/security/sig/rsa/RSAPSSSignature.java @@ -38,18 +38,19 @@ exception statement from your version. */ package gnu.java.security.sig.rsa; +import gnu.classpath.Configuration; import gnu.java.security.Registry; import gnu.java.security.hash.HashFactory; import gnu.java.security.hash.IMessageDigest; import gnu.java.security.sig.BaseSignature; import gnu.java.security.util.Util; -import java.io.PrintWriter; import java.math.BigInteger; import java.security.PrivateKey; import java.security.PublicKey; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; +import java.util.logging.Logger; /** * <p>The RSA-PSS signature scheme is a public-key encryption scheme combining @@ -73,26 +74,7 @@ import java.security.interfaces.RSAPublicKey; */ public class RSAPSSSignature extends BaseSignature { - - // Debugging methods and variables - // ------------------------------------------------------------------------- - - private static final String NAME = "rsa-pss"; - - private static final boolean DEBUG = false; - - private static final int debuglevel = 1; - - private static final PrintWriter err = new PrintWriter(System.out, true); - - private static void debug(String s) - { - err.println(">>> " + NAME + ": " + s); - } - - // Constants and variables - // ------------------------------------------------------------------------- - + private static final Logger log = Logger.getLogger(RSAPSSSignature.class.getName()); /** The underlying EMSA-PSS instance for this object. */ private EMSA_PSS pss; @@ -201,10 +183,8 @@ public class RSAPSSSignature extends BaseSignature byte[] salt = new byte[sLen]; this.nextRandomBytes(salt); byte[] EM = pss.encode(md.digest(), modBits - 1, salt); - if (DEBUG && debuglevel > 8) - { - debug("EM (sign): " + Util.toString(EM)); - } + if (Configuration.DEBUG) + log.fine("EM (sign): " + Util.toString(EM)); // 2. Convert the encoded message EM to an integer message representative // m (see Section 1.2.2): m = OS2IP(EM). BigInteger m = new BigInteger(1, EM); @@ -262,10 +242,8 @@ public class RSAPSSSignature extends BaseSignature int emBits = modBits - 1; int emLen = (emBits + 7) / 8; byte[] EM = m.toByteArray(); - if (DEBUG && debuglevel > 8) - { - debug("EM (verify): " + Util.toString(EM)); - } + if (Configuration.DEBUG) + log.fine("EM (verify): " + Util.toString(EM)); if (EM.length > emLen) { return false; diff --git a/gnu/java/security/util/Base64.java b/gnu/java/security/util/Base64.java index f9998c38f..6c4657b7c 100644 --- a/gnu/java/security/util/Base64.java +++ b/gnu/java/security/util/Base64.java @@ -38,8 +38,10 @@ exception statement from your version. */ package gnu.java.security.util; -import java.io.PrintWriter; +import gnu.classpath.Configuration; + import java.io.UnsupportedEncodingException; +import java.util.logging.Logger; /** * Most of this implementation is from Robert Harder's public domain Base64 @@ -47,26 +49,7 @@ import java.io.UnsupportedEncodingException; */ public class Base64 { - - // Debugging methods and variables - // ------------------------------------------------------------------------- - - private static final String NAME = "Base64"; - - private static final boolean DEBUG = true; - - private static final int debuglevel = 9; - - private static final PrintWriter err = new PrintWriter(System.out, true); - - private static void debug(String s) - { - err.println(">>> " + NAME + ": " + s); - } - - // Constants and variables - // ------------------------------------------------------------------------- - + private static final Logger log = Logger.getLogger(Base64.class.getName()); /** Maximum line length (76) of Base64 output. */ private static final int MAX_LINE_LENGTH = 76; @@ -383,12 +366,12 @@ public class Base64 } catch (Exception x) { - if (DEBUG && debuglevel > 8) + if (Configuration.DEBUG) { - debug("" + src[sOffset] + ": " + (DECODABET[src[sOffset]])); - debug("" + src[sOffset + 1] + ": " + (DECODABET[src[sOffset + 1]])); - debug("" + src[sOffset + 2] + ": " + (DECODABET[src[sOffset + 2]])); - debug("" + src[sOffset + 3] + ": " + (DECODABET[src[sOffset + 3]])); + log.fine("" + src[sOffset ] + ": " + (DECODABET[src[sOffset ]])); + log.fine("" + src[sOffset + 1] + ": " + (DECODABET[src[sOffset + 1]])); + log.fine("" + src[sOffset + 2] + ": " + (DECODABET[src[sOffset + 2]])); + log.fine("" + src[sOffset + 3] + ": " + (DECODABET[src[sOffset + 3]])); } return -1; } diff --git a/gnu/java/security/util/Prime2.java b/gnu/java/security/util/Prime2.java index 6e46f5fca..49e4072f6 100644 --- a/gnu/java/security/util/Prime2.java +++ b/gnu/java/security/util/Prime2.java @@ -38,37 +38,20 @@ exception statement from your version. */ package gnu.java.security.util; -import java.io.PrintWriter; +import gnu.classpath.Configuration; + import java.lang.ref.WeakReference; import java.math.BigInteger; import java.util.Map; import java.util.WeakHashMap; +import java.util.logging.Logger; /** * <p>A collection of prime number related utilities used in this library.</p> */ public class Prime2 { - - // Debugging methods and variables - // ------------------------------------------------------------------------- - - private static final String NAME = "prime"; - - private static final boolean DEBUG = false; - - private static final int debuglevel = 5; - - private static final PrintWriter err = new PrintWriter(System.out, true); - - private static void debug(String s) - { - err.println(">>> " + NAME + ": " + s); - } - - // Constants and variables - // ------------------------------------------------------------------------- - + private static final Logger log = Logger.getLogger(Prime2.class.getName()); private static final int DEFAULT_CERTAINTY = 20; // XXX is this a good value? private static final BigInteger ZERO = BigInteger.ZERO; @@ -116,7 +99,7 @@ public class Prime2 } } time += System.currentTimeMillis(); - if (DEBUG && debuglevel > 8) + if (Configuration.DEBUG) { StringBuffer sb; for (int i = 0; i < (SMALL_PRIME_COUNT / 10); i++) @@ -126,13 +109,13 @@ public class Prime2 { sb.append(String.valueOf(SMALL_PRIME[i * 10 + j])).append(" "); } - debug(sb.toString()); + log.fine(sb.toString()); } } - if (DEBUG && debuglevel > 4) + if (Configuration.DEBUG) { - debug("Generating first " + String.valueOf(SMALL_PRIME_COUNT) - + " primes took: " + String.valueOf(time) + " ms."); + log.fine("Generating first " + String.valueOf(SMALL_PRIME_COUNT) + + " primes took: " + String.valueOf(time) + " ms."); } } @@ -169,17 +152,13 @@ public class Prime2 prime = SMALL_PRIME[i]; if (w.mod(prime).equals(ZERO)) { - if (DEBUG && debuglevel > 4) - { - debug(prime.toString(16) + " | " + w.toString(16) + "..."); - } + if (Configuration.DEBUG) + log.fine(prime.toString(16) + " | " + w.toString(16) + "..."); return true; } } - if (DEBUG && debuglevel > 4) - { - debug(w.toString(16) + " has no small prime divisors..."); - } + if (Configuration.DEBUG) + log.fine(w.toString(16) + " has no small prime divisors..."); return false; } @@ -361,8 +340,8 @@ public class Prime2 for (int i = 0; i < SMALL_PRIME_COUNT; i++) if (w.equals(SMALL_PRIME[i])) { - if (DEBUG && debuglevel > 4) - debug(w.toString(16) + " is a small prime"); + if (Configuration.DEBUG) + log.fine(w.toString(16) + " is a small prime"); return true; } @@ -370,16 +349,16 @@ public class Prime2 WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { - if (DEBUG && debuglevel > 4) - debug("found in known primes"); + if (Configuration.DEBUG) + log.fine("found in known primes"); return true; } // trial division with first 1000 primes if (hasSmallPrimeDivisor(w)) { - if (DEBUG && debuglevel > 4) - debug(w.toString(16) + " has a small prime divisor. Rejected..."); + if (Configuration.DEBUG) + log.fine(w.toString(16) + " has a small prime divisor. Rejected..."); return false; } @@ -411,7 +390,7 @@ public class Prime2 private static final void debugBI(String msg, BigInteger bn) { - if (DEBUG && debuglevel > 4) - debug("*** " + msg + ": 0x" + bn.toString(16)); + if (Configuration.DEBUG) + log.fine("*** " + msg + ": 0x" + bn.toString(16)); } } diff --git a/gnu/java/security/x509/X509CRL.java b/gnu/java/security/x509/X509CRL.java index 5b2d3b141..d8cbe988b 100644 --- a/gnu/java/security/x509/X509CRL.java +++ b/gnu/java/security/x509/X509CRL.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.x509; +import gnu.classpath.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/gnu/java/security/x509/X509CRLEntry.java b/gnu/java/security/x509/X509CRLEntry.java index a3bcfdea8..f3f3a93d6 100644 --- a/gnu/java/security/x509/X509CRLEntry.java +++ b/gnu/java/security/x509/X509CRLEntry.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.x509; +import gnu.classpath.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/gnu/java/security/x509/ext/Extension.java b/gnu/java/security/x509/ext/Extension.java index 97097a2f3..4deafe23e 100644 --- a/gnu/java/security/x509/ext/Extension.java +++ b/gnu/java/security/x509/ext/Extension.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.security.x509.ext; +import gnu.classpath.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) |
