commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commit-cp] classpath/gnu javax/crypto/key/dhGnuDHKeyPairGe...


From: Raif S. Naffah
Subject: [commit-cp] classpath/gnu javax/crypto/key/dhGnuDHKeyPairGe...
Date: Sun, 11 Jun 2006 12:14:47 +0000

CVSROOT:        /cvsroot/classpath
Module name:    classpath
Changes by:     Raif S. Naffah <raif>   06/06/11 12:14:46

Modified files:
        gnu/javax/crypto/key/dh: GnuDHKeyPairGenerator.java 
        gnu/javax/security/auth/login: GnuConfiguration.java 
                                       ConfigFileParser.java 
        gnu/javax/crypto/cipher: Twofish.java BaseCipher.java 
                                 Rijndael.java Anubis.java Khazad.java 
        gnu/javax/crypto/jce/keyring: GnuKeyring.java 
        gnu/javax/crypto/keyring: GnuPublicKeyring.java 
                                  GnuPrivateKeyring.java Entry.java 
                                  PasswordEncryptedEntry.java 
                                  PasswordAuthenticatedEntry.java 
                                  EnvelopeEntry.java 
        gnu/java/security/key/rsa: GnuRSAPrivateKey.java 
                                   RSAKeyPairPKCS8Codec.java 
                                   RSAKeyPairX509Codec.java 
                                   RSAKeyPairGenerator.java 
        gnu/javax/crypto/jce/prng: UMacRandomSpi.java ICMRandomSpi.java 
        gnu/java/security/x509: X509CRLEntry.java X509CRL.java 
        gnu/javax/crypto/pad: TBC.java PKCS7.java PKCS1_V1_5.java 
                              BasePad.java 
        gnu/java/security/hash: Whirlpool.java 
        gnu/javax/crypto/prng: CSPRNG.java 
        gnu/java/security/key/dss: DSSPrivateKey.java 
                                   DSSKeyPairPKCS8Codec.java 
                                   DSSKeyPairGenerator.java 
        gnu/java/security/x509/ext: Extension.java 
        gnu/javax/crypto/sasl/srp: SRPServer.java SRPClient.java 
        gnu/java/security/util: Prime2.java Base64.java 
        gnu/javax/crypto/key/srp6: SRPKeyPairGenerator.java 
        gnu/java/security/sig/rsa: EMSA_PSS.java RSAPSSSignature.java 
        gnu/java/security/pkcs: PKCS7SignedData.java SignerInfo.java 
        gnu/java/security/jce/sig: SignatureAdapter.java 
                                   EncodedKeyFactory.java 
        gnu/java/security: Properties.java 
        gnu/java/security/provider: PKIXCertPathValidatorImpl.java 
        gnu/javax/crypto/sasl: SaslInputStream.java 
                               SaslOutputStream.java 
        .              : ChangeLog 
        gnu/javax/crypto/mac: OMAC.java 

Log message:
        2006-06-11  Raif S. Naffah  <address@hidden>
        
                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.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java?cvsroot=classpath&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/security/auth/login/GnuConfiguration.java?cvsroot=classpath&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/security/auth/login/ConfigFileParser.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/cipher/Twofish.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/cipher/BaseCipher.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/cipher/Rijndael.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/cipher/Anubis.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/cipher/Khazad.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/keyring/Entry.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/keyring/PasswordEncryptedEntry.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/keyring/EnvelopeEntry.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/key/rsa/GnuRSAPrivateKey.java?cvsroot=classpath&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java?cvsroot=classpath&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java?cvsroot=classpath&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/key/rsa/RSAKeyPairGenerator.java?cvsroot=classpath&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/jce/prng/UMacRandomSpi.java?cvsroot=classpath&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/jce/prng/ICMRandomSpi.java?cvsroot=classpath&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/x509/X509CRLEntry.java?cvsroot=classpath&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/x509/X509CRL.java?cvsroot=classpath&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/pad/TBC.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/pad/PKCS7.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/pad/PKCS1_V1_5.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/pad/BasePad.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/hash/Whirlpool.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/prng/CSPRNG.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/key/dss/DSSPrivateKey.java?cvsroot=classpath&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java?cvsroot=classpath&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/key/dss/DSSKeyPairGenerator.java?cvsroot=classpath&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/x509/ext/Extension.java?cvsroot=classpath&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/sasl/srp/SRPClient.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/util/Prime2.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/util/Base64.java?cvsroot=classpath&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/sig/rsa/EMSA_PSS.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/sig/rsa/RSAPSSSignature.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/pkcs/PKCS7SignedData.java?cvsroot=classpath&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/pkcs/SignerInfo.java?cvsroot=classpath&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/jce/sig/SignatureAdapter.java?cvsroot=classpath&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/jce/sig/EncodedKeyFactory.java?cvsroot=classpath&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/Properties.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/security/provider/PKIXCertPathValidatorImpl.java?cvsroot=classpath&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/sasl/SaslInputStream.java?cvsroot=classpath&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/sasl/SaslOutputStream.java?cvsroot=classpath&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7770&r2=1.7771
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/crypto/mac/OMAC.java?cvsroot=classpath&r1=1.2&r2=1.3

Patches:
Index: javax/crypto/key/dh/GnuDHKeyPairGenerator.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- javax/crypto/key/dh/GnuDHKeyPairGenerator.java      22 Apr 2006 17:57:19 
-0000      1.5
+++ javax/crypto/key/dh/GnuDHKeyPairGenerator.java      11 Jun 2006 12:14:43 
-0000      1.6
@@ -38,18 +38,19 @@
 
 package gnu.javax.crypto.key.dh;
 
+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;
 import java.security.PublicKey;
 import java.security.SecureRandom;
 import java.util.Map;
+import java.util.logging.Logger;
 
 import javax.crypto.spec.DHGenParameterSpec;
 import javax.crypto.spec.DHParameterSpec;
@@ -66,26 +67,7 @@
  */
 public class GnuDHKeyPairGenerator implements IKeyPairGenerator
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = "dh";
-
-  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(GnuDHKeyPairGenerator.class.getName());
   /**
    * Property name of an optional address@hidden SecureRandom} instance to 
use. The
    * default is to use a classloader singleton from address@hidden PRNG}.
@@ -240,14 +222,14 @@
         p = params[RFC2631.DH_PARAMS_P];
         j = params[RFC2631.DH_PARAMS_J];
         g = params[RFC2631.DH_PARAMS_G];
-        if (DEBUG && debuglevel > 0)
+        if (Configuration.DEBUG)
           {
-            debug("seed: 0x" + seed.toString(16));
-            debug("counter: " + counter.intValue());
-            debug("q: 0x" + q.toString(16));
-            debug("p: 0x" + p.toString(16));
-            debug("j: 0x" + j.toString(16));
-            debug("g: 0x" + g.toString(16));
+            log.fine("seed: 0x" + seed.toString(16));
+            log.fine("counter: " + counter.intValue());
+            log.fine("q: 0x" + q.toString(16));
+            log.fine("p: 0x" + p.toString(16));
+            log.fine("j: 0x" + j.toString(16));
+            log.fine("g: 0x" + g.toString(16));
           }
       }
 

Index: javax/security/auth/login/GnuConfiguration.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/security/auth/login/GnuConfiguration.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- javax/security/auth/login/GnuConfiguration.java     15 Jan 2006 19:42:52 
-0000      1.1
+++ javax/security/auth/login/GnuConfiguration.java     11 Jun 2006 12:14:43 
-0000      1.2
@@ -50,6 +50,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.logging.Logger;
 
 import javax.security.auth.AuthPermission;
 import javax.security.auth.login.AppConfigurationEntry;
@@ -127,12 +128,7 @@
  */
 public final class GnuConfiguration extends Configuration
 {
-  // Constants and fields
-  // --------------------------------------------------------------------------
-
-  private static final boolean DEBUG = true;
-  private static final void debug(String m) {if (DEBUG) 
System.err.println(m);};
-
+  private static final Logger log = 
Logger.getLogger(GnuConfiguration.class.getName());
   /**
    * The internal map of login modules keyed by application name. Each entry in
    * this map is a address@hidden List} of address@hidden 
AppConfigurationEntry}s for that
@@ -179,7 +175,8 @@
     if (loginModules == null || loginModules.size() == 0)
       return null;
 
-    debug("DEBUG: " + appName + " -> " + loginModules.size() + " entry(ies)");
+    if (gnu.classpath.Configuration.DEBUG)
+      log.fine(appName + " -> " + loginModules.size() + " entry(ies)");
     return (AppConfigurationEntry[]) loginModules.toArray(new 
AppConfigurationEntry[0]);
   }
 
@@ -193,7 +190,7 @@
    * @throws SecurityException if the caller does not have an
    * address@hidden AuthPermission} for the action named
    * <code>refreshLoginConfiguration</code>.
-   * @see address@hidden AuthPermission}
+   * @see AuthPermission
    */
   public void refresh()
   {
@@ -215,13 +212,25 @@
   private void init()
   {
     if (processSecurityProperties())
-      debug(" INFO: Using login configuration defined by Security 
property(ies)");
+      {
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("Using login configuration defined by Security 
property(ies)");
+      }
     else if (processSystemProperty())
-      debug(" INFO: Using login configuration defined by System property");
+      {
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("Using login configuration defined by System property");
+      }
     else if (processUserHome())
-      debug(" INFO: Using login configuration defined in ${user.home}");
+      {
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("Using login configuration defined in ${user.home}");
+      }
     else
-      debug(" WARN: No login configuration file found");
+      {
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("No login configuration file found");
+      }
   }
 
   /**
@@ -249,7 +258,8 @@
           s = s.trim();
           if (s.length() != 0)
             {
-              debug("DEBUG: java.security.auth.login.config.url." + counter
+              if (gnu.classpath.Configuration.DEBUG)
+                log.fine("java.security.auth.login.config.url." + counter
                     + " = " + s);
               parseConfig(getInputStreamFromURL(s));
               result = true;
@@ -257,7 +267,8 @@
         }
       catch (Throwable t)
         {
-          debug(" WARN: Exception while handling Security property at #"
+          if (gnu.classpath.Configuration.DEBUG)
+            log.fine("Exception while handling Security property at #"
                 + counter + ". Continue: " + t);
         }
     return result;
@@ -287,7 +298,8 @@
       }
     catch (MalformedURLException x)
       {
-        debug(" WARN: Failed opening as URL: " + s + ". Will try as File");
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("Failed opening as URL: " + s + ". Will try as File");
         result = new FileInputStream(s);
       }
     return result;
@@ -311,7 +323,8 @@
             s = s.trim();
             if (s.length() != 0)
               {
-                debug("DEBUG: java.security.auth.login.config = " + s);
+                if (gnu.classpath.Configuration.DEBUG)
+                  log.fine("java.security.auth.login.config = " + s);
                 parseConfig(getInputStreamFromURL(s));
                 result = true;
               }
@@ -319,7 +332,8 @@
       }
     catch (Throwable t)
       {
-        debug(" WARN: Exception while handling System property. Continue: " + 
t);
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("Exception while handling System property. Continue: " + t);
       }
     return result;
   }
@@ -349,7 +363,8 @@
 
         if (jaasFile == null)
           {
-            debug(" WARN: Login Configuration file, in " + userHome
+            if (gnu.classpath.Configuration.DEBUG)
+              log.fine("Login Configuration file, in " + userHome
                     + ", does not exist or is inaccessible");
             return result;
           }
@@ -360,7 +375,8 @@
       }
     catch (Throwable t)
       {
-        debug(" WARN: Exception while handling ${user.home}: " + t);
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("Exception (ignored) while handling ${user.home}: " + t);
       }
     return result;
   }
@@ -397,54 +413,54 @@
     String uh = System.getProperty("user.home");
     if (uh == null || uh.trim().length() == 0)
       {
-        debug(" WARN: User home path is not set or is empty");
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("User home path is not set or is empty");
         return null;
       }
-
     uh = uh.trim();
     File result = new File(uh);
-    if (!result.exists())
+    if (! result.exists())
       {
-        debug(" WARN: User home '" + uh + "' does not exist");
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("User home '" + uh + "' does not exist");
         return null;
       }
-
-    if (!result.isDirectory())
+    if (! result.isDirectory())
       {
-        debug(" WARN: User home '" + uh + "' is not a directory");
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("User home '" + uh + "' is not a directory");
         return null;
       }
-
-    if (!result.canRead())
+    if (! result.canRead())
       {
-        debug(" WARN: User home '" + uh + "' is not readable");
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("User home '" + uh + "' is not readable");
         return null;
       }
-
     return result;
   }
 
   private File getConfigFromUserHome(File userHome, String fileName)
   {
     File result = new File(userHome, fileName);
-    if (!result.exists())
+    if (! result.exists())
       {
-        debug(" WARN: File '" + fileName + "' does not exist in user's home");
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("File '" + fileName + "' does not exist in user's home");
         return null;
       }
-
-    if (!result.isFile())
+    if (! result.isFile())
       {
-        debug(" WARN: File '" + fileName + "' in user's home is not a file");
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("File '" + fileName + "' in user's home is not a file");
         return null;
       }
-
-    if (!result.canRead())
+    if (! result.canRead())
       {
-        debug(" WARN: File '" + fileName + "' in user's home is not readable");
+        if (gnu.classpath.Configuration.DEBUG)
+          log.fine("File '" + fileName + "' in user's home is not readable");
         return null;
       }
-
     return result;
   }
 }

Index: javax/security/auth/login/ConfigFileParser.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/security/auth/login/ConfigFileParser.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- javax/security/auth/login/ConfigFileParser.java     11 Jun 2006 00:05:10 
-0000      1.3
+++ javax/security/auth/login/ConfigFileParser.java     11 Jun 2006 12:14:43 
-0000      1.4
@@ -38,12 +38,15 @@
 
 package gnu.javax.security.auth.login;
 
+import gnu.classpath.Configuration;
+
 import java.io.IOException;
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.logging.Logger;
 
 import javax.security.auth.login.AppConfigurationEntry;
 
@@ -88,26 +91,12 @@
  */
 public final class ConfigFileParser
 {
-  // Constants and fields
-  // --------------------------------------------------------------------------
-
-  private static final boolean DEBUG = false;
-  private static final void debug(String m) {if (DEBUG) 
System.err.println(m);};
-
+  private static final Logger log = 
Logger.getLogger(ConfigFileParser.class.getName());
   private ConfigFileTokenizer cft;
   private Map map = new HashMap();
 
-  // Constructor(s)
-  // --------------------------------------------------------------------------
-
   // default 0-arguments constructor
 
-  // Class methods
-  // --------------------------------------------------------------------------
-
-  // Instance methods
-  // --------------------------------------------------------------------------
-
   /**
    * Returns the parse result as a address@hidden Map} where the keys are 
application
    * names, and the entries are address@hidden List}s of address@hidden 
AppConfigurationEntry}
@@ -161,7 +150,8 @@
       }
 
     String appName = cft.sval;
-    debug("DEBUG: APP_NAME_OR_OTHER = " + appName);
+    if (Configuration.DEBUG)
+      log.fine("APP_NAME_OR_OTHER = " + appName);
     if (cft.nextToken() != '{')
       abort("Missing '{' after APP_NAME_OR_OTHER");
 
@@ -202,13 +192,15 @@
       }
 
     String clazz = validateClassName(cft.sval);
-    debug("DEBUG: MODULE_CLASS = " + clazz);
+    if (Configuration.DEBUG)
+      log.fine("MODULE_CLASS = " + clazz);
 
     if (cft.nextToken() != ConfigFileTokenizer.TT_WORD)
       abort("Was expecting FLAG but found none");
 
     String flag = cft.sval;
-    debug("DEBUG: FLAG = " + flag);
+    if (Configuration.DEBUG)
+      log.fine("DEBUG: FLAG = " + flag);
     AppConfigurationEntry.LoginModuleControlFlag f = null;
     if (flag.equalsIgnoreCase("required"))
       f = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
@@ -230,32 +222,39 @@
           abort("Was expecting PARAM_NAME but got '" + ((char) c) + "'");
 
         paramName = cft.sval;
-        debug("DEBUG: PARAM_NAME = " + paramName);
+        if (Configuration.DEBUG)
+          log.fine("PARAM_NAME = " + paramName);
         if (cft.nextToken() != '=')
           abort("Missing '=' after PARAM_NAME");
 
         c = cft.nextToken();
         if (c != '"' && c != '\'')
-          debug(" WARN: Was expecting a quoted string but got no quote " +
-                "character. Assume unquoted string");
-
+          {
+          if (Configuration.DEBUG)
+            log.fine("Was expecting a quoted string but got no quote 
character."
+                     + " Assume unquoted string");
+          }
         paramValue = expandParamValue(cft.sval);
-        debug("DEBUG: PARAM_VALUE = " + paramValue);
+        if (Configuration.DEBUG)
+          log.fine("PARAM_VALUE = " + paramValue);
         options.put(paramName, paramValue);
 
         c = cft.nextToken();
       }
-
     AppConfigurationEntry ace = new AppConfigurationEntry(clazz, f, options);
-    debug("DEBUG: LOGIN_MODULE_ENTRY = " + ace);
+    if (Configuration.DEBUG)
+      log.fine("LOGIN_MODULE_ENTRY = " + ace);
     listOfACEs.add(ace);
     return true;
   }
 
   private void abort(String m) throws IOException
   {
-    debug("ERROR: " + m);
-    debug("DEBUG: Map (so far) = " + String.valueOf(map));
+    if (Configuration.DEBUG)
+      {
+        log.fine(m);
+        log.fine("Map (so far) = " + String.valueOf(map));
+      }
     throw new IOException(m);
   }
 
@@ -312,14 +311,17 @@
             int j = s.indexOf("}", i + 2);
             if (j == -1)
               {
-                debug(" WARN: Found a ${ prefix with no } suffix. Ignore");
+                if (Configuration.DEBUG)
+                  log.fine("Found a ${ prefix with no } suffix. Ignore");
                 break;
               }
 
             String sysPropName = s.substring(i + 2, j);
-            debug("DEBUG: Found a reference to System property " + 
sysPropName);
+            if (Configuration.DEBUG)
+              log.fine("Found a reference to System property " + sysPropName);
             String sysPropValue = System.getProperty(sysPropName);
-            debug("DEBUG: Resolved " + sysPropName + " to '" + sysPropValue + 
"'");
+            if (Configuration.DEBUG)
+              log.fine("Resolved " + sysPropName + " to '" + sysPropValue + 
"'");
             if (sysPropValue != null)
               {
                 result = s.substring(0, i) + sysPropValue + s.substring(j + 1);
@@ -331,7 +333,8 @@
       }
     catch (Exception x)
       {
-        debug(" WARN: Exception while expanding " + s + ". Ignore: " + x);
+        if (Configuration.DEBUG)
+          log.fine("Exception (ignored) while expanding " + s + ": " + x);
       }
 
     return result;

Index: javax/crypto/cipher/Twofish.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/cipher/Twofish.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/cipher/Twofish.java    21 Apr 2006 10:52:26 -0000      1.2
+++ javax/crypto/cipher/Twofish.java    11 Jun 2006 12:14:43 -0000      1.3
@@ -38,14 +38,15 @@
 
 package gnu.javax.crypto.cipher;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.util.Util;
 
-//import java.io.PrintWriter;
 import java.security.InvalidKeyException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.logging.Logger;
 
 /**
  * <p>Twofish is a balanced 128-bit Feistel cipher, consisting of 16 rounds. In
@@ -68,23 +69,7 @@
  */
 public final class Twofish extends BaseCipher
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  //   private static final String NAME = "twofish";
-  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(String s) {
-  //      err.println(">>> "+NAME+": "+s);
-  //   }
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
+  private static final Logger log = Logger.getLogger(Twofish.class.getName());
   private static final int DEFAULT_BLOCK_SIZE = 16; // in bytes
 
   private static final int DEFAULT_KEY_SIZE = 16; // in bytes
@@ -265,62 +250,43 @@
 
       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("MDS[0][]:");
+          log.fine("Static Data");
+          log.fine("MDS[0][]:");
+          StringBuilder sb;
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 4; j++)
-                {
-                  System.out.print("0x" + Util.toString(MDS[0][i * 4 + j])
-                                   + ", ");
+                sb.append("0x").append(Util.toString(MDS[0][i * 4 + 
j])).append(", ");
+              log.fine(sb.toString());
                 }
-              System.out.println();
-            }
-
-          System.out.println();
-          System.out.println("MDS[1][]:");
+          log.fine("MDS[1][]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 4; j++)
-                {
-                  System.out.print("0x" + Util.toString(MDS[1][i * 4 + j])
-                                   + ", ");
+                sb.append("0x").append(Util.toString(MDS[1][i * 4 + 
j])).append(", ");
+              log.fine(sb.toString());
                 }
-              System.out.println();
-            }
-
-          System.out.println();
-          System.out.println("MDS[2][]:");
+          log.fine("MDS[2][]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 4; j++)
-                {
-                  System.out.print("0x" + Util.toString(MDS[2][i * 4 + j])
-                                   + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(MDS[2][i * 4 + 
j])).append(", ");
+              log.fine(sb.toString());
             }
-
-          System.out.println();
-          System.out.println("MDS[3][]:");
+          log.fine("MDS[3][]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 4; j++)
-                {
-                  System.out.print("0x" + Util.toString(MDS[3][i * 4 + j])
-                                   + ", ");
+                sb.append("0x").append(Util.toString(MDS[3][i * 4 + 
j])).append(", ");
+              log.fine(sb.toString());
                 }
-              System.out.println();
-            }
-
-          System.out.println();
-          System.out.println("Total initialization time: " + time + " ms.");
-          System.out.println();
+          log.fine("Total initialization time: " + time + " ms.");
         }
     }
 
@@ -630,64 +596,49 @@
                                              ^ b3(k0)];
           }
       }
-
-    if (DEBUG && debuglevel > 7)
+    if (Configuration.DEBUG)
       {
-        System.out.println("S-box[]:");
+        StringBuilder sb;
+        log.fine("S-box[]:");
         for (i = 0; i < 64; i++)
           {
+            sb = new StringBuilder();
             for (j = 0; j < 4; j++)
-              {
-                System.out.print("0x" + Util.toString(sBox[i * 4 + j]) + ", ");
-              }
-            System.out.println();
+              sb.append("0x").append(Util.toString(sBox[i * 4 + j])).append(", 
");
+            log.fine(sb.toString());
           }
-        System.out.println();
+        log.fine("");
         for (i = 0; i < 64; i++)
           {
+            sb = new StringBuilder();
             for (j = 0; j < 4; j++)
-              {
-                System.out.print("0x" + Util.toString(sBox[256 + i * 4 + j])
-                                 + ", ");
-              }
-            System.out.println();
+              sb.append("0x").append(Util.toString(sBox[256 + i * 4 + 
j])).append(", ");
+            log.fine(sb.toString());
           }
-        System.out.println();
+        log.fine("");
         for (i = 0; i < 64; i++)
           {
+            sb = new StringBuilder();
             for (j = 0; j < 4; j++)
-              {
-                System.out.print("0x" + Util.toString(sBox[512 + i * 4 + j])
-                                 + ", ");
-              }
-            System.out.println();
+              sb.append("0x").append(Util.toString(sBox[512 + i * 4 + 
j])).append(", ");
+            log.fine(sb.toString());
           }
-        System.out.println();
+        log.fine("");
         for (i = 0; i < 64; i++)
           {
+            sb = new StringBuilder();
             for (j = 0; j < 4; j++)
-              {
-                System.out.print("0x" + Util.toString(sBox[768 + i * 4 + j])
-                                 + ", ");
-              }
-            System.out.println();
+              sb.append("0x").append(Util.toString(sBox[768 + i * 4 + 
j])).append(", ");
+            log.fine(sb.toString());
           }
-        System.out.println();
-        System.out.println("User (odd, even) keys  --> S-Box keys:");
+        log.fine("User (odd, even) keys  --> S-Box keys:");
         for (i = 0; i < k64Cnt; i++)
-          {
-            System.out.println("0x" + Util.toString(k32o[i]) + "  0x"
-                               + Util.toString(k32e[i]) + " --> 0x"
-                               + Util.toString(sBoxKey[k64Cnt - 1 - i]));
-          }
-        System.out.println();
-        System.out.println("Round keys:");
+          log.fine("0x" + Util.toString(k32o[i]) + "  0x" + 
Util.toString(k32e[i])
+                   + " --> 0x" + Util.toString(sBoxKey[k64Cnt - 1 - i]));
+        log.fine("Round keys:");
         for (i = 0; i < ROUND_SUBKEYS + 2 * ROUNDS; i += 2)
-          {
-            System.out.println("0x" + Util.toString(subKeys[i]) + "  0x"
-                               + Util.toString(subKeys[i + 1]));
-          }
-        System.out.println();
+          log.fine("0x" + Util.toString(subKeys[i])
+                   + "  0x" + Util.toString(subKeys[i + 1]));
       }
 
     return new Object[] { sBox, subKeys };
@@ -704,12 +655,8 @@
     Object[] sk = (Object[]) sessionKey; // extract S-box and session key
     int[] sBox = (int[]) sk[0];
     int[] sKey = (int[]) sk[1];
-
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("PT=" + Util.toString(in, inOffset, bs));
-      }
-
+    if (Configuration.DEBUG)
+      log.fine("PT=" + Util.toString(in, inOffset, bs));
     int x0 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
              | (in[inOffset++] & 0xFF) << 16 | (in[inOffset++] & 0xFF) << 24;
     int x1 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
@@ -723,12 +670,9 @@
     x1 ^= sKey[INPUT_WHITEN + 1];
     x2 ^= sKey[INPUT_WHITEN + 2];
     x3 ^= sKey[INPUT_WHITEN + 3];
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("PTw=" + Util.toString(x0) + Util.toString(x1)
+    if (Configuration.DEBUG)
+      log.fine("PTw=" + Util.toString(x0) + Util.toString(x1)
                            + Util.toString(x2) + Util.toString(x3));
-      }
-
     int t0, t1;
     int k = ROUND_SUBKEYS;
     for (int R = 0; R < ROUNDS; R += 2)
@@ -739,36 +683,26 @@
         x2 = x2 >>> 1 | x2 << 31;
         x3 = x3 << 1 | x3 >>> 31;
         x3 ^= t0 + 2 * t1 + sKey[k++];
-        if (DEBUG && debuglevel > 6)
-          {
-            System.out.println("CT" + (R) + "=" + Util.toString(x0)
-                               + Util.toString(x1) + Util.toString(x2)
-                               + Util.toString(x3));
-          }
-
+        if (Configuration.DEBUG)
+          log.fine("CT" + (R) + "=" + Util.toString(x0) + Util.toString(x1)
+                   + Util.toString(x2) + Util.toString(x3));
         t0 = Fe32(sBox, x2, 0);
         t1 = Fe32(sBox, x3, 3);
         x0 ^= t0 + t1 + sKey[k++];
         x0 = x0 >>> 1 | x0 << 31;
         x1 = x1 << 1 | x1 >>> 31;
         x1 ^= t0 + 2 * t1 + sKey[k++];
-        if (DEBUG && debuglevel > 6)
-          {
-            System.out.println("CT" + (R + 1) + "=" + Util.toString(x0)
-                               + Util.toString(x1) + Util.toString(x2)
-                               + Util.toString(x3));
-          }
+        if (Configuration.DEBUG)
+          log.fine("CT" + (R + 1) + "=" + Util.toString(x0) + Util.toString(x1)
+                   + Util.toString(x2) + Util.toString(x3));
       }
     x2 ^= sKey[OUTPUT_WHITEN];
     x3 ^= sKey[OUTPUT_WHITEN + 1];
     x0 ^= sKey[OUTPUT_WHITEN + 2];
     x1 ^= sKey[OUTPUT_WHITEN + 3];
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("CTw=" + Util.toString(x0) + Util.toString(x1)
+    if (Configuration.DEBUG)
+      log.fine("CTw=" + Util.toString(x0) + Util.toString(x1)
                            + Util.toString(x2) + Util.toString(x3));
-      }
-
     out[outOffset++] = (byte) x2;
     out[outOffset++] = (byte) (x2 >>> 8);
     out[outOffset++] = (byte) (x2 >>> 16);
