diff options
Diffstat (limited to 'javax/security')
18 files changed, 124 insertions, 111 deletions
diff --git a/javax/security/auth/Policy.java b/javax/security/auth/Policy.java index 4da9a84df..90185be0e 100644 --- a/javax/security/auth/Policy.java +++ b/javax/security/auth/Policy.java @@ -1,5 +1,5 @@ /* Policy.java -- deprecated precursor to java.security.Policy. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,6 +45,7 @@ import java.security.PermissionCollection; * @deprecated The classes java.security.Policy and * java.security.ProtectionDomain provide the functionality of this class. */ +@Deprecated public abstract class Policy { diff --git a/javax/security/auth/PrivateCredentialPermission.java b/javax/security/auth/PrivateCredentialPermission.java index 7c5f02090..1bb3c3987 100644 --- a/javax/security/auth/PrivateCredentialPermission.java +++ b/javax/security/auth/PrivateCredentialPermission.java @@ -1,5 +1,5 @@ /* PrivateCredentialPermission.java -- permissions governing private credentials. - Copyright (C) 2004, 2014 Free Software Foundation, Inc. + Copyright (C) 2004, 2014, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -64,7 +64,6 @@ import java.util.StringTokenizer; * wildcard character.</p> */ public final class PrivateCredentialPermission extends Permission - implements Serializable { /** * For compatability with Sun's JDK 1.4.2 rev. 5 @@ -125,6 +124,7 @@ public final class PrivateCredentialPermission extends Permission // Instance methods. // ------------------------------------------------------------------------- + @Override public boolean equals (Object o) { if (! (o instanceof PrivateCredentialPermission)) @@ -141,20 +141,20 @@ public final class PrivateCredentialPermission extends Permission return false; } - final String[][] principals = getPrincipals(); + final String[][] thisPrincipals = getPrincipals(); final String[][] thatPrincipals = that.getPrincipals(); if (thatPrincipals == null) { return false; } - if (thatPrincipals.length != principals.length) + if (thatPrincipals.length != thisPrincipals.length) { return false; } - for (int i = 0; i < principals.length; i++) + for (int i = 0; i < thisPrincipals.length; i++) { - if (!principals[i][0].equals (thatPrincipals[i][0]) || - !principals[i][1].equals (thatPrincipals[i][1])) + if (!thisPrincipals[i][0].equals (thatPrincipals[i][0]) || + !thisPrincipals[i][1].equals (thatPrincipals[i][1])) { return false; } @@ -168,6 +168,7 @@ public final class PrivateCredentialPermission extends Permission * * @return The list of actions. */ + @Override public String getActions() { return "read"; @@ -205,6 +206,7 @@ public final class PrivateCredentialPermission extends Permission return ret; } + @Override public int hashCode() { return credentialClass.hashCode() + principals.hashCode(); @@ -228,6 +230,7 @@ public final class PrivateCredentialPermission extends Permission * @param p The permission to check. * @return True if this permission implies <i>p</i>. */ + @Override public boolean implies (Permission p) { if (! (p instanceof PrivateCredentialPermission)) @@ -240,19 +243,19 @@ public final class PrivateCredentialPermission extends Permission { return false; } - String[][] principals = getPrincipals(); + String[][] thisPrincipals = getPrincipals(); String[][] thatPrincipals = that.getPrincipals(); if (thatPrincipals == null) { return false; } - for (int i = 0; i < principals.length; i++) + for (int i = 0; i < thisPrincipals.length; i++) { for (int j = 0; j < thatPrincipals.length; j++) { - if (principals[i][0].equals (thatPrincipals[j][0]) && - (principals[i][1].equals ("*") || - principals[i][1].equals (thatPrincipals[j][1]))) + if (thisPrincipals[i][0].equals (thatPrincipals[j][0]) && + (thisPrincipals[i][1].equals ("*") || + thisPrincipals[i][1].equals (thatPrincipals[j][1]))) { return true; } @@ -266,6 +269,7 @@ public final class PrivateCredentialPermission extends Permission * * @return null. */ + @Override public PermissionCollection newPermissionCollection() { return null; @@ -300,6 +304,7 @@ public final class PrivateCredentialPermission extends Permission // Instance methods. // ----------------------------------------------------------------------- + @Override public boolean equals (Object o) { if (!(o instanceof CredOwner)) @@ -310,6 +315,7 @@ public final class PrivateCredentialPermission extends Permission principalName.equals (((CredOwner) o).getPrincipalName()); } + @Override public int hashCode() { return principalClass.hashCode() + principalName.hashCode(); diff --git a/javax/security/auth/SubjectDomainCombiner.java b/javax/security/auth/SubjectDomainCombiner.java index a50e54b12..8c441af38 100644 --- a/javax/security/auth/SubjectDomainCombiner.java +++ b/javax/security/auth/SubjectDomainCombiner.java @@ -1,5 +1,5 @@ /* SubjectDomainCombiner.java -- domain combiner for Subjects. - Copyright (C) 2004, 2005, 2014 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2014, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -63,6 +63,7 @@ public class SubjectDomainCombiner implements DomainCombiner // Instance methods. // ------------------------------------------------------------------------- + @Override public ProtectionDomain[] combine (final ProtectionDomain[] current, final ProtectionDomain[] assigned) { diff --git a/javax/security/auth/callback/ConfirmationCallback.java b/javax/security/auth/callback/ConfirmationCallback.java index fccc87236..8df94c41e 100644 --- a/javax/security/auth/callback/ConfirmationCallback.java +++ b/javax/security/auth/callback/ConfirmationCallback.java @@ -1,5 +1,5 @@ /* ConfirmationCallback.java -- callback for confirmations. - Copyright (C) 2003, 2014 Free Software Foundation, Inc. + Copyright (C) 2003, 2014, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -477,14 +477,14 @@ public class ConfirmationCallback implements Callback, Serializable private void setOptions(String[] options, int selectedOption) throws IllegalArgumentException { - if ((selectedOption < 0) || (selectedOption > options.length - 1)) - { - throw new IllegalArgumentException("invalid selection"); - } if ((options == null) || (options.length == 0)) { throw new IllegalArgumentException("options is null or empty"); } + if ((selectedOption < 0) || (selectedOption > options.length - 1)) + { + throw new IllegalArgumentException("invalid selection"); + } for (int i = 0; i < options.length; i++) { if ((options[i] == null) || (options[i].length() == 0)) diff --git a/javax/security/auth/kerberos/KerberosKey.java b/javax/security/auth/kerberos/KerberosKey.java index e5735fbd5..863b01aba 100644 --- a/javax/security/auth/kerberos/KerberosKey.java +++ b/javax/security/auth/kerberos/KerberosKey.java @@ -1,5 +1,5 @@ /* KerberosKey.java -- kerberos key - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,8 +40,6 @@ package javax.security.auth.kerberos; import gnu.classpath.NotImplementedException; -import java.io.Serializable; - import javax.crypto.SecretKey; import javax.security.auth.DestroyFailedException; import javax.security.auth.Destroyable; @@ -54,7 +52,7 @@ import javax.security.auth.Destroyable; * @since 1.4 */ public class KerberosKey - implements Serializable, SecretKey, Destroyable + implements SecretKey, Destroyable { private static final long serialVersionUID = -4625402278148246993L; @@ -95,6 +93,7 @@ public class KerberosKey /** * Return the name of the algorithm used to create this key. */ + @Override public final String getAlgorithm() { checkDestroyed(); @@ -104,6 +103,7 @@ public class KerberosKey /** * Return the format of this key. This implementation always returns "RAW". */ + @Override public final String getFormat() { checkDestroyed(); @@ -141,15 +141,17 @@ public class KerberosKey /** * Return the encoded form of this key. */ + @Override public final byte[] getEncoded() { checkDestroyed(); - return (byte[]) key.key.clone(); + return key.key.clone(); } /** * Destroy this key. */ + @Override public void destroy() throws DestroyFailedException { if (key == null) @@ -161,6 +163,7 @@ public class KerberosKey * Return true if this key has been destroyed. After this has been * called, other methods on this object will throw IllegalStateException. */ + @Override public boolean isDestroyed() { return key == null; @@ -172,6 +175,7 @@ public class KerberosKey throw new IllegalStateException("key is destroyed"); } + @Override public String toString() { // FIXME: random choice here. diff --git a/javax/security/auth/kerberos/KerberosPrincipal.java b/javax/security/auth/kerberos/KerberosPrincipal.java index 46da0fa1c..71002a987 100644 --- a/javax/security/auth/kerberos/KerberosPrincipal.java +++ b/javax/security/auth/kerberos/KerberosPrincipal.java @@ -1,5 +1,5 @@ /* KerberosPrincipal.java -- a kerberos principal - Copyright (C) 2006, 2014 Free Software Foundation, Inc. + Copyright (C) 2006, 2014, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -165,6 +165,7 @@ public final class KerberosPrincipal /** * Return the name of this principal. */ + @Override public String getName() { return name; @@ -186,11 +187,13 @@ public final class KerberosPrincipal return type; } + @Override public int hashCode() { return name.hashCode(); } + @Override public boolean equals(Object other) { if (! (other instanceof KerberosPrincipal)) @@ -199,6 +202,7 @@ public final class KerberosPrincipal return name.equals(kp.name) && type == kp.type; } + @Override public String toString() { // This is what came to mind. diff --git a/javax/security/auth/kerberos/KerberosTicket.java b/javax/security/auth/kerberos/KerberosTicket.java index 66227fd20..e53ea9b34 100644 --- a/javax/security/auth/kerberos/KerberosTicket.java +++ b/javax/security/auth/kerberos/KerberosTicket.java @@ -1,5 +1,5 @@ /* KerberosTicket.java -- a kerberos ticket - Copyright (C) 2006, 2014 Free Software Foundation, Inc. + Copyright (C) 2006, 2014, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -73,7 +73,7 @@ public class KerberosTicket private static final int INITIAL = 9; private static final int NUM_FLAGS = 12; - @SuppressWarnings("unusedPrivate") private byte[] asn1Encoding; + private byte[] asn1Encoding; private KeyImpl sessionKey; private boolean[] flags; private Date authTime; @@ -116,13 +116,12 @@ public class KerberosTicket Date endTime, Date renewTill, InetAddress[] clientAddresses) { - this.asn1Encoding = (byte[]) asn1Encoding.clone(); + this.asn1Encoding = asn1Encoding.clone(); this.sessionKey = new KeyImpl(key, type); this.flags = new boolean[NUM_FLAGS]; if (flags != null) System.arraycopy(flags, 0, this.flags, 0, Math.min(flags.length, NUM_FLAGS)); - this.flags = (boolean[]) flags.clone(); this.authTime = (Date) authTime.clone(); this.startTime = (Date) ((startTime == null) ? authTime : startTime).clone(); @@ -139,6 +138,7 @@ public class KerberosTicket * Destroy this ticket. This discards secret information. After this * method is called, other methods will throw IllegalStateException. */ + @Override public void destroy() throws DestroyFailedException { if (sessionKey == null) @@ -150,6 +150,7 @@ public class KerberosTicket /** * Return true if this ticket has been destroyed. */ + @Override public boolean isDestroyed() { return sessionKey == null; @@ -159,6 +160,7 @@ public class KerberosTicket * Return true if the ticket is currently valid. This is true if * the system time is between the ticket's start and end times. */ + @Override public boolean isCurrent() { long now = System.currentTimeMillis(); @@ -170,6 +172,7 @@ public class KerberosTicket * attempt to renew the ticket. * @throws RefreshFailedException if the renewal fails for any reason */ + @Override public void refresh() throws RefreshFailedException, NotImplementedException { if (! isRenewable()) @@ -261,7 +264,7 @@ public class KerberosTicket */ public final boolean[] getFlags() { - return (boolean[]) flags.clone(); + return flags.clone(); } /** @@ -314,7 +317,7 @@ public class KerberosTicket public final byte[] getEncoded() { checkDestroyed(); - return (byte[]) sessionKey.key.clone(); + return sessionKey.key.clone(); } /** @@ -332,6 +335,7 @@ public class KerberosTicket throw new IllegalStateException("key is destroyed"); } + @Override public String toString() { return getClass().getName() + diff --git a/javax/security/auth/kerberos/KeyImpl.java b/javax/security/auth/kerberos/KeyImpl.java index d8027c07e..8f7e89296 100644 --- a/javax/security/auth/kerberos/KeyImpl.java +++ b/javax/security/auth/kerberos/KeyImpl.java @@ -1,5 +1,5 @@ /* KeyImpl.java -- kerberos key implementation - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,15 +38,13 @@ exception statement from your version. */ package javax.security.auth.kerberos; -import java.io.Serializable; - import javax.crypto.SecretKey; /** * Note that the name of this class is fixed by the serialization * spec, even though the class itself is not public. */ -final class KeyImpl implements Serializable, SecretKey +final class KeyImpl implements SecretKey { // Enable this when serialization works. private static final long serialVersionUID = -7889313790214321193L; @@ -65,7 +63,7 @@ final class KeyImpl implements Serializable, SecretKey else this.algorithm = "FIXME"; this.type = type; - this.key = (byte[]) key.clone(); + this.key = key.clone(); } public KeyImpl(char[] passwd, String algo) @@ -75,22 +73,26 @@ final class KeyImpl implements Serializable, SecretKey this.key = null; // double FIXME } + @Override public String getAlgorithm() { return algorithm; } + @Override public byte[] getEncoded() { return key; } + @Override public String getFormat() { // FIXME. return null; } + @Override public String toString() { return getClass().getName() + diff --git a/javax/security/auth/login/AppConfigurationEntry.java b/javax/security/auth/login/AppConfigurationEntry.java index fd4d09210..ecb7afa3a 100644 --- a/javax/security/auth/login/AppConfigurationEntry.java +++ b/javax/security/auth/login/AppConfigurationEntry.java @@ -1,5 +1,5 @@ /* AppConfigurationEntry.java - Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -95,6 +95,7 @@ public class AppConfigurationEntry // Object methods ---------------------------------------------------------- + @Override public String toString() { @@ -127,6 +128,7 @@ public class AppConfigurationEntry // Instance methods. // ----------------------------------------------------------------------- + @Override public String toString() { if (this == LoginModuleControlFlag.REQUIRED) diff --git a/javax/security/auth/login/Configuration.java b/javax/security/auth/login/Configuration.java index bbaef065d..93782950f 100644 --- a/javax/security/auth/login/Configuration.java +++ b/javax/security/auth/login/Configuration.java @@ -1,5 +1,5 @@ /* Configuration.java - Copyright (C) 2004, 2006, 2014 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2014, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,11 +38,11 @@ exception statement from your version. */ package javax.security.auth.login; +import gnu.java.security.action.GetSecurityPropertyAction; + import gnu.javax.security.auth.login.GnuConfiguration; import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.Security; import javax.security.auth.AuthPermission; @@ -97,13 +97,7 @@ public abstract class Configuration if (config == null) { String conf = AccessController.doPrivileged - (new PrivilegedAction<String>() - { - public String run() - { - return Security.getProperty ("login.configuration.provider"); - } - }); + (new GetSecurityPropertyAction ("login.configuration.provider")); try { if (conf != null) diff --git a/javax/security/auth/login/LoginContext.java b/javax/security/auth/login/LoginContext.java index 39d8702c9..f05c660b5 100644 --- a/javax/security/auth/login/LoginContext.java +++ b/javax/security/auth/login/LoginContext.java @@ -96,13 +96,13 @@ public class LoginContext this.cbHandler = cbHandler; if (config == null) config = Configuration.getConfig(); - AppConfigurationEntry[] entries = config.getAppConfigurationEntry (name); - if (entries == null) - entries = config.getAppConfigurationEntry (OTHER); - if (entries == null) + AppConfigurationEntry[] appEntries = config.getAppConfigurationEntry (name); + if (appEntries == null) + appEntries = config.getAppConfigurationEntry (OTHER); + if (appEntries == null) throw new LoginException ("no configured modules for application " + name); - this.entries = entries; + this.entries = appEntries; modules = new LoginModule[entries.length]; sharedState = new HashMap<String,Object>(); for (int i = 0; i < entries.length; i++) @@ -223,7 +223,7 @@ public class LoginContext } private LoginModule lookupModule (AppConfigurationEntry entry, - Subject subject, Map<String,?> sharedState) + Subject subj, Map<String,?> state) throws LoginException { LoginModule module = null; @@ -251,7 +251,7 @@ public class LoginContext cause = ie; } - if (cause != null) + if (module == null) { LoginException le = new LoginException ("could not load module " + entry.getLoginModuleName()); @@ -259,7 +259,7 @@ public class LoginContext throw le; } - module.initialize (subject, cbHandler, sharedState, entry.getOptions()); + module.initialize (subj, cbHandler, state, entry.getOptions()); return module; } } diff --git a/javax/security/auth/login/NullConfiguration.java b/javax/security/auth/login/NullConfiguration.java index a3f0c9943..579c1386b 100644 --- a/javax/security/auth/login/NullConfiguration.java +++ b/javax/security/auth/login/NullConfiguration.java @@ -1,5 +1,5 @@ /* NullConfiguration.java -- no-op default login configuration. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -51,11 +51,13 @@ final class NullConfiguration extends Configuration // Instance methods. // ------------------------------------------------------------------------- + @Override public AppConfigurationEntry[] getAppConfigurationEntry (String applicationName) { return null; } + @Override public void refresh() { } diff --git a/javax/security/auth/x500/X500Principal.java b/javax/security/auth/x500/X500Principal.java index 79c3336e1..91b028ebc 100644 --- a/javax/security/auth/x500/X500Principal.java +++ b/javax/security/auth/x500/X500Principal.java @@ -141,6 +141,7 @@ public final class X500Principal implements Principal, Serializable // Instance methods. // ------------------------------------------------------------------------ + @Override public int hashCode() { int result = size(); @@ -156,6 +157,7 @@ public final class X500Principal implements Principal, Serializable return result; } + @Override public boolean equals(Object o) { if (!(o instanceof X500Principal)) @@ -183,9 +185,10 @@ public final class X500Principal implements Principal, Serializable { if (encoded == null) encodeDer(); - return (byte[]) encoded.clone(); + return encoded.clone(); } + @Override public String getName() { return getName (RFC2253); @@ -241,6 +244,7 @@ public final class X500Principal implements Principal, Serializable return str.toString(); } + @Override public String toString() { return getName (RFC2253); @@ -318,7 +322,7 @@ public final class X500Principal implements Principal, Serializable } } - private String readAttributeType(Reader in) throws IOException + private static String readAttributeType(Reader in) throws IOException { CPStringBuilder buf = new CPStringBuilder(); int ch; @@ -441,9 +445,9 @@ public final class X500Principal implements Principal, Serializable } } - private void parseDer (InputStream encoded) throws IOException + private void parseDer (InputStream encodedStream) throws IOException { - DERReader der = new DERReader (encoded); + DERReader der = new DERReader (encodedStream); DERValue name = der.read(); if (!name.isConstructed()) throw new IOException ("malformed Name"); diff --git a/javax/security/auth/x500/X500PrivateCredential.java b/javax/security/auth/x500/X500PrivateCredential.java index 8cba93c6f..f042335c1 100644 --- a/javax/security/auth/x500/X500PrivateCredential.java +++ b/javax/security/auth/x500/X500PrivateCredential.java @@ -1,5 +1,5 @@ /* X500PrivateCredential.java -- certificate and private key pair. - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -129,6 +129,7 @@ public final class X500PrivateCredential implements Destroyable * Destroy the sensitive data of this credential, setting the certificate, * private key, and keystore alias to null. */ + @Override public void destroy() { certificate = null; @@ -142,6 +143,7 @@ public final class X500PrivateCredential implements Destroyable * * @return True if this object has been destroyed. */ + @Override public boolean isDestroyed() { return certificate == null && key == null; diff --git a/javax/security/cert/Certificate.java b/javax/security/cert/Certificate.java index 50c7340fb..53d690e11 100644 --- a/javax/security/cert/Certificate.java +++ b/javax/security/cert/Certificate.java @@ -1,5 +1,5 @@ /* Certificate.java -- base class of public-key certificates. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -74,6 +74,7 @@ public abstract class Certificate * @param other The object to test. * @return True if the certificates are equal. */ + @Override public boolean equals(Object other) { if (other == null || !(other instanceof Certificate)) @@ -99,6 +100,7 @@ public abstract class Certificate * * @return The hash code. */ + @Override public int hashCode() { try @@ -165,6 +167,7 @@ public abstract class Certificate * * @return The string. */ + @Override public abstract String toString(); /** diff --git a/javax/security/cert/X509CertBridge.java b/javax/security/cert/X509CertBridge.java index 36fc4202a..39fd44db8 100644 --- a/javax/security/cert/X509CertBridge.java +++ b/javax/security/cert/X509CertBridge.java @@ -1,5 +1,5 @@ /* X509CertBridge.java -- bridge between JDK and JSSE cert APIs. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -70,6 +70,7 @@ final class X509CertBridge extends X509Certificate // Instance methods. // ------------------------------------------------------------------------- + @Override public byte[] getEncoded() throws CertificateEncodingException { try @@ -82,6 +83,7 @@ final class X509CertBridge extends X509Certificate } } + @Override public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException @@ -96,6 +98,7 @@ final class X509CertBridge extends X509Certificate } } + @Override public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException @@ -110,16 +113,19 @@ final class X509CertBridge extends X509Certificate } } + @Override public String toString() { return cert.toString(); } + @Override public PublicKey getPublicKey() { return cert.getPublicKey(); } + @Override public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException { @@ -137,6 +143,7 @@ final class X509CertBridge extends X509Certificate } } + @Override public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException { @@ -154,46 +161,55 @@ final class X509CertBridge extends X509Certificate } } + @Override public int getVersion() { return cert.getVersion(); } + @Override public BigInteger getSerialNumber() { return cert.getSerialNumber(); } + @Override public Principal getIssuerDN() { return cert.getIssuerDN(); } + @Override public Principal getSubjectDN() { return cert.getSubjectDN(); } + @Override public Date getNotBefore() { return cert.getNotBefore(); } + @Override public Date getNotAfter() { return cert.getNotAfter(); } + @Override public String getSigAlgName() { return cert.getSigAlgName(); } + @Override public String getSigAlgOID() { return cert.getSigAlgOID(); } + @Override public byte[] getSigAlgParams() { return cert.getSigAlgParams(); diff --git a/javax/security/sasl/Sasl.java b/javax/security/sasl/Sasl.java index e77bdb86b..89e7588d2 100644 --- a/javax/security/sasl/Sasl.java +++ b/javax/security/sasl/Sasl.java @@ -1,5 +1,5 @@ /* Sasl.java -- - Copyright (C) 2003, 2004, 2005, 2014 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2014, 2015 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -416,13 +416,11 @@ public class Sasl } if (clazz == null) continue; - else - clazz = clazz.trim(); + clazz = clazz.trim(); } try { - result = null; factory = (SaslClientFactory) Class.forName(clazz).newInstance(); result = factory.createSaslClient(mechanisms, authorizationID, protocol, serverName, props, cbh); @@ -610,12 +608,10 @@ public class Sasl } if (clazz == null) continue; - else - clazz = clazz.trim(); + clazz = clazz.trim(); try { - result = null; factory = (SaslServerFactory) Class.forName(clazz).newInstance(); result = factory.createSaslServer(mechanism, protocol, serverName, props, cbh); diff --git a/javax/security/sasl/SaslException.java b/javax/security/sasl/SaslException.java index f4407e761..073dc0991 100644 --- a/javax/security/sasl/SaslException.java +++ b/javax/security/sasl/SaslException.java @@ -1,5 +1,5 @@ /* SaslException.java - Copyright (C) 2003, 2005, Free Software Foundation, Inc. + Copyright (C) 2003, 2005, 2015, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,16 +41,13 @@ package javax.security.sasl; import gnu.java.lang.CPStringBuilder; import java.io.IOException; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.Serializable; /** * This class represents an error that has occurred when using SASL. * * @since 1.5 */ -public class SaslException extends IOException implements Serializable +public class SaslException extends IOException { // Constants and variables @@ -106,7 +103,7 @@ public class SaslException extends IOException implements Serializable */ public SaslException(String detail, Throwable ex) { - super(detail); + super(detail, ex); _exception = ex; } @@ -123,49 +120,23 @@ public class SaslException extends IOException implements Serializable * * @return the possibly <code>null</code> exception that caused this exception. */ + @Override public Throwable getCause() { return _exception; } /** - * Prints this exception's stack trace to <code>System.err</code>. If this - * exception has a root exception; the stack trace of the root exception is - * also printed to <code>System.err</code>. - */ - public void printStackTrace() - { - super.printStackTrace(); - if (_exception != null) - _exception.printStackTrace(); - } - - /** - * Prints this exception's stack trace to a print stream. If this exception - * has a root exception; the stack trace of the root exception is also - * printed to the print stream. - * - * @param ps the non-null print stream to which to print. - */ - public void printStackTrace(PrintStream ps) - { - super.printStackTrace(ps); - if (_exception != null) - _exception.printStackTrace(ps); - } - - /** - * Prints this exception's stack trace to a print writer. If this exception - * has a root exception; the stack trace of the root exception is also - * printed to the print writer. - * - * @param pw the non-null print writer to use for output. + * @inheritDoc */ - public void printStackTrace(PrintWriter pw) + @Override + public Throwable initCause(Throwable cause) { - super.printStackTrace(pw); - if (_exception != null) - _exception.printStackTrace(pw); + super.initCause(cause); + // Sync our copy if the superclass one changed + if (super.getCause() == cause) + _exception = cause; + return this; } /** @@ -178,6 +149,7 @@ public class SaslException extends IOException implements Serializable * @return the non-null string representation of this exception. * @see Throwable#getMessage() */ + @Override public String toString() { CPStringBuilder sb = new CPStringBuilder(this.getClass().getName()) |