diff options
Diffstat (limited to 'libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java')
-rw-r--r-- | libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java | 69 |
1 files changed, 30 insertions, 39 deletions
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java b/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java index 490eb4458fa..5243919c3c9 100644 --- a/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java +++ b/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.javax.crypto.keyring; +import gnu.java.security.Configuration; import gnu.java.security.Registry; import java.io.DataInputStream; @@ -50,17 +51,13 @@ import java.util.Date; import java.util.Iterator; import java.util.logging.Logger; -public class GnuPublicKeyring extends BaseKeyring implements IPublicKeyring +public class GnuPublicKeyring + extends BaseKeyring + implements IPublicKeyring { - // Fields. - // ------------------------------------------------------------------------ - private static final Logger log = Logger.getLogger(GnuPublicKeyring.class.getName()); public static final int USAGE = Registry.GKR_CERTIFICATES; - // Constructors. - // ------------------------------------------------------------------------ - public GnuPublicKeyring(String mac, int macLen) { keyring = new PasswordAuthenticatedEntry(mac, macLen, new Properties()); @@ -72,13 +69,10 @@ public class GnuPublicKeyring extends BaseKeyring implements IPublicKeyring { } - // Instance methods. - // ------------------------------------------------------------------------ - public boolean containsCertificate(String alias) { - log.entering(this.getClass().getName(), "containsCertificate", alias); - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "containsCertificate", alias); boolean result = false; if (containsAlias(alias)) for (Iterator it = get(alias).iterator(); it.hasNext();) @@ -87,16 +81,16 @@ public class GnuPublicKeyring extends BaseKeyring implements IPublicKeyring result = true; break; } - - log.exiting(this.getClass().getName(), "containsCertificate", - Boolean.valueOf(result)); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "containsCertificate", + Boolean.valueOf(result)); return result; } public Certificate getCertificate(String alias) { - log.entering(this.getClass().getName(), "getCertificate", alias); - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getCertificate", alias); Certificate result = null; if (containsAlias(alias)) for (Iterator it = get(alias).iterator(); it.hasNext();) @@ -108,53 +102,50 @@ public class GnuPublicKeyring extends BaseKeyring implements IPublicKeyring break; } } - - log.exiting(this.getClass().getName(), "getCertificate", result); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getCertificate", result); return result; } public void putCertificate(String alias, Certificate cert) { - log.entering(this.getClass().getName(), "putCertificate", - new Object[] { alias, cert }); - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "putCertificate", + new Object[] { alias, cert }); if (! containsCertificate(alias)) { Properties p = new Properties(); p.put("alias", fixAlias(alias)); add(new CertificateEntry(cert, new Date(), p)); } - else - log.finer("Keyring already contains alias: " + alias); - - log.exiting(this.getClass().getName(), "putCertificate"); + 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 { - log.entering(this.getClass().getName(), "load", - new Object[] { in, String.valueOf(password) }); - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "load"); if (in.read() != USAGE) throw new MalformedKeyringException("incompatible keyring usage"); - if (in.read() != PasswordAuthenticatedEntry.TYPE) - throw new MalformedKeyringException("expecting password-authenticated entry tag"); - + throw new MalformedKeyringException( + "expecting password-authenticated entry tag"); DataInputStream dis = new DataInputStream(in); keyring = PasswordAuthenticatedEntry.decode(dis, password); - - log.exiting(this.getClass().getName(), "load"); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "load"); } protected void store(OutputStream out, char[] password) throws IOException { - log.entering(this.getClass().getName(), "store", - new Object[] { out, String.valueOf(password) }); - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "store"); out.write(USAGE); keyring.encode(new DataOutputStream(out), password); - - log.exiting(this.getClass().getName(), "store"); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "store"); } } |