@@ -785,12 +719,8 @@
     out[outOffset++] = (byte) (x1 >>> 8);
     out[outOffset++] = (byte) (x1 >>> 16);
     out[outOffset] = (byte) (x1 >>> 24);
-
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("CT=" + Util.toString(out, outOffset - 15, 16));
-        System.out.println();
-      }
+    if (Configuration.DEBUG)
+      log.fine("CT=" + Util.toString(out, outOffset - 15, 16) + "\n");
   }
 
   public void decrypt(byte[] in, int inOffset, byte[] out, int outOffset,
@@ -804,12 +734,8 @@
     Object[] sk = (Object[]) sessionKey; // extract S-box and session key
     int[] sBox = (int[]) sk[0];
     int[] sKey = (int[]) sk[1];
-
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("CT=" + Util.toString(in, inOffset, bs));
-      }
-
+    if (Configuration.DEBUG)
+      log.fine("CT=" + Util.toString(in, inOffset, bs));
     int x2 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
              | (in[inOffset++] & 0xFF) << 16 | (in[inOffset++] & 0xFF) << 24;
     int x3 = (in[inOffset++] & 0xFF) | (in[inOffset++] & 0xFF) << 8
@@ -823,12 +749,9 @@
     x3 ^= sKey[OUTPUT_WHITEN + 1];
     x0 ^= sKey[OUTPUT_WHITEN + 2];
     x1 ^= sKey[OUTPUT_WHITEN + 3];
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("CTw=" + Util.toString(x2) + Util.toString(x3)
+    if (Configuration.DEBUG)
+      log.fine("CTw=" + Util.toString(x2) + Util.toString(x3)
                            + Util.toString(x0) + Util.toString(x1));
-      }
-
     int k = ROUND_SUBKEYS + 2 * ROUNDS - 1;
     int t0, t1;
     for (int R = 0; R < ROUNDS; R += 2)
@@ -839,36 +762,26 @@
         x1 = x1 >>> 1 | x1 << 31;
         x0 = x0 << 1 | x0 >>> 31;
         x0 ^= t0 + t1 + sKey[k--];
-        if (DEBUG && debuglevel > 6)
-          {
-            System.out.println("PT" + (ROUNDS - R) + "=" + Util.toString(x2)
-                               + Util.toString(x3) + Util.toString(x0)
-                               + Util.toString(x1));
-          }
-
+        if (Configuration.DEBUG)
+          log.fine("PT" + (ROUNDS - R) + "=" + Util.toString(x2)
+                   + Util.toString(x3) + Util.toString(x0) + 
Util.toString(x1));
         t0 = Fe32(sBox, x0, 0);
         t1 = Fe32(sBox, x1, 3);
         x3 ^= t0 + 2 * t1 + sKey[k--];
         x3 = x3 >>> 1 | x3 << 31;
         x2 = x2 << 1 | x2 >>> 31;
         x2 ^= t0 + t1 + sKey[k--];
-        if (DEBUG && debuglevel > 6)
-          {
-            System.out.println("PT" + (ROUNDS - R - 1) + "="
-                               + Util.toString(x2) + Util.toString(x3)
-                               + Util.toString(x0) + Util.toString(x1));
-          }
+        if (Configuration.DEBUG)
+          log.fine("PT" + (ROUNDS - R - 1) + "=" + Util.toString(x2)
+                   + Util.toString(x3) + Util.toString(x0) + 
Util.toString(x1));
       }
     x0 ^= sKey[INPUT_WHITEN];
     x1 ^= sKey[INPUT_WHITEN + 1];
     x2 ^= sKey[INPUT_WHITEN + 2];
     x3 ^= sKey[INPUT_WHITEN + 3];
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("PTw=" + Util.toString(x2) + Util.toString(x3)
+    if (Configuration.DEBUG)
+      log.fine("PTw=" + Util.toString(x2) + Util.toString(x3)
                            + Util.toString(x0) + Util.toString(x1));
-      }
-
     out[outOffset++] = (byte) x0;
     out[outOffset++] = (byte) (x0 >>> 8);
     out[outOffset++] = (byte) (x0 >>> 16);
@@ -885,12 +798,8 @@
     out[outOffset++] = (byte) (x3 >>> 8);
     out[outOffset++] = (byte) (x3 >>> 16);
     out[outOffset] = (byte) (x3 >>> 24);
-
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("PT=" + Util.toString(out, outOffset - 15, 16));
-        System.out.println();
-      }
+    if (Configuration.DEBUG)
+      log.fine("PT=" + Util.toString(out, outOffset - 15, 16) + "\n");
   }
 
   public boolean selfTest()

Index: javax/crypto/cipher/BaseCipher.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/cipher/BaseCipher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/cipher/BaseCipher.java 4 Jun 2006 06:57:25 -0000       1.2
+++ javax/crypto/cipher/BaseCipher.java 11 Jun 2006 12:14:43 -0000      1.3
@@ -38,10 +38,14 @@
 
 package gnu.javax.crypto.cipher;
 
+import gnu.classpath.Configuration;
+
 import java.security.InvalidKeyException;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * <p>A basic abstract class to facilitate implementing symmetric key block
@@ -49,10 +53,7 @@
  */
 public abstract class BaseCipher implements IBlockCipher, IBlockCipherSpi
 {
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
+  private static final Logger log = 
Logger.getLogger(BaseCipher.class.getName());
   /** The canonical name prefix of the cipher. */
   protected String name;
 
@@ -263,7 +264,8 @@
       }
     catch (Exception x)
       {
-        x.printStackTrace(System.err);
+        if (Configuration.DEBUG)
+          log.log(Level.FINE, "Exception in testSymmetry() for " + name(), x);
         return false;
       }
   }
@@ -295,7 +297,8 @@
       }
     catch (Exception x)
       {
-        x.printStackTrace(System.err);
+        if (Configuration.DEBUG)
+          log.log(Level.FINE, "Exception in testKat() for " + name(), x);
         return false;
       }
   }

Index: javax/crypto/cipher/Rijndael.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/cipher/Rijndael.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/cipher/Rijndael.java   21 Apr 2006 10:52:26 -0000      1.2
+++ javax/crypto/cipher/Rijndael.java   11 Jun 2006 12:14:43 -0000      1.3
@@ -38,14 +38,15 @@
 
 package gnu.javax.crypto.cipher;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.util.Util;
 
-//import java.io.PrintWriter;
 import java.security.InvalidKeyException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.logging.Logger;
 
 /**
  * <p>Rijndael --pronounced Reindaal-- is the AES. It is a variable block-size
@@ -63,23 +64,7 @@
  */
 public final class Rijndael extends BaseCipher
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  //   private static final String NAME = "rijndael";
-  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(String s) {
-  //      err.println(">>> "+NAME+": "+s);
-  //   }
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
+  private static final Logger log = Logger.getLogger(Rijndael.class.getName());
   private static final int DEFAULT_BLOCK_SIZE = 16; // in bytes
 
   private static final int DEFAULT_KEY_SIZE = 16; // in bytes
@@ -222,169 +207,134 @@
         }
 
       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("S[]:");
+          log.fine("Static Data");
+          log.fine("S[]:");
+          StringBuilder sb;
           for (i = 0; i < 16; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 16; j++)
-                {
-                  System.out.print("0x" + Util.toString(S[i * 16 + j]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(S[i * 16 + j])).append(", 
");
+              log.fine(sb.toString());
             }
-          System.out.println();
-          System.out.println("Si[]:");
+          log.fine("Si[]:");
           for (i = 0; i < 16; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 16; j++)
-                {
-                  System.out.print("0x" + Util.toString(Si[i * 16 + j]) + ", 
");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(Si[i * 16 + 
j])).append(", ");
+              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]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T1[i * 4 + j])).append(", 
");
+              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]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T2[i * 4 + j])).append(", 
");
+              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]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T3[i * 4 + j])).append(", 
");
+              log.fine(sb.toString());
             }
-          System.out.println();
-          System.out.println("T4[]:");
+          log.fine("T4[]:");
           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]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T4[i * 4 + j])).append(", 
");
+              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]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T5[i * 4 + j])).append(", 
");
+              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(T6[i * 4 + j]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T6[i * 4 + j])).append(", 
");
+              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(T7[i * 4 + j]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T7[i * 4 + j])).append(", 
");
+              log.fine(sb.toString());
             }
-          System.out.println();
-          System.out.println("T8[]:");
+          log.fine("T8[]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 4; j++)
-                {
-                  System.out.print("0x" + Util.toString(T8[i * 4 + j]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T8[i * 4 + j])).append(", 
");
+              log.fine(sb.toString());
             }
 
-          System.out.println();
-          System.out.println("U1[]:");
+          log.fine("U1[]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 4; j++)
-                {
-                  System.out.print("0x" + Util.toString(U1[i * 4 + j]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(U1[i * 4 + j])).append(", 
");
+              log.fine(sb.toString());
             }
-          System.out.println();
-          System.out.println("U2[]:");
+          log.fine("U2[]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 4; j++)
-                {
-                  System.out.print("0x" + Util.toString(U2[i * 4 + j]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(U2[i * 4 + j])).append(", 
");
+              log.fine(sb.toString());
             }
-          System.out.println();
-          System.out.println("U3[]:");
+          log.fine("U3[]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 4; j++)
-                {
-                  System.out.print("0x" + Util.toString(U3[i * 4 + j]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(U3[i * 4 + j])).append(", 
");
+              log.fine(sb.toString());
             }
-          System.out.println();
-          System.out.println("U4[]:");
+          log.fine("U4[]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 4; j++)
-                {
-                  System.out.println("0x" + Util.toString(U4[i * 4 + j]) + ", 
");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(U4[i * 4 + j])).append(", 
");
+              log.fine(sb.toString());
             }
 
-          System.out.println();
-          System.out.println("rcon[]:");
+          log.fine("rcon[]:");
           for (i = 0; i < 5; i++)
             {
+              sb = new StringBuilder();
               for (j = 0; j < 6; j++)
-                {
-                  System.out.print("0x" + Util.toString(rcon[i * 6 + j]) + ", 
");
+                sb.append("0x").append(Util.toString(rcon[i * 6 + 
j])).append(", ");
+              log.fine(sb.toString());
                 }
-              System.out.println();
-            }
-
-          System.out.println();
-          System.out.println("Total initialization time: " + time + " ms.");
-          System.out.println();
+          log.fine("Total initialization time: " + time + " ms.");
         }
     }
 
@@ -454,11 +404,8 @@
           }
 
         System.arraycopy(a, 0, t, 0, BC);
-
-        if (DEBUG && debuglevel > 6)
-          {
-            System.out.println("CT" + r + "=" + Util.toString(t));
-          }
+        if (Configuration.DEBUG)
+          log.fine("CT" + r + "=" + Util.toString(t));
       }
 
     for (i = 0; i < BC; i++)
@@ -469,12 +416,8 @@
         out[outOffset++] = (byte) (S[(t[(i + s2) % BC] >>> 8) & 0xFF] ^ (tt 
>>> 8));
         out[outOffset++] = (byte) (S[t[(i + s3) % BC] & 0xFF] ^ tt);
       }
-
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("CT=" + Util.toString(out, outOffset - bs + 1, bs));
-        System.out.println();
-      }
+    if (Configuration.DEBUG)
+      log.fine("CT=" + Util.toString(out, outOffset - bs, bs));
   }
 
   private static void rijndaelDecrypt(byte[] in, int inOffset, byte[] out,
@@ -510,11 +453,8 @@
           }
 
         System.arraycopy(a, 0, t, 0, BC);
-
-        if (DEBUG && debuglevel > 6)
-          {
-            System.out.println("PT" + r + "=" + Util.toString(t));
-          }
+        if (Configuration.DEBUG)
+          log.fine("PT" + r + "=" + Util.toString(t));
       }
 
     for (i = 0; i < BC; i++)
@@ -525,12 +465,8 @@
         out[outOffset++] = (byte) (Si[(t[(i + s2) % BC] >>> 8) & 0xFF] ^ (tt 
>>> 8));
         out[outOffset++] = (byte) (Si[t[(i + s3) % BC] & 0xFF] ^ tt);
       }
-
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("PT=" + Util.toString(out, outOffset - bs + 1, bs));
-        System.out.println();
-      }
+    if (Configuration.DEBUG)
+      log.fine("PT=" + Util.toString(out, outOffset - bs, bs));
   }
 
   private static void aesEncrypt(byte[] in, int i, byte[] out, int j, Object 
key)
@@ -565,15 +501,10 @@
         t1 = a1;
         t2 = a2;
         t3 = a3;
-
-        if (DEBUG && debuglevel > 6)
-          {
-            System.out.println("CT" + r + "=" + Util.toString(t0)
-                               + Util.toString(t1) + Util.toString(t2)
-                               + Util.toString(t3));
+        if (Configuration.DEBUG)
+          log.fine("CT" + r + "=" + Util.toString(t0) + Util.toString(t1)
+                   + Util.toString(t2) + Util.toString(t3));
           }
-      }
-
     // last round is special
     Ker = Ke[ROUNDS];
     int tt = Ker[0];
@@ -596,12 +527,8 @@
     out[j++] = (byte) (S[(t0 >>> 16) & 0xFF] ^ (tt >>> 16));
     out[j++] = (byte) (S[(t1 >>> 8) & 0xFF] ^ (tt >>> 8));
     out[j++] = (byte) (S[t2 & 0xFF] ^ tt);
-
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("CT=" + Util.toString(out, j - 15, 16));
-        System.out.println();
-      }
+    if (Configuration.DEBUG)
+      log.fine("CT=" + Util.toString(out, j - 16, 16));
   }
 
   private static void aesDecrypt(byte[] in, int i, byte[] out, int j, Object 
key)
@@ -636,15 +563,10 @@
         t1 = a1;
         t2 = a2;
         t3 = a3;
-
-        if (DEBUG && debuglevel > 6)
-          {
-            System.out.println("PT" + r + "=" + Util.toString(t0)
-                               + Util.toString(t1) + Util.toString(t2)
-                               + Util.toString(t3));
-          }
+        if (Configuration.DEBUG)
+          log.fine("PT" + r + "=" + Util.toString(t0) + Util.toString(t1)
+                   + Util.toString(t2) + Util.toString(t3));
       }
-
     // last round is special
     Kdr = Kd[ROUNDS];
     int tt = Kdr[0];
@@ -667,12 +589,8 @@
     out[j++] = (byte) (Si[(t2 >>> 16) & 0xFF] ^ (tt >>> 16));
     out[j++] = (byte) (Si[(t1 >>> 8) & 0xFF] ^ (tt >>> 8));
     out[j++] = (byte) (Si[t0 & 0xFF] ^ tt);
-
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("PT=" + Util.toString(out, j - 15, 16));
-        System.out.println();
-      }
+    if (Configuration.DEBUG)
+      log.fine("PT=" + Util.toString(out, j - 16, 16));
   }
 
   // Instance methods

Index: javax/crypto/cipher/Anubis.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/cipher/Anubis.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/cipher/Anubis.java     21 Apr 2006 10:52:26 -0000      1.2
+++ javax/crypto/cipher/Anubis.java     11 Jun 2006 12:14:43 -0000      1.3
@@ -38,14 +38,15 @@
 
 package gnu.javax.crypto.cipher;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.util.Util;
 
-//import java.io.PrintWriter;
 import java.security.InvalidKeyException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.logging.Logger;
 
 /**
  * <p>Anubis is a 128-bit block cipher that accepts a variable-length key. The
@@ -65,23 +66,7 @@
  */
 public final class Anubis extends BaseCipher
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  //   private static final String NAME = "anubis";
-  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(String s) {
-  //      err.println(">>> "+NAME+": "+s);
-  //   }
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
+  private static final Logger log = Logger.getLogger(Anubis.class.getName());
   private static final int DEFAULT_BLOCK_SIZE = 16; // in bytes
 
   private static final int DEFAULT_KEY_SIZE = 16; // in bytes
@@ -189,84 +174,62 @@
 
       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 (t = 0; t < 4; t++)
-                {
-                  System.out.print("0x" + Util.toString(T0[i * 4 + t]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T0[i * 4 + t])).append(", 
");
+              log.fine(sb.toString());
             }
-          System.out.println();
-          System.out.println("T1[]:");
+          log.fine("T1[]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (t = 0; t < 4; t++)
-                {
-                  System.out.print("0x" + Util.toString(T1[i * 4 + t]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T1[i * 4 + t])).append(", 
");
+              log.fine(sb.toString());
             }
-          System.out.println();
-          System.out.println("T2[]:");
+          log.fine("T2[]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (t = 0; t < 4; t++)
-                {
-                  System.out.print("0x" + Util.toString(T2[i * 4 + t]) + ", ");
+                sb.append("0x").append(Util.toString(T2[i * 4 + t])).append(", 
");
+              log.fine(sb.toString());
                 }
-              System.out.println();
-            }
-          System.out.println();
-          System.out.println("T3[]:");
+          log.fine("T3[]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (t = 0; t < 4; t++)
-                {
-                  System.out.print("0x" + Util.toString(T3[i * 4 + t]) + ", ");
+                sb.append("0x").append(Util.toString(T3[i * 4 + t])).append(", 
");
+              log.fine(sb.toString());
                 }
-              System.out.println();
-            }
-          System.out.println();
-          System.out.println("T4[]:");
+          log.fine("T4[]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (t = 0; t < 4; t++)
-                {
-                  System.out.print("0x" + Util.toString(T4[i * 4 + t]) + ", ");
+                sb.append("0x").append(Util.toString(T4[i * 4 + t])).append(", 
");
+              log.fine(sb.toString());
                 }
-              System.out.println();
-            }
-          System.out.println();
-          System.out.println("T5[]:");
+          log.fine("T5[]:");
           for (i = 0; i < 64; i++)
             {
+              sb = new StringBuilder();
               for (t = 0; t < 4; t++)
-                {
-                  System.out.print("0x" + Util.toString(T5[i * 4 + t]) + ", ");
-                }
-              System.out.println();
+                sb.append("0x").append(Util.toString(T5[i * 4 + t])).append(", 
");
+              log.fine(sb.toString());
             }
-          System.out.println();
-          System.out.println("rc[]:");
+          log.fine("rc[]:");
           for (i = 0; i < 18; i++)
-            {
-              System.out.println("0x" + Util.toString(rc[i]));
-            }
-          System.out.println();
-
-          System.out.println();
-          System.out.println("Total initialization time: " + time + " ms.");
-          System.out.println();
+            log.fine("0x" + Util.toString(rc[i]));
+          log.fine("Total initialization time: " + time + " ms.");
         }
     }
 
@@ -315,12 +278,9 @@
         a1 = b1;
         a2 = b2;
         a3 = b3;
-        if (DEBUG && debuglevel > 6)
-          {
-            System.out.println("T" + r + "=" + Util.toString(a0)
-                               + Util.toString(a1) + Util.toString(a2)
-                               + Util.toString(a3));
-          }
+        if (Configuration.DEBUG)
+          log.fine("T" + r + "=" + Util.toString(a0) + Util.toString(a1)
+                   + Util.toString(a2) + Util.toString(a3));
       }
 
     // last round function
@@ -346,11 +306,8 @@
     out[j++] = (byte) (S[a2 & 0xFF] ^ (tt >>> 8));
     out[j] = (byte) (S[a3 & 0xFF] ^ tt);
 
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("T=" + Util.toString(out, j - 15, 16));
-        System.out.println();
-      }
+    if (Configuration.DEBUG)
+      log.fine("T=" + Util.toString(out, j - 15, 16) + "\n");
   }
 
   // Instance methods
@@ -517,29 +474,26 @@
           }
       }
 
-    if (DEBUG && debuglevel > 8)
+    if (Configuration.DEBUG)
       {
-        System.out.println();
-        System.out.println("Key schedule");
-        System.out.println();
-        System.out.println("Ke[]:");
+        log.fine("Key schedule");
+        log.fine("Ke[]:");
+        StringBuilder sb;
         for (r = 0; r < R + 1; r++)
           {
-            System.out.print("#" + r + ": ");
+            sb = new StringBuilder("#").append(r).append(": ");
             for (j = 0; j < 4; j++)
-              System.out.print("0x" + Util.toString(Ke[r][j]) + ", ");
-            System.out.println();
+              sb.append("0x").append(Util.toString(Ke[r][j])).append(", ");
+            log.fine(sb.toString());
           }
-        System.out.println();
-        System.out.println("Kd[]:");
+        log.fine("Kd[]:");
         for (r = 0; r < R + 1; r++)
           {
-            System.out.print("#" + r + ": ");
+            sb = new StringBuilder("#").append(r).append(": ");
             for (j = 0; j < 4; j++)
-              System.out.print("0x" + Util.toString(Kd[r][j]) + ", ");
-            System.out.println();
+              sb.append("0x").append(Util.toString(Kd[r][j])).append(", ");
+            log.fine(sb.toString());
           }
-        System.out.println();
       }
 
     return new Object[] { Ke, Kd };

Index: javax/crypto/cipher/Khazad.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/cipher/Khazad.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/cipher/Khazad.java     21 Apr 2006 10:52:26 -0000      1.2
+++ javax/crypto/cipher/Khazad.java     11 Jun 2006 12:14:43 -0000      1.3
@@ -38,14 +38,15 @@
 
 package gnu.javax.crypto.cipher;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.util.Util;
 
-//import java.io.PrintWriter;
 import java.security.InvalidKeyException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.logging.Logger;
 
 /**
  * <p>Khazad is a 64-bit (legacy-level) block cipher that accepts a 128-bit 
key.
@@ -65,23 +66,7 @@
  */
 public final class Khazad extends BaseCipher
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  //   private static final String NAME = "khazad";
-  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(String s) {
-  //      err.println(">>> "+NAME+": "+s);
-  //   }
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
+  private static final Logger log = Logger.getLogger(Khazad.class.getName());
   private static final int DEFAULT_BLOCK_SIZE = 8; // in bytes
 
   private static final int DEFAULT_KEY_SIZE = 16; // in bytes
@@ -194,86 +179,78 @@
 
       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 b;
           for (i = 0; i < 64; i++)
             {
+              b = new StringBuilder();
               for (j = 0; j < 4; j++)
-                System.out.print("0x" + Util.toString(T0[i * 4 + j]) + ", ");
-              System.out.println();
+                b.append("0x").append(Util.toString(T0[i * 4 + j])).append(", 
");
+              log.fine(b.toString());
             }
-          System.out.println();
-          System.out.println("T1[]:");
+          log.fine("T1[]:");
           for (i = 0; i < 64; i++)
             {
+              b = new StringBuilder();
               for (j = 0; j < 4; j++)
-                System.out.print("0x" + Util.toString(T1[i * 4 + j]) + ", ");
-              System.out.println();
+                b.append("0x").append(Util.toString(T1[i * 4 + j])).append(", 
");
+              log.fine(b.toString());
             }
-          System.out.println();
-          System.out.println("T2[]:");
+          log.fine("T2[]:");
           for (i = 0; i < 64; i++)
             {
+              b = new StringBuilder();
               for (j = 0; j < 4; j++)
-                System.out.print("0x" + Util.toString(T2[i * 4 + j]) + ", ");
-              System.out.println();
+                b.append("0x").append(Util.toString(T2[i * 4 + j])).append(", 
");
+              log.fine(b.toString());
             }
-          System.out.println();
-          System.out.println("T3[]:");
+          log.fine("T3[]:");
           for (i = 0; i < 64; i++)
             {
+              b = new StringBuilder();
               for (j = 0; j < 4; j++)
-                System.out.print("0x" + Util.toString(T3[i * 4 + j]) + ", ");
-              System.out.println();
+                b.append("0x").append(Util.toString(T3[i * 4 + j])).append(", 
");
+              log.fine(b.toString());
             }
-          System.out.println();
-          System.out.println("T4[]:");
+          log.fine("T4[]:");
           for (i = 0; i < 64; i++)
             {
+              b = new StringBuilder();
               for (j = 0; j < 4; j++)
-                System.out.print("0x" + Util.toString(T4[i * 4 + j]) + ", ");
-              System.out.println();
+                b.append("0x").append(Util.toString(T4[i * 4 + j])).append(", 
");
+              log.fine(b.toString());
             }
-          System.out.println();
-          System.out.println("T5[]:");
+          log.fine("T5[]:");
           for (i = 0; i < 64; i++)
             {
+              b = new StringBuilder();
               for (j = 0; j < 4; j++)
-                System.out.print("0x" + Util.toString(T5[i * 4 + j]) + ", ");
-              System.out.println();
+                b.append("0x").append(Util.toString(T5[i * 4 + j])).append(", 
");
+              log.fine(b.toString());
             }
-          System.out.println();
-          System.out.println("T6[]:");
+          log.fine("T6[]:");
           for (i = 0; i < 64; i++)
             {
+              b = new StringBuilder();
               for (j = 0; j < 4; j++)
-                System.out.print("0x" + Util.toString(T6[i * 4 + j]) + ", ");
-              System.out.println();
+                b.append("0x").append(Util.toString(T6[i * 4 + j])).append(", 
");
+              log.fine(b.toString());
             }
-          System.out.println();
-          System.out.println("T7[]:");
+          log.fine("T7[]:");
           for (i = 0; i < 64; i++)
             {
+              b = new StringBuilder();
               for (j = 0; j < 4; j++)
-                System.out.print("0x" + Util.toString(T7[i * 4 + j]) + ", ");
-              System.out.println();
+                b.append("0x").append(Util.toString(T7[i * 4 + j])).append(", 
");
+              log.fine(b.toString());
             }
-          System.out.println();
-          System.out.println("rc[]:");
+          log.fine("rc[]:");
           for (i = 0; i < R + 1; i++)
-            System.out.print("0x" + Util.toString(rc[i][0])
-                             + Util.toString(rc[i][1]));
-          System.out.println();
-
-          System.out.println("Total initialization time: " + time + " ms.");
-          System.out.println();
+            log.fine("0x" + Util.toString(rc[i][0]) + Util.toString(rc[i][1]));
+          log.fine("Total initialization time: " + time + " ms.");
         }
     }
 
@@ -313,12 +290,8 @@
              ^ T6[(a0 >>> 8) & 0xFF] ^ T7[a0 & 0xFF] ^ k1;
         a0 = b0;
         a1 = b1;
-
-        if (DEBUG && debuglevel > 6)
-          {
-            System.out.println("T" + r + "=" + Util.toString(a0)
-                               + Util.toString(a1));
-          }
+        if (Configuration.DEBUG)
+          log.fine("T" + r + "=" + Util.toString(a0) + Util.toString(a1));
       }
 
     // sigma(K[R]) o gamma applied to previous output
@@ -333,12 +306,8 @@
     out[j++] = (byte) (S[(a1 >>> 16) & 0xFF] ^ (k1 >>> 16));
     out[j++] = (byte) (S[(a1 >>> 8) & 0xFF] ^ (k1 >>> 8));
     out[j] = (byte) (S[a1 & 0xFF] ^ k1);
-
-    if (DEBUG && debuglevel > 6)
-      {
-        System.out.println("T=" + Util.toString(out, j - 7, 8));
-        System.out.println();
-      }
+    if (Configuration.DEBUG)
+      log.fine("T=" + Util.toString(out, j - 7, 8) + "\n");
   }
 
   // Instance methods
@@ -458,26 +427,17 @@
                            ^ T7[S[kr0 & 0xFF] & 0xFF];
           }
       }
-
-    if (DEBUG && debuglevel > 8)
+    if (Configuration.DEBUG)
       {
-        System.out.println();
-        System.out.println("Key schedule");
-        System.out.println();
-        System.out.println("Ke[]:");
+        log.fine("Key schedule");
+        log.fine("Ke[]:");
         for (r = 0; r < R + 1; r++)
-          {
-            System.out.println("#" + r + ": 0x" + Util.toString(Ke[r][0])
-                               + Util.toString(Ke[r][1]));
-          }
-        System.out.println();
-        System.out.println("Kd[]:");
+          log.fine("#" + r + ": 0x"
+                   + Util.toString(Ke[r][0]) + Util.toString(Ke[r][1]));
+        log.fine("Kd[]:");
         for (r = 0; r < R + 1; r++)
-          {
-            System.out.println("#" + r + ": 0x" + Util.toString(Kd[r][0])
-                               + Util.toString(Kd[r][1]));
-          }
-        System.out.println();
+          log.fine("#" + r + ": 0x"
+                   + Util.toString(Kd[r][0]) + Util.toString(Kd[r][1]));
       }
 
     return new Object[] { Ke, Kd };

Index: javax/crypto/jce/keyring/GnuKeyring.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- javax/crypto/jce/keyring/GnuKeyring.java    20 May 2006 03:04:20 -0000      
1.3
+++ javax/crypto/jce/keyring/GnuKeyring.java    11 Jun 2006 12:14:43 -0000      
1.4
@@ -38,6 +38,7 @@
 
 package gnu.javax.crypto.jce.keyring;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.javax.crypto.keyring.GnuPrivateKeyring;
 import gnu.javax.crypto.keyring.GnuPublicKeyring;
@@ -90,6 +91,7 @@
 
   public Enumeration engineAliases()
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineAliases");
     ensureLoaded();
     Enumeration result;
@@ -106,7 +108,8 @@
                 alias = alias.trim();
                 if (alias.length() > 0)
                   {
-                    log.finest("Adding alias (from private keyring): " + 
alias);
+                    if (Configuration.DEBUG)
+                      log.fine("Adding alias (from private keyring): " + 
alias);
                     aliases.add(alias);
                   }
               }
@@ -119,29 +122,34 @@
                 alias = alias.trim();
                 if (alias.length() > 0)
                   {
-                    log.finest("Adding alias (from public keyring): " + alias);
+                    if (Configuration.DEBUG)
+                      log.fine("Adding alias (from public keyring): " + alias);
                     aliases.add(alias);
                   }
               }
           }
-        log.finest("Will enumerate: " + aliases);
+        if (Configuration.DEBUG)
+          log.fine("Will enumerate: " + aliases);
         result = Collections.enumeration(aliases);
       }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineAliases");
     return result;
   }
 
   public boolean engineContainsAlias(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineContainsAlias", alias);
-
     ensureLoaded();
     boolean inPrivateKR = privateKR.containsAlias(alias);
-    log.finest("inPrivateKR=" + inPrivateKR);
+    if (Configuration.DEBUG)
+      log.fine("inPrivateKR=" + inPrivateKR);
     boolean inPublicKR = publicKR.containsAlias(alias);
-    log.finest("inPublicKR=" + inPublicKR);
+    if (Configuration.DEBUG)
+      log.fine("inPublicKR=" + inPublicKR);
     boolean result = inPrivateKR || inPublicKR;
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineContainsAlias",
                 Boolean.valueOf(result));
     return result;
