public abstract class AbstractSaslParticipant extends Object implements SaslWrapper
Modifier and Type | Field and Description |
---|---|
static int |
COMPLETE_STATE
The SASL negotiation completed state.
|
static int |
FAILED_STATE
The SASL negotiation failure state.
|
static byte[] |
NO_BYTES
An empty byte array.
|
IDENTITY
Modifier | Constructor and Description |
---|---|
protected |
AbstractSaslParticipant(String mechanismName,
String protocol,
String serverName,
CallbackHandler callbackHandler)
Deprecated.
|
protected |
AbstractSaslParticipant(String mechanismName,
String protocol,
String serverName,
CallbackHandler callbackHandler,
org.wildfly.security._private.ElytronMessages log)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assertComplete()
A convenience method to throw a
IllegalStateException is authentication is not yet complete. |
void |
dispose()
Dispose of this participant.
|
protected byte[] |
evaluateMessage(byte[] message) |
protected abstract byte[] |
evaluateMessage(int state,
byte[] message) |
protected CallbackHandler |
getCallbackHandler()
Get the configured authentication callback handler.
|
int |
getIntProperty(Map<String,?> map,
String key,
int defaultVal)
Get a string property value from the given map.
|
String |
getMechanismName()
Get the name of this mechanism.
|
Object |
getNegotiatedProperty(String propName)
Get a property negotiated between this participant and the other.
|
protected String |
getProtocol()
Get the protocol name.
|
protected String |
getServerName()
Get the server name.
|
String |
getStringProperty(Map<String,?> map,
String key,
String defaultVal)
Get a string property value from the given map.
|
protected SaslWrapper |
getWrapper()
Get the current configured SASL wrapper, if any.
|
protected void |
handleCallbacks(Callback... callbacks)
Handle callbacks, wrapping exceptions as needed (including unsupported callbacks).
|
void |
init() |
boolean |
isComplete()
Determine whether the authentication exchange has completed.
|
void |
negotiationComplete()
Indicate that negotiation is complete.
|
void |
setNegotiationState(int newState)
Set the state to use for the next incoming message.
|
protected void |
setWrapper(SaslWrapper wrapper)
Set the current configured SASL wrapper, if any.
|
protected void |
tryHandleCallbacks(Callback... callbacks)
Handle callbacks, wrapping exceptions as needed.
|
byte[] |
unwrap(byte[] incoming,
int offset,
int len)
Unwraps a byte array received from the other participant.
|
byte[] |
wrap(byte[] outgoing,
int offset,
int len)
Wraps a byte array to be sent to the other participant.
|
public static final byte[] NO_BYTES
public static final int FAILED_STATE
public static final int COMPLETE_STATE
protected AbstractSaslParticipant(String mechanismName, String protocol, String serverName, CallbackHandler callbackHandler, org.wildfly.security._private.ElytronMessages log)
mechanismName
- the name of the defined mechanismprotocol
- the protocolserverName
- the server namecallbackHandler
- the callback handlerlog
- mechanism specific logger@Deprecated protected AbstractSaslParticipant(String mechanismName, String protocol, String serverName, CallbackHandler callbackHandler)
mechanismName
- the name of the defined mechanismprotocol
- the protocolserverName
- the server namecallbackHandler
- the callback handlerprotected void handleCallbacks(Callback... callbacks) throws SaslException
callbacks
- the callbacks to handleSaslException
- if a callback failedprotected void tryHandleCallbacks(Callback... callbacks) throws SaslException, UnsupportedCallbackException
callbacks
- the callbacks to handleSaslException
- if a callback failedUnsupportedCallbackException
- if a callback isn't supportedpublic void init()
public String getMechanismName()
protected String getProtocol()
protected String getServerName()
protected CallbackHandler getCallbackHandler()
protected SaslWrapper getWrapper()
null
if none is configuredpublic void setNegotiationState(int newState)
newState
- the new statepublic void negotiationComplete()
setNegotiationState(int)
.protected byte[] evaluateMessage(byte[] message) throws SaslException
SaslException
protected abstract byte[] evaluateMessage(int state, byte[] message) throws SaslException
SaslException
protected void setWrapper(SaslWrapper wrapper)
wrapper
- the SASL wrapper, or null
to disable wrappingpublic byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException
wrap
in interface SaslWrapper
outgoing
- a non-null
byte array containing the bytes to encodeoffset
- the first byte to encodelen
- the number of bytes to usenull
byte array containing the encoded bytesSaslException
- if wrapping failsIllegalStateException
- if wrapping is not configuredpublic byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException
unwrap
in interface SaslWrapper
incoming
- a non-null
byte array containing the bytes to decodeoffset
- the first byte to decodelen
- the number of bytes to usenull
byte array containing the decoded bytesSaslException
- if wrapping failsIllegalStateException
- if wrapping is not configuredpublic boolean isComplete()
true
if the exchange has completedprotected void assertComplete()
IllegalStateException
is authentication is not yet complete.
To be called by methods that must only be called after authentication is complete.public Object getNegotiatedProperty(String propName)
propName
- the property namenull
if not definedpublic String getStringProperty(Map<String,?> map, String key, String defaultVal)
map
- the property mapkey
- the propertydefaultVal
- the value to return if the key is not in the mappublic int getIntProperty(Map<String,?> map, String key, int defaultVal)
map
- the property mapkey
- the propertydefaultVal
- the value to return if the key is not in the mappublic void dispose() throws SaslException
SaslException
- if disposal failedCopyright © 2020 JBoss by Red Hat. All rights reserved.