net.spy.memcached.protocol.binary
Class SASLBaseOperationImpl

java.lang.Object
  extended by net.spy.memcached.compat.SpyObject
      extended by net.spy.memcached.protocol.BaseOperationImpl
          extended by net.spy.memcached.protocol.binary.SASLBaseOperationImpl
Direct Known Subclasses:
SASLAuthOperationImpl, SASLStepOperationImpl

public abstract class SASLBaseOperationImpl
extends BaseOperationImpl


Field Summary
protected  javax.security.auth.callback.CallbackHandler cbh
           
protected  byte[] challenge
           
protected static byte[] EMPTY_BYTES
           
protected static int ERR_EINVAL
           
protected static int ERR_EXISTS
           
protected static int ERR_NOT_FOUND
          Error code for items that were not found.
protected static int ERR_NOT_STORED
           
protected  int errorCode
           
protected static OperationStatus EXISTS_STATUS
           
protected  int keyLen
           
protected  java.lang.String[] mech
           
protected static int MIN_RECV_PACKET
           
protected static OperationStatus NOT_FOUND_STATUS
           
protected static OperationStatus NOT_STORED_STATUS
           
protected  int opaque
           
protected  java.util.Map<java.lang.String,?> props
           
protected static byte REQ_MAGIC
           
protected static byte RES_MAGIC
           
protected  long responseCas
           
protected  int responseCmd
           
protected  int responseOpaque
           
protected  java.lang.String serverName
           
protected static OperationStatus STATUS_OK
           
 
Fields inherited from class net.spy.memcached.protocol.BaseOperationImpl
callback, CANCELLED
 
Constructor Summary
SASLBaseOperationImpl(int c, java.lang.String[] m, byte[] ch, java.lang.String s, java.util.Map<java.lang.String,?> p, javax.security.auth.callback.CallbackHandler h, OperationCallback cb)
           
 
Method Summary
protected abstract  byte[] buildResponse(javax.security.sasl.SaslClient sc)
           
protected  void decodePayload(byte[] pl)
          Decode the given payload for this command.
protected  void finishedPayload(byte[] pl)
           
protected  OperationStatus getStatusForErrorCode(int errCode, byte[] errPl)
          Get the OperationStatus object for the given error code.
 void initialize()
           
protected  boolean opaqueIsValid()
          Validate an opaque value from the header.
protected  void prepareBuffer(java.lang.String key, long cas, byte[] val, java.lang.Object... extraHeaders)
          Prepare a send buffer.
 void readFromBuffer(java.nio.ByteBuffer b)
           
protected  void resetInput()
           
 
Methods inherited from class net.spy.memcached.protocol.BaseOperationImpl
cancel, getBuffer, getCallback, getException, getHandlingNode, getState, handleError, handleRead, hasErrored, isCancelled, setBuffer, setCallback, setHandlingNode, transitionState, wasCancelled, writeComplete
 
Methods inherited from class net.spy.memcached.compat.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mech

protected final java.lang.String[] mech

challenge

protected final byte[] challenge

serverName

protected final java.lang.String serverName

props

protected final java.util.Map<java.lang.String,?> props

cbh

protected final javax.security.auth.callback.CallbackHandler cbh

REQ_MAGIC

protected static final byte REQ_MAGIC
See Also:
Constant Field Values

RES_MAGIC

protected static final byte RES_MAGIC
See Also:
Constant Field Values

MIN_RECV_PACKET

protected static final int MIN_RECV_PACKET
See Also:
Constant Field Values

ERR_NOT_FOUND

protected static final int ERR_NOT_FOUND
Error code for items that were not found.

See Also:
Constant Field Values

ERR_EXISTS

protected static final int ERR_EXISTS
See Also:
Constant Field Values

ERR_EINVAL

protected static final int ERR_EINVAL
See Also:
Constant Field Values

ERR_NOT_STORED

protected static final int ERR_NOT_STORED
See Also:
Constant Field Values

NOT_FOUND_STATUS

protected static final OperationStatus NOT_FOUND_STATUS

EXISTS_STATUS

protected static final OperationStatus EXISTS_STATUS

NOT_STORED_STATUS

protected static final OperationStatus NOT_STORED_STATUS

EMPTY_BYTES

protected static final byte[] EMPTY_BYTES

STATUS_OK

protected static final OperationStatus STATUS_OK

opaque

protected final int opaque

keyLen

protected int keyLen

responseCmd

protected int responseCmd

errorCode

protected int errorCode

responseOpaque

protected int responseOpaque

responseCas

protected long responseCas
Constructor Detail

SASLBaseOperationImpl

public SASLBaseOperationImpl(int c,
                             java.lang.String[] m,
                             byte[] ch,
                             java.lang.String s,
                             java.util.Map<java.lang.String,?> p,
                             javax.security.auth.callback.CallbackHandler h,
                             OperationCallback cb)
Method Detail

initialize

public void initialize()
Specified by:
initialize in class BaseOperationImpl

buildResponse

protected abstract byte[] buildResponse(javax.security.sasl.SaslClient sc)
                                 throws javax.security.sasl.SaslException
Throws:
javax.security.sasl.SaslException

decodePayload

protected void decodePayload(byte[] pl)
Decode the given payload for this command.

Parameters:
pl - the payload.

finishedPayload

protected void finishedPayload(byte[] pl)
                        throws java.io.IOException
Throws:
java.io.IOException

resetInput

protected void resetInput()

readFromBuffer

public void readFromBuffer(java.nio.ByteBuffer b)
                    throws java.io.IOException
Specified by:
readFromBuffer in class BaseOperationImpl
Throws:
java.io.IOException

getStatusForErrorCode

protected OperationStatus getStatusForErrorCode(int errCode,
                                                byte[] errPl)
Get the OperationStatus object for the given error code.

Parameters:
errCode - the error code
Returns:
the status to return, or null if this is an exceptional case

opaqueIsValid

protected boolean opaqueIsValid()
Validate an opaque value from the header. This may be overridden from a subclass where the opaque isn't expected to always be the same as the request opaque.


prepareBuffer

protected void prepareBuffer(java.lang.String key,
                             long cas,
                             byte[] val,
                             java.lang.Object... extraHeaders)
Prepare a send buffer.

Parameters:
key - the key (for keyed ops)
cas - the cas value
val - the data payload
extraHeaders - any additional headers that need to be sent