@@ -149,34 +157,34 @@
 
   public void engineDeleteEntry(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineDeleteEntry", alias);
-
     ensureLoaded();
     if (privateKR.containsAlias(alias))
       privateKR.remove(alias);
     else if (publicKR.containsAlias(alias))
       publicKR.remove(alias);
-    else
-      log.finer("Unknwon alias: " + alias);
-
+    else if (Configuration.DEBUG)
+      log.fine("Unknwon alias: " + alias);
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineDeleteEntry");
   }
 
   public Certificate engineGetCertificate(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineGetCertificate", alias);
-
     ensureLoaded();
     Certificate result = publicKR.getCertificate(alias);
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineGetCertificate", result);
     return result;
   }
 
   public String engineGetCertificateAlias(Certificate cert)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineGetCertificateAlias", cert);
-
     ensureLoaded();
     String result = null;
     for (Enumeration aliases = publicKR.aliases(); aliases.hasMoreElements();)
@@ -189,7 +197,7 @@
             break;
           }
       }
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineGetCertificateAlias", 
result);
     return result;
   }
@@ -197,6 +205,7 @@
   public void engineSetCertificateEntry(String alias, Certificate cert)
       throws KeyStoreException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineSetCertificateEntry",
                  new Object[] { alias, cert });
     ensureLoaded();
@@ -206,35 +215,37 @@
                                   + "Trusted Certificate Entry");
     if (publicKR.containsCertificate(alias))
       {
+        if (Configuration.DEBUG)
         log.fine("Public keyring already contains Alias [" + alias
                  + "]. Will remove it");
         publicKR.remove(alias);
       }
-
     publicKR.putCertificate(alias, cert);
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineSetCertificateEntry");
   }
 
   public Certificate[] engineGetCertificateChain(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineGetCertificateChain", 
alias);
-
     ensureLoaded();
     Certificate[] result = privateKR.getCertPath(alias);
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineGetCertificateChain", 
result);
     return result;
   }
 
   public Date engineGetCreationDate(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineGetCreationDate", alias);
-
     ensureLoaded();
     Date result = getCreationDate(alias, privateKR);
     if (result == null)
       result = getCreationDate(alias, publicKR);
 
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineGetCreationDate", result);
     return result;
   }
@@ -242,6 +253,7 @@
   public Key engineGetKey(String alias, char[] password)
       throws UnrecoverableKeyException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineGetKey", alias);
     ensureLoaded();
     Key result = null;
@@ -253,6 +265,7 @@
     else if (privateKR.containsPrivateKey(alias))
       result = privateKR.getPrivateKey(alias, password); 
 
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineGetKey",
                 result == null ? "null" : result.getClass().getName());
     return result;
@@ -262,6 +275,7 @@
                                 Certificate[] chain)
       throws KeyStoreException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineSetKeyEntry",
                  new Object[] { alias, key.getClass().getName(), chain });
     ensureLoaded();
@@ -282,9 +296,11 @@
                                       + key.getClass().getName());
         privateKR.remove(alias);
         privateKR.putCertPath(alias, chain);
-        log.finest("About to put private key in keyring...");
+        if (Configuration.DEBUG)
+          log.fine("About to put private key in keyring...");
         privateKR.putPrivateKey(alias, key, password);
       }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineSetKeyEntry");
   }
 
@@ -292,17 +308,18 @@
       throws KeyStoreException
   {
     KeyStoreException x = new KeyStoreException("method not supported");
+    if (Configuration.DEBUG)
     log.throwing(this.getClass().getName(), "engineSetKeyEntry(3)", x);
     throw x;
   }
 
   public boolean engineIsCertificateEntry(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineIsCertificateEntry", alias);
-
     ensureLoaded();
     boolean result = publicKR.containsCertificate(alias);
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineIsCertificateEntry",
                 Boolean.valueOf(result));
     return result;
@@ -310,12 +327,12 @@
 
   public boolean engineIsKeyEntry(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineIsKeyEntry", alias);
-
     ensureLoaded();
     boolean result = privateKR.containsPublicKey(alias)
                   || privateKR.containsPrivateKey(alias);
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineIsKeyEntry",
                 Boolean.valueOf(result));
     return result;
@@ -323,6 +340,7 @@
 
   public void engineLoad(InputStream in, char[] password) throws IOException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineLoad");
     if (in != null)
       {
@@ -336,11 +354,13 @@
       createNewKeyrings();
 
     loaded = true;
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineLoad");
   }
 
   public void engineStore(OutputStream out, char[] password) throws IOException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineStore");
     ensureLoaded();
     HashMap attr = new HashMap();
@@ -349,16 +369,19 @@
 
     privateKR.store(attr);
     publicKR.store(attr);
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineStore");
   }
 
   public int engineSize()
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineSize");
     int result = 0;
     for (Enumeration e = engineAliases(); e.hasMoreElements(); result++)
       e.nextElement();
 
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineSize", 
Integer.valueOf(result));
     return result;
   }
@@ -386,8 +409,8 @@
   private void loadPrivateKeyring(InputStream in, char[] password)
       throws MalformedKeyringException, IOException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "loadPrivateKeyring");
-
     in.mark(5);
     for (int i = 0; i < 4; i++)
       if (in.read() != Registry.GKR_MAGIC[i])
@@ -403,7 +426,7 @@
     attr.put(IKeyring.KEYRING_PASSWORD, password);
     privateKR = new GnuPrivateKeyring();
     privateKR.load(attr);
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "loadPrivateKeyring");
   }
 
@@ -418,8 +441,8 @@
   private void loadPublicKeyring(InputStream in, char[] password)
       throws MalformedKeyringException, IOException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "loadPublicKeyring");
-
     in.mark(5);
     for (int i = 0; i < 4; i++)
       if (in.read() != Registry.GKR_MAGIC[i])
@@ -435,7 +458,7 @@
     attr.put(IKeyring.KEYRING_PASSWORD, password);
     publicKR = new GnuPublicKeyring();
     publicKR.load(attr);
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "loadPublicKeyring");
   }
 
@@ -450,9 +473,9 @@
    */
   private Date getCreationDate(String alias, IKeyring keyring)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "getCreationDate",
                  new Object[] { alias, keyring });
-
     Date result = null;
     if (keyring != null)
       for (Iterator it = keyring.get(alias).iterator(); it.hasNext();)
@@ -464,7 +487,7 @@
               break;
             }
         }
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "getCreationDate", result);
     return result;
   }
@@ -472,11 +495,11 @@
   /** Create empty keyrings. */
   private void createNewKeyrings()
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "createNewKeyrings");
-
     privateKR = new GnuPrivateKeyring("HMAC-SHA-1", 20, "AES", "OFB", 16);
     publicKR = new GnuPublicKeyring("HMAC-SHA-1", 20);
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "createNewKeyrings");
   }
 }

Index: javax/crypto/keyring/GnuPublicKeyring.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- javax/crypto/keyring/GnuPublicKeyring.java  20 May 2006 02:38:20 -0000      
1.3
+++ javax/crypto/keyring/GnuPublicKeyring.java  11 Jun 2006 12:14:43 -0000      
1.4
@@ -38,6 +38,7 @@
 
 package gnu.javax.crypto.keyring;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 
 import java.io.DataInputStream;
@@ -77,6 +78,7 @@
 
   public boolean containsCertificate(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "containsCertificate", alias);
     boolean result = false;
     if (containsAlias(alias))
@@ -86,6 +88,7 @@
             result = true;
             break;
           }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "containsCertificate",
                 Boolean.valueOf(result));
     return result;
@@ -93,6 +96,7 @@
 
   public Certificate getCertificate(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "getCertificate", alias);
     Certificate result = null;
     if (containsAlias(alias))
@@ -105,12 +109,14 @@
               break;
             }
         }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "getCertificate", result);
     return result;
   }
 
   public void putCertificate(String alias, Certificate cert)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "putCertificate",
                  new Object[] { alias, cert });
     if (! containsCertificate(alias))
@@ -119,14 +125,16 @@
         p.put("alias", fixAlias(alias));
         add(new CertificateEntry(cert, new Date(), p));
       }
-    else
-      log.finer("Keyring already contains alias: " + alias);
+    else if (Configuration.DEBUG)
+      log.fine("Keyring already contains alias: " + alias);
 
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "putCertificate");
   }
 
   protected void load(InputStream in, char[] password) throws IOException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "load");
     if (in.read() != USAGE)
       throw new MalformedKeyringException("incompatible keyring usage");
@@ -136,14 +144,17 @@
 
     DataInputStream dis = new DataInputStream(in);
     keyring = PasswordAuthenticatedEntry.decode(dis, password);
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "load");
   }
 
   protected void store(OutputStream out, char[] password) throws IOException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "store");
     out.write(USAGE);
     keyring.encode(new DataOutputStream(out), password);
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "store");
   }
 }

Index: javax/crypto/keyring/GnuPrivateKeyring.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- javax/crypto/keyring/GnuPrivateKeyring.java 20 May 2006 02:38:20 -0000      
1.3
+++ javax/crypto/keyring/GnuPrivateKeyring.java 11 Jun 2006 12:14:43 -0000      
1.4
@@ -38,6 +38,7 @@
 
 package gnu.javax.crypto.keyring;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 
 import java.io.DataInputStream;
@@ -105,6 +106,7 @@
 
   public boolean containsPrivateKey(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "containsPrivateKey", alias);
     boolean result = false;
     if (containsAlias(alias))
@@ -114,6 +116,7 @@
             result = true;
             break;
           }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "containsPrivateKey",
                 Boolean.valueOf(result));
     return result;
@@ -122,6 +125,7 @@
   public Key getPrivateKey(String alias, char[] password)
       throws UnrecoverableKeyException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "getPrivateKey", alias);
     Key result = null;
     if (containsAlias(alias))
@@ -130,6 +134,7 @@
         for (Iterator it = get(alias).iterator(); it.hasNext();)
           {
             Entry e = (Entry) it.next();
+            if (Configuration.DEBUG)
             log.finest("Entry: " + e);
             if (e instanceof PasswordAuthenticatedEntry)
               {
@@ -137,8 +142,8 @@
                 break;
               }
           }
-
-        log.finest("e1 = " + e1);
+        if (Configuration.DEBUG)
+          log.fine("e1 = " + e1);
         if (e1 != null)
           {
             try
@@ -147,6 +152,7 @@
               }
             catch (Exception e)
               {
+                if (Configuration.DEBUG)
                 log.throwing(this.getClass().getName(), "getPrivateKey", e);
                 throw new UnrecoverableKeyException("authentication failed");
               }
@@ -186,6 +192,7 @@
               }
           }
       }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "getPrivateKey",
                 result == null ? "null" : result.getClass().getName());
     return result;
@@ -193,6 +200,7 @@
 
   public void putPrivateKey(String alias, Key key, char[] password)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "putPrivateKey",
                  new Object[] { alias, key.getClass().getName() });
     if (! containsPrivateKey(alias))
@@ -201,8 +209,8 @@
         Properties p = new Properties();
         p.put("alias", alias);
         PrivateKeyEntry pke = new PrivateKeyEntry(key, new Date(), p);
-
-        log.finest("About to encrypt the key...");
+        if (Configuration.DEBUG)
+          log.fine("About to encrypt the key...");
         PasswordEncryptedEntry enc;
         enc = new PasswordEncryptedEntry(cipher, mode, keylen, new 
Properties());
         enc.add(pke);
@@ -212,12 +220,13 @@
           }
         catch (IOException x)
           {
-            log.log(Level.FINER, "Exception while encrypting the key. "
+            if (Configuration.DEBUG)
+              log.log(Level.FINE, "Exception while encrypting the key. "
                                  + "Rethrow as IllegalArgumentException", x);
             throw new IllegalArgumentException(x.toString());
           }
-
-        log.finest("About to authenticate the encrypted key...");
+        if (Configuration.DEBUG)
+          log.fine("About to authenticate the encrypted key...");
         PasswordAuthenticatedEntry auth;
         auth = new PasswordAuthenticatedEntry(mac, maclen, new Properties());
         auth.add(enc);
@@ -227,21 +236,24 @@
           }
         catch (IOException x)
           {
-            log.log(Level.FINER, "Exception while authenticating the encrypted 
"
+            if (Configuration.DEBUG)
+              log.log(Level.FINE, "Exception while authenticating the 
encrypted "
                                  + "key. Rethrow as IllegalArgumentException", 
x);
             throw new IllegalArgumentException(x.toString());
           }
 
         keyring.add(auth);
       }
-    else
-      log.finer("Keyring already contains alias: " + alias);
+    else if (Configuration.DEBUG)
+      log.fine("Keyring already contains alias: " + alias);
 
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "putPrivateKey");
   }
 
   public boolean containsPublicKey(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "containsPublicKey", alias);
     boolean result = false;
     if (containsAlias(alias))
@@ -251,6 +263,7 @@
             result = true;
             break;
           }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "containsPublicKey",
                 Boolean.valueOf(result));
     return result;
@@ -258,6 +271,7 @@
 
   public PublicKey getPublicKey(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "getPublicKey", alias);
     PublicKey result = null;
     if (containsAlias(alias))
@@ -270,6 +284,7 @@
               break;
             }
         }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "getPublicKey",
                 result == null ? "null" : result.getClass().getName());
     return result;
@@ -277,6 +292,7 @@
 
   public void putPublicKey(String alias, PublicKey key)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "putPublicKey",
                  new Object[] { alias, key.getClass().getName() });
     if (! containsPublicKey(alias))
@@ -285,14 +301,16 @@
         p.put("alias", fixAlias(alias));
         add(new PublicKeyEntry(key, new Date(), p));
       }
-    else
-      log.finer("Keyring already contains alias: " + alias);
+    else if (Configuration.DEBUG)
+      log.fine("Keyring already contains alias: " + alias);
 
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "putPublicKey");
   }
 
   public boolean containsCertPath(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "containsCertPath", alias);
     boolean result = false;
     if (containsAlias(alias))
@@ -302,6 +320,7 @@
             result = true;
             break;
           }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "containsCertPath",
                 Boolean.valueOf(result));
     return result;
@@ -309,6 +328,7 @@
 
   public Certificate[] getCertPath(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "getCertPath", alias);
     Certificate[] result = null;
     if (containsAlias(alias))
@@ -321,12 +341,14 @@
               break;
             }
         }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "getCertPath", result);
     return result;
   }
 
   public void putCertPath(String alias, Certificate[] path)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "putCertPath",
                  new Object[] { alias, path });
     if (! containsCertPath(alias))
@@ -335,14 +357,16 @@
         p.put("alias", fixAlias(alias));
         add(new CertPathEntry(path, new Date(), p));
       }
-    else
-      log.finer("Keyring already contains alias: " + alias);
+    else if (Configuration.DEBUG)
+      log.fine("Keyring already contains alias: " + alias);
 
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "putCertPath");
   }
 
   protected void load(InputStream in, char[] password) throws IOException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "load");
     if (in.read() != USAGE)
       throw new MalformedKeyringException("incompatible keyring usage");
@@ -352,14 +376,17 @@
 
     keyring = PasswordAuthenticatedEntry.decode(new DataInputStream(in),
                                                 password);
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "load");
   }
 
   protected void store(OutputStream out, char[] password) throws IOException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "store");
     out.write(USAGE);
     keyring.encode(new DataOutputStream(out), password);
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "store");
   }
 }

Index: javax/crypto/keyring/Entry.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/keyring/Entry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/keyring/Entry.java     20 May 2006 02:38:20 -0000      1.2
+++ javax/crypto/keyring/Entry.java     11 Jun 2006 12:14:43 -0000      1.3
@@ -38,6 +38,8 @@
 
 package gnu.javax.crypto.keyring;
 
+import gnu.classpath.Configuration;
+
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -179,7 +181,8 @@
       {
         throw new IOException("corrupt length");
       }
-    log.finest("About to instantiate new payload byte array for " + this);
+    if (Configuration.DEBUG)
+      log.fine("About to instantiate new payload byte array for " + this);
     payload = new byte[len];
     in.readFully(payload);
   }

Index: javax/crypto/keyring/PasswordEncryptedEntry.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/keyring/PasswordEncryptedEntry.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- javax/crypto/keyring/PasswordEncryptedEntry.java    20 May 2006 02:38:20 
-0000      1.3
+++ javax/crypto/keyring/PasswordEncryptedEntry.java    11 Jun 2006 12:14:43 
-0000      1.4
@@ -38,6 +38,7 @@
 
 package gnu.javax.crypto.keyring;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.prng.IRandom;
 import gnu.java.security.prng.LimitReachedException;
@@ -132,6 +133,7 @@
   public void decrypt(char[] password) throws IllegalArgumentException,
       WrongPaddingException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "decrypt");
     if (isMasked() && payload != null)
       {
@@ -162,15 +164,18 @@
             throw new IllegalArgumentException("decryption failed");
           }
         tt += System.currentTimeMillis();
-        log.finer("Decrypted in " + tt + "ms.");
+        log.fine("Decrypted in " + tt + "ms.");
       }
-    else
-      log.finer("Skip decryption; " + (isMasked() ? "null payload" : 
"unmasked"));
+    else if (Configuration.DEBUG)
+      log.fine("Skip decryption; " + (isMasked() ? "null payload" : 
"unmasked"));
+
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "decrypt");
   }
 
   public void encrypt(char[] password) throws IOException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "encrypt", 
String.valueOf(password));
     long tt = - System.currentTimeMillis();
     long t1 = - System.currentTimeMillis();
@@ -178,7 +183,8 @@
     byte[] salt = new byte[8];
     PRNG.getInstance().nextBytes(salt);
     t1 += System.currentTimeMillis();
-    log.finer("-- Generated salt in " + t1 + "ms.");
+    if (Configuration.DEBUG)
+      log.fine("-- Generated salt in " + t1 + "ms.");
     properties.put("salt", Util.toString(salt));
     IMode mode = getMode(password, IMode.ENCRYPTION);
     IPad pad = PadFactory.getInstance("PKCS7");
@@ -188,11 +194,13 @@
     for (Iterator it = entries.iterator(); it.hasNext();)
       {
         Entry entry = (Entry) it.next();
-        log.finer("-- About to encode one " + entry);
+        if (Configuration.DEBUG)
+          log.fine("-- About to encode one " + entry);
         t1 = - System.currentTimeMillis();
         entry.encode(out2);
         t1 += System.currentTimeMillis();
-        log.finer("-- Encoded an Entry in " + t1 + "ms.");
+        if (Configuration.DEBUG)
+          log.fine("-- Encoded an Entry in " + t1 + "ms.");
       }
     byte[] plaintext = bout.toByteArray();
     byte[] padding = pad.pad(plaintext, 0, plaintext.length);
@@ -212,9 +220,12 @@
     setMasked(true);
 
     tt += System.currentTimeMillis();
-    log.finer("Encrypted in " + tt + "ms.");
+    if (Configuration.DEBUG)
+      {
+        log.fine("Encrypted in " + tt + "ms.");
     log.exiting(this.getClass().getName(), "encrypt");
   }
+  }
 
   public void encode(DataOutputStream out, char[] password) throws IOException
   {
@@ -226,6 +237,7 @@
   {
     if (payload == null)
       {
+        if (Configuration.DEBUG)
         log.fine("Null payload: " + this);
         throw new IllegalStateException("not encrypted");
       }

Index: javax/crypto/keyring/PasswordAuthenticatedEntry.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/keyring/PasswordAuthenticatedEntry.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- javax/crypto/keyring/PasswordAuthenticatedEntry.java        20 May 2006 
02:38:19 -0000      1.3
+++ javax/crypto/keyring/PasswordAuthenticatedEntry.java        11 Jun 2006 
12:14:43 -0000      1.4
@@ -38,6 +38,7 @@
 
 package gnu.javax.crypto.keyring;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.prng.IRandom;
 import gnu.java.security.prng.LimitReachedException;
@@ -146,10 +147,12 @@
 
   public void verify(char[] password)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "verify");
     if (isMasked() && payload != null)
       {
-        log.finest("payload to verify: " + Util.dumpString(payload));
+        if (Configuration.DEBUG)
+          log.fine("payload to verify: " + Util.dumpString(payload));
         long tt = - System.currentTimeMillis();
         IMac m = null;
         try
@@ -184,15 +187,19 @@
           }
 
         tt += System.currentTimeMillis();
-        log.finer("Verified in " + tt + "ms.");
+        if (Configuration.DEBUG)
+          log.fine("Verified in " + tt + "ms.");
       }
-    else
-      log.finer("Skip verification; " + (isMasked() ? "null payload" : 
"unmasked"));
+    else if (Configuration.DEBUG)
+      log.fine("Skip verification; " + (isMasked() ? "null payload" : 
"unmasked"));
+
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "verify");
   }
 
   public void authenticate(char[] password) throws IOException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "authenticate");
     long tt = - System.currentTimeMillis();
     long t1 = - System.currentTimeMillis();
@@ -203,7 +210,8 @@
     byte[] salt = new byte[8];
     PRNG.getInstance().nextBytes(salt);
     t1 += System.currentTimeMillis();
-    log.finer("-- Generated salt in " + t1 + "ms.");
+    if (Configuration.DEBUG)
+      log.fine("-- Generated salt in " + t1 + "ms.");
     properties.put("salt", Util.toString(salt));
     IMac m = getMac(password);
     ByteArrayOutputStream bout = new ByteArrayOutputStream(1024);
@@ -212,22 +220,28 @@
     for (Iterator it = entries.iterator(); it.hasNext();)
       {
         Entry entry = (Entry) it.next();
-        log.finer("-- About to authenticate one " + entry);
+        if (Configuration.DEBUG)
+          log.fine("-- About to authenticate one " + entry);
         t1 = - System.currentTimeMillis();
         entry.encode(out2);
         t1 += System.currentTimeMillis();
-        log.finer("-- Authenticated an Entry in " + t1 + "ms.");
+        if (Configuration.DEBUG)
+          log.fine("-- Authenticated an Entry in " + t1 + "ms.");
       }
     bout.write(m.digest());
 
     payload = bout.toByteArray();
-    log.finest("authenticated payload: " + Util.dumpString(payload));
+    if (Configuration.DEBUG)
+      log.fine("authenticated payload: " + Util.dumpString(payload));
     setMasked(true);
 
     tt += System.currentTimeMillis();
-    log.finer("Authenticated in " + tt + "ms.");
+    if (Configuration.DEBUG)
+      {
+        log.fine("Authenticated in " + tt + "ms.");
     log.exiting(this.getClass().getName(), "authenticate");
   }
+  }
 
   public void encode(DataOutputStream out, char[] password) throws IOException
   {
@@ -249,6 +263,7 @@
 
   private IMac getMac(char[] password) throws MalformedKeyringException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "getMac");
     String saltString = properties.get("salt");
     if (saltString == null)
@@ -303,6 +318,7 @@
       {
         throw new Error(shouldNotHappen.toString());
       }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "getMac");
     return mac;
   }

Index: javax/crypto/keyring/EnvelopeEntry.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/keyring/EnvelopeEntry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/keyring/EnvelopeEntry.java     20 May 2006 02:38:20 -0000      
1.2
+++ javax/crypto/keyring/EnvelopeEntry.java     11 Jun 2006 12:14:43 -0000      
1.3
@@ -38,6 +38,8 @@
 
 package gnu.javax.crypto.keyring;
 
+import gnu.classpath.Configuration;
+
 import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
@@ -94,6 +96,7 @@
    */
   public void add(Entry entry)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "add", entry);
     if (! containsEntry(entry))
       {
@@ -101,9 +104,11 @@
           ((EnvelopeEntry) entry).setContainingEnvelope(this);
 
         entries.add(entry);
-        log.finest("Payload is " + (payload == null ? "" : "not ") + "null");
+        if (Configuration.DEBUG)
+          log.fine("Payload is " + (payload == null ? "" : "not ") + "null");
         makeAliasList();
       }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "add");
   }
 
@@ -117,9 +122,11 @@
    */
   public boolean containsAlias(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "containsAlias", alias);
     String aliases = getAliasList();
-    log.finest("aliases = [" + aliases + "]");
+    if (Configuration.DEBUG)
+      log.fine("aliases = [" + aliases + "]");
     boolean result = false;
     if (aliases != null)
       {
@@ -131,7 +138,9 @@
               break;
             }
       }
-    log.exiting(this.getClass().getName(), "containsAlias", 
Boolean.valueOf(result));
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "containsAlias",
+                  Boolean.valueOf(result));
     return result;
   }
 
@@ -182,8 +191,8 @@
    */
   public List get(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "get", alias);
