public class SaslImpl extends java.lang.Object implements Sasl, SaslFrameBody.SaslFrameBodyHandler<java.lang.Void>, SaslFrameHandler
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
SaslImpl.Role |
private class |
SaslImpl.SaslTransportWrapper |
Sasl.SaslOutcome, Sasl.SaslState| Modifier and Type | Field and Description |
|---|---|
private boolean |
_allowSkip |
private Binary |
_challengeResponse |
private Symbol |
_chosenMechanism |
private DecoderImpl |
_decoder |
private boolean |
_done |
private EncoderImpl |
_encoder |
private SaslFrameParser |
_frameParser |
private FrameWriter |
_frameWriter |
private boolean |
_head_closed |
private boolean |
_headerWritten |
private java.lang.String |
_hostname |
private boolean |
_initReceived |
private boolean |
_initSent |
private java.nio.ByteBuffer |
_inputBuffer |
private static java.util.logging.Logger |
_logger |
private Symbol[] |
_mechanisms |
private boolean |
_mechanismsSent |
private Sasl.SaslOutcome |
_outcome |
private java.nio.ByteBuffer |
_outputBuffer |
private java.nio.ByteBuffer |
_pending |
private SaslImpl.Role |
_role |
private Sasl.SaslState |
_state |
private boolean |
_tail_closed |
private TransportImpl |
_transport |
static byte |
SASL_FRAME_TYPE |
PN_SASL_AUTH, PN_SASL_NONE, PN_SASL_OK, PN_SASL_PERM, PN_SASL_SKIPPED, PN_SASL_SYS, PN_SASL_TEMP| Constructor and Description |
|---|
SaslImpl(TransportImpl transport,
int maxFrameSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
allowSkip(boolean allowSkip)
Set whether servers may accept incoming connections
that skip the SASL layer negotiation.
|
private void |
checkRole(SaslImpl.Role role) |
private Sasl.SaslState |
classifyStateFromOutcome(Sasl.SaslOutcome outcome) |
void |
client() |
void |
done(Sasl.SaslOutcome outcome)
Set the outcome of SASL negotiation
Used by the server to set the result of the negotiation process.
|
(package private) void |
fail() |
(package private) Binary |
getChallengeResponse() |
Symbol |
getChosenMechanism() |
java.lang.String |
getHostname()
Retrieve the hostname indicated by the client when sending its SaslInit.
|
Sasl.SaslOutcome |
getOutcome()
Retrieve the outcome of SASL negotiation.
|
java.lang.String[] |
getRemoteMechanisms()
Retrieve the list of SASL mechanisms provided by the remote.
|
Sasl.SaslState |
getState()
Access the current state of the layer.
|
void |
handle(SaslFrameBody frameBody,
Binary payload) |
void |
handleChallenge(SaslChallenge saslChallenge,
Binary payload,
java.lang.Void context) |
void |
handleInit(SaslInit saslInit,
Binary payload,
java.lang.Void context) |
void |
handleMechanisms(SaslMechanisms saslMechanisms,
Binary payload,
java.lang.Void context) |
void |
handleOutcome(SaslOutcome saslOutcome,
Binary payload,
java.lang.Void context) |
void |
handleResponse(SaslResponse saslResponse,
Binary payload,
java.lang.Void context) |
boolean |
isDone() |
int |
pending()
Determine the size of the bytes available via recv().
|
void |
plain(java.lang.String username,
java.lang.String password)
Configure the SASL layer to use the "PLAIN" mechanism.
|
private void |
process() |
(package private) int |
processHeader() |
private void |
processInit() |
private void |
processResponse() |
int |
recv(byte[] bytes,
int offset,
int size)
Read challenge/response data sent from the peer.
|
int |
send(byte[] bytes,
int offset,
int size)
Send challenge or response data to the peer.
|
void |
server() |
(package private) void |
setChallengeResponse(Binary challengeResponse) |
void |
setMechanism(Symbol mechanism) |
void |
setMechanisms(java.lang.String... mechanisms)
Set the acceptable SASL mechanisms for the layer.
|
(package private) void |
setPending(java.nio.ByteBuffer pending) |
void |
setRemoteHostname(java.lang.String hostname)
Set the remote hostname to indicate the host being connected to when
sending a SaslInit to the server.
|
void |
setResponse(Binary initialResponse) |
java.lang.String |
toString() |
TransportWrapper |
wrap(TransportInput input,
TransportOutput output) |
private void |
writeFrame(SaslFrameBody frameBody) |
private void |
writeSaslOutput() |
private static final java.util.logging.Logger _logger
public static final byte SASL_FRAME_TYPE
private final DecoderImpl _decoder
private final EncoderImpl _encoder
private final TransportImpl _transport
private boolean _tail_closed
private final java.nio.ByteBuffer _inputBuffer
private boolean _head_closed
private final java.nio.ByteBuffer _outputBuffer
private final FrameWriter _frameWriter
private java.nio.ByteBuffer _pending
private boolean _headerWritten
private Binary _challengeResponse
private SaslFrameParser _frameParser
private boolean _initReceived
private boolean _mechanismsSent
private boolean _initSent
private Sasl.SaslOutcome _outcome
private Sasl.SaslState _state
private java.lang.String _hostname
private boolean _done
private Symbol[] _mechanisms
private Symbol _chosenMechanism
private SaslImpl.Role _role
private boolean _allowSkip
SaslImpl(TransportImpl transport, int maxFrameSize)
maxFrameSize - the size of the input and output buffers
returned by SaslTransportWrapper#getInputBuffer() and
SaslTransportWrapper#getOutputBuffer().void fail()
public boolean isDone()
isDone in interface SaslFrameHandlerprivate void writeSaslOutput()
private void process()
private void writeFrame(SaslFrameBody frameBody)
public final int recv(byte[] bytes,
int offset,
int size)
Saslpublic final int send(byte[] bytes,
int offset,
int size)
Saslfinal int processHeader()
public int pending()
Saslvoid setPending(java.nio.ByteBuffer pending)
public Sasl.SaslState getState()
Saslfinal Binary getChallengeResponse()
final void setChallengeResponse(Binary challengeResponse)
public void setMechanisms(java.lang.String... mechanisms)
SaslsetMechanisms in interface Saslmechanisms - a list of acceptable SASL mechanismspublic java.lang.String[] getRemoteMechanisms()
SaslgetRemoteMechanisms in interface Saslpublic void setMechanism(Symbol mechanism)
public Symbol getChosenMechanism()
public void setResponse(Binary initialResponse)
public void handle(SaslFrameBody frameBody, Binary payload)
handle in interface SaslFrameHandlerpublic void handleInit(SaslInit saslInit, Binary payload, java.lang.Void context)
handleInit in interface SaslFrameBody.SaslFrameBodyHandler<java.lang.Void>public void handleResponse(SaslResponse saslResponse, Binary payload, java.lang.Void context)
handleResponse in interface SaslFrameBody.SaslFrameBodyHandler<java.lang.Void>public void done(Sasl.SaslOutcome outcome)
Saslprivate void checkRole(SaslImpl.Role role)
public void handleMechanisms(SaslMechanisms saslMechanisms, Binary payload, java.lang.Void context)
handleMechanisms in interface SaslFrameBody.SaslFrameBodyHandler<java.lang.Void>public void handleChallenge(SaslChallenge saslChallenge, Binary payload, java.lang.Void context)
handleChallenge in interface SaslFrameBody.SaslFrameBodyHandler<java.lang.Void>public void handleOutcome(SaslOutcome saslOutcome, Binary payload, java.lang.Void context)
handleOutcome in interface SaslFrameBody.SaslFrameBodyHandler<java.lang.Void>private Sasl.SaslState classifyStateFromOutcome(Sasl.SaslOutcome outcome)
private void processResponse()
private void processInit()
public void plain(java.lang.String username,
java.lang.String password)
Saslpublic Sasl.SaslOutcome getOutcome()
SaslgetOutcome in interface Saslpublic void allowSkip(boolean allowSkip)
Saslpublic TransportWrapper wrap(TransportInput input, TransportOutput output)
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getHostname()
SaslgetHostname in interface Saslpublic void setRemoteHostname(java.lang.String hostname)
SaslsetRemoteHostname in interface Sasl