Interface SaslClientContext
- All Superinterfaces:
SaslContext
SASL Client operating context used by an
Engine
that has been
configured as a SASL client or that has initialed the SASL exchange by
being the first to initiate the AMQP header exchange.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.qpid.protonj2.engine.sasl.SaslContext
SaslContext.Role
-
Method Summary
Modifier and TypeMethodDescriptionsaslFailure
(SaslException failure) Allows the client implementation to fail the SASL negotiation process due to some unrecoverable error.default SaslClientContext
sendChosenMechanism
(String mechanism, String host, ProtonBuffer initialResponse) Sends a response to the SASL server indicating the chosen mechanism for this client and the host name that this client is identifying itself as.sendChosenMechanism
(Symbol mechanism, String host, ProtonBuffer initialResponse) Sends a response to the SASL server indicating the chosen mechanism for this client and the host name that this client is identifying itself as.sendResponse
(ProtonBuffer response) Sends a response to a server side challenge that comprises the challenge / response exchange for the chosen SASL mechanism.Sends the AMQP Header indicating the desire for SASL negotiations to be commenced on this connection.setListener
(SaslClientListener listener) Sets theSaslClientListener
that will be used to driver the client side SASL negotiations with a connected "server".Methods inherited from interface org.apache.qpid.protonj2.engine.sasl.SaslContext
getAttachments, getChosenMechanism, getHostname, getLinkedResource, getLinkedResource, getRole, getSaslOutcome, getSaslState, getServerMechanisms, isClient, isDone, isServer, setLinkedResource
-
Method Details
-
setListener
Sets theSaslClientListener
that will be used to driver the client side SASL negotiations with a connected "server". As the server initiates or responds to the various phases of the SASL negotiation theSaslClientListener
will be notified and allowed to respond.- Parameters:
listener
- TheSaslClientListener
to use for SASL negotiations, cannot be null.- Returns:
- this client context.
-
getListener
SaslClientListener getListener()- Returns:
- the currently set
SaslClientListener
instance.
-
sendSASLHeader
Sends the AMQP Header indicating the desire for SASL negotiations to be commenced on this connection. The hosting application my wish to start SASL negotiations prior to opening aConnection
in order to validation authentication state out of band of the normal open process.- Returns:
- this client context.
- Throws:
EngineStateException
- if theEngine
has been shut down or a failure occurs processing this header.
-
sendChosenMechanism
SaslClientContext sendChosenMechanism(Symbol mechanism, String host, ProtonBuffer initialResponse) throws EngineStateException Sends a response to the SASL server indicating the chosen mechanism for this client and the host name that this client is identifying itself as.- Parameters:
mechanism
- The chosen mechanism selected from the list the server provided.host
- The host name that the client is identified as or null if none selected.initialResponse
- The initial response data sent as defined by the chosen mechanism or null if none required.- Returns:
- this client context.
- Throws:
EngineStateException
- if theEngine
has been shut down or a failure occurs processing this mechanism.
-
sendChosenMechanism
default SaslClientContext sendChosenMechanism(String mechanism, String host, ProtonBuffer initialResponse) throws EngineStateException Sends a response to the SASL server indicating the chosen mechanism for this client and the host name that this client is identifying itself as.- Parameters:
mechanism
- The chosen mechanism selected from the list the server provided.host
- The host name that the client is identified as or null if none selected.initialResponse
- The initial response data sent as defined by the chosen mechanism or null if none required.- Returns:
- this client context.
- Throws:
EngineStateException
- if theEngine
has been shut down or a failure occurs processing this mechanism.
-
sendResponse
Sends a response to a server side challenge that comprises the challenge / response exchange for the chosen SASL mechanism. The server may response with another challenge or complete the SASL exchange by sending an outcome.- Parameters:
response
- The response bytes to be sent to the server for this cycle.- Returns:
- this client context.
- Throws:
EngineStateException
- if theEngine
has been shut down or a failure occurs processing this response.
-
saslFailure
Allows the client implementation to fail the SASL negotiation process due to some unrecoverable error. Failing the process will signal the engine that the SASL process has failed and place the engine in a failed state as well as notify the registered error handler for theEngine
.Once the SASL negotiation completes after an outcome has arrived calling this method will not produce any effect as the SASL layer will be shutdown at this point, this method is for failing negotiations that are ongoing. If a failed SASL outcome arrives the client should take action by shutting down the engine or failing it to trigger an event that is handled or by closing the I/O channel in use.
- Parameters:
failure
- The exception to report to theEngine
that describes the failure.- Returns:
- this client context.
-