-
     List result = new LinkedList();
     for (Iterator it = entries.iterator(); it.hasNext();)
       {
@@ -199,13 +208,14 @@
                 MaskableEnvelopeEntry mee = (MaskableEnvelopeEntry) ee;
                 if (mee.isMasked())
                   {
-                    log.finer("Processing masked entry: " + mee);
+                    if (Configuration.DEBUG)
+                      log.fine("Processing masked entry: " + mee);
                     result.add(mee);
                     continue;
                   }
               }
-
-            log.finer("Processing unmasked entry: " + ee);
+            if (Configuration.DEBUG)
+              log.fine("Processing unmasked entry: " + ee);
             result.addAll(ee.get(alias));
           }
         else if (e instanceof PrimitiveEntry)
@@ -215,7 +225,7 @@
               result.add(e);
           }
       }
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "get", result);
     return result;
   }
@@ -247,6 +257,7 @@
    */
   public boolean remove(Entry entry)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "remove", entry);
     boolean ret = false;
     for (Iterator it = entries.iterator(); it.hasNext();)
@@ -278,11 +289,14 @@
       }
     if (ret)
       {
-        log.finest("State before: " + this);
+        if (Configuration.DEBUG)
+          log.fine("State before: " + this);
         payload = null;
         makeAliasList();
-        log.finest("State after: " + this);
+        if (Configuration.DEBUG)
+          log.fine("State after: " + this);
       }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "remove", Boolean.valueOf(ret));
     return ret;
   }
@@ -298,6 +312,7 @@
    */
   public boolean remove(String alias)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "remove", alias);
     boolean result = false;
     for (Iterator it = entries.iterator(); it.hasNext();)
@@ -320,11 +335,14 @@
       }
     if (result)
       {
-        log.finest("State before: " + this);
+        if (Configuration.DEBUG)
+          log.fine("State before: " + this);
         payload = null;
         makeAliasList();
-        log.finest("State after: " + this);
+        if (Configuration.DEBUG)
+          log.fine("State after: " + this);
       }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "remove", Boolean.valueOf(result));
     return result;
   }
@@ -410,6 +428,7 @@
 
   private void makeAliasList()
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "makeAliasList");
     if (! entries.isEmpty())
       {
@@ -423,7 +442,7 @@
               aliasOrList = ((EnvelopeEntry) entry).getAliasList();
             else if (entry instanceof PrimitiveEntry)
               aliasOrList = ((PrimitiveEntry) entry).getAlias();
-            else
+            else if (Configuration.DEBUG)
               log.fine("Entry with no Alias. Ignored: " + entry);
 
             if (aliasOrList != null)
@@ -439,10 +458,12 @@
           }
         String aliasList = buf.toString();
         properties.put("alias-list", aliasList);
-        log.finer("alias-list=[" + aliasList + "]");
+        if (Configuration.DEBUG)
+          log.fine("alias-list=[" + aliasList + "]");
         if (containingEnvelope != null)
           containingEnvelope.makeAliasList();
       }
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "makeAliasList");
   }
 }

Index: java/security/key/rsa/GnuRSAPrivateKey.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/key/rsa/GnuRSAPrivateKey.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- java/security/key/rsa/GnuRSAPrivateKey.java 29 Apr 2006 06:53:06 -0000      
1.5
+++ java/security/key/rsa/GnuRSAPrivateKey.java 11 Jun 2006 12:14:43 -0000      
1.6
@@ -38,6 +38,7 @@
 
 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 @@
 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 @@
         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;

Index: java/security/key/rsa/RSAKeyPairPKCS8Codec.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- java/security/key/rsa/RSAKeyPairPKCS8Codec.java     29 Apr 2006 06:53:06 
-0000      1.4
+++ java/security/key/rsa/RSAKeyPairPKCS8Codec.java     11 Jun 2006 12:14:43 
-0000      1.5
@@ -38,15 +38,7 @@
 
 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.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 address@hidden IKeyPairCodec} that knows how to 
encode /
  * decode PKCS#8 ASN.1 external representation of RSA private keys.
@@ -122,6 +123,7 @@
    */
   public byte[] encodePrivateKey(PrivateKey key)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "encodePrivateKey()", key);
 
     if (! (key instanceof GnuRSAPrivateKey))
@@ -190,7 +192,7 @@
         y.initCause(x);
         throw y;
       }
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "encodePrivateKey()", result);
     return result;
   }
@@ -213,6 +215,7 @@
    */
   public PrivateKey decodePrivateKey(byte[] input)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "decodePrivateKey()", input);
 
     if (input == null)
@@ -287,6 +290,7 @@
 
     PrivateKey result = new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID, n, e,
                                              d, p, q, dP, dQ, qInv);
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "decodePrivateKey()", result);
     return result;
   }

Index: java/security/key/rsa/RSAKeyPairX509Codec.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- java/security/key/rsa/RSAKeyPairX509Codec.java      29 Apr 2006 06:53:06 
-0000      1.5
+++ java/security/key/rsa/RSAKeyPairX509Codec.java      11 Jun 2006 12:14:43 
-0000      1.6
@@ -38,6 +38,7 @@
 
 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,6 +115,7 @@
    */
   public byte[] encodePublicKey(PublicKey key)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "encodePublicKey()", key);
 
     if (! (key instanceof GnuRSAPublicKey))
@@ -160,7 +162,7 @@
         y.initCause(x);
         throw y;
       }
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "encodePublicKey()", result);
     return result;
   }
@@ -183,6 +185,7 @@
    */
   public PublicKey decodePublicKey(byte[] input)
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "decodePublicKey()", input);
 
     if (input == null)
@@ -235,6 +238,7 @@
       }
 
     PublicKey result = new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e);
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "decodePublicKey()", result);
     return result;
   }

Index: java/security/key/rsa/RSAKeyPairGenerator.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/key/rsa/RSAKeyPairGenerator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- java/security/key/rsa/RSAKeyPairGenerator.java      29 Apr 2006 06:53:06 
-0000      1.4
+++ java/security/key/rsa/RSAKeyPairGenerator.java      11 Jun 2006 12:14:43 
-0000      1.5
@@ -38,6 +38,7 @@
 
 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 void setup(Map 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,7 +182,7 @@
     Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT);
     preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT
                                        : formatID.intValue();
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "setup");
   }
 
@@ -193,6 +194,7 @@
    */
   public KeyPair generate()
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "generate");
 
     BigInteger p, q, n, d;
@@ -243,6 +245,7 @@
     PrivateKey secK = new GnuRSAPrivateKey(preferredFormat, p, q, e, d);
 
     KeyPair result = new KeyPair(pubK, secK);
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "generate", result);
     return result;
   }

Index: javax/crypto/jce/prng/UMacRandomSpi.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/jce/prng/UMacRandomSpi.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- javax/crypto/jce/prng/UMacRandomSpi.java    26 Jan 2006 02:25:09 -0000      
1.1
+++ javax/crypto/jce/prng/UMacRandomSpi.java    11 Jun 2006 12:14:44 -0000      
1.2
@@ -38,15 +38,16 @@
 
 package gnu.javax.crypto.jce.prng;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
-import gnu.javax.crypto.cipher.IBlockCipher;
 import gnu.java.security.prng.LimitReachedException;
+import gnu.javax.crypto.cipher.IBlockCipher;
 import gnu.javax.crypto.prng.UMacGenerator;
 
-import java.io.PrintWriter;
 import java.security.SecureRandomSpi;
 import java.util.HashMap;
 import java.util.Random;
+import java.util.logging.Logger;
 
 /**
  * <p>An <em>Adapter</em> class around address@hidden UMacGenerator} to allow 
using this
@@ -54,24 +55,7 @@
  */
 public class UMacRandomSpi extends SecureRandomSpi
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = "UMacRandomSpi";
-
-  private static final boolean DEBUG = false;
-
-  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(UMacRandomSpi.class.getName());
   /** Class-wide prng to generate random material for the underlying prng.*/
   private static final UMacGenerator prng; // blank final
   static
@@ -181,10 +165,10 @@
               }
             catch (LimitReachedException x)
               {
-                if (DEBUG)
+                if (Configuration.DEBUG)
                   {
-                    debug(MSG + String.valueOf(x));
-                    debug(RETRY);
+                    log.fine(MSG + String.valueOf(x));
+                    log.fine(RETRY);
                   }
               }
           }

Index: javax/crypto/jce/prng/ICMRandomSpi.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/jce/prng/ICMRandomSpi.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- javax/crypto/jce/prng/ICMRandomSpi.java     26 Jan 2006 02:25:09 -0000      
1.1
+++ javax/crypto/jce/prng/ICMRandomSpi.java     11 Jun 2006 12:14:44 -0000      
1.2
@@ -38,16 +38,17 @@
 
 package gnu.javax.crypto.jce.prng;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
+import gnu.java.security.prng.LimitReachedException;
 import gnu.javax.crypto.cipher.IBlockCipher;
 import gnu.javax.crypto.prng.ICMGenerator;
-import gnu.java.security.prng.LimitReachedException;
 
-import java.io.PrintWriter;
 import java.math.BigInteger;
 import java.security.SecureRandomSpi;
 import java.util.HashMap;
 import java.util.Random;
+import java.util.logging.Logger;
 
 /**
  * <p>An <em>Adapter</em> class around address@hidden ICMGenerator} to allow 
using this
@@ -55,26 +56,7 @@
  */
 public class ICMRandomSpi extends SecureRandomSpi
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = "ICMRandomSpi";
-
-  private static final boolean DEBUG = false;
-
-  private static final int debuglevel = 0;
-
-  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(ICMRandomSpi.class.getName());
   /** Class-wide prng to generate random material for the underlying prng.*/
   private static final ICMGenerator prng; // blank final
   static
@@ -106,8 +88,8 @@
 
   private static void resetLocalPRNG()
   {
-    if (DEBUG && debuglevel > 8)
-      debug(">>> resetLocalPRNG()");
+    if (Configuration.DEBUG)
+      log.entering(ICMRandomSpi.class.getName(), "resetLocalPRNG");
     HashMap attributes = new HashMap();
     attributes.put(ICMGenerator.CIPHER, Registry.AES_CIPHER);
     byte[] key = new byte[128 / 8]; // AES default key size
@@ -131,8 +113,8 @@
     attributes.put(ICMGenerator.SEGMENT_INDEX, new BigInteger(1, index));
 
     prng.setup(attributes);
-    if (DEBUG && debuglevel > 8)
-      debug("<<< resetLocalPRNG()");
+    if (Configuration.DEBUG)
+      log.exiting(ICMRandomSpi.class.getName(), "resetLocalPRNG");
   }
 
   // Instance methods
@@ -142,25 +124,25 @@
 
   public byte[] engineGenerateSeed(int numBytes)
   {
-    if (DEBUG && debuglevel > 8)
-      debug(">>> engineGenerateSeed()");
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "engineGenerateSeed");
     if (numBytes < 1)
       {
-        if (DEBUG && debuglevel > 8)
-          debug("<<< engineGenerateSeed()");
+        if (Configuration.DEBUG)
+          log.exiting(this.getClass().getName(), "engineGenerateSeed");
         return new byte[0];
       }
     byte[] result = new byte[numBytes];
     this.engineNextBytes(result);
-    if (DEBUG && debuglevel > 8)
-      debug("<<< engineGenerateSeed()");
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "engineGenerateSeed");
     return result;
   }
 
   public void engineNextBytes(byte[] bytes)
   {
-    if (DEBUG && debuglevel > 8)
-      debug(">>> engineNextBytes()");
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "engineNextBytes");
     if (!adaptee.isInitialised())
       {
         this.engineSetSeed(new byte[0]);
@@ -175,23 +157,22 @@
           }
         catch (LimitReachedException x)
           { // reseed the generator
-            if (DEBUG)
+            if (Configuration.DEBUG)
               {
-                debug(LIMIT_REACHED_MSG + String.valueOf(x));
-                x.printStackTrace(err);
-                debug(RESEED);
+                log.fine(LIMIT_REACHED_MSG + String.valueOf(x));
+                log.fine(RESEED);
               }
             resetLocalPRNG();
           }
       }
-    if (DEBUG && debuglevel > 8)
-      debug("<<< engineNextBytes()");
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "engineNextBytes");
   }
 
   public void engineSetSeed(byte[] seed)
   {
-    if (DEBUG && debuglevel > 8)
-      debug(">>> engineSetSeed()");
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "engineSetSeed");
     // compute the total number of random bytes required to setup adaptee
     int materialLength = 0;
     materialLength += 16; // key material size
@@ -224,10 +205,10 @@
               }
             catch (LimitReachedException x)
               {
-                if (DEBUG)
+                if (Configuration.DEBUG)
                   {
-                    debug(MSG + String.valueOf(x));
-                    debug(RETRY);
+                    log.fine(MSG + String.valueOf(x));
+                    log.fine(RETRY);
                   }
               }
           }
@@ -254,7 +235,7 @@
     attributes.put(ICMGenerator.SEGMENT_INDEX, new BigInteger(1, index));
 
     adaptee.init(attributes);
-    if (DEBUG && debuglevel > 8)
-      debug("<<< engineSetSeed()");
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "engineSetSeed");
   }
 }
\ No newline at end of file

Index: java/security/x509/X509CRLEntry.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/x509/X509CRLEntry.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- java/security/x509/X509CRLEntry.java        2 Jul 2005 20:32:14 -0000       
1.5
+++ java/security/x509/X509CRLEntry.java        11 Jun 2006 12:14:44 -0000      
1.6
@@ -38,6 +38,7 @@
 
 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.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 @@
 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 @@
   {
     // 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 @@
         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);
           }
       }
   }

Index: java/security/x509/X509CRL.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/x509/X509CRL.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- java/security/x509/X509CRL.java     2 Jul 2005 20:32:14 -0000       1.7
+++ java/security/x509/X509CRL.java     11 Jun 2006 12:14:44 -0000      1.8
@@ -38,6 +38,7 @@
 
 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.HashSet;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.logging.Logger;
 
 import javax.security.auth.x500.X500Principal;
 
@@ -75,20 +77,7 @@
 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 @@
     // 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 @@
     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 @@
       }
     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 @@
     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 @@
         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 @@
             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();
   }

Index: javax/crypto/pad/TBC.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/pad/TBC.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/pad/TBC.java   4 Jun 2006 06:57:25 -0000       1.2
+++ javax/crypto/pad/TBC.java   11 Jun 2006 12:14:44 -0000      1.3
@@ -38,10 +38,11 @@
 
 package gnu.javax.crypto.pad;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.util.Util;
 
-import java.io.PrintWriter;
+import java.util.logging.Logger;
 
 /**
  * <p>The implementation of the Trailing Bit Complement (TBC) padding 
algorithm.</p>
@@ -59,28 +60,7 @@
  */
 public final class TBC extends BasePad
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = "tbc";
-
-  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(String s)
-  {
-    err.println(">>> " + NAME + ": " + s);
-  }
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
-  // Constructor(s)
-  // -------------------------------------------------------------------------
+  private static final Logger log = Logger.getLogger(TBC.class.getName());
 
   /**
    * Trivial package-private constructor for use by the <i>Factory</i> 
class.<p>
@@ -123,10 +103,8 @@
           }
       } // else it's already set to zeroes by virtue of initialisation
 
-    if (DEBUG && debuglevel > 8)
-      {
-        debug("padding: 0x" + Util.toString(result));
-      }
+    if (Configuration.DEBUG)
+      log.fine("padding: 0x" + Util.toString(result));
     return result;
   }
 
@@ -146,11 +124,8 @@
       {
         throw new WrongPaddingException();
       }
-
-    if (DEBUG && debuglevel > 8)
-      {
-        debug("padding length: " + String.valueOf(result));
-      }
+    if (Configuration.DEBUG)
+      log.fine("padding length: " + result);
     return result;
   }
 }
\ No newline at end of file

Index: javax/crypto/pad/PKCS7.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/pad/PKCS7.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/pad/PKCS7.java 4 Jun 2006 06:57:25 -0000       1.2
+++ javax/crypto/pad/PKCS7.java 11 Jun 2006 12:14:44 -0000      1.3
@@ -38,10 +38,11 @@
 
 package gnu.javax.crypto.pad;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.util.Util;
 
-import java.io.PrintWriter;
+import java.util.logging.Logger;
 
 /**
  * <p>The implementation of the PKCS7 padding algorithm.</p>
@@ -60,28 +61,7 @@
  */
 public final class PKCS7 extends BasePad
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = "pkcs7";
-
-  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(String s)
-  {
-    err.println(">>> " + NAME + ": " + s);
-  }
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
-  // Constructor(s)
-  // -------------------------------------------------------------------------
+  private static final Logger log = Logger.getLogger(PKCS7.class.getName());
 
   /**
    * Trivial package-private constructor for use by the <i>Factory</i> 
class.<p>
@@ -119,11 +99,8 @@
       {
         result[i++] = (byte) padLength;
       }
-
-    if (DEBUG && debuglevel > 8)
-      {
-        debug("padding: 0x" + Util.toString(result));
-      }
+    if (Configuration.DEBUG)
+      log.fine("padding: 0x" + Util.toString(result));
     return result;
   }
 
@@ -139,11 +116,8 @@
             throw new WrongPaddingException();
           }
       }
-
-    if (DEBUG && debuglevel > 8)
-      {
-        debug("padding length: " + String.valueOf(result));
-      }
+    if (Configuration.DEBUG)
+      log.fine("padding length: " + result);
     return result;
   }
 }
\ No newline at end of file

Index: javax/crypto/pad/PKCS1_V1_5.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/pad/PKCS1_V1_5.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- javax/crypto/pad/PKCS1_V1_5.java    4 Jun 2006 06:57:25 -0000       1.3
+++ javax/crypto/pad/PKCS1_V1_5.java    11 Jun 2006 12:14:44 -0000      1.4
@@ -38,12 +38,14 @@
 
 package gnu.javax.crypto.pad;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.sig.rsa.EME_PKCS1_V1_5;
 import gnu.java.security.util.PRNG;
 import gnu.java.security.util.Util;
 
-import java.io.PrintWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * <p>A padding algorithm implementation of the EME-PKCS1-V1.5 
encoding/decoding
@@ -63,26 +65,7 @@
  */
 public class PKCS1_V1_5 extends BasePad
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = Registry.EME_PKCS1_V1_5_PAD;
-
-  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(PKCS1_V1_5.class.getName());
   private EME_PKCS1_V1_5 codec;
 
   // Constructor(s)
@@ -117,10 +100,8 @@
     final byte[] EM = codec.encode(M);
     final byte[] result = new byte[blockSize - length];
     System.arraycopy(EM, 0, result, 0, result.length);
-    if (DEBUG && debuglevel > 8)
-      {
-        debug("padding: 0x" + Util.toString(result));
-      }
+    if (Configuration.DEBUG)
+      log.fine("padding: 0x" + Util.toString(result));
     return result;
   }
 
@@ -130,10 +111,8 @@
     final byte[] EM = new byte[length];
     System.arraycopy(in, offset, EM, 0, length);
     final int result = length - codec.decode(EM).length;
-    if (DEBUG && debuglevel > 8)
-      {
-        debug("padding length: " + String.valueOf(result));
-      }
+    if (Configuration.DEBUG)
+      log.fine("padding length: " + String.valueOf(result));
     return result;
   }
 
@@ -156,7 +135,10 @@
             p = pad(M, 0, j);
             if (j + p.length != blockSize)
               {
-                new RuntimeException(name()).printStackTrace(System.err);
+                if (Configuration.DEBUG)
+                  log.log(Level.SEVERE,
+                          "Length of padded text MUST be a multiple of " + 
blockSize,
+                          new RuntimeException(name()));
                 return false;
               }
 
@@ -166,13 +148,17 @@
               {
                 if (p.length != unpad(EM, 0, blockSize))
                   {
-                    new RuntimeException(name()).printStackTrace(System.err);
+                    if (Configuration.DEBUG)
+                      log.log(Level.SEVERE,
+                              "Failed symmetric operation",
+                              new RuntimeException(name()));
                     return false;
                   }
               }
             catch (WrongPaddingException x)
               {
-                x.printStackTrace(System.err);
+                if (Configuration.DEBUG)
+                  log.throwing(this.getClass().getName(), "selfTest", x);
                 return false;
               }
           }

Index: javax/crypto/pad/BasePad.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/pad/BasePad.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/pad/BasePad.java       9 Jun 2006 11:28:46 -0000       1.2
+++ javax/crypto/pad/BasePad.java       11 Jun 2006 12:14:44 -0000      1.3
@@ -38,18 +38,19 @@
 
 package gnu.javax.crypto.pad;
 
+import gnu.classpath.Configuration;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 /**
- * <p>An abstract class to facilitate implementing padding algorithms.</p>
+ * An abstract class to facilitate implementing padding algorithms.
  */
 public abstract class BasePad implements IPad
 {
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
+  private static final Logger log = Logger.getLogger(BasePad.class.getName());
   /** The canonical name prefix of the padding algorithm. */
   protected String name;
-
   /** The block size, in bytes, for this instance. */
   protected int blockSize;
 
@@ -139,7 +140,10 @@
         padBytes = pad(buffer, offset, i);
         if (((i + padBytes.length) % blockSize) != 0)
           {
-            new RuntimeException(name()).printStackTrace(System.err);
+            if (Configuration.DEBUG)
+              log.log(Level.SEVERE,
+                      "Length of padded text MUST be a multiple of " + 
blockSize,
+                      new RuntimeException(name()));
             return false;
           }
         System.arraycopy(padBytes, 0, buffer, offset + i, padBytes.length);
@@ -147,13 +151,17 @@
           {
             if (padBytes.length != unpad(buffer, offset, i + padBytes.length))
               {
-                new RuntimeException(name()).printStackTrace(System.err);
+                if (Configuration.DEBUG)
+                  log.log(Level.SEVERE,
+                          "IPad [" + name() + "] failed symmetric operation",
+                          new RuntimeException(name()));
                 return false;
               }
           }
         catch (WrongPaddingException x)
           {
-            x.printStackTrace(System.err);
+            if (Configuration.DEBUG)
+              log.throwing(this.getClass().getName(), "test1BlockSize", x);
             return false;
           }
       }

Index: java/security/hash/Whirlpool.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/hash/Whirlpool.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- java/security/hash/Whirlpool.java   21 Apr 2006 10:35:36 -0000      1.3
+++ java/security/hash/Whirlpool.java   11 Jun 2006 12:14:44 -0000      1.4
@@ -38,9 +38,12 @@
 
 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 @@
  */
 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 @@
                 ^ (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.");
         }
     }
 

Index: javax/crypto/prng/CSPRNG.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/prng/CSPRNG.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- javax/crypto/prng/CSPRNG.java       4 Jun 2006 06:57:25 -0000       1.3
+++ javax/crypto/prng/CSPRNG.java       11 Jun 2006 12:14:44 -0000      1.4
@@ -38,6 +38,7 @@
 
 package gnu.javax.crypto.prng;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Properties;
 import gnu.java.security.Registry;
 import gnu.java.security.hash.HashFactory;
