Package org.apache.qpid.proton.engine.impl

# Class SaslImpl

java.lang.Object
org.apache.qpid.proton.engine.impl.SaslImpl

All Implemented Interfaces:
  `SaslFrameBody.SaslFrameBodyHandler<Void>`, `TransportLayer`, `Sasl`

public class SaslImpl extends Object implements Sasl, SaslFrameBody.SaslFrameBodyHandler<Void>, TransportLayer

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.apache.qpid.proton.engine.Sasl

`Sasl.SaslOutcome, Sasl.SaslState`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final byte`
`SASL_FRAME_TYPE`

### Fields inherited from interface org.apache.qpid.proton.engine.Sasl

`PN_SASL_AUTH, PN_SASL_NONE, PN_SASL_OK, PN_SASL_PERM, PN_SASL_SKIPPED, PN_SASL_SYS, PN_SASL_TEMP`

## Method Summary

Modifier and Type
Method
Description
`void`
`allowSkip(boolean allowSkip)`
Set whether servers may accept incoming connections that skip the SASL layer negotiation.
`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.
`Symbol`
`getChosenMechanism()`
`String`
`getHostname()`
Retrieve the hostname indicated by the client when sending its SaslInit.
`Sasl.SaslOutcome`
`getOutcome()`
Retrieve the outcome of SASL negotiation.
`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, Void context)`
`void`
`handleInit(SaslInit saslInit, Binary payload, Void context)`
`void`
`handleMechanisms(SaslMechanisms saslMechanisms, Binary payload, Void context)`
`void`
`handleOutcome(SaslOutcome saslOutcome, Binary payload, Void context)`
`void`
`handleResponse(SaslResponse saslResponse, Binary payload, Void context)`
`boolean`
`isDone()`
`int`
`pending()`
Determine the size of the bytes available via recv().
`void`
`plain(String username, String password)`
Configure the SASL layer to use the "PLAIN" mechanism.
`final int`
`recv(byte[] bytes, int offset, int size)`
Read challenge/response/additional data sent from the peer.
`final int`
`send(byte[] bytes, int offset, int size)`
Send challenge/response/additional data to the peer.
`void`
`server()`
`void`
`setListener(SaslListener saslListener)`
Adds a listener to receive notice of frames having arrived.
`void`
`setMechanism(Symbol mechanism)`
`void`
`setMechanisms(String... mechanisms)`
Set the acceptable SASL mechanisms for the layer.
`void`
`setRemoteHostname(String hostname)`
Set the remote hostname to indicate the host being connected to when sending a SaslInit to the server.
`void`
`setResponse(Binary initialResponse)`
`String`
`toString()`
`TransportWrapper`
`wrap(TransportInput input, TransportOutput output)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### SASL_FRAME_TYPE

public static final byte SASL_FRAME_TYPE

See Also:
  - Constant Field Values

## Method Details

### isDone

public boolean isDone()

### recv

public final int recv(byte[] bytes, int offset, int size)
Description copied from interface: `Sasl`
Read challenge/response/additional data sent from the peer. Use pending to determine the size of the data.

Specified by:
  `recv` in interface `Sasl`
Parameters:
  `bytes` - written with up to size bytes of inbound data.
  `offset` - the offset in the array to begin writing at
  `size` - maximum number of bytes that bytes can accept.
Returns:
  The number of bytes written to bytes, or an error code if < 0.

### send

public final int send(byte[] bytes, int offset, int size)
Description copied from interface: `Sasl`
Send challenge/response/additional data to the peer.

Specified by:
  `send` in interface `Sasl`
Parameters:
  `bytes` - The challenge/response data.
  `offset` - the point within the array at which the data starts at
  `size` - The number of data octets in bytes.
Returns:
  The number of octets read from bytes, or an error code if < 0

### pending

public int pending()
Description copied from interface: `Sasl`
Determine the size of the bytes available via recv(). Returns the size in bytes available via recv().

Specified by:
  `pending` in interface `Sasl`
Returns:
  The number of bytes available, zero if no available data.

### getState

public Sasl.SaslState getState()
Description copied from interface: `Sasl`
Access the current state of the layer.

Specified by:
  `getState` in interface `Sasl`
Returns:
  The state of the sasl layer.

### setMechanisms

public void setMechanisms(String... mechanisms)
Description copied from interface: `Sasl`
Set the acceptable SASL mechanisms for the layer.

Specified by:
  `setMechanisms` in interface `Sasl`
Parameters:
  `mechanisms` - a list of acceptable SASL mechanisms

### getRemoteMechanisms

public String[] getRemoteMechanisms()
Description copied from interface: `Sasl`
Retrieve the list of SASL mechanisms provided by the remote.

Specified by:
  `getRemoteMechanisms` in interface `Sasl`
Returns:
  the SASL mechanisms advertised by the remote

### setMechanism

public void setMechanism(Symbol mechanism)

### getChosenMechanism

public Symbol getChosenMechanism()

### setResponse

public void setResponse(Binary initialResponse)

### handle

public void handle(SaslFrameBody frameBody, Binary payload)

### handleInit

public void handleInit(SaslInit saslInit, Binary payload, Void context)

Specified by:
  `handleInit` in interface `SaslFrameBody.SaslFrameBodyHandler<Void>`

### handleResponse

public void handleResponse(SaslResponse saslResponse, Binary payload, Void context)

Specified by:
  `handleResponse` in interface `SaslFrameBody.SaslFrameBodyHandler<Void>`

### done

public void done(Sasl.SaslOutcome outcome)
Description copied from interface: `Sasl`
Set the outcome of SASL negotiation Used by the server to set the result of the negotiation process.

Specified by:
  `done` in interface `Sasl`
Parameters:
  `outcome` - the outcome of the SASL negotiation

### handleMechanisms

public void handleMechanisms(SaslMechanisms saslMechanisms, Binary payload, Void context)

Specified by:
  `handleMechanisms` in interface `SaslFrameBody.SaslFrameBodyHandler<Void>`

### handleChallenge

public void handleChallenge(SaslChallenge saslChallenge, Binary payload, Void context)

Specified by:
  `handleChallenge` in interface `SaslFrameBody.SaslFrameBodyHandler<Void>`

### handleOutcome

public void handleOutcome(SaslOutcome saslOutcome, Binary payload, Void context)

Specified by:
  `handleOutcome` in interface `SaslFrameBody.SaslFrameBodyHandler<Void>`

### plain

public void plain(String username, String password)
Description copied from interface: `Sasl`
Configure the SASL layer to use the "PLAIN" mechanism. A utility function to configure a simple client SASL layer using PLAIN authentication.

Specified by:
  `plain` in interface `Sasl`
Parameters:
  `username` - credential for the PLAIN authentication mechanism
  `password` - credential for the PLAIN authentication mechanism

### getOutcome

public Sasl.SaslOutcome getOutcome()
Description copied from interface: `Sasl`
Retrieve the outcome of SASL negotiation.

Specified by:
  `getOutcome` in interface `Sasl`

### client

public void client()

Specified by:
  `client` in interface `Sasl`

### server

public void server()

Specified by:
  `server` in interface `Sasl`

### allowSkip

public void allowSkip(boolean allowSkip)
Description copied from interface: `Sasl`
Set whether servers may accept incoming connections that skip the SASL layer negotiation.

Specified by:
  `allowSkip` in interface `Sasl`

### wrap

public TransportWrapper wrap(TransportInput input, TransportOutput output)

Specified by:
  `wrap` in interface `TransportLayer`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### getHostname

public String getHostname()
Description copied from interface: `Sasl`
Retrieve the hostname indicated by the client when sending its SaslInit.

Specified by:
  `getHostname` in interface `Sasl`
Returns:
  the hostname indicated by the remote client, or null if none specified.

### setRemoteHostname

public void setRemoteHostname(String hostname)
Description copied from interface: `Sasl`
Set the remote hostname to indicate the host being connected to when sending a SaslInit to the server.

Specified by:
  `setRemoteHostname` in interface `Sasl`

### setListener

public void setListener(SaslListener saslListener)
Description copied from interface: `Sasl`
Adds a listener to receive notice of frames having arrived.

Specified by:
  `setListener` in interface `Sasl`