diff options
Diffstat (limited to 'libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java')
-rw-r--r-- | libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java | 150 |
1 files changed, 39 insertions, 111 deletions
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java b/libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java index 45873ae6b27..7f8e9c120b4 100644 --- a/libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java +++ b/libjava/classpath/gnu/javax/crypto/sasl/ClientMechanism.java @@ -42,50 +42,37 @@ import gnu.java.security.Registry; import java.util.HashMap; import java.util.Map; + import javax.security.auth.callback.CallbackHandler; import javax.security.sasl.Sasl; import javax.security.sasl.SaslClient; import javax.security.sasl.SaslException; /** - * <p>A base class to facilitate implementing SASL client-side mechanisms.</p> + * A base class to facilitate implementing SASL client-side mechanisms. */ -public abstract class ClientMechanism implements SaslClient +public abstract class ClientMechanism + implements SaslClient { - - // Constants and variables - // ------------------------------------------------------------------------- - /** Name of this mechanism. */ protected String mechanism; - /** The authorisation identity. */ protected String authorizationID; - /** Name of protocol using this mechanism. */ protected String protocol; - /** Name of server to authenticate to. */ protected String serverName; - /** Properties of qualities desired for this mechanism. */ protected Map properties; - /** Callback handler to use with this mechanism instance. */ protected CallbackHandler handler; - /** Channel binding data to use with this mechanism instance. */ protected byte[] channelBinding; - /** Whether authentication phase is completed (true) or not (false). */ protected boolean complete = false; - /** The state of the authentication automaton. */ protected int state = -1; - // Constructor(s) - // ------------------------------------------------------------------------- - protected ClientMechanism(final String mechanism) { super(); @@ -94,20 +81,10 @@ public abstract class ClientMechanism implements SaslClient this.state = -1; } - // Class methods - // ------------------------------------------------------------------------- - - // Instance methods - // ------------------------------------------------------------------------- - - // abstract methods to be implemented by concrete subclasses --------------- - protected abstract void initMechanism() throws SaslException; protected abstract void resetMechanism() throws SaslException; - // javax.security.sasl.SaslClient interface implementation ----------------- - public abstract byte[] evaluateChallenge(byte[] challenge) throws SaslException; @@ -121,20 +98,16 @@ public abstract class ClientMechanism implements SaslClient public byte[] unwrap(final byte[] incoming, final int offset, final int len) throws SaslException { - if (!isComplete()) - { - throw new IllegalMechanismStateException(); - } + if (! isComplete()) + throw new IllegalMechanismStateException(); return this.engineUnwrap(incoming, offset, len); } public byte[] wrap(final byte[] outgoing, final int offset, final int len) throws SaslException { - if (!isComplete()) - { - throw new IllegalMechanismStateException(); - } + if (! isComplete()) + throw new IllegalMechanismStateException(); return this.engineWrap(outgoing, offset, len); } @@ -145,58 +118,32 @@ public abstract class ClientMechanism implements SaslClient public Object getNegotiatedProperty(final String propName) { - if (!isComplete()) - { - throw new IllegalStateException(); - } + if (! isComplete()) + throw new IllegalStateException(); if (Sasl.QOP.equals(propName)) - { - return getNegotiatedQOP(); - } + return getNegotiatedQOP(); if (Sasl.STRENGTH.equals(propName)) - { - return getNegotiatedStrength(); - } + return getNegotiatedStrength(); if (Sasl.SERVER_AUTH.equals(propName)) - { - return getNegotiatedServerAuth(); - } + return getNegotiatedServerAuth(); if (Sasl.MAX_BUFFER.equals(propName)) - { - return getNegotiatedMaxBuffer(); - } + return getNegotiatedMaxBuffer(); if (Sasl.RAW_SEND_SIZE.equals(propName)) - { - return getNegotiatedRawSendSize(); - } + return getNegotiatedRawSendSize(); if (Sasl.POLICY_NOPLAINTEXT.equals(propName)) - { - return getNegotiatedPolicyNoPlainText(); - } + return getNegotiatedPolicyNoPlainText(); if (Sasl.POLICY_NOACTIVE.equals(propName)) - { - return getNegotiatedPolicyNoActive(); - } + return getNegotiatedPolicyNoActive(); if (Sasl.POLICY_NODICTIONARY.equals(propName)) - { - return getNegotiatedPolicyNoDictionary(); - } + return getNegotiatedPolicyNoDictionary(); if (Sasl.POLICY_NOANONYMOUS.equals(propName)) - { - return getNegotiatedPolicyNoAnonymous(); - } + return getNegotiatedPolicyNoAnonymous(); if (Sasl.POLICY_FORWARD_SECRECY.equals(propName)) - { - return getNegotiatedPolicyForwardSecrecy(); - } + return getNegotiatedPolicyForwardSecrecy(); if (Sasl.POLICY_PASS_CREDENTIALS.equals(propName)) - { - return getNegotiatedPolicyPassCredentials(); - } + return getNegotiatedPolicyPassCredentials(); if (Sasl.REUSE.equals(propName)) - { - return getReuse(); - } + return getReuse(); return null; } @@ -204,8 +151,6 @@ public abstract class ClientMechanism implements SaslClient { } - // other Instance methods -------------------------------------------------- - public String getAuthorizationID() { return authorizationID; @@ -288,30 +233,23 @@ public abstract class ClientMechanism implements SaslClient } /** - * <p>Initialises the mechanism with designated attributes. Permissible names - * and values are mechanism specific.</p> - * + * Initialises the mechanism with designated attributes. Permissible names and + * values are mechanism specific. + * * @param attributes a set of name-value pairs that describes the desired - * future behaviour of this instance. + * future behaviour of this instance. * @throws IllegalMechanismStateException if the instance is already - * initialised. + * initialised. * @throws SaslException if an exception occurs during the process. */ public void init(final Map attributes) throws SaslException { if (state != -1) - { - throw new IllegalMechanismStateException("init()"); - } - + throw new IllegalMechanismStateException("init()"); if (properties == null) - { - properties = new HashMap(); - } + properties = new HashMap(); else - { - properties.clear(); - } + properties.clear(); if (attributes != null) { authorizationID = (String) attributes.get(Registry.SASL_AUTHORISATION_ID); @@ -322,35 +260,25 @@ public abstract class ClientMechanism implements SaslClient properties.putAll(attributes); } else - { - handler = null; - } + handler = null; if (authorizationID == null) - { - authorizationID = ""; - } + authorizationID = ""; if (protocol == null) - { - protocol = ""; - } + protocol = ""; if (serverName == null) - { - serverName = ""; - } + serverName = ""; if (channelBinding == null) - { - channelBinding = new byte[0]; - } + channelBinding = new byte[0]; initMechanism(); complete = false; state = 0; } /** - * <p>Resets the mechanism instance for re-initialisation and use with other - * characteristics.</p> - * + * Resets the mechanism instance for re-initialisation and use with other + * characteristics. + * * @throws SaslException if an exception occurs during the process. */ public void reset() throws SaslException @@ -362,4 +290,4 @@ public abstract class ClientMechanism implements SaslClient complete = false; state = -1; } -}
\ No newline at end of file +} |