@@ -68,6 +69,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * <p>An entropy pool-based pseudo-random number generator based on the PRNG
@@ -84,18 +87,7 @@
  */
 public class CSPRNG extends BasePRNG
 {
-
-  // Constants and fields.
-  // -------------------------------------------------------------------------
-
-  private static final boolean DEBUG = false;
-
-  private static void debug(String msg)
-  {
-    System.err.print(">>> CSPRNG: ");
-    System.err.println(msg);
-  }
-
+  private static final Logger log = Logger.getLogger(CSPRNG.class.getName());
   /**
    * Property name for the list of files to read for random values. The
    * mapped value is a list with the following values:
@@ -480,34 +472,25 @@
   public void setup(Map attrib)
   {
     List list = null;
-
-    if (DEBUG)
-      {
-        debug(String.valueOf(attrib));
-      }
+    if (Configuration.DEBUG)
+      log.fine("attrib=" + String.valueOf(attrib));
     try
       {
         list = (List) attrib.get(FILE_SOURCES);
-        if (DEBUG)
-          {
-            debug(String.valueOf(list));
-          }
+        if (Configuration.DEBUG)
+          log.fine("list=" + String.valueOf(list));
         if (list != null)
           {
             files.clear();
             for (Iterator it = list.iterator(); it.hasNext();)
               {
                 List l = (List) it.next();
-                if (DEBUG)
-                  {
-                    debug("l=" + l);
-                  }
+                if (Configuration.DEBUG)
+                  log.fine("l=" + l);
                 if (l.size() != 4)
                   {
-                    if (DEBUG)
-                      {
-                        debug("file list too small: " + l.size());
-                      }
+                    if (Configuration.DEBUG)
+                      log.fine("file list too small: " + l.size());
                     throw new IllegalArgumentException("invalid file list");
                   }
                 Double quality = (Double) l.get(0);
@@ -520,37 +503,28 @@
       }
     catch (ClassCastException cce)
       {
-        if (DEBUG)
-          {
-            debug("bad file list: " + cce.getMessage());
-            cce.printStackTrace();
-          }
+        if (Configuration.DEBUG)
+          log.log(Level.FINE, "bad file list", cce);
         throw new IllegalArgumentException("invalid file list");
       }
 
     try
       {
         list = (List) attrib.get(URL_SOURCES);
-        if (DEBUG)
-          {
-            debug(String.valueOf(list));
-          }
+        if (Configuration.DEBUG)
+          log.fine("list=" + String.valueOf(list));
         if (list != null)
           {
             urls.clear();
             for (Iterator it = list.iterator(); it.hasNext();)
               {
                 List l = (List) it.next();
-                if (DEBUG)
-                  {
-                    debug("l=" + l);
-                  }
+                if (Configuration.DEBUG)
+                  log.fine("l=" + l);
                 if (l.size() != 4)
                   {
-                    if (DEBUG)
-                      {
-                        debug("URL list too small: " + l.size());
-                      }
+                    if (Configuration.DEBUG)
+                      log.fine("URL list too small: " + l.size());
                     throw new IllegalArgumentException("invalid URL list");
                   }
                 Double quality = (Double) l.get(0);
@@ -563,37 +537,28 @@
       }
     catch (ClassCastException cce)
       {
-        if (DEBUG)
-          {
-            debug("bad URL list: " + cce.getMessage());
-            cce.printStackTrace();
-          }
+        if (Configuration.DEBUG)
+          log.log(Level.FINE, "bad URL list", cce);
         throw new IllegalArgumentException("invalid URL list");
       }
 
     try
       {
         list = (List) attrib.get(PROGRAM_SOURCES);
-        if (DEBUG)
-          {
-            debug(String.valueOf(list));
-          }
+        if (Configuration.DEBUG)
+          log.fine("list=" + String.valueOf(list));
         if (list != null)
           {
             progs.clear();
             for (Iterator it = list.iterator(); it.hasNext();)
               {
                 List l = (List) it.next();
-                if (DEBUG)
-                  {
-                    debug("l=" + l);
-                  }
+                if (Configuration.DEBUG)
+                  log.fine("l=" + l);
                 if (l.size() != 4)
                   {
-                    if (DEBUG)
-                      {
-                        debug("program list too small: " + l.size());
-                      }
+                    if (Configuration.DEBUG)
+                      log.fine("program list too small: " + l.size());
                     throw new IllegalArgumentException("invalid program list");
                   }
                 Double quality = (Double) l.get(0);
@@ -606,31 +571,24 @@
       }
     catch (ClassCastException cce)
       {
-        if (DEBUG)
-          {
-            debug("bad program list: " + cce.getMessage());
-            cce.printStackTrace();
-          }
+        if (Configuration.DEBUG)
+          log.log(Level.FINE, "bad program list", cce);
         throw new IllegalArgumentException("invalid program list");
       }
 
     try
       {
         list = (List) attrib.get(OTHER_SOURCES);
-        if (DEBUG)
-          {
-            debug(String.valueOf(list));
-          }
+        if (Configuration.DEBUG)
+          log.fine("list=" + String.valueOf(list));
         if (list != null)
           {
             other.clear();
             for (Iterator it = list.iterator(); it.hasNext();)
               {
                 EntropySource src = (EntropySource) it.next();
-                if (DEBUG)
-                  {
-                    debug("src=" + src);
-                  }
+                if (Configuration.DEBUG)
+                  log.fine("src=" + src);
                 if (src == null)
                   {
                     throw new NullPointerException("null source in source 
list");
@@ -674,16 +632,12 @@
 
   public void fillBlock() throws LimitReachedException
   {
-    if (DEBUG)
-      {
-        debug("fillBlock");
-      }
+    if (Configuration.DEBUG)
+      log.fine("fillBlock");
     if (getQuality() < 100.0)
       {
-        if (DEBUG)
-          {
-            debug("doing slow poll");
-          }
+        if (Configuration.DEBUG)
+          log.fine("doing slow poll");
         slowPoll();
       }
 
@@ -759,10 +713,10 @@
       {
         throw new ArrayIndexOutOfBoundsException();
       }
-    if (DEBUG)
+    if (Configuration.DEBUG)
       {
-        debug("adding random bytes:");
-        debug(Util.toString(buf, off, len));
+        log.fine("adding random bytes:");
+        log.fine(Util.toString(buf, off, len));
       }
     final int count = off + len;
     for (int i = off; i < count; i++)
@@ -785,10 +739,8 @@
    */
   public synchronized void addRandomByte(byte b)
   {
-    if (DEBUG)
-      {
-        debug("adding byte " + Integer.toHexString(b));
-      }
+    if (Configuration.DEBUG)
+      log.fine("adding byte " + Integer.toHexString(b));
     pool[index++] ^= b;
     if (index >= pool.length)
       {
@@ -802,18 +754,14 @@
 
   synchronized void addQuality(double quality)
   {
-    if (DEBUG)
-      {
-        debug("adding quality " + quality);
-      }
+    if (Configuration.DEBUG)
+      log.fine("adding quality " + quality);
     if (this.quality < 100)
       {
         this.quality += quality;
       }
-    if (DEBUG)
-      {
-        debug("quality now " + this.quality);
-      }
+    if (Configuration.DEBUG)
+      log.fine("quality now " + this.quality);
   }
 
   synchronized double getQuality()
@@ -923,11 +871,9 @@
 
   private void slowPoll() throws LimitReachedException
   {
-    if (DEBUG)
-      {
-        debug("poller is alive? "
+    if (Configuration.DEBUG)
+      log.fine("poller is alive? "
               + (pollerThread == null ? false : pollerThread.isAlive()));
-      }
     if (pollerThread == null || !pollerThread.isAlive())
       {
         boolean interrupted = false;
@@ -951,12 +897,9 @@
         // and there in insufficient randomness, throw an exception.
         if (!interrupted && blocking && quality < 100.0)
           {
-            if (DEBUG)
-              {
-                debug("insufficient quality: " + quality);
-              }
-            throw new LimitReachedException(
-                                            "insufficient randomness was 
polled");
+            if (Configuration.DEBUG)
+              log.fine("insufficient quality: " + quality);
+            throw new LimitReachedException("insufficient randomness was 
polled");
           }
       }
   }
@@ -1054,11 +997,11 @@
     public void run()
     {
       running = true;
-      if (DEBUG)
+      if (Configuration.DEBUG)
         {
-          debug("files: " + files);
-          debug("URLs: " + urls);
-          debug("progs: " + progs);
+          log.fine("files: " + files);
+          log.fine("URLs: " + urls);
+          log.fine("progs: " + progs);
         }
       Iterator files_it = files.iterator();
       Iterator urls_it = urls.iterator();
@@ -1080,10 +1023,8 @@
               try
                 {
                   List l = (List) files_it.next();
-                  if (DEBUG)
-                    {
-                      debug(l.toString());
-                    }
+                  if (Configuration.DEBUG)
+                    log.fine(l.toString());
                   double qual = ((Double) l.get(0)).doubleValue();
                   int offset = ((Integer) l.get(1)).intValue();
                   int count = ((Integer) l.get(2)).intValue();
@@ -1100,18 +1041,13 @@
                       pool.addRandomBytes(buf, 0, len);
                       pool.addQuality(qual * ((double) len / (double) count));
                     }
-                  if (DEBUG)
-                    {
-                      debug("got " + len + " bytes from " + src);
-                    }
+                  if (Configuration.DEBUG)
+                    log.fine("got " + len + " bytes from " + src);
                 }
               catch (Exception x)
                 {
-                  if (DEBUG)
-                    {
-                      debug(x.toString());
-                      x.printStackTrace();
-                    }
+                  if (Configuration.DEBUG)
+                    log.throwing(this.getClass().getName(), "run", x);
                 }
             }
 
@@ -1125,10 +1061,8 @@
               try
                 {
                   List l = (List) urls_it.next();
-                  if (DEBUG)
-                    {
-                      debug(l.toString());
-                    }
+                  if (Configuration.DEBUG)
+                    log.fine(l.toString());
                   double qual = ((Double) l.get(0)).doubleValue();
                   int offset = ((Integer) l.get(1)).intValue();
                   int count = ((Integer) l.get(2)).intValue();
@@ -1145,18 +1079,13 @@
                       pool.addRandomBytes(buf, 0, len);
                       pool.addQuality(qual * ((double) len / (double) count));
                     }
-                  if (DEBUG)
-                    {
-                      debug("got " + len + " bytes from " + src);
-                    }
+                  if (Configuration.DEBUG)
+                    log.fine("got " + len + " bytes from " + src);
                 }
               catch (Exception x)
                 {
-                  if (DEBUG)
-                    {
-                      debug(x.toString());
-                      x.printStackTrace();
-                    }
+                  if (Configuration.DEBUG)
+                    log.throwing(this.getClass().getName(), "run", x);
                 }
             }
 
@@ -1171,10 +1100,8 @@
               try
                 {
                   List l = (List) prog_it.next();
-                  if (DEBUG)
-                    {
-                      debug(l.toString());
-                    }
+                  if (Configuration.DEBUG)
+                    log.finer(l.toString());
                   double qual = ((Double) l.get(0)).doubleValue();
                   int offset = ((Integer) l.get(1)).intValue();
                   int count = ((Integer) l.get(2)).intValue();
@@ -1195,18 +1122,13 @@
                     }
                   proc.destroy();
                   proc.waitFor();
-                  if (DEBUG)
-                    {
-                      debug("got " + len + " bytes from " + src);
-                    }
+                  if (Configuration.DEBUG)
+                    log.fine("got " + len + " bytes from " + src);
                 }
               catch (Exception x)
                 {
-                  if (DEBUG)
-                    {
-                      debug(x.toString());
-                      x.printStackTrace();
-                    }
+                  if (Configuration.DEBUG)
+                    log.throwing(this.getClass().getName(), "run", x);
                   try
                     {
                       if (proc != null)
@@ -1238,18 +1160,13 @@
                     }
                   pool.addRandomBytes(buf, 0, buf.length);
                   pool.addQuality(src.quality());
-                  if (DEBUG)
-                    {
-                      debug("got " + buf.length + " bytes from " + src);
-                    }
+                  if (Configuration.DEBUG)
+                    log.fine("got " + buf.length + " bytes from " + src);
                 }
               catch (Exception x)
                 {
-                  if (DEBUG)
-                    {
-                      debug(x.toString());
-                      x.printStackTrace();
-                    }
+                  if (Configuration.DEBUG)
+                    log.throwing(this.getClass().getName(), "run", x);
                 }
             }
         }

Index: java/security/key/dss/DSSPrivateKey.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/key/dss/DSSPrivateKey.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- java/security/key/dss/DSSPrivateKey.java    26 Mar 2006 22:57:46 -0000      
1.4
+++ java/security/key/dss/DSSPrivateKey.java    11 Jun 2006 12:14:44 -0000      
1.5
@@ -38,6 +38,7 @@
 
 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 @@
  */
 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 &lt; x &lt;
    * q</code>.</p>
@@ -210,7 +206,8 @@
         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();
       }
 

Index: java/security/key/dss/DSSKeyPairPKCS8Codec.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- java/security/key/dss/DSSKeyPairPKCS8Codec.java     25 Mar 2006 11:19:26 
-0000      1.5
+++ java/security/key/dss/DSSKeyPairPKCS8Codec.java     11 Jun 2006 12:14:44 
-0000      1.6
@@ -38,6 +38,7 @@
 
 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 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 @@
         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 @@
         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);
   }
 }

Index: java/security/key/dss/DSSKeyPairGenerator.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/key/dss/DSSKeyPairGenerator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- java/security/key/dss/DSSKeyPairGenerator.java      23 Feb 2006 12:54:46 
-0000      1.4
+++ java/security/key/dss/DSSKeyPairGenerator.java      11 Jun 2006 12:14:44 
-0000      1.5
@@ -38,12 +38,12 @@
 
 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.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 @@
  */
 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 @@
         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));
           }
       }
 

Index: java/security/x509/ext/Extension.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/x509/ext/Extension.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- java/security/x509/ext/Extension.java       1 Oct 2005 18:48:46 -0000       
1.5
+++ java/security/x509/ext/Extension.java       11 Jun 2006 12:14:44 -0000      
1.6
@@ -38,6 +38,7 @@
 
 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.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 @@
 
     // 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 @@
     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 @@
       }
     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 @@
         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)

Index: javax/crypto/sasl/srp/SRPServer.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- javax/crypto/sasl/srp/SRPServer.java        13 Apr 2006 21:07:03 -0000      
1.3
+++ javax/crypto/sasl/srp/SRPServer.java        11 Jun 2006 12:14:44 -0000      
1.4
@@ -38,18 +38,18 @@
 
 package gnu.javax.crypto.sasl.srp;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.util.PRNG;
 import gnu.java.security.util.Util;
-
 import gnu.javax.crypto.assembly.Direction;
 import gnu.javax.crypto.cipher.CipherFactory;
 import gnu.javax.crypto.cipher.IBlockCipher;
 import gnu.javax.crypto.key.IKeyAgreementParty;
-import gnu.javax.crypto.key.KeyAgreementFactory;
+import gnu.javax.crypto.key.IncomingMessage;
 import gnu.javax.crypto.key.KeyAgreementException;
+import gnu.javax.crypto.key.KeyAgreementFactory;
 import gnu.javax.crypto.key.OutgoingMessage;
-import gnu.javax.crypto.key.IncomingMessage;
 import gnu.javax.crypto.key.srp6.SRP6KeyAgreement;
 import gnu.javax.crypto.sasl.IllegalMechanismStateException;
 import gnu.javax.crypto.sasl.InputBuffer;
@@ -57,114 +57,55 @@
 import gnu.javax.crypto.sasl.OutputBuffer;
 import gnu.javax.crypto.sasl.ServerMechanism;
 
-import java.io.IOException;
-import java.io.PrintWriter;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.StringTokenizer;
+import java.util.logging.Logger;
 
 import javax.security.sasl.AuthenticationException;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
 
 /**
- * <p>The SASL-SRP server-side mechanism.</p>
+ * The SASL-SRP server-side mechanism.
  */
 public class SRPServer extends ServerMechanism implements SaslServer
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = "SRPServer";
-
-  //   private static final String ERROR = "ERROR";
-  private static final String WARN = " WARN";
-
-  private static final String INFO = " INFO";
-
-  private static final String TRACE = "DEBUG";
-
-  private static final boolean DEBUG = true;
-
-  private static final int debuglevel = 3;
-
-  private static final PrintWriter err = new PrintWriter(System.out, true);
-
-  private static void debug(final String level, final Object obj)
-  {
-    err.println("[" + level + "] " + NAME + ": " + String.valueOf(obj));
-  }
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
+  private static final Logger log = 
Logger.getLogger(SRPServer.class.getName());
   private String U = null; // client's username
-
   private BigInteger N, g, A, B;
-
   private byte[] s; // salt
-
   private byte[] cIV, sIV; // client+server IVs, when confidentiality is on
-
   private byte[] cn, sn; // client's and server's nonce
-
   private SRP srp; // SRP algorithm instance used by this server
-
   private byte[] sid; // session ID when re-used
-
   private int ttl = 360; // session time-to-live in seconds
-
   private byte[] cCB; // peer's channel binding'
-
   private String mandatory; // List of available options
-
   private String L = null;
-
   private String o;
-
   private String chosenIntegrityAlgorithm;
-
   private String chosenConfidentialityAlgorithm;
-
   private int rawSendSize = Registry.SASL_BUFFER_MAX_LIMIT;
-
   private byte[] K; // shared session key
-
   private boolean replayDetection = true; // whether Replay Detection is on
-
   private int inCounter = 0; // messages sequence numbers
-
   private int outCounter = 0;
-
   private IALG inMac, outMac; // if !null, use for integrity
-
   private CALG inCipher, outCipher; // if !null, use for confidentiality
-
   private IKeyAgreementParty serverHandler = 
KeyAgreementFactory.getPartyBInstance(Registry.SRP_SASL_KA);
-
   /** Our default source of randomness. */
   private PRNG prng = null;
 
-  // Constructor(s)
-  // -------------------------------------------------------------------------
-
   public SRPServer()
   {
     super(Registry.SASL_SRP_MECHANISM);
   }
 
-  // Class methods
-  // -------------------------------------------------------------------------
-
-  // Instance methods
-  // -------------------------------------------------------------------------
-
-  // abstract methods implementation -----------------------------------------
-
   protected void initMechanism() throws SaslException
   {
     // TODO:
@@ -187,21 +128,18 @@
     sid = null;
   }
 
-  // javax.security.sasl.SaslServer interface implementation -----------------
-
   public byte[] evaluateResponse(final byte[] response) throws SaslException
   {
     switch (state)
       {
       case 0:
         if (response == null)
-          {
             return null;
-          }
+
         state++;
         return sendProtocolElements(response);
       case 1:
-        if (!complete)
+        if (! complete)
           {
             state++;
             return sendEvidence(response);
@@ -215,65 +153,15 @@
   protected byte[] engineUnwrap(final byte[] incoming, final int offset,
                                 final int len) throws SaslException
   {
-    //      if (DEBUG && debuglevel > 8) debug(TRACE, "==> engineUnwrap()");
-    //
-    //      if (inMac == null && inCipher == null) {
-    //         throw new IllegalStateException("connection is not protected");
-    //      }
-    //
-    //      if (DEBUG && debuglevel > 6) debug(TRACE, "Incoming buffer (before 
security): "+Util.dumpString(incoming, offset, len));
-    //
-    //      byte[] data = null;
-    //      try {
-    //         InputBuffer frameIn = InputBuffer.getInstance(incoming, offset, 
len);
-    //         data = frameIn.getEOS();
-    //         if (inMac != null) {
-    //            byte[] received_mac = frameIn.getOS();
-    //            if (DEBUG && debuglevel > 6) debug(TRACE, "Got C (received 
MAC): "+Util.dumpString(received_mac));
-    //            inMac.update(data);
-    //            if (replayDetection) {
-    //               inCounter++;
-    //               if (DEBUG && debuglevel > 6) debug(TRACE, 
"inCounter="+String.valueOf(inCounter));
-    //               inMac.update(new byte[] {
-    //                  (byte)(inCounter >>> 24),
-    //                  (byte)(inCounter >>> 16),
-    //                  (byte)(inCounter >>>  8),
-    //                  (byte) inCounter });
-    //            }
-    //            final byte[] computed_mac = inMac.doFinal();
-    //            if (DEBUG && debuglevel > 6) debug(TRACE, "Computed MAC: 
"+Util.dumpString(computed_mac));
-    //            if (!Arrays.equals(received_mac, computed_mac))
-    //               throw new IntegrityException("engineUnwrap()");
-    //         }
-    //         if (inCipher != null) {
-    //            data = inCipher.doFinal(data);
-    //         }
-    //       } catch (IOException x) {
-    //          if (x instanceof SaslException) {
-    //             throw (SaslException) x;
-    //          }
-    //          throw new SaslException("engineUnwrap()", x);
-    //       }
-    //
-    //      if (DEBUG && debuglevel > 6) debug(TRACE, "Incoming buffer (after 
security): "+Util.dumpString(data));
-    //      if (DEBUG && debuglevel > 8) debug(TRACE, "<== engineUnwrap()");
-    //      return data;
-
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> engineUnwrap()");
-
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "engineUnwrap");
     if (inMac == null && inCipher == null)
-      {
         throw new IllegalStateException("connection is not protected");
-      }
-
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Incoming buffer (before security): "
+    if (Configuration.DEBUG)
+      log.fine("Incoming buffer (before security): "
                    + Util.dumpString(incoming, offset, len));
-
     // at this point one, or both, of confidentiality and integrity protection
     // services are active.
-
     final byte[] result;
     try
       {
@@ -284,137 +172,67 @@
             final byte[] received_mac = new byte[macBytesCount];
             System.arraycopy(incoming, offset + payloadLength, received_mac, 0,
                              macBytesCount);
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Got C (received MAC): "
-                           + Util.dumpString(received_mac));
+            if (Configuration.DEBUG)
+              log.fine("Got C (received MAC): " + 
Util.dumpString(received_mac));
             inMac.update(incoming, offset, payloadLength);
             if (replayDetection)
               {
                 inCounter++;
-                if (DEBUG && debuglevel > 6)
-                  debug(TRACE, "inCounter=" + String.valueOf(inCounter));
-                inMac.update(new byte[] { (byte) (inCounter >>> 24),
-                                         (byte) (inCounter >>> 16),
-                                         (byte) (inCounter >>> 8),
+                if (Configuration.DEBUG)
+                  log.fine("inCounter=" + String.valueOf(inCounter));
+                inMac.update(new byte[] { (byte)(inCounter >>> 24),
+                                          (byte)(inCounter >>> 16),
+                                          (byte)(inCounter >>> 8),
                                          (byte) inCounter });
               }
-
             final byte[] computed_mac = inMac.doFinal();
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Computed MAC: " + Util.dumpString(computed_mac));
+            if (Configuration.DEBUG)
+              log.fine("Computed MAC: " + Util.dumpString(computed_mac));
             if (!Arrays.equals(received_mac, computed_mac))
-              {
                 throw new IntegrityException("engineUnwrap()");
-              }
 
             // deal with the payload, which can be either plain or encrypted
             if (inCipher != null)
-              {
                 result = inCipher.doFinal(incoming, offset, payloadLength);
-              }
             else
               {
                 result = new byte[payloadLength];
                 System.arraycopy(incoming, offset, result, 0, result.length);
               }
           }
-        else
-          { // no integrity protection; just confidentiality
-          //            if (inCipher != null) {
+        else // no integrity protection; just confidentiality
             result = inCipher.doFinal(incoming, offset, len);
-            //            } else {
-            //               result = new byte[len];
-            //               System.arraycopy(incoming, offset, result, 0, 
len);
-            //            }
-          }
       }
     catch (IOException x)
       {
         if (x instanceof SaslException)
-          {
             throw (SaslException) x;
-          }
         throw new SaslException("engineUnwrap()", x);
       }
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Incoming buffer (after security): "
-                   + Util.dumpString(result));
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== engineUnwrap()");
+    if (Configuration.DEBUG)
+      {
+        log.fine("Incoming buffer (after security): " + 
Util.dumpString(result));
+        log.exiting(this.getClass().getName(), "engineUnwrap");
+      }
     return result;
   }
 
   protected byte[] engineWrap(final byte[] outgoing, final int offset,
                               final int len) throws SaslException
   {
-    //      if (DEBUG && debuglevel > 8) debug(TRACE, "==> engineWrap()");
-    //
-    //      if (outMac == null && outCipher == null) {
-    //         throw new IllegalStateException("connection is not protected");
-    //      }
-    //
-    //      byte[] data = new byte[len];
-    //      System.arraycopy(outgoing, offset, data, 0, len);
-    //
-    //      if (DEBUG && debuglevel > 6) debug(TRACE, "Outgoing buffer (before 
security) (hex): "+Util.dumpString(data));
-    //      if (DEBUG && debuglevel > 6) debug(TRACE, "Outgoing buffer (before 
security) (str): \""+new String(data)+"\"");
-    //
-    //      final byte[] result;
-    //      try {
-    //         OutputBuffer frameOut = new OutputBuffer();
-    //         // Process the data
-    //         if (outCipher != null) {
-    //            data = outCipher.doFinal(data);
-    //            if (DEBUG && debuglevel > 6) debug(TRACE, "Encoding c 
(encrypted plaintext): "+Util.dumpString(data));
-    //         } else {
-    //            if (DEBUG && debuglevel > 6) debug(TRACE, "Encoding p 
(plaintext): "+Util.dumpString(data));
-    //         }
-    //         frameOut.setEOS(data);
-    //         if (outMac != null) {
-    //            outMac.update(data);
-    //            if (replayDetection) {
-    //               outCounter++;
-    //               if (DEBUG && debuglevel > 6) debug(TRACE, 
"outCounter="+String.valueOf(outCounter));
-    //               outMac.update(new byte[] {
-    //                  (byte)(outCounter >>> 24),
-    //                  (byte)(outCounter >>> 16),
-    //                  (byte)(outCounter >>>  8),
-    //                  (byte) outCounter});
-    //            }
-    //            byte[] C = outMac.doFinal();
-    //            frameOut.setOS(C);
-    //            if (DEBUG && debuglevel > 6) debug(TRACE, "Encoding C 
(integrity checksum): "+Util.dumpString(C));
-    //         }
-    //         result = frameOut.wrap();
-    //
-    //      } catch (IOException x) {
-    //         if (x instanceof SaslException) {
-    //            throw (SaslException) x;
-    //         }
-    //         throw new SaslException("engineWrap()", x);
-    //      }
-    //
-    //      if (DEBUG && debuglevel > 8) debug(TRACE, "<== engineWrap()");
-    //      return result;
-
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> engineWrap()");
-
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "engineWrap");
     if (outMac == null && outCipher == null)
-      {
         throw new IllegalStateException("connection is not protected");
-      }
-
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Outgoing buffer (before security) (hex): "
+    if (Configuration.DEBUG)
+      {
+        log.fine("Outgoing buffer (before security) (hex): "
                    + Util.dumpString(outgoing, offset, len));
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Outgoing buffer (before security) (str): \""
+        log.fine("Outgoing buffer (before security) (str): \""
                    + new String(outgoing, offset, len) + "\"");
-
+      }
     // at this point one, or both, of confidentiality and integrity protection
     // services are active.
-
     byte[] result;
     try
       {
@@ -422,74 +240,62 @@
         if (outCipher != null)
           {
             result = outCipher.doFinal(outgoing, offset, len);
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Encoding c (encrypted plaintext): "
+            if (Configuration.DEBUG)
+              log.fine("Encoding c (encrypted plaintext): "
                            + Util.dumpString(result));
-
             out.write(result);
-
             if (outMac != null)
               {
                 outMac.update(result);
                 if (replayDetection)
                   {
                     outCounter++;
-                    if (DEBUG && debuglevel > 6)
-                      debug(TRACE, "outCounter=" + String.valueOf(outCounter));
-                    outMac.update(new byte[] { (byte) (outCounter >>> 24),
-                                              (byte) (outCounter >>> 16),
-                                              (byte) (outCounter >>> 8),
+                    if (Configuration.DEBUG)
+                      log.fine("outCounter=" + outCounter);
+                    outMac.update(new byte[] { (byte)(outCounter >>> 24),
+                                               (byte)(outCounter >>> 16),
+                                               (byte)(outCounter >>> 8),
                                               (byte) outCounter });
                   }
                 final byte[] C = outMac.doFinal();
                 out.write(C);
-                if (DEBUG && debuglevel > 6)
-                  debug(TRACE, "Encoding C (integrity checksum): "
-                               + Util.dumpString(C));
-              } // else ciphertext only; do nothing
+                if (Configuration.DEBUG)
+                  log.fine("Encoding C (integrity checksum): " + 
Util.dumpString(C));
           }
-        else
-          { // no confidentiality; just integrity [+ replay detection]
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Encoding p (plaintext): "
+            // else ciphertext only; do nothing
+          }
+        else // no confidentiality; just integrity [+ replay detection]
+          {
+            if (Configuration.DEBUG)
+              log.fine("Encoding p (plaintext): "
                            + Util.dumpString(outgoing, offset, len));
-
             out.write(outgoing, offset, len);
-
-            //            if (outMac != null) {
             outMac.update(outgoing, offset, len);
             if (replayDetection)
               {
                 outCounter++;
-                if (DEBUG && debuglevel > 6)
-                  debug(TRACE, "outCounter=" + String.valueOf(outCounter));
-                outMac.update(new byte[] { (byte) (outCounter >>> 24),
-                                          (byte) (outCounter >>> 16),
-                                          (byte) (outCounter >>> 8),
+                if (Configuration.DEBUG)
+                  log.fine("outCounter=" + outCounter);
+                outMac.update(new byte[] { (byte)(outCounter >>> 24),
+                                           (byte)(outCounter >>> 16),
+                                           (byte)(outCounter >>> 8),
                                           (byte) outCounter });
               }
             final byte[] C = outMac.doFinal();
             out.write(C);
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Encoding C (integrity checksum): "
-                           + Util.dumpString(C));
-            //            } // else plaintext only; do nothing
+            if (Configuration.DEBUG)
+              log.fine("Encoding C (integrity checksum): " + 
Util.dumpString(C));
           }
-
         result = out.toByteArray();
-
       }
     catch (IOException x)
       {
         if (x instanceof SaslException)
-          {
             throw (SaslException) x;
-          }
         throw new SaslException("engineWrap()", x);
       }
-
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== engineWrap()");
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "engineWrap");
     return result;
   }
 
@@ -498,14 +304,10 @@
     if (inMac != null)
       {
         if (inCipher != null)
-          {
             return Registry.QOP_AUTH_CONF;
-          }
-        else
-          {
+
             return Registry.QOP_AUTH_INT;
           }
-      }
     return Registry.QOP_AUTH;
   }
 
@@ -514,14 +316,10 @@
     if (inMac != null)
       {
         if (inCipher != null)
-          {
             return Registry.STRENGTH_HIGH;
-          }
-        else
-          {
+
             return Registry.STRENGTH_MEDIUM;
           }
-      }
     return Registry.STRENGTH_LOW;
   }
 
@@ -535,45 +333,39 @@
     return Registry.REUSE_TRUE;
   }
 
-  // other methods -----------------------------------------------------------
-
   private byte[] sendProtocolElements(final byte[] input) throws SaslException
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> sendProtocolElements()");
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "C: " + Util.dumpString(input));
-
+    if (Configuration.DEBUG)
+      {
+        log.entering(this.getClass().getName(), "sendProtocolElements");
+        log.fine("C: " + Util.dumpString(input));
+      }
     // Client send U, I, sid, cn
     final InputBuffer frameIn = new InputBuffer(input);
     try
       {
         U = frameIn.getText(); // Extract username
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got U (username): \"" + U + "\"");
+        if (Configuration.DEBUG)
+          log.fine("Got U (username): \"" + U + "\"");
         authorizationID = frameIn.getText(); // Extract authorisation ID
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got I (userid): \"" + authorizationID + "\"");
+        if (Configuration.DEBUG)
+          log.fine("Got I (userid): \"" + authorizationID + "\"");
         sid = frameIn.getEOS();
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got sid (session ID): " + new String(sid));
+        if (Configuration.DEBUG)
+          log.fine("Got sid (session ID): " + new String(sid));
         cn = frameIn.getOS();
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got cn (client nonce): " + Util.dumpString(cn));
+        if (Configuration.DEBUG)
+          log.fine("Got cn (client nonce): " + Util.dumpString(cn));
         cCB = frameIn.getEOS();
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got cCB (client channel binding): "
-                       + Util.dumpString(cCB));
+        if (Configuration.DEBUG)
+          log.fine("Got cCB (client channel binding): " + 
Util.dumpString(cCB));
       }
     catch (IOException x)
       {
         if (x instanceof SaslException)
-          {
             throw (SaslException) x;
-          }
         throw new AuthenticationException("sendProtocolElements()", x);
       }
-
     // do/can we re-use?
     if (ServerStore.instance().isAlive(sid))
       {
@@ -589,15 +381,11 @@
         outMac = ctx.getOutMac();
         inCipher = ctx.getInCipher();
         outCipher = ctx.getOutCipher();
-
         if (sn == null || sn.length != 16)
-          {
             sn = new byte[16];
-          }
-        getDefaultPRNG().nextBytes(sn);
 
+        getDefaultPRNG().nextBytes(sn);
         setupSecurityServices(false);
-
         final OutputBuffer frameOut = new OutputBuffer();
         try
           {
@@ -608,34 +396,27 @@
         catch (IOException x)
           {
             if (x instanceof SaslException)
-              {
                 throw (SaslException) x;
-              }
             throw new AuthenticationException("sendProtocolElements()", x);
           }
         final byte[] result = frameOut.encode();
-        if (DEBUG && debuglevel > 8)
-          debug(TRACE, "<== sendProtocolElements()");
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "Old session...");
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "S: " + Util.dumpString(result));
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "  sn = " + Util.dumpString(sn));
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, " sCB = " + Util.dumpString(channelBinding));
+        if (Configuration.DEBUG)
+          {
+            log.fine("Old session...");
+            log.fine("S: " + Util.dumpString(result));
+            log.fine("  sn = " + Util.dumpString(sn));
+            log.fine(" sCB = " + Util.dumpString(channelBinding));
+            log.exiting(this.getClass().getName(), "sendProtocolElements");
+          }
         return result;
       }
     else
       { // new session
         authenticator.activate(properties);
-
         // -------------------------------------------------------------------
         final HashMap mapB = new HashMap();
-        //         mapB.put(SRP6KeyAgreement.HASH_FUNCTION,    
srp.newDigest());
         mapB.put(SRP6KeyAgreement.HASH_FUNCTION, srp.getAlgorithm());
         mapB.put(SRP6KeyAgreement.HOST_PASSWORD_DB, authenticator);
-
         try
           {
             serverHandler.init(mapB);
@@ -643,7 +424,6 @@
             out.writeString(U);
             IncomingMessage in = new IncomingMessage(out.toByteArray());
             out = serverHandler.processMessage(in);
-
             in = new IncomingMessage(out.toByteArray());
             N = in.readMPI();
             g = in.readMPI();
@@ -655,26 +435,22 @@
             throw new SaslException("sendProtocolElements()", x);
           }
         // -------------------------------------------------------------------
-
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Encoding N (modulus): " + Util.dump(N));
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Encoding g (generator): " + Util.dump(g));
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Encoding s (client's salt): " + Util.dumpString(s));
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Encoding B (server ephemeral public key): "
-                       + Util.dump(B));
-
+        if (Configuration.DEBUG)
+          {
+            log.fine("Encoding N (modulus): " + Util.dump(N));
+            log.fine("Encoding g (generator): " + Util.dump(g));
+            log.fine("Encoding s (client's salt): " + Util.dumpString(s));
+            log.fine("Encoding B (server ephemeral public key): " + 
Util.dump(B));
+          }
         // The server creates an options list (L), which consists of a
         // comma-separated list of option strings that specify the security
         // service options the server supports.
         L = createL();
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Encoding L (available options): \"" + L + "\"");
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Encoding sIV (server IV): " + Util.dumpString(sIV));
-
+        if (Configuration.DEBUG)
+          {
+            log.fine("Encoding L (available options): \"" + L + "\"");
+            log.fine("Encoding sIV (server IV): " + Util.dumpString(sIV));
+          }
         final OutputBuffer frameOut = new OutputBuffer();
         try
           {
@@ -688,69 +464,58 @@
         catch (IOException x)
           {
             if (x instanceof SaslException)
-              {
                 throw (SaslException) x;
-              }
             throw new AuthenticationException("sendProtocolElements()", x);
           }
         final byte[] result = frameOut.encode();
-        if (DEBUG && debuglevel > 8)
-          debug(TRACE, "<== sendProtocolElements()");
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "New session...");
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "S: " + Util.dumpString(result));
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "   N = 0x" + N.toString(16));
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "   g = 0x" + g.toString(16));
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "   s = " + Util.dumpString(s));
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "   B = 0x" + B.toString(16));
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "   L = " + L);
+        if (Configuration.DEBUG)
+          {
+            log.fine("New session...");
+            log.fine("S: " + Util.dumpString(result));
+            log.fine("   N = 0x" + N.toString(16));
+            log.fine("   g = 0x" + g.toString(16));
+            log.fine("   s = " + Util.dumpString(s));
+            log.fine("   B = 0x" + B.toString(16));
+            log.fine("   L = " + L);
+            log.exiting(this.getClass().getName(), "sendProtocolElements");
+          }
         return result;
       }
   }
 
   private byte[] sendEvidence(final byte[] input) throws SaslException
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> sendEvidence()");
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "C: " + Util.dumpString(input));
-
+    if (Configuration.DEBUG)
+      {
+        log.entering(this.getClass().getName(), "sendEvidence");
+        log.fine("C: " + Util.dumpString(input));
+      }
     // Client send A, M1, o, cIV
     final InputBuffer frameIn = new InputBuffer(input);
     final byte[] M1;
     try
       {
         A = frameIn.getMPI(); // Extract client's ephemeral public key
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got A (client ephemeral public key): " + Util.dump(A));
+        if (Configuration.DEBUG)
+          log.fine("Got A (client ephemeral public key): " + Util.dump(A));
         M1 = frameIn.getOS(); // Extract evidence
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got M1 (client evidence): " + Util.dumpString(M1));
+        if (Configuration.DEBUG)
+          log.fine("Got M1 (client evidence): " + Util.dumpString(M1));
         o = frameIn.getText(); // Extract client's options list
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got o (client chosen options): \"" + o + "\"");
+        if (Configuration.DEBUG)
+          log.fine("Got o (client chosen options): \"" + o + "\"");
         cIV = frameIn.getOS(); // Extract client's IV
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got cIV (client IV): " + Util.dumpString(cIV));
+        if (Configuration.DEBUG)
+          log.fine("Got cIV (client IV): " + Util.dumpString(cIV));
       }
     catch (IOException x)
       {
         if (x instanceof SaslException)
-          {
             throw (SaslException) x;
-          }
         throw new AuthenticationException("sendEvidence()", x);
       }
-
     // Parse client's options and set security layer variables
     parseO(o);
-
     // ----------------------------------------------------------------------
     try
       {
@@ -765,10 +530,8 @@
         throw new SaslException("sendEvidence()", x);
       }
     // ----------------------------------------------------------------------
-
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "K: " + Util.dumpString(K));
-
+    if (Configuration.DEBUG)
+      log.fine("K: " + Util.dumpString(K));
     final byte[] expected;
     try
       {
@@ -779,15 +542,11 @@
       {
         throw new AuthenticationException("sendEvidence()", x);
       }
-
     // Verify client evidence
     if (!Arrays.equals(M1, expected))
-      {
         throw new AuthenticationException("M1 mismatch");
-      }
 
     setupSecurityServices(true);
-
     final byte[] M2;
     try
       {
@@ -798,7 +557,6 @@
       {
         throw new AuthenticationException("sendEvidence()", x);
       }
-
     final OutputBuffer frameOut = new OutputBuffer();
     try
       {
@@ -811,93 +569,71 @@
     catch (IOException x)
       {
         if (x instanceof SaslException)
-          {
             throw (SaslException) x;
-          }
         throw new AuthenticationException("sendEvidence()", x);
       }
     final byte[] result = frameOut.encode();
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, "S: " + Util.dumpString(result));
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, "  M2 = " + Util.dumpString(M2));
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, " sIV = " + Util.dumpString(sIV));
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, " sid = " + new String(sid));
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, " ttl = " + ttl);
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, " sCB = " + Util.dumpString(channelBinding));
-
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== sendEvidence()");
+    if (Configuration.DEBUG)
+      {
+        log.fine("S: " + Util.dumpString(result));
+        log.fine("  M2 = " + Util.dumpString(M2));
+        log.fine(" sIV = " + Util.dumpString(sIV));
+        log.fine(" sid = " + new String(sid));
+        log.fine(" ttl = " + ttl);
+        log.fine(" sCB = " + Util.dumpString(channelBinding));
+        log.exiting(this.getClass().getName(), "sendEvidence");
+      }
     return result;
   }
 
   private String createL()
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> createL()");
-
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "createL()");
     String s = (String) properties.get(SRPRegistry.SRP_MANDATORY);
     if (s == null)
-      {
         s = SRPRegistry.DEFAULT_MANDATORY;
-      }
-    if (!SRPRegistry.MANDATORY_NONE.equals(s)
-        && !SRPRegistry.OPTION_REPLAY_DETECTION.equals(s)
-        && !SRPRegistry.OPTION_INTEGRITY.equals(s)
-        && !SRPRegistry.OPTION_CONFIDENTIALITY.equals(s))
-      {
-        if (DEBUG && debuglevel > 4)
-          debug(WARN, "Unrecognised mandatory option (" + s
-                      + "). Using default...");
+
+    if (! SRPRegistry.MANDATORY_NONE.equals(s)
+        && ! SRPRegistry.OPTION_REPLAY_DETECTION.equals(s)
+        && ! SRPRegistry.OPTION_INTEGRITY.equals(s)
+        && ! SRPRegistry.OPTION_CONFIDENTIALITY.equals(s))
+      {
+        if (Configuration.DEBUG)
+          log.fine("Unrecognised mandatory option (" + s + "). Using 
default...");
         s = SRPRegistry.DEFAULT_MANDATORY;
       }
-
     mandatory = s;
-
     s = (String) properties.get(SRPRegistry.SRP_CONFIDENTIALITY);
     final boolean confidentiality = (s == null ? 
SRPRegistry.DEFAULT_CONFIDENTIALITY
                                               : 
Boolean.valueOf(s).booleanValue());
-
     s = (String) properties.get(SRPRegistry.SRP_INTEGRITY_PROTECTION);
     boolean integrity = (s == null ? SRPRegistry.DEFAULT_INTEGRITY
                                   : Boolean.valueOf(s).booleanValue());
-
     s = (String) properties.get(SRPRegistry.SRP_REPLAY_DETECTION);
     final boolean replayDetection = (s == null ? 
SRPRegistry.DEFAULT_REPLAY_DETECTION
                                               : 
Boolean.valueOf(s).booleanValue());
-
     final StringBuffer sb = new StringBuffer();
-    sb.append(SRPRegistry.OPTION_SRP_DIGEST).append("=").append(
-                                                                
srp.getAlgorithm()).append(
-                                                                               
            ",");
+    sb.append(SRPRegistry.OPTION_SRP_DIGEST).append("=")
+      .append(srp.getAlgorithm()).append(",");
+
+    if (! SRPRegistry.MANDATORY_NONE.equals(mandatory))
+      sb.append(SRPRegistry.OPTION_MANDATORY)
+        .append("=").append(mandatory).append(",");
 
-    if (!SRPRegistry.MANDATORY_NONE.equals(mandatory))
-      {
-        
sb.append(SRPRegistry.OPTION_MANDATORY).append("=").append(mandatory).append(
-                                                                               
      ",");
-      }
     if (replayDetection)
       {
         sb.append(SRPRegistry.OPTION_REPLAY_DETECTION).append(",");
         // if replay detection is on then force integrity protection
         integrity = true;
       }
-
     int i;
     if (integrity)
       {
         for (i = 0; i < SRPRegistry.INTEGRITY_ALGORITHMS.length; i++)
-          {
-            sb.append(SRPRegistry.OPTION_INTEGRITY).append("=").append(
-                                                                       
SRPRegistry.INTEGRITY_ALGORITHMS[i]).append(
-                                                                               
                                    ",");
-          }
+          sb.append(SRPRegistry.OPTION_INTEGRITY).append("=")
+            .append(SRPRegistry.INTEGRITY_ALGORITHMS[i]).append(",");
       }
-
     if (confidentiality)
       {
         IBlockCipher cipher;
@@ -905,19 +641,15 @@
           {
             cipher = 
CipherFactory.getInstance(SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i]);
             if (cipher != null)
-              {
-                
sb.append(SRPRegistry.OPTION_CONFIDENTIALITY).append("=").append(
-                                                                               
  SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i]).append(
-                                                                               
                                                    ",");
-              }
+              sb.append(SRPRegistry.OPTION_CONFIDENTIALITY).append("=")
+                .append(SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i]).append(",");
           }
       }
-
-    final String result = sb.append(SRPRegistry.OPTION_MAX_BUFFER_SIZE).append(
-                                                                               
"=").append(
-                                                                               
            Registry.SASL_BUFFER_MAX_LIMIT).toString();
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== createL()");
+    final String result = sb.append(SRPRegistry.OPTION_MAX_BUFFER_SIZE)
+                            .append("=").append(Registry.SASL_BUFFER_MAX_LIMIT)
+                            .toString();
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "createL");
     return result;
   }
 
@@ -934,24 +666,18 @@
     while (st.hasMoreTokens())
       {
         option = st.nextToken();
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "option: <" + option + ">");
+        if (Configuration.DEBUG)
+          log.fine("option: <" + option + ">");
         if (option.equals(SRPRegistry.OPTION_REPLAY_DETECTION))
-          {
             replayDetection = true;
-          }
         else if (option.startsWith(SRPRegistry.OPTION_INTEGRITY + "="))
           {
             if (integrity)
-              {
-                throw new AuthenticationException(
-                                                  "Only one integrity 
algorithm may be chosen");
-              }
-            else
-              {
+              throw new AuthenticationException("Only one integrity algorithm 
may be chosen");
+
                 option = option.substring(option.indexOf('=') + 1);
-                if (DEBUG && debuglevel > 6)
-                  debug(TRACE, "algorithm: <" + option + ">");
+            if (Configuration.DEBUG)
+              log.fine("algorithm: <" + option + ">");
                 for (i = 0; i < SRPRegistry.INTEGRITY_ALGORITHMS.length; i++)
                   {
                     if (SRPRegistry.INTEGRITY_ALGORITHMS[i].equals(option))
@@ -961,26 +687,18 @@
                         break;
                       }
                   }
-                if (!integrity)
-                  {
-                    throw new AuthenticationException(
-                                                      "Unknown integrity 
algorithm: "
+            if (! integrity)
+              throw new AuthenticationException("Unknown integrity algorithm: "
                                                           + option);
                   }
-              }
-          }
         else if (option.startsWith(SRPRegistry.OPTION_CONFIDENTIALITY + "="))
           {
             if (confidentiality)
-              {
-                throw new AuthenticationException(
-                                                  "Only one confidentiality 
algorithm may be chosen");
-              }
-            else
-              {
+              throw new AuthenticationException("Only one confidentiality 
algorithm may be chosen");
+
                 option = option.substring(option.indexOf('=') + 1);
-                if (DEBUG && debuglevel > 6)
-                  debug(TRACE, "algorithm: <" + option + ">");
+            if (Configuration.DEBUG)
+              log.fine("algorithm: <" + option + ">");
                 for (i = 0; i < SRPRegistry.CONFIDENTIALITY_ALGORITHMS.length; 
i++)
                   {
                     if 
(SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i].equals(option))
@@ -990,14 +708,10 @@
                         break;
                       }
                   }
-                if (!confidentiality)
-                  {
-                    throw new AuthenticationException(
-                                                      "Unknown confidentiality 
algorithm: "
+            if (! confidentiality)
+              throw new AuthenticationException("Unknown confidentiality 
algorithm: "
                                                           + option);
                   }
-              }
-          }
         else if (option.startsWith(SRPRegistry.OPTION_MAX_BUFFER_SIZE + "="))
           {
             final String maxBufferSize = option.substring(option.indexOf('=') 
+ 1);
@@ -1006,71 +720,49 @@
                 rawSendSize = Integer.parseInt(maxBufferSize);
                 if (rawSendSize > Registry.SASL_BUFFER_MAX_LIMIT
                     || rawSendSize < 1)
-                  throw new AuthenticationException(
-                                                    "Illegal value for 
'maxbuffersize' option");
+                  throw new AuthenticationException("Illegal value for 
'maxbuffersize' option");
               }
             catch (NumberFormatException x)
               {
-                throw new AuthenticationException(
-                                                  
SRPRegistry.OPTION_MAX_BUFFER_SIZE
-                                                      + "="
-                                                      + 
String.valueOf(maxBufferSize),
+                throw new 
AuthenticationException(SRPRegistry.OPTION_MAX_BUFFER_SIZE
+                                                  + "=" + maxBufferSize,
                                                   x);
               }
           }
       }
-
     // check if client did the right thing
     if (replayDetection)
       {
-        if (!integrity)
-          {
-            throw new AuthenticationException(
-                                              "Missing integrity protection 
algorithm "
+        if (! integrity)
+          throw new AuthenticationException("Missing integrity protection 
algorithm "
                                                   + "but replay detection is 
chosen");
           }
-      }
     if (mandatory.equals(SRPRegistry.OPTION_REPLAY_DETECTION))
       {
-        if (!replayDetection)
-          {
-            throw new AuthenticationException(
-                                              "Replay detection is mandatory 
but was not chosen");
-          }
+        if (! replayDetection)
+          throw new AuthenticationException("Replay detection is mandatory but 
was not chosen");
       }
     if (mandatory.equals(SRPRegistry.OPTION_INTEGRITY))
       {
-        if (!integrity)
-          {
-            throw new AuthenticationException(
-                                              "Integrity protection is 
mandatory but was not chosen");
-          }
+        if (! integrity)
+          throw new AuthenticationException("Integrity protection is mandatory 
but was not chosen");
       }
     if (mandatory.equals(SRPRegistry.OPTION_CONFIDENTIALITY))
       {
-        if (!confidentiality)
-          {
-            throw new AuthenticationException(
-                                              "Confidentiality is mandatory 
but was not chosen");
-          }
+        if (! confidentiality)
+          throw new AuthenticationException("Confidentiality is mandatory but 
was not chosen");
       }
-
     int blockSize = 0;
     if (chosenConfidentialityAlgorithm != null)
       {
         final IBlockCipher cipher = 
CipherFactory.getInstance(chosenConfidentialityAlgorithm);
         if (cipher != null)
-          {
             blockSize = cipher.defaultBlockSize();
-          }
-        else
-          { // should not happen
+        else // should not happen
             throw new AuthenticationException("Confidentiality algorithm ("
                                               + chosenConfidentialityAlgorithm
                                               + ") not available");
           }
-      }
-
     sIV = new byte[blockSize];
     if (blockSize > 0)
       getDefaultPRNG().nextBytes(sIV);
@@ -1086,30 +778,26 @@
         // instantiate cipher if confidentiality protection filter is active
         if (chosenConfidentialityAlgorithm != null)
           {
-            if (DEBUG && debuglevel > 2)
-              debug(INFO, "Activating confidentiality protection filter");
+            if (Configuration.DEBUG)
+              log.fine("Activating confidentiality protection filter");
             inCipher = CALG.getInstance(chosenConfidentialityAlgorithm);
             outCipher = CALG.getInstance(chosenConfidentialityAlgorithm);
           }
         // instantiate hmacs if integrity protection filter is active
         if (chosenIntegrityAlgorithm != null)
           {
-            if (DEBUG && debuglevel > 2)
-              debug(INFO, "Activating integrity protection filter");
+            if (Configuration.DEBUG)
+              log.fine("Activating integrity protection filter");
             inMac = IALG.getInstance(chosenIntegrityAlgorithm);
             outMac = IALG.getInstance(chosenIntegrityAlgorithm);
           }
-
         // generate a new sid if at least integrity is used
         sid = (inMac != null ? ServerStore.getNewSessionID() : new byte[0]);
       }
-    else
-      { // same session new keys
+    else // same session new keys
         K = srp.generateKn(K, cn, sn);
-      }
 
     final KDF kdf = KDF.getInstance(K);
-
     // initialise in/out ciphers if confidentaility protection is used
     if (inCipher != null)
       {
@@ -1122,15 +810,12 @@
         outMac.init(kdf);
         inMac.init(kdf);
       }
-
     if (sid != null && sid.length != 0)
       { // update the security context and save in map
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "Updating security context for sid = " + new 
String(sid));
-        ServerStore.instance().cacheSession(
-                                            ttl,
-                                            new SecurityContext(
-                                                                
srp.getAlgorithm(),
+        if (Configuration.DEBUG)
+          log.fine("Updating security context for sid = " + new String(sid));
+        ServerStore.instance().cacheSession(ttl,
+                                            new 
SecurityContext(srp.getAlgorithm(),
                                                                 sid,
                                                                 K,
                                                                 cIV,

Index: javax/crypto/sasl/srp/SRPClient.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/sasl/srp/SRPClient.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/sasl/srp/SRPClient.java        3 Feb 2006 19:29:01 -0000       
1.2
+++ javax/crypto/sasl/srp/SRPClient.java        11 Jun 2006 12:14:44 -0000      
1.3
@@ -38,147 +38,84 @@
 
 package gnu.javax.crypto.sasl.srp;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.hash.MD5;
 import gnu.java.security.util.PRNG;
 import gnu.java.security.util.Util;
-
+import gnu.javax.crypto.assembly.Direction;
+import gnu.javax.crypto.cipher.CipherFactory;
+import gnu.javax.crypto.cipher.IBlockCipher;
 import gnu.javax.crypto.key.IKeyAgreementParty;
 import gnu.javax.crypto.key.IncomingMessage;
-import gnu.javax.crypto.key.KeyAgreementFactory;
 import gnu.javax.crypto.key.KeyAgreementException;
+import gnu.javax.crypto.key.KeyAgreementFactory;
 import gnu.javax.crypto.key.OutgoingMessage;
 import gnu.javax.crypto.key.srp6.SRP6KeyAgreement;
-import gnu.javax.crypto.assembly.Direction;
-import gnu.javax.crypto.cipher.CipherFactory;
-import gnu.javax.crypto.cipher.IBlockCipher;
 import gnu.javax.crypto.sasl.ClientMechanism;
 import gnu.javax.crypto.sasl.IllegalMechanismStateException;
 import gnu.javax.crypto.sasl.InputBuffer;
 import gnu.javax.crypto.sasl.IntegrityException;
 import gnu.javax.crypto.sasl.OutputBuffer;
-
 import gnu.javax.security.auth.Password;
 
-import java.io.IOException;
-import java.io.PrintWriter;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.StringTokenizer;
+import java.util.logging.Logger;
 
+import javax.security.auth.DestroyFailedException;
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.NameCallback;
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.DestroyFailedException;
 import javax.security.sasl.AuthenticationException;
 import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslException;
 
 /**
- * <p>The SASL-SRP client-side mechanism.</p>
+ * The SASL-SRP client-side mechanism.
  */
 public class SRPClient extends ClientMechanism implements SaslClient
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = "SRPClient";
-
-  //   private static final String ERROR = "ERROR";
-  //   private static final String WARN =  " WARN";
-  private static final String INFO = " INFO";
-
-  private static final String TRACE = "DEBUG";
-
-  private static final boolean DEBUG = true;
-
-  private static final int debuglevel = 3;
-
-  private static final PrintWriter err = new PrintWriter(System.out, true);
-
-  private static void debug(final String level, final Object obj)
-  {
-    err.println("[" + level + "] " + NAME + ": " + String.valueOf(obj));
-  }
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
-  //   private static final HashMap uid2ctx = new HashMap();
-
+  private static final Logger log = 
Logger.getLogger(SRPClient.class.getName());
   private String uid; // the unique key for this type of client
-
   private String U; // the authentication identity
-
   BigInteger N, g, A, B;
-
   private Password password; // the authentication credentials
-
   private byte[] s; // the user's salt
-
   private byte[] cIV, sIV; // client+server IVs, when confidentiality is on
-
   private byte[] M1, M2; // client+server evidences
-
   private byte[] cn, sn; // client's and server's nonce
-
   private SRP srp; // SRP algorithm instance used by this client
-
   private byte[] sid; // session ID when re-used
-
   private int ttl; // session time-to-live in seconds
-
   private byte[] sCB; // the peer's channel binding data
-
   private String L; // available options
-
   private String o;
-
   private String chosenIntegrityAlgorithm;
-
   private String chosenConfidentialityAlgorithm;
-
   private int rawSendSize = Registry.SASL_BUFFER_MAX_LIMIT;
-
   private byte[] K; // shared session key
-
   private boolean replayDetection = true; // whether Replay Detection is on
-
   private int inCounter = 0; // messages sequence numbers
-
   private int outCounter = 0;
-
   private IALG inMac, outMac; // if !null, use for integrity
-
   private CALG inCipher, outCipher; // if !null, use for confidentiality
-
   private IKeyAgreementParty clientHandler = 
KeyAgreementFactory.getPartyAInstance(Registry.SRP_SASL_KA);
-
   /** Our default source of randomness. */
   private PRNG prng = null;
 
-  // Constructor(s)
-  // -------------------------------------------------------------------------
-
   public SRPClient()
   {
     super(Registry.SASL_SRP_MECHANISM);
   }
 
-  // Class methods
-  // -------------------------------------------------------------------------
-
-  // Instance methods
-  // -------------------------------------------------------------------------
-
-  // abstract methods implementation -----------------------------------------
-
   protected void initMechanism() throws SaslException
   {
     // we shall keep track of the sid (and the security context of this
@@ -195,9 +132,8 @@
     b = protocol.getBytes();
     md.update(b, 0, b.length);
     if (channelBinding.length > 0)
-      {
         md.update(channelBinding, 0, channelBinding.length);
-      }
+
     uid = Util.toBase64(md.digest());
     if (ClientStore.instance().isAlive(uid))
       {
@@ -253,8 +189,6 @@
     sn = null;
   }
 
-  // javax.security.sasl.SaslClient interface implementation -----------------
-
   public boolean hasInitialResponse()
   {
     return true;
@@ -282,7 +216,7 @@
           }
         return result;
       case 2: // should only occur if session re-use was rejected
-        if (!complete)
+        if (! complete)
           {
             state++;
             return receiveEvidence(challenge);
@@ -296,22 +230,15 @@
   protected byte[] engineUnwrap(final byte[] incoming, final int offset,
                                 final int len) throws SaslException
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> engineUnwrap()");
-
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "engineUnwrap");
     if (inMac == null && inCipher == null)
-      {
         throw new IllegalStateException("connection is not protected");
-      }
-
     // at this point one, or both, of confidentiality and integrity protection
     // services are active.
-
     final byte[] result;
     try
       {
-        //         final InputBuffer frameIn = 
InputBuffer.getInstance(incoming, offset, len);
-        //         result = frameIn.getEOS();
         if (inMac != null)
           { // integrity bytes are at the end of the stream
             final int macBytesCount = inMac.length();
@@ -320,16 +247,14 @@
             final byte[] received_mac = new byte[macBytesCount];
             System.arraycopy(incoming, offset + payloadLength, received_mac, 0,
                              macBytesCount);
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Got C (received MAC): "
-                           + Util.dumpString(received_mac));
-            //            inMac.update(result);
+            if (Configuration.DEBUG)
+              log.fine("Got C (received MAC): " + 
Util.dumpString(received_mac));
             inMac.update(incoming, offset, payloadLength);
             if (replayDetection)
               {
                 inCounter++;
-                if (DEBUG && debuglevel > 6)
-                  debug(TRACE, "inCounter=" + String.valueOf(inCounter));
+                if (Configuration.DEBUG)
+                  log.fine("inCounter=" + inCounter);
                 inMac.update(new byte[] { (byte) (inCounter >>> 24),
                                          (byte) (inCounter >>> 16),
                                          (byte) (inCounter >>> 8),
@@ -337,170 +262,106 @@
               }
 
             final byte[] computed_mac = inMac.doFinal();
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Computed MAC: " + Util.dumpString(computed_mac));
+            if (Configuration.DEBUG)
+              log.fine("Computed MAC: " + Util.dumpString(computed_mac));
             if (!Arrays.equals(received_mac, computed_mac))
-              {
                 throw new IntegrityException("engineUnwrap()");
-              }
-
             // deal with the payload, which can be either plain or encrypted
             if (inCipher != null)
-              {
                 result = inCipher.doFinal(incoming, offset, payloadLength);
-              }
             else
               {
                 result = new byte[len - macBytesCount];
                 System.arraycopy(incoming, offset, result, 0, result.length);
               }
           }
-        else
-          { // no integrity protection; just confidentiality
-          //            if (inCipher != null) {
+        else // no integrity protection; just confidentiality
             result = inCipher.doFinal(incoming, offset, len);
-            //            } else {
-            //               result = new byte[len];
-            //               System.arraycopy(incoming, offset, result, 0, 
len);
-            //            }
-          }
-        //         if (inCipher != null) {
-        //            result = inCipher.doFinal(result);
-        //         }
       }
     catch (IOException x)
       {
         if (x instanceof SaslException)
-          {
             throw (SaslException) x;
-          }
         throw new SaslException("engineUnwrap()", x);
       }
-
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== engineUnwrap()");
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "engineUnwrap");
     return result;
   }
 
   protected byte[] engineWrap(final byte[] outgoing, final int offset,
                               final int len) throws SaslException
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> engineWrap()");
-
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "engineWrap");
     if (outMac == null && outCipher == null)
-      {
         throw new IllegalStateException("connection is not protected");
-      }
-
     // at this point one, or both, of confidentiality and integrity protection
     // services are active.
-
-    //      byte[] data = new byte[len];
-    //      System.arraycopy(outgoing, offset, data, 0, len);
     byte[] result;
     try
       {
-        //         OutputBuffer frameOut = new OutputBuffer();
         final ByteArrayOutputStream out = new ByteArrayOutputStream();
         // Process the data
         if (outCipher != null)
           {
-            //            data = outCipher.doFinal(data);
             result = outCipher.doFinal(outgoing, offset, len);
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Encoding c (encrypted plaintext): "
+            if (Configuration.DEBUG)
+              log.fine("Encoding c (encrypted plaintext): "
                            + Util.dumpString(result));
-
-            //            frameOut.setEOS(data);
             out.write(result);
-
             if (outMac != null)
               {
                 outMac.update(result);
                 if (replayDetection)
                   {
                     outCounter++;
-                    if (DEBUG && debuglevel > 6)
-                      debug(TRACE, "outCounter=" + String.valueOf(outCounter));
-                    outMac.update(new byte[] { (byte) (outCounter >>> 24),
-                                              (byte) (outCounter >>> 16),
-                                              (byte) (outCounter >>> 8),
+                    if (Configuration.DEBUG)
+                      log.fine("outCounter=" + outCounter);
+                    outMac.update(new byte[] { (byte)(outCounter >>> 24),
+                                               (byte)(outCounter >>> 16),
+                                               (byte)(outCounter >>> 8),
                                               (byte) outCounter });
                   }
                 final byte[] C = outMac.doFinal();
-                //               frameOut.setOS(C);
                 out.write(C);
-                if (DEBUG && debuglevel > 6)
-                  debug(TRACE, "Encoding C (integrity checksum): "
-                               + Util.dumpString(C));
-              } // else confidentiality only; do nothing
+                if (Configuration.DEBUG)
+                  log.fine("Encoding C (integrity checksum): " + 
Util.dumpString(C));
           }
-        else
-          { // no confidentiality; just integrity [+ replay detection]
-          //            if (DEBUG && debuglevel > 6) debug(TRACE, "Encoding p 
(plaintext): "+Util.dumpString(data));
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Encoding p (plaintext): "
+            // else confidentiality only; do nothing
+          }
+        else // no confidentiality; just integrity [+ replay detection]
+          {
+            if (Configuration.DEBUG)
+              log.fine("Encoding p (plaintext): "
                            + Util.dumpString(outgoing, offset, len));
-
-            //            frameOut.setEOS(data);
             out.write(outgoing, offset, len);
-
-            //            if (outMac != null) {
-            //               outMac.update(data);
             outMac.update(outgoing, offset, len);
             if (replayDetection)
               {
                 outCounter++;
-                if (DEBUG && debuglevel > 6)
-                  debug(TRACE, "outCounter=" + String.valueOf(outCounter));
-                outMac.update(new byte[] { (byte) (outCounter >>> 24),
-                                          (byte) (outCounter >>> 16),
-                                          (byte) (outCounter >>> 8),
+                if (Configuration.DEBUG)
+                  log.fine("outCounter=" + outCounter);
+                outMac.update(new byte[] { (byte)(outCounter >>> 24),
+                                           (byte)(outCounter >>> 16),
+                                           (byte)(outCounter >>> 8),
                                           (byte) outCounter });
               }
             final byte[] C = outMac.doFinal();
-            //               frameOut.setOS(C);
             out.write(C);
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Encoding C (integrity checksum): "
-                           + Util.dumpString(C));
-            //            }
-          }
-
-        //         frameOut.setEOS(data);
-        //
-        //         if (outMac != null) {
-        //            outMac.update(data);
-        //            if (replayDetection) {
-        //               outCounter++;
-        //               if (DEBUG && debuglevel > 6) debug(TRACE, 
"outCounter="+String.valueOf(outCounter));
-        //               outMac.update(new byte[] {
-        //                  (byte)(outCounter >>> 24),
-        //                  (byte)(outCounter >>> 16),
-        //                  (byte)(outCounter >>>  8),
-        //                  (byte) outCounter });
-        //            }
-        //            byte[] C = outMac.doFinal();
-        //            frameOut.setOS(C);
-        //            if (DEBUG && debuglevel > 6) debug(TRACE, "Encoding C 
(integrity checksum): "+Util.dumpString(C));
-        //         }
-
-        //         result = frameOut.wrap();
+            if (Configuration.DEBUG)
+              log.fine("Encoding C (integrity checksum): " + 
Util.dumpString(C));
+          }
         result = out.toByteArray();
-
       }
     catch (IOException x)
       {
         if (x instanceof SaslException)
-          {
             throw (SaslException) x;
-          }
         throw new SaslException("engineWrap()", x);
       }
-
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== engineWrap()");
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "engineWrap");
     return result;
   }
 
@@ -509,14 +370,10 @@
     if (inMac != null)
       {
         if (inCipher != null)
-          {
             return Registry.QOP_AUTH_CONF;
-          }
-        else
-          {
+
             return Registry.QOP_AUTH_INT;
           }
-      }
     return Registry.QOP_AUTH;
   }
 
@@ -525,14 +382,10 @@
     if (inMac != null)
       {
         if (inCipher != null)
-          {
             return Registry.STRENGTH_HIGH;
-          }
-        else
-          {
+
             return Registry.STRENGTH_MEDIUM;
           }
-      }
     return Registry.STRENGTH_LOW;
   }
 
@@ -550,19 +403,16 @@
 
   private byte[] sendIdentities() throws SaslException
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> sendIdentities()");
-
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "sendIdentities");
     // If necessary, prompt the client for the username and password
     getUsernameAndPassword();
-
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Password: \"" + new String(password.getPassword()) + "\"");
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Encoding U (username): \"" + U + "\"");
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Encoding I (userid): \"" + authorizationID + "\"");
-
+    if (Configuration.DEBUG)
+      {
+        log.fine("Password: \"" + new String(password.getPassword()) + "\"");
+        log.fine("Encoding U (username): \"" + U + "\"");
+        log.fine("Encoding I (userid): \"" + authorizationID + "\"");
+      }
     // if session re-use generate new 16-byte nonce
     if (sid.length != 0)
       {
@@ -570,9 +420,7 @@
         getDefaultPRNG().nextBytes(cn);
       }
     else
-      {
         cn = new byte[0];
-      }
 
     final OutputBuffer frameOut = new OutputBuffer();
     try
@@ -586,36 +434,30 @@
     catch (IOException x)
       {
         if (x instanceof SaslException)
-          {
             throw (SaslException) x;
-          }
         throw new AuthenticationException("sendIdentities()", x);
       }
     final byte[] result = frameOut.encode();
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== sendIdentities()");
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, "C: " + Util.dumpString(result));
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, "  U = " + U);
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, "  I = " + authorizationID);
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, "sid = " + new String(sid));
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, " cn = " + Util.dumpString(cn));
-    if (DEBUG && debuglevel > 2)
-      debug(INFO, "cCB = " + Util.dumpString(channelBinding));
+    if (Configuration.DEBUG)
+      {
+        log.fine("C: " + Util.dumpString(result));
+        log.fine("  U = " + U);
+        log.fine("  I = " + authorizationID);
+        log.fine("sid = " + new String(sid));
+        log.fine(" cn = " + Util.dumpString(cn));
+        log.fine("cCB = " + Util.dumpString(channelBinding));
+        log.exiting(this.getClass().getName(), "sendIdentities");
+      }
     return result;
   }
 
   private byte[] sendPublicKey(final byte[] input) throws SaslException
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> sendPublicKey()");
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "S: " + Util.dumpString(input));
-
+    if (Configuration.DEBUG)
+      {
+        log.entering(this.getClass().getName(), "sendPublicKey");
+        log.fine("S: " + Util.dumpString(input));
+      }
     // Server sends [00], N, g, s, B, L
     // or [FF], sn, sCB
     final InputBuffer frameIn = new InputBuffer(input);
