public final class SaslUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static byte[] |
EMPTY_BYTES
A zero-length byte array, useful for sending and receiving empty SASL messages.
|
Modifier and Type | Method and Description |
---|---|
static java.util.Map<java.lang.String,java.lang.Object> |
createPropertyMap(OptionMap optionMap,
boolean secure)
Create a SASL property map from an XNIO option map.
|
static byte[] |
evaluateChallenge(javax.security.sasl.SaslClient client,
java.nio.ByteBuffer source)
Evaluate a sasl challenge.
|
static boolean |
evaluateChallenge(javax.security.sasl.SaslClient client,
java.nio.ByteBuffer destination,
java.nio.ByteBuffer source)
Evaluate a sasl challenge.
|
static byte[] |
evaluateResponse(javax.security.sasl.SaslServer server,
java.nio.ByteBuffer source)
Evaluate a sasl response.
|
static boolean |
evaluateResponse(javax.security.sasl.SaslServer server,
java.nio.ByteBuffer destination,
java.nio.ByteBuffer source)
Evaluate a sasl response.
|
static java.util.Iterator<javax.security.sasl.SaslClientFactory> |
getSaslClientFactories()
Returns an iterator of all of the registered
SaslClientFactory s where the order is based on the
order of the Provider registration and/or class path order. |
static java.util.Iterator<javax.security.sasl.SaslClientFactory> |
getSaslClientFactories(java.lang.ClassLoader classLoader,
boolean includeGlobal)
Returns an iterator of all of the registered
SaslClientFactory s where the order is based on the
order of the Provider registration and/or class path order. |
static java.util.Iterator<javax.security.sasl.SaslServerFactory> |
getSaslServerFactories()
Returns an iterator of all of the registered
SaslServerFactory s where the order is based on the
order of the Provider registration and/or class path order. |
static java.util.Iterator<javax.security.sasl.SaslServerFactory> |
getSaslServerFactories(java.lang.ClassLoader classLoader,
boolean includeGlobal)
Returns an iterator of all of the registered
SaslServerFactory s where the order is based on the
order of the Provider registration and/or class path order. |
static byte[] |
unwrap(javax.security.sasl.SaslClient client,
java.nio.ByteBuffer source)
Unwrap a message.
|
static void |
unwrap(javax.security.sasl.SaslClient client,
java.nio.ByteBuffer destination,
java.nio.ByteBuffer source)
Unwrap a message.
|
static byte[] |
unwrap(javax.security.sasl.SaslServer server,
java.nio.ByteBuffer source)
Unwrap a message.
|
static void |
unwrap(javax.security.sasl.SaslServer server,
java.nio.ByteBuffer destination,
java.nio.ByteBuffer source)
Unwrap a message.
|
static byte[] |
wrap(javax.security.sasl.SaslClient client,
java.nio.ByteBuffer source)
Wrap a message.
|
static void |
wrap(javax.security.sasl.SaslClient client,
java.nio.ByteBuffer destination,
java.nio.ByteBuffer source)
Wrap a message.
|
static byte[] |
wrap(javax.security.sasl.SaslServer server,
java.nio.ByteBuffer source)
Wrap a message.
|
static void |
wrap(javax.security.sasl.SaslServer server,
java.nio.ByteBuffer destination,
java.nio.ByteBuffer source)
Wrap a message.
|
public static final byte[] EMPTY_BYTES
public static java.util.Iterator<javax.security.sasl.SaslServerFactory> getSaslServerFactories(java.lang.ClassLoader classLoader, boolean includeGlobal)
SaslServerFactory
s where the order is based on the
order of the Provider registration and/or class path order. Class path providers are listed before
global providers; in the event of a name conflict, the class path provider is preferred.classLoader
- the class loader to useincludeGlobal
- true
to include globally registered providers, false
to exclude themIterator
of SaslServerFactory
spublic static java.util.Iterator<javax.security.sasl.SaslServerFactory> getSaslServerFactories()
SaslServerFactory
s where the order is based on the
order of the Provider registration and/or class path order.Iterator
of SaslServerFactory
spublic static java.util.Iterator<javax.security.sasl.SaslClientFactory> getSaslClientFactories(java.lang.ClassLoader classLoader, boolean includeGlobal)
SaslClientFactory
s where the order is based on the
order of the Provider registration and/or class path order. Class path providers are listed before
global providers; in the event of a name conflict, the class path provider is preferred.classLoader
- the class loader to useincludeGlobal
- true
to include globally registered providers, false
to exclude themIterator
of SaslClientFactory
spublic static java.util.Iterator<javax.security.sasl.SaslClientFactory> getSaslClientFactories()
SaslClientFactory
s where the order is based on the
order of the Provider registration and/or class path order.Iterator
of SaslClientFactory
spublic static boolean evaluateChallenge(javax.security.sasl.SaslClient client, java.nio.ByteBuffer destination, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
false
then the negotiation is not yet complete and the data
written into the destination buffer needs to be sent to the server as a response. If the result is true
then negotiation was successful and no response needs to be sent to the server.
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message. The SASL message itself does not encode any length information so it is up to the protocol implementer
to ensure that the message is properly framed.
client
- the SASL client to use to evaluate the challenge messagedestination
- the destination buffer into which the response message should be written, if anysource
- the source buffer from which the challenge message should be readtrue
if negotiation is complete and successful, false
otherwisejavax.security.sasl.SaslException
- if negotiation failed or another error occurredpublic static byte[] evaluateChallenge(javax.security.sasl.SaslClient client, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
null
then the negotiation is not yet complete and the data
returned needs to be sent to the server as a response. If the result is null
then negotiation was successful and no response needs to be sent to the server.
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message. The SASL message itself does not encode any length information so it is up to the protocol implementer
to ensure that the message is properly framed.
client
- the SASL client to use to evaluate the challenge messagesource
- the source buffer from which the challenge message should be readnull
if negotiation is complete and successful, or the response otherwisejavax.security.sasl.SaslException
- if negotiation failed or another error occurredpublic static boolean evaluateResponse(javax.security.sasl.SaslServer server, java.nio.ByteBuffer destination, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
false
then the negotiation is not yet complete and the data
written into the destination buffer needs to be sent to the server as a response. If the result is true
then negotiation was successful and no response needs to be sent to the client (other than a successful completion
message, depending on the protocol).
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message. The SASL message itself does not encode any length information so it is up to the protocol implementer
to ensure that the message is properly framed.
server
- the SASL server to use to evaluate the response messagedestination
- the destination buffer into which the response message should be written, if anysource
- the source buffer from which the response message should be readtrue
if negotiation is complete and successful, false
otherwisejavax.security.sasl.SaslException
- if negotiation failed or another error occurredpublic static byte[] evaluateResponse(javax.security.sasl.SaslServer server, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
null
then the negotiation is not yet complete and the data
returned needs to be sent to the server as a response. If the result is null
then negotiation was successful and no response needs to be sent to the client (other than a successful completion
message, depending on the protocol).
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message. The SASL message itself does not encode any length information so it is up to the protocol implementer
to ensure that the message is properly framed.
server
- the SASL server to use to evaluate the response messagesource
- the source buffer from which the response message should be readtrue
if negotiation is complete and successful, false
otherwisejavax.security.sasl.SaslException
- if negotiation failed or another error occurredpublic static void wrap(javax.security.sasl.SaslClient client, java.nio.ByteBuffer destination, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message (without the length field). The SASL message itself does not encode any length information so it is up
to the protocol implementer to ensure that the message is properly framed.
client
- the SASL client to wrap withdestination
- the buffer into which bytes should be writtensource
- the buffers from which bytes should be readjavax.security.sasl.SaslException
- if a SASL error occursSaslClient.wrap(byte[], int, int)
public static byte[] wrap(javax.security.sasl.SaslClient client, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message (without the length field). The SASL message itself does not encode any length information so it is up
to the protocol implementer to ensure that the message is properly framed.
client
- the SASL client to wrap withsource
- the buffers from which bytes should be readjavax.security.sasl.SaslException
- if a SASL error occursSaslClient.wrap(byte[], int, int)
public static void wrap(javax.security.sasl.SaslServer server, java.nio.ByteBuffer destination, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message (without the length field). The SASL message itself does not encode any length information so it is up
to the protocol implementer to ensure that the message is properly framed.
server
- the SASL server to wrap withdestination
- the buffer into which bytes should be writtensource
- the buffers from which bytes should be readjavax.security.sasl.SaslException
- if a SASL error occursSaslServer.wrap(byte[], int, int)
public static byte[] wrap(javax.security.sasl.SaslServer server, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message (without the length field). The SASL message itself does not encode any length information so it is up
to the protocol implementer to ensure that the message is properly framed.
server
- the SASL server to wrap withsource
- the buffers from which bytes should be readjavax.security.sasl.SaslException
- if a SASL error occursSaslServer.wrap(byte[], int, int)
public static void unwrap(javax.security.sasl.SaslClient client, java.nio.ByteBuffer destination, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message (without the length field). The SASL message itself does not encode any length information so it is up
to the protocol implementer to ensure that the message is properly framed.
client
- the SASL client to unwrap withdestination
- the buffer into which bytes should be writtensource
- the buffers from which bytes should be readjavax.security.sasl.SaslException
- if a SASL error occursSaslClient.unwrap(byte[], int, int)
public static byte[] unwrap(javax.security.sasl.SaslClient client, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message (without the length field). The SASL message itself does not encode any length information so it is up
to the protocol implementer to ensure that the message is properly framed.
client
- the SASL client to unwrap withsource
- the buffers from which bytes should be readjavax.security.sasl.SaslException
- if a SASL error occursSaslClient.unwrap(byte[], int, int)
public static void unwrap(javax.security.sasl.SaslServer server, java.nio.ByteBuffer destination, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message (without the length field). The SASL message itself does not encode any length information so it is up
to the protocol implementer to ensure that the message is properly framed.
server
- the SASL server to unwrap withdestination
- the buffer into which bytes should be writtensource
- the buffers from which bytes should be readjavax.security.sasl.SaslException
- if a SASL error occursSaslServer.unwrap(byte[], int, int)
public static byte[] unwrap(javax.security.sasl.SaslServer server, java.nio.ByteBuffer source) throws javax.security.sasl.SaslException
The source
buffer should have its position and remaining length set to encompass exactly one SASL
message (without the length field). The SASL message itself does not encode any length information so it is up
to the protocol implementer to ensure that the message is properly framed.
server
- the SASL server to unwrap withsource
- the buffers from which bytes should be readjavax.security.sasl.SaslException
- if a SASL error occursSaslServer.unwrap(byte[], int, int)
public static java.util.Map<java.lang.String,java.lang.Object> createPropertyMap(OptionMap optionMap, boolean secure)
optionMap
- the option mapsecure
- true
if the channel is secure, false
otherwiseCopyright © 2016 JBoss, a division of Red Hat, Inc.