Package org.apache.thrift.transport.sasl
Class ServerSaslPeer
java.lang.Object
org.apache.thrift.transport.sasl.ServerSaslPeer
- All Implemented Interfaces:
SaslPeer
Server side sasl peer, a wrapper around SaslServer to provide some handy methods.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Close this peer and release resources.byte[]
evaluate
(byte[] negotiationMessage) Evaluate and validate the negotiation message (response/challenge) received from peer.boolean
boolean
This method can only be called when the negotiation is complete (isAuthenticated returns true).byte[]
unwrap
(byte[] data, int offset, int length) Unwrap protected data to raw bytes.byte[]
wrap
(byte[] data, int offset, int length) Wrap raw bytes to protect it.
-
Constructor Details
-
ServerSaslPeer
-
-
Method Details
-
evaluate
Description copied from interface:SaslPeer
Evaluate and validate the negotiation message (response/challenge) received from peer.- Specified by:
evaluate
in interfaceSaslPeer
- Parameters:
negotiationMessage
- response/challenge received from peer.- Returns:
- new response/challenge to send to peer, can be null if authentication becomes success.
- Throws:
TSaslNegotiationException
- if sasl authentication fails.
-
isAuthenticated
public boolean isAuthenticated()- Specified by:
isAuthenticated
in interfaceSaslPeer
- Returns:
- true if authentication is done.
-
isDataProtected
public boolean isDataProtected()Description copied from interface:SaslPeer
This method can only be called when the negotiation is complete (isAuthenticated returns true). Otherwise it will throw IllegalStateExceptiion.- Specified by:
isDataProtected
in interfaceSaslPeer
- Returns:
- if the qop requires some integrity/confidential protection.
-
wrap
Description copied from interface:SaslPeer
Wrap raw bytes to protect it.- Specified by:
wrap
in interfaceSaslPeer
- Parameters:
data
- raw bytes.offset
- the start position of the content to wrap.length
- the length of the content to wrap.- Returns:
- bytes with protection to send to peer.
- Throws:
TTransportException
- if failure.
-
unwrap
Description copied from interface:SaslPeer
Unwrap protected data to raw bytes.- Specified by:
unwrap
in interfaceSaslPeer
- Parameters:
data
- protected data received from peer.offset
- the start position of the content to unwrap.length
- the length of the content to unwrap.- Returns:
- raw bytes.
- Throws:
TTransportException
- if failed.
-
dispose
public void dispose()Description copied from interface:SaslPeer
Close this peer and release resources.
-