@@ -626,57 +468,47 @@
         if (ack == 0x00)
           { // new session
             N = frameIn.getMPI();
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Got N (modulus): " + Util.dump(N));
+            if (Configuration.DEBUG)
+              log.fine("Got N (modulus): " + Util.dump(N));
             g = frameIn.getMPI();
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Got g (generator): " + Util.dump(g));
+            if (Configuration.DEBUG)
+              log.fine("Got g (generator): " + Util.dump(g));
             s = frameIn.getOS();
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Got s (salt): " + Util.dumpString(s));
+            if (Configuration.DEBUG)
+              log.fine("Got s (salt): " + Util.dumpString(s));
             B = frameIn.getMPI();
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Got B (server ephermeral public key): "
-                           + Util.dump(B));
+            if (Configuration.DEBUG)
+              log.fine("Got B (server ephermeral public key): " + 
Util.dump(B));
             L = frameIn.getText();
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Got L (available options): \"" + L + "\"");
+            if (Configuration.DEBUG)
+              log.fine("Got L (available options): \"" + L + "\"");
           }
         else if (ack == 0xFF)
           { // session re-use
             sn = frameIn.getOS();
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Got sn (server nonce): " + Util.dumpString(sn));
+            if (Configuration.DEBUG)
+              log.fine("Got sn (server nonce): " + Util.dumpString(sn));
             sCB = frameIn.getEOS();
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "Got sCB (server channel binding): "
-                           + Util.dumpString(sCB));
+            if (Configuration.DEBUG)
+              log.fine("Got sCB (server channel binding): " + 
Util.dumpString(sCB));
           }
-        else
-          { // unexpected scalar
+        else // unexpected scalar
             throw new SaslException("sendPublicKey(): Invalid scalar (" + ack
                                     + ") in server's request");
           }
-      }
     catch (IOException x)
       {
         if (x instanceof SaslException)
-          {
             throw (SaslException) x;
-          }
         throw new SaslException("sendPublicKey()", x);
       }
-
     if (ack == 0x00)
       { // new session ---------------------------------------
         o = createO(L.toLowerCase()); // do this first to initialise the SRP 
hash
-
         final byte[] pBytes; // use ASCII encoding to inter-operate w/ non-java
         pBytes = password.getBytes();
-
         // 
----------------------------------------------------------------------
         final HashMap mapA = new HashMap();
-        //         mapA.put(SRP6KeyAgreement.HASH_FUNCTION, srp.newDigest());
         mapA.put(SRP6KeyAgreement.HASH_FUNCTION, srp.getAlgorithm());
         mapA.put(SRP6KeyAgreement.USER_IDENTITY, U);
         mapA.put(SRP6KeyAgreement.USER_PASSWORD, pBytes);
@@ -689,9 +521,6 @@
           {
             throw new SaslException("sendPublicKey()", x);
           }
-
-        // 
----------------------------------------------------------------------
-
         // -------------------------------------------------------------------
         try
           {
@@ -702,7 +531,6 @@
             out.writeMPI(B);
             IncomingMessage in = new IncomingMessage(out.toByteArray());
             out = clientHandler.processMessage(in);
-
             in = new IncomingMessage(out.toByteArray());
             A = in.readMPI();
             K = clientHandler.getSharedSecret();
@@ -712,13 +540,11 @@
             throw new SaslException("sendPublicKey()", x);
           }
         // -------------------------------------------------------------------
-
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "K: " + Util.dumpString(K));
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Encoding A (client ephemeral public key): "
-                       + Util.dump(A));
-
+        if (Configuration.DEBUG)
+          {
+            log.fine("K: " + Util.dumpString(K));
+            log.fine("Encoding A (client ephemeral public key): " + 
Util.dump(A));
+          }
         try
           {
             M1 = srp.generateM1(N, g, U, s, A, B, K, authorizationID, L, cn,
@@ -728,13 +554,11 @@
           {
             throw new AuthenticationException("sendPublicKey()", x);
           }
-
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Encoding o (client chosen options): \"" + o + "\"");
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Encoding cIV (client IV): \"" + Util.dumpString(cIV)
-                       + "\"");
-
+        if (Configuration.DEBUG)
+          {
+            log.fine("Encoding o (client chosen options): \"" + o + "\"");
+            log.fine("Encoding cIV (client IV): \"" + Util.dumpString(cIV) + 
"\"");
+          }
         final OutputBuffer frameOut = new OutputBuffer();
         try
           {
@@ -746,74 +570,65 @@
         catch (IOException x)
           {
             if (x instanceof SaslException)
-              {
                 throw (SaslException) x;
-              }
             throw new AuthenticationException("sendPublicKey()", x);
           }
         final byte[] result = frameOut.encode();
-        if (DEBUG && debuglevel > 8)
-          debug(TRACE, "<== sendPublicKey()");
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "New session, or session re-use rejected...");
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "C: " + Util.dumpString(result));
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "  A = 0x" + A.toString(16));
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, " M1 = " + Util.dumpString(M1));
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "  o = " + o);
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "cIV = " + Util.dumpString(cIV));
-
+        if (Configuration.DEBUG)
+          {
+            log.fine("New session, or session re-use rejected...");
+            log.fine("C: " + Util.dumpString(result));
+            log.fine("  A = 0x" + A.toString(16));
+            log.fine(" M1 = " + Util.dumpString(M1));
+            log.fine("  o = " + o);
+            log.fine("cIV = " + Util.dumpString(cIV));
+            log.exiting(this.getClass().getName(), "sendPublicKey");
+          }
         return result;
       }
-    else
-      { // session re-use accepted -------------------------------------
+    else // session re-use accepted -------------------------------------------
+      {
         setupSecurityServices(true);
-        if (DEBUG && debuglevel > 8)
-          debug(TRACE, "<== sendPublicKey()");
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "Session re-use accepted...");
+        if (Configuration.DEBUG)
+          {
+            log.fine("Session re-use accepted...");
+            log.exiting(this.getClass().getName(), "sendPublicKey");
+          }
         return null;
       }
   }
 
   private byte[] receiveEvidence(byte[] input) throws SaslException
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> receiveEvidence()");
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "S: " + Util.dumpString(input));
-
+    if (Configuration.DEBUG)
+      {
+        log.entering(this.getClass().getName(), "receiveEvidence");
+        log.fine("S: " + Util.dumpString(input));
+      }
     // Server send M2, sIV, sCB, sid, ttl
     final InputBuffer frameIn = new InputBuffer(input);
     try
       {
         M2 = frameIn.getOS();
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got M2 (server evidence): " + Util.dumpString(M2));
+        if (Configuration.DEBUG)
+          log.fine("Got M2 (server evidence): " + Util.dumpString(M2));
         sIV = frameIn.getOS();
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got sIV (server IV): " + Util.dumpString(sIV));
+        if (Configuration.DEBUG)
+          log.fine("Got sIV (server IV): " + Util.dumpString(sIV));
         sid = frameIn.getEOS();
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got sid (session ID): " + new String(sid));
+        if (Configuration.DEBUG)
+          log.fine("Got sid (session ID): " + new String(sid));
         ttl = (int) frameIn.getScalar(4);
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got ttl (session time-to-live): " + ttl + "sec.");
+        if (Configuration.DEBUG)
+          log.fine("Got ttl (session time-to-live): " + ttl + "sec.");
         sCB = frameIn.getEOS();
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Got sCB (server channel binding): "
-                       + Util.dumpString(sCB));
+        if (Configuration.DEBUG)
+          log.fine("Got sCB (server channel binding): " + 
Util.dumpString(sCB));
       }
     catch (IOException x)
       {
         if (x instanceof SaslException)
-          {
             throw (SaslException) x;
-          }
         throw new AuthenticationException("receiveEvidence()", x);
       }
 
@@ -827,18 +642,14 @@
       {
         throw new AuthenticationException("receiveEvidence()", x);
       }
-
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Expected: " + Util.dumpString(expected));
+    if (Configuration.DEBUG)
+      log.fine("Expected: " + Util.dumpString(expected));
     if (!Arrays.equals(M2, expected))
-      {
         throw new AuthenticationException("M2 mismatch");
-      }
 
     setupSecurityServices(false);
-
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== receiveEvidence()");
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "receiveEvidence");
     return null;
   }
 
