jboss-sasl 1.0.0.Beta1

org.jboss.sasl.util
Class AbstractSaslParticipant

java.lang.Object
  extended by org.jboss.sasl.util.AbstractSaslParticipant
Direct Known Subclasses:
AbstractSaslClient, AbstractSaslServer

public abstract class AbstractSaslParticipant
extends Object

A common base class for SASL participants.

Author:
David M. Lloyd

Field Summary
static byte[] NO_BYTES
          An empty byte array.
 
Constructor Summary
protected AbstractSaslParticipant(String mechanismName, String protocol, String serverName, CallbackHandler callbackHandler)
          Construct a new instance.
 
Method Summary
 void dispose()
          Dispose of this participant.
protected  CallbackHandler getCallbackHandler()
          Get the configured authentication callback handler.
 SaslStateContext getContext()
          Get the current negotiation state context.
 String getMechanismName()
          Get the name of this mechanism.
 Object getNegotiatedProperty(String propName)
          Get a property negotiated between this participant and the other.
protected  String getProtocol()
          Get the protocol name.
protected  String getServerName()
          Get the server name.
protected  SaslWrapper getWrapper()
          Get the current configured SASL wrapper, if any.
protected  void handleCallbacks(Callback... callbacks)
          Handle callbacks, wrapping exceptions as needed (including unsupported callbacks).
 boolean isComplete()
          Determine whether the authentication exchange has completed.
protected  void setWrapper(SaslWrapper wrapper)
          Set the current configured SASL wrapper, if any.
protected  void tryHandleCallbacks(Callback... callbacks)
          Handle callbacks, wrapping exceptions as needed.
 byte[] unwrap(byte[] incoming, int offset, int len)
          Unwraps a byte array received from the other participant.
 byte[] wrap(byte[] outgoing, int offset, int len)
          Wraps a byte array to be sent to the other participant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_BYTES

public static final byte[] NO_BYTES
An empty byte array.

Constructor Detail

AbstractSaslParticipant

protected AbstractSaslParticipant(String mechanismName,
                                  String protocol,
                                  String serverName,
                                  CallbackHandler callbackHandler)
Construct a new instance.

Parameters:
mechanismName - the name of the defined mechanism
protocol - the protocol
serverName - the server name
callbackHandler - the callback handler
Method Detail

handleCallbacks

protected void handleCallbacks(Callback... callbacks)
                        throws SaslException
Handle callbacks, wrapping exceptions as needed (including unsupported callbacks).

Parameters:
callbacks - the callbacks to handle
Throws:
SaslException - if a callback failed

tryHandleCallbacks

protected void tryHandleCallbacks(Callback... callbacks)
                           throws SaslException,
                                  UnsupportedCallbackException
Handle callbacks, wrapping exceptions as needed.

Parameters:
callbacks - the callbacks to handle
Throws:
SaslException - if a callback failed
UnsupportedCallbackException - if a callback isn't supported

getMechanismName

public String getMechanismName()
Get the name of this mechanism.

Returns:
the mechanism name

getProtocol

protected String getProtocol()
Get the protocol name.

Returns:
the protocol name

getServerName

protected String getServerName()
Get the server name.

Returns:
the server name

getCallbackHandler

protected CallbackHandler getCallbackHandler()
Get the configured authentication callback handler.

Returns:
the callback handler

getWrapper

protected SaslWrapper getWrapper()
Get the current configured SASL wrapper, if any.

Returns:
the SASL wrapper, or null if none is configured

getContext

public SaslStateContext getContext()
Get the current negotiation state context.

Returns:
the context

setWrapper

protected void setWrapper(SaslWrapper wrapper)
Set the current configured SASL wrapper, if any.

Parameters:
wrapper - the SASL wrapper, or null to disable wrapping

wrap

public byte[] wrap(byte[] outgoing,
                   int offset,
                   int len)
            throws SaslException
Wraps a byte array to be sent to the other participant.

Parameters:
outgoing - a non-null byte array containing the bytes to encode
offset - the first byte to encode
len - the number of bytes to use
Returns:
A non-null byte array containing the encoded bytes
Throws:
SaslException - if wrapping fails
IllegalStateException - if wrapping is not configured

unwrap

public byte[] unwrap(byte[] incoming,
                     int offset,
                     int len)
              throws SaslException
Unwraps a byte array received from the other participant.

Parameters:
incoming - a non-null byte array containing the bytes to decode
offset - the first byte to decode
len - the number of bytes to use
Returns:
A non-null byte array containing the decoded bytes
Throws:
SaslException - if wrapping fails
IllegalStateException - if wrapping is not configured

isComplete

public boolean isComplete()
Determine whether the authentication exchange has completed.

Returns:
true if the exchange has completed

getNegotiatedProperty

public Object getNegotiatedProperty(String propName)
Get a property negotiated between this participant and the other.

Parameters:
propName - the property name
Returns:
the property value or null if not defined

dispose

public void dispose()
             throws SaslException
Dispose of this participant.

Throws:
SaslException - if disposal failed

jboss-sasl 1.0.0.Beta1

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.