@@ -846,19 +657,15 @@
   {
     try
       {
-        if ((!properties.containsKey(Registry.SASL_USERNAME))
-            && (!properties.containsKey(Registry.SASL_PASSWORD)))
+        if ((! properties.containsKey(Registry.SASL_USERNAME))
+            && (! properties.containsKey(Registry.SASL_PASSWORD)))
           {
             final NameCallback nameCB;
             final String defaultName = System.getProperty("user.name");
             if (defaultName == null)
-              {
                 nameCB = new NameCallback("username: ");
-              }
             else
-              {
                 nameCB = new NameCallback("username: ", defaultName);
-              }
             final PasswordCallback pwdCB = new PasswordCallback("password: ",
                                                                 false);
             handler.handle(new Callback[] { nameCB, pwdCB });
@@ -868,21 +675,15 @@
         else
           {
             if (properties.containsKey(Registry.SASL_USERNAME))
-              {
                 this.U = (String) properties.get(Registry.SASL_USERNAME);
-              }
             else
               {
                 final NameCallback nameCB;
                 final String defaultName = System.getProperty("user.name");
                 if (defaultName == null)
-                  {
                     nameCB = new NameCallback("username: ");
-                  }
                 else
-                  {
                     nameCB = new NameCallback("username: ", defaultName);
-                  }
                 this.handler.handle(new Callback[] { nameCB });
                 this.U = nameCB.getName();
               }
@@ -897,14 +698,12 @@
                 else if (pw instanceof String)
                   password = new Password(((String) pw).toCharArray());
                 else
-                  throw new IllegalArgumentException(
-                                                     pw.getClass().getName()
+                  throw new IllegalArgumentException(pw.getClass().getName()
                                                          + "is not a valid 
password class");
               }
             else
               {
-                final PasswordCallback pwdCB = new PasswordCallback(
-                                                                    "password: 
",
+                final PasswordCallback pwdCB = new PasswordCallback("password: 
",
                                                                     false);
                 this.handler.handle(new Callback[] { pwdCB });
                 password = new Password(pwdCB.getPassword());
@@ -912,14 +711,10 @@
           }
 
         if (U == null)
-          {
             throw new AuthenticationException("null username supplied");
-          }
         if (password == null)
-          {
             throw new AuthenticationException("null password supplied");
           }
-      }
     catch (UnsupportedCallbackException x)
       {
         throw new AuthenticationException("getUsernameAndPassword()", x);
@@ -935,9 +730,8 @@
   // to us by the client.
   private String createO(final String aol) throws AuthenticationException
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> createO(\"" + aol + "\")");
-
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "createO", aol);
     boolean replaydetectionAvailable = false;
     boolean integrityAvailable = false;
     boolean confidentialityAvailable = false;
@@ -945,7 +739,6 @@
     int i;
 
     String mdName = SRPRegistry.SRP_DEFAULT_DIGEST_NAME;
-
     final StringTokenizer st = new StringTokenizer(aol, ",");
     while (st.hasMoreTokens())
       {
@@ -953,8 +746,8 @@
         if (option.startsWith(SRPRegistry.OPTION_SRP_DIGEST + "="))
           {
             option = option.substring(option.indexOf('=') + 1);
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "mda: <" + option + ">");
+            if (Configuration.DEBUG)
+              log.fine("mda: <" + option + ">");
             for (i = 0; i < SRPRegistry.INTEGRITY_ALGORITHMS.length; i++)
               {
                 if (SRPRegistry.SRP_ALGORITHMS[i].equals(option))
@@ -965,14 +758,12 @@
               }
           }
         else if (option.equals(SRPRegistry.OPTION_REPLAY_DETECTION))
-          {
             replaydetectionAvailable = true;
-          }
         else if (option.startsWith(SRPRegistry.OPTION_INTEGRITY + "="))
           {
             option = option.substring(option.indexOf('=') + 1);
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "ialg: <" + option + ">");
+            if (Configuration.DEBUG)
+              log.fine("ialg: <" + option + ">");
             for (i = 0; i < SRPRegistry.INTEGRITY_ALGORITHMS.length; i++)
               {
                 if (SRPRegistry.INTEGRITY_ALGORITHMS[i].equals(option))
@@ -986,8 +777,8 @@
         else if (option.startsWith(SRPRegistry.OPTION_CONFIDENTIALITY + "="))
           {
             option = option.substring(option.indexOf('=') + 1);
-            if (DEBUG && debuglevel > 6)
-              debug(TRACE, "calg: <" + option + ">");
+            if (Configuration.DEBUG)
+              log.fine("calg: <" + option + ">");
             for (i = 0; i < SRPRegistry.CONFIDENTIALITY_ALGORITHMS.length; i++)
               {
                 if (SRPRegistry.CONFIDENTIALITY_ALGORITHMS[i].equals(option))
@@ -999,9 +790,7 @@
               }
           }
         else if (option.startsWith(SRPRegistry.OPTION_MANDATORY + "="))
-          {
             mandatory = option.substring(option.indexOf('=') + 1);
-          }
         else if (option.startsWith(SRPRegistry.OPTION_MAX_BUFFER_SIZE + "="))
           {
             final String maxBufferSize = option.substring(option.indexOf('=') 
+ 1);
@@ -1010,32 +799,22 @@
                 rawSendSize = Integer.parseInt(maxBufferSize);
                 if (rawSendSize > Registry.SASL_BUFFER_MAX_LIMIT
                     || rawSendSize < 1)
-                  {
-                    throw new AuthenticationException(
-                                                      "Illegal value for 
'maxbuffersize' option");
-                  }
+                  throw new AuthenticationException("Illegal value for 
'maxbuffersize' option");
               }
             catch (NumberFormatException x)
               {
-                throw new AuthenticationException(
-                                                  
SRPRegistry.OPTION_MAX_BUFFER_SIZE
-                                                      + "="
-                                                      + 
String.valueOf(maxBufferSize),
+                throw new 
AuthenticationException(SRPRegistry.OPTION_MAX_BUFFER_SIZE
+                                                  + "=" + maxBufferSize,
                                                   x);
               }
           }
       }
-
     replayDetection = replaydetectionAvailable
-                      && Boolean.valueOf(
-                                         (String) 
properties.get(SRPRegistry.SRP_REPLAY_DETECTION)).booleanValue();
+                      && Boolean.valueOf((String) 
properties.get(SRPRegistry.SRP_REPLAY_DETECTION)).booleanValue();
     boolean integrity = integrityAvailable
-                        && Boolean.valueOf(
-                                           (String) 
properties.get(SRPRegistry.SRP_INTEGRITY_PROTECTION)).booleanValue();
+                        && Boolean.valueOf((String) 
properties.get(SRPRegistry.SRP_INTEGRITY_PROTECTION)).booleanValue();
     boolean confidentiality = confidentialityAvailable
-                              && Boolean.valueOf(
-                                                 (String) 
properties.get(SRPRegistry.SRP_CONFIDENTIALITY)).booleanValue();
-
+                              && Boolean.valueOf((String) 
properties.get(SRPRegistry.SRP_CONFIDENTIALITY)).booleanValue();
     // make sure we do the right thing
     if (SRPRegistry.OPTION_REPLAY_DETECTION.equals(mandatory))
       {
@@ -1043,95 +822,67 @@
         integrity = true;
       }
     else if (SRPRegistry.OPTION_INTEGRITY.equals(mandatory))
-      {
         integrity = true;
-      }
     else if (SRPRegistry.OPTION_CONFIDENTIALITY.equals(mandatory))
-      {
         confidentiality = true;
-      }
+
     if (replayDetection)
       {
         if (chosenIntegrityAlgorithm == null)
-          {
             throw new AuthenticationException(
-                                              "Replay detection is required 
but no "
-                                                  + "integrity protection 
algorithm was chosen");
-          }
+              "Replay detection is required but no integrity protection 
algorithm was chosen");
       }
     if (integrity)
       {
         if (chosenIntegrityAlgorithm == null)
-          {
             throw new AuthenticationException(
-                                              "Integrity protection is 
required but no "
-                                                  + "algorithm was chosen");
-          }
+              "Integrity protection is required but no algorithm was chosen");
       }
     if (confidentiality)
       {
         if (chosenConfidentialityAlgorithm == null)
-          {
             throw new AuthenticationException(
-                                              "Confidentiality protection is 
required "
-                                                  + "but no algorithm was 
chosen");
-          }
+              "Confidentiality protection is required but no algorithm was 
chosen");
       }
-
     // 1. check if we'll be using confidentiality; if not set IV to 0-byte
     if (chosenConfidentialityAlgorithm == null)
-      {
         cIV = new byte[0];
-      }
     else
       {
         // 2. get the block size of the cipher
         final IBlockCipher cipher = 
CipherFactory.getInstance(chosenConfidentialityAlgorithm);
         if (cipher == null)
-          {
             throw new AuthenticationException("createO()",
                                               new NoSuchAlgorithmException());
-          }
         final int blockSize = cipher.defaultBlockSize();
         // 3. generate random iv
         cIV = new byte[blockSize];
         getDefaultPRNG().nextBytes(cIV);
       }
-
     srp = SRP.instance(mdName);
-
     // Now create the options list specifying which of the available options
     // we have chosen.
 
     // For now we just select the defaults. Later we need to add support for
     // properties (perhaps in a file) where a user can specify the list of
     // algorithms they would prefer to use.
-
     final StringBuffer sb = new StringBuffer();
-    sb.append(SRPRegistry.OPTION_SRP_DIGEST).append("=").append(mdName).append(
-                                                                               
",");
+    sb.append(SRPRegistry.OPTION_SRP_DIGEST)
+      .append("=").append(mdName).append(",");
     if (replayDetection)
-      {
         sb.append(SRPRegistry.OPTION_REPLAY_DETECTION).append(",");
-      }
     if (integrity)
-      {
-        sb.append(SRPRegistry.OPTION_INTEGRITY).append("=").append(
-                                                                   
chosenIntegrityAlgorithm).append(
-                                                                               
                     ",");
-      }
+      sb.append(SRPRegistry.OPTION_INTEGRITY)
+        .append("=").append(chosenIntegrityAlgorithm).append(",");
     if (confidentiality)
-      {
-        sb.append(SRPRegistry.OPTION_CONFIDENTIALITY).append("=").append(
-                                                                         
chosenConfidentialityAlgorithm).append(
-                                                                               
                                 ",");
-      }
-    final String result = sb.append(SRPRegistry.OPTION_MAX_BUFFER_SIZE).append(
-                                                                               
"=").append(
-                                                                               
            Registry.SASL_BUFFER_MAX_LIMIT).toString();
+      sb.append(SRPRegistry.OPTION_CONFIDENTIALITY)
+        .append("=").append(chosenConfidentialityAlgorithm).append(",");
 
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== createO() --> " + result);
+    final String result = sb.append(SRPRegistry.OPTION_MAX_BUFFER_SIZE)
+                            .append("=").append(Registry.SASL_BUFFER_MAX_LIMIT)
+                            .toString();
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "createO", result);
     return result;
   }
 
@@ -1139,33 +890,30 @@
       throws SaslException
   {
     complete = true; // signal end of authentication phase
-    if (!sessionReUse)
+    if (! sessionReUse)
       {
         outCounter = inCounter = 0;
         // instantiate cipher if confidentiality protection filter is active
         if (chosenConfidentialityAlgorithm != null)
           {
-            if (DEBUG && debuglevel > 2)
-              debug(INFO, "Activating confidentiality protection filter");
+            if (Configuration.DEBUG)
+              log.fine("Activating confidentiality protection filter");
             inCipher = CALG.getInstance(chosenConfidentialityAlgorithm);
             outCipher = CALG.getInstance(chosenConfidentialityAlgorithm);
           }
         // instantiate hmacs if integrity protection filter is active
         if (chosenIntegrityAlgorithm != null)
           {
-            if (DEBUG && debuglevel > 2)
-              debug(INFO, "Activating integrity protection filter");
+            if (Configuration.DEBUG)
+              log.fine("Activating integrity protection filter");
             inMac = IALG.getInstance(chosenIntegrityAlgorithm);
             outMac = IALG.getInstance(chosenIntegrityAlgorithm);
           }
       }
-    else
-      { // same session new Keys
+    else // same session new Keys
         K = srp.generateKn(K, cn, sn);
-      }
 
     final KDF kdf = KDF.getInstance(K);
-
     // initialise in/out ciphers if confidentiality protection is used
     if (inCipher != null)
       {
@@ -1178,16 +926,13 @@
         inMac.init(kdf);
         outMac.init(kdf);
       }
-
     if (sid != null && sid.length != 0)
       { // update the security context and save in map
-        if (DEBUG && debuglevel > 2)
-          debug(INFO, "Updating security context for UID = " + uid);
-        ClientStore.instance().cacheSession(
-                                            uid,
+        if (Configuration.DEBUG)
+          log.fine("Updating security context for UID = " + uid);
+        ClientStore.instance().cacheSession(uid,
                                             ttl,
-                                            new SecurityContext(
-                                                                
srp.getAlgorithm(),
+                                            new 
SecurityContext(srp.getAlgorithm(),
                                                                 sid,
                                                                 K,
                                                                 cIV,

Index: java/security/util/Prime2.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/util/Prime2.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- java/security/util/Prime2.java      29 Jan 2006 13:54:03 -0000      1.2
+++ java/security/util/Prime2.java      11 Jun 2006 12:14:44 -0000      1.3
@@ -38,37 +38,20 @@
 
 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 @@
             }
         }
       time += System.currentTimeMillis();
-      if (DEBUG && debuglevel > 8)
+      if (Configuration.DEBUG)
         {
           StringBuffer sb;
           for (int i = 0; i < (SMALL_PRIME_COUNT / 10); i++)
@@ -126,12 +109,12 @@
                 {
                   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)
+          log.fine("Generating first " + String.valueOf(SMALL_PRIME_COUNT)
                 + " primes took: " + String.valueOf(time) + " ms.");
         }
     }
@@ -169,17 +152,13 @@
         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 @@
     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 @@
     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 @@
 
   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));
   }
 }

Index: java/security/util/Base64.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/util/Base64.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- java/security/util/Base64.java      26 Jan 2006 02:25:11 -0000      1.1
+++ java/security/util/Base64.java      11 Jun 2006 12:14:44 -0000      1.2
@@ -38,8 +38,10 @@
 
 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 @@
  */
 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 @@
       }
     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;
       }

Index: javax/crypto/key/srp6/SRPKeyPairGenerator.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/key/srp6/SRPKeyPairGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/key/srp6/SRPKeyPairGenerator.java      3 Feb 2006 19:29:01 
-0000       1.2
+++ javax/crypto/key/srp6/SRPKeyPairGenerator.java      11 Jun 2006 12:14:44 
-0000      1.3
@@ -38,16 +38,17 @@
 
 package gnu.javax.crypto.key.srp6;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.key.IKeyPairGenerator;
 import gnu.java.security.util.PRNG;
 import gnu.java.security.util.Prime2;
 
-import java.io.PrintWriter;
 import java.math.BigInteger;
 import java.security.KeyPair;
 import java.security.SecureRandom;
 import java.util.Map;
+import java.util.logging.Logger;
 
 /**
  *
@@ -60,26 +61,7 @@
  */
 public class SRPKeyPairGenerator implements IKeyPairGenerator
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = "srp";
-
-  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(SRPKeyPairGenerator.class.getName());
   private static final BigInteger ZERO = BigInteger.ZERO;
 
   private static final BigInteger ONE = BigInteger.ONE;
@@ -235,11 +217,11 @@
         BigInteger q = params[0];
         N = params[1];
         g = params[2];
-        if (DEBUG && debuglevel > 0)
+        if (Configuration.DEBUG)
           {
-            debug("q: " + q.toString(16));
-            debug("N: " + N.toString(16));
-            debug("g: " + g.toString(16));
+            log.fine("q: " + q.toString(16));
+            log.fine("N: " + N.toString(16));
+            log.fine("g: " + g.toString(16));
           }
       }
 

Index: java/security/sig/rsa/EMSA_PSS.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/sig/rsa/EMSA_PSS.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- java/security/sig/rsa/EMSA_PSS.java 26 Mar 2006 22:57:46 -0000      1.2
+++ java/security/sig/rsa/EMSA_PSS.java 11 Jun 2006 12:14:44 -0000      1.3
@@ -38,12 +38,13 @@
 
 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 @@
  */
 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 @@
     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 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 @@
     // 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 @@
     //    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 @@
     //    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 @@
       }
     // 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 @@
       {
         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. "
+        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.

Index: java/security/sig/rsa/RSAPSSSignature.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/sig/rsa/RSAPSSSignature.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- java/security/sig/rsa/RSAPSSSignature.java  26 Mar 2006 22:57:46 -0000      
1.3
+++ java/security/sig/rsa/RSAPSSSignature.java  11 Jun 2006 12:14:44 -0000      
1.4
@@ -38,18 +38,19 @@
 
 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 @@
  */
 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 @@
     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 @@
     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;

Index: java/security/pkcs/PKCS7SignedData.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/pkcs/PKCS7SignedData.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- java/security/pkcs/PKCS7SignedData.java     25 Mar 2006 11:19:17 -0000      
1.4
+++ java/security/pkcs/PKCS7SignedData.java     11 Jun 2006 12:14:44 -0000      
1.5
@@ -37,6 +37,7 @@
 
 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.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.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 @@
     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 @@
       {
         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 @@
         else
           algId.add(null);
 
-        log.finest("      digestAlgorithmIdentifiers params: ");
-        log.finest(Util.dumpString((byte[]) algId.get(1),
+        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 @@
               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 @@
           {
             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 @@
       {
         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 @@
                (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 @@
     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

Index: java/security/pkcs/SignerInfo.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/pkcs/SignerInfo.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- java/security/pkcs/SignerInfo.java  25 Mar 2006 11:19:26 -0000      1.5
+++ java/security/pkcs/SignerInfo.java  11 Jun 2006 12:14:44 -0000      1.6
@@ -37,6 +37,7 @@
 
 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 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 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 @@
       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 @@
 
     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 @@
       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 @@
     else
       digestAlgorithmParams = null;
 
-    log.finest("    digestAlgorithm params: ");
-    log.finest(Util.dumpString(digestAlgorithmParams,
+    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 @@
     else
       authenticatedAttributes = null;
 
-    log.finest("  AuthenticatedAttributes: ");
-    log.finest(Util.dumpString(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 @@
     else
       digestEncryptionAlgorithmParams = null;
 
-    log.finest("    digestEncryptionAlgorithm params: ");
-    log.finest(Util.dumpString(digestEncryptionAlgorithmParams,
+    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,
+    if (Configuration.DEBUG)
+      {
+        log.fine("  UnauthenticatedAttributes: ");
+        log.fine(Util.dumpString(unauthenticatedAttributes,
                                "  UnauthenticatedAttributes: "));
-
+      }
     if (ber.peek() == 0)
       ber.read();
   }

Index: java/security/jce/sig/SignatureAdapter.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/jce/sig/SignatureAdapter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- java/security/jce/sig/SignatureAdapter.java 26 Mar 2006 22:57:46 -0000      
1.3
+++ java/security/jce/sig/SignatureAdapter.java 11 Jun 2006 12:14:44 -0000      
1.4
@@ -38,6 +38,7 @@
 
 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 @@
 
   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 @@
       {
         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;
   }
 

Index: java/security/jce/sig/EncodedKeyFactory.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/jce/sig/EncodedKeyFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- java/security/jce/sig/EncodedKeyFactory.java        26 Feb 2006 04:10:38 
-0000      1.5
+++ java/security/jce/sig/EncodedKeyFactory.java        11 Jun 2006 12:14:44 
-0000      1.6
@@ -38,6 +38,7 @@
 
 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,6 +197,7 @@
   protected PublicKey engineGeneratePublic(KeySpec keySpec)
       throws InvalidKeySpecException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineGeneratePublic()", keySpec);
 
     PublicKey result = null;
@@ -220,6 +222,7 @@
           }
         catch (InvalidParameterException ignored)
           {
+            if (Configuration.DEBUG)
             log.log(Level.FINE, "Exception in DSSPublicKey.valueOf(). Ignore",
                     ignored);
           }
@@ -232,6 +235,7 @@
             }
           catch (InvalidParameterException ignored)
             {
+              if (Configuration.DEBUG)
               log.log(Level.FINE,
                       "Exception in GnuRSAPublicKey.valueOf(). Ignore",
                       ignored);
@@ -240,7 +244,7 @@
           if (! ok) // try DH
             result = decodeDHPublicKey(input);
       }
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineGeneratePublic()", result);
     return result;
   }
@@ -248,6 +252,7 @@
   protected PrivateKey engineGeneratePrivate(KeySpec keySpec)
       throws InvalidKeySpecException
   {
+    if (Configuration.DEBUG)
     log.entering(this.getClass().getName(), "engineGeneratePrivate()", 
keySpec);
 
     PrivateKey result = null;
@@ -272,6 +277,7 @@
           }
         catch (InvalidParameterException ignored)
           {
+            if (Configuration.DEBUG)
             log.log(Level.FINE, "Exception in DSSPrivateKey.valueOf(). Ignore",
                     ignored);
           }
@@ -284,6 +290,7 @@
             }
           catch (InvalidParameterException ignored)
             {
+              if (Configuration.DEBUG)
               log.log(Level.FINE,
                       "Exception in GnuRSAPrivateKey.valueOf(). Ignore",
                       ignored);
@@ -292,7 +299,7 @@
         if (! ok) // try DH
           result = decodeDHPrivateKey(input);
       }
-
+    if (Configuration.DEBUG)
     log.exiting(this.getClass().getName(), "engineGeneratePrivate()", result);
     return result;
   }

Index: java/security/Properties.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/Properties.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- java/security/Properties.java       21 Apr 2006 10:09:26 -0000      1.2
+++ java/security/Properties.java       11 Jun 2006 12:14:44 -0000      1.3
@@ -38,13 +38,15 @@
 
 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 @@
  */
 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 @@
       }
     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,13 +299,13 @@
           }
         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 + ": "
+            if (Configuration.DEBUG)
+              log.fine("Security error reading " + propFile + ": "
                     + se.getMessage());
           }
       }
@@ -350,8 +333,8 @@
       }
     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 @@
         // 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");
           }
       }
   }

Index: java/security/provider/PKIXCertPathValidatorImpl.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/security/provider/PKIXCertPathValidatorImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- java/security/provider/PKIXCertPathValidatorImpl.java       4 Jun 2006 
05:29:44 -0000       1.7
+++ java/security/provider/PKIXCertPathValidatorImpl.java       11 Jun 2006 
12:14:44 -0000      1.8
@@ -38,6 +38,7 @@
 
 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.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 @@
  */
 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 @@
                                        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 @@
         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 @@
     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 @@
 
   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;
       }

Index: javax/crypto/sasl/SaslInputStream.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/sasl/SaslInputStream.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- javax/crypto/sasl/SaslInputStream.java      26 Jan 2006 02:25:09 -0000      
1.1
+++ javax/crypto/sasl/SaslInputStream.java      11 Jun 2006 12:14:44 -0000      
1.2
@@ -38,12 +38,13 @@
 
 package gnu.javax.crypto.sasl;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.util.Util;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InterruptedIOException;
-import java.io.IOException;
-import java.io.PrintWriter;
+import java.util.logging.Logger;
 
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslClient;
@@ -55,41 +56,11 @@
  */
 public class SaslInputStream extends InputStream
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = "SaslOutputStream";
-
-  private static final String ERROR = "ERROR";
-
-  private static final String WARN = " WARN";
-
-  //   private static final String INFO =  " INFO";
-  private static final String TRACE = "DEBUG";
-
-  private static final boolean DEBUG = true;
-
-  private static final int debuglevel = 3;
-
-  private static final PrintWriter err = new PrintWriter(System.out, true);
-
-  private static void debug(String level, Object obj)
-  {
-    err.println("[" + level + "] " + NAME + ": " + String.valueOf(obj));
-  }
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
+  private static final Logger log = 
Logger.getLogger(SaslInputStream.class.getName());
   private SaslClient client;
-
   private SaslServer server;
-
   private int maxRawSendSize;
-
   private InputStream source;
-
   private byte[] internalBuf;
 
   // Constructor(s)
@@ -168,7 +139,6 @@
         else
           {
             byte[] tmp = new byte[internalBuf.length - 1];
-            //            System.arraycopy(internalBuf, 0, tmp, 0, tmp.length);
             System.arraycopy(internalBuf, 1, tmp, 0, tmp.length);
             internalBuf = tmp;
           }
@@ -241,32 +211,22 @@
    */
   public int read(byte[] b, int off, int len) throws IOException
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> read(b, " + String.valueOf(off) + ", "
-                   + String.valueOf(len) + ")");
-
-    if (b == null)
-      {
-        throw new NullPointerException("b");
-      }
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "read",
+                   new Object[] { b, Integer.valueOf(off), 
Integer.valueOf(len) });
     if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length)
         || ((off + len) < 0))
-      {
-        throw new IndexOutOfBoundsException("off=" + String.valueOf(off)
-                                            + ", len=" + String.valueOf(len)
-                                            + ", b.length="
-                                            + String.valueOf(b.length));
-      }
+      throw new IndexOutOfBoundsException("off=" + off
+                                          + ", len=" + len
+                                          + ", b.length=" + b.length);
     if (len == 0)
       {
-        if (DEBUG && debuglevel > 8)
-          debug(TRACE, "<== read() --> 0");
+        if (Configuration.DEBUG)
+          log.exiting(this.getClass().getName(), "read", Integer.valueOf(0));
         return 0;
       }
-
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Available: " + String.valueOf(available()));
-
+    if (Configuration.DEBUG)
+      log.finer("Available: " + available());
     int result = 0;
     if (internalBuf == null || internalBuf.length < 1)
       try
@@ -274,21 +234,24 @@
           internalBuf = readSaslBuffer();
           if (internalBuf == null)
             {
-              if (DEBUG && debuglevel > 4)
-                debug(WARN, "Underlying stream empty. Returning -1");
-              if (DEBUG && debuglevel > 8)
-                debug(TRACE, "<== read() --> -1");
+              if (Configuration.DEBUG)
+                {
+                  log.finer("Underlying stream empty. Returning -1");
+                  log.exiting(this.getClass().getName(), "read",
+                              Integer.valueOf(-1));
+                }
               return -1;
             }
         }
       catch (InterruptedIOException x)
         {
-          if (DEBUG && debuglevel > 6)
-            debug(TRACE, x);
-          if (DEBUG && debuglevel > 4)
-            debug(WARN, "Reading thread was interrupted. Returning -1");
-          if (DEBUG && debuglevel > 8)
-            debug(TRACE, "<== read() --> -1");
+          if (Configuration.DEBUG)
+            {
+              log.finer("Reading thread was interrupted. Returning -1");
+              log.throwing(this.getClass().getName(), "read", x);
+              log.exiting(this.getClass().getName(), "read",
+                          Integer.valueOf(-1));
+            }
           return -1;
         }
 
@@ -328,8 +291,8 @@
               data = readSaslBuffer();
               if (data == null)
                 {
-                  if (DEBUG && debuglevel > 4)
-                    debug(WARN, "Underlying stream exhausted. Breaking...");
+                  if (Configuration.DEBUG)
+                    log.finer("Underlying stream exhausted. Breaking...");
                   break;
                 }
 
@@ -352,18 +315,16 @@
             }
           else
             { // nothing much we can do except return what we have
-              if (DEBUG && debuglevel > 4)
-                debug(WARN,
-                      "Not enough bytes in source to read a buffer. 
Breaking...");
+              if (Configuration.DEBUG)
+                log.finer("Not enough bytes in source to read a buffer. 
Breaking...");
               break;
             }
       }
-
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Remaining: "
-                   + (internalBuf == null ? 0 : internalBuf.length));
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== read() --> " + String.valueOf(result));
+    if (Configuration.DEBUG)
+      {
+        log.finer("Remaining: " + (internalBuf == null ? 0 : 
internalBuf.length));
+        log.exiting(this.getClass().getName(), "read()", 
String.valueOf(result));
+      }
     return result;
   }
 
@@ -379,9 +340,8 @@
    */
   private byte[] readSaslBuffer() throws IOException
   {
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> readSaslBuffer()");
-
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "readSaslBuffer()");
     int realLength; // check if we read as many bytes as we're supposed to
     byte[] result = new byte[4];
     try
@@ -389,32 +349,27 @@
         realLength = source.read(result);
         if (realLength == -1)
           {
-            if (DEBUG && debuglevel > 8)
-              debug(TRACE, "<== readSaslBuffer() --> null");
+            if (Configuration.DEBUG)
+              log.exiting(this.getClass().getName(), "readSaslBuffer");
             return null;
           }
       }
     catch (IOException x)
       {
-        if (DEBUG && debuglevel > 0)
-          debug(ERROR, x);
+        if (Configuration.DEBUG)
+          log.throwing(this.getClass().getName(), "readSaslBuffer", x);
         throw x;
       }
 
     if (realLength != 4)
-      {
-        throw new IOException("Was expecting 4 but found "
-                              + String.valueOf(realLength));
-      }
+      throw new IOException("Was expecting 4 but found " + realLength);
     int bufferLength = result[0] << 24 | (result[1] & 0xFF) << 16
                        | (result[2] & 0xFF) << 8 | (result[3] & 0xFF);
 
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "SASL buffer size: " + bufferLength);
+    if (Configuration.DEBUG)
+      log.finer("SASL buffer size: " + bufferLength);
     if (bufferLength > maxRawSendSize || bufferLength < 0)
-      {
         throw new SaslEncodingException("SASL buffer (security layer) too 
long");
-      }
 
     result = new byte[bufferLength];
     try
@@ -423,37 +378,34 @@
       }
     catch (IOException x)
       {
-        if (DEBUG && debuglevel > 0)
-          debug(ERROR, x);
+        if (Configuration.DEBUG)
+          log.throwing(this.getClass().getName(), "readSaslBuffer", x);
         throw x;
       }
 
     if (realLength != bufferLength)
-      throw new IOException("Was expecting " + String.valueOf(bufferLength)
-                            + " but found " + String.valueOf(realLength));
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Incoming buffer (before security) (hex): "
+      throw new IOException("Was expecting " + bufferLength
+                            + " but found " + realLength);
+    if (Configuration.DEBUG)
+      {
+        log.finer("Incoming buffer (before security) (hex): "
                    + Util.dumpString(result));
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Incoming buffer (before security) (str): \""
+        log.finer("Incoming buffer (before security) (str): \""
                    + new String(result) + "\"");
-
+      }
     if (client != null)
-      {
         result = client.unwrap(result, 0, realLength);
-      }
     else
-      {
         result = server.unwrap(result, 0, realLength);
-      }
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Incoming buffer (after security) (hex): "
+
+    if (Configuration.DEBUG)
+      {
+        log.finer("Incoming buffer (after security) (hex): "
                    + Util.dumpString(result));
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "Incoming buffer (after security) (str): \""
+        log.finer("Incoming buffer (after security) (str): \""
                    + new String(result) + "\"");
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== readSaslBuffer()");
+        log.exiting(this.getClass().getName(), "readSaslBuffer");
+      }
     return result;
   }
 }
\ No newline at end of file

Index: javax/crypto/sasl/SaslOutputStream.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/javax/crypto/sasl/SaslOutputStream.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- javax/crypto/sasl/SaslOutputStream.java     26 Jan 2006 02:25:09 -0000      
1.1
+++ javax/crypto/sasl/SaslOutputStream.java     11 Jun 2006 12:14:44 -0000      
1.2
@@ -38,11 +38,12 @@
 
 package gnu.javax.crypto.sasl;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.util.Util;
 
-import java.io.OutputStream;
 import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.OutputStream;
+import java.util.logging.Logger;
 
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslClient;
@@ -54,37 +55,10 @@
  */
 public class SaslOutputStream extends OutputStream
 {
-
-  // Debugging methods and variables
-  // -------------------------------------------------------------------------
-
-  private static final String NAME = "SaslOutputStream";
-
-  //   private static final String ERROR = "ERROR";
-  //   private static final String WARN =  " WARN";
-  //   private static final String INFO =  " INFO";
-  private static final String TRACE = "DEBUG";
-
-  private static final boolean DEBUG = true;
-
-  private static final int debuglevel = 3;
-
-  private static final PrintWriter err = new PrintWriter(System.out, true);
-
-  private static void debug(String level, Object obj)
-  {
-    err.println("[" + level + "] " + NAME + ": " + String.valueOf(obj));
-  }
-
-  // Constants and variables
-  // -------------------------------------------------------------------------
-
+  private static final Logger log = 
Logger.getLogger(SaslOutputStream.class.getName());
   private SaslClient client;
-
   private SaslServer server;
-
   private int maxRawSendSize;
-
   private OutputStream dest;
 
   // Constructor(s)
@@ -148,52 +122,45 @@
    */
   public void write(byte[] b, int off, int len) throws IOException
   {
-    if (b == null)
-      {
-        throw new NullPointerException("b");
-      }
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "write");
     if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length)
         || ((off + len) < 0))
-      {
-        throw new IndexOutOfBoundsException("off=" + String.valueOf(off)
-                                            + ", len=" + String.valueOf(len)
-                                            + ", b.length="
-                                            + String.valueOf(b.length));
-      }
+      throw new IndexOutOfBoundsException("off=" + off
+                                          + ", len=" + len
+                                          + ", b.length=" + b.length);
     if (len == 0)
       {
+        if (Configuration.DEBUG)
+          log.exiting(this.getClass().getName(), "write");
         return;
       }
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "==> write()");
-
     int chunckSize, length, chunck = 1;
     byte[] output = null, result;
-    if (DEBUG && debuglevel > 6)
-      debug(TRACE, "About to wrap " + String.valueOf(len) + " byte(s)...");
+    if (Configuration.DEBUG)
+      log.finer("About to wrap " + len + " byte(s)...");
     while (len > 0)
       {
         chunckSize = (len > maxRawSendSize ? maxRawSendSize : len);
-
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Outgoing buffer (before security) (hex): "
+        if (Configuration.DEBUG)
+          {
+            log.finer("Outgoing buffer (before security) (hex): "
                        + Util.dumpString(b, off, chunckSize));
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Outgoing buffer (before security) (str): \""
+            log.finer("Outgoing buffer (before security) (str): \""
                        + new String(b, off, chunckSize) + "\"");
-
+          }
         if (client != null)
           output = client.wrap(b, off, chunckSize);
         else
           output = server.wrap(b, off, chunckSize);
 
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Outgoing buffer (after security) (hex): "
+        if (Configuration.DEBUG)
+          {
+            log.finer("Outgoing buffer (after security) (hex): "
                        + Util.dumpString(output));
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Outgoing buffer (after security) (str): \""
+            log.finer("Outgoing buffer (after security) (str): \""
                        + new String(output) + "\"");
-
+          }
         length = output.length;
         result = new byte[length + 4];
         result[0] = (byte) (length >>> 24);
@@ -206,13 +173,12 @@
 
         off += chunckSize;
         len -= chunckSize;
-        if (DEBUG && debuglevel > 6)
-          debug(TRACE, "Wrapped chunck #" + String.valueOf(chunck));
+        if (Configuration.DEBUG)
+          log.finer("Wrapped chunck #" + chunck);
         chunck++;
       }
-
     dest.flush();
-    if (DEBUG && debuglevel > 8)
-      debug(TRACE, "<== write()");
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "write");
   }
 }
\ No newline at end of file


Index: javax/crypto/mac/OMAC.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/mac/OMAC.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- javax/crypto/mac/OMAC.java  4 Jun 2006 06:57:26 -0000       1.2
+++ javax/crypto/mac/OMAC.java  11 Jun 2006 12:14:46 -0000      1.3
@@ -38,6 +38,7 @@
 
 package gnu.javax.crypto.mac;
 
+import gnu.classpath.Configuration;
 import gnu.java.security.Registry;
 import gnu.java.security.util.Util;
 import gnu.javax.crypto.cipher.CipherFactory;
@@ -48,6 +49,7 @@
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.logging.Logger;
 
 /**
  * <p>The One-Key CBC MAC, OMAC. This message authentication code is based on
@@ -62,18 +64,7 @@
  */
 public class OMAC implements IMac
 {
-
-  // Constants and fields.
-  // ------------------------------------------------------------------------
-
-  private static final boolean DEBUG = false;
-
-  private static void debug(String msg)
-  {
-    System.out.print(">>> OMAC: ");
-    System.out.println(msg);
-  }
-
+  private static final Logger log = Logger.getLogger(OMAC.class.getName());
   private static final byte C1 = (byte) 0x87;
 
   private static final byte C2 = 0x1b;
@@ -157,12 +148,8 @@
 
     byte[] L = new byte[blockSize];
     cipher.encryptBlock(L, 0, L, 0);
-
-    if (DEBUG)
-      {
-        debug("L = " + Util.toString(L).toLowerCase());
-      }
-
+    if (Configuration.DEBUG)
+      log.fine("L = " + Util.toString(L).toLowerCase());
     if (Lu != null)
       {
         Arrays.fill(Lu, (byte) 0);
@@ -214,11 +201,8 @@
                                                    + blockSize);
           }
       }
-    if (DEBUG)
-      {
-        debug("Lu = " + Util.toString(Lu).toLowerCase());
-      }
-
+    if (Configuration.DEBUG)
+      log.fine("Lu = " + Util.toString(Lu).toLowerCase());
     msb = (Lu[0] & 0x80) != 0;
     for (int i = 0; i < blockSize; i++)
       {
@@ -239,11 +223,8 @@
             Lu2[Lu2.length - 1] ^= C2;
           }
       }
-    if (DEBUG)
-      {
-        debug("Lu2 = " + Util.toString(Lu2).toLowerCase());
-      }
-
+    if (Configuration.DEBUG)
+      log.fine("Lu2 = " + Util.toString(Lu2).toLowerCase());
     if (M != null)
       {
         Arrays.fill(M, (byte) 0);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]