Class SaslMechanismSelector
- java.lang.Object
-
- org.apache.qpid.protonj2.engine.sasl.client.SaslMechanismSelector
-
public class SaslMechanismSelector extends java.lang.Object
Client side mechanism used to select a matching mechanism from the server offered list of mechanisms. The client configures the list of allowedMechanism
names and when the server mechanisms are offered mechanism is chosen from the allowed set. If the client does not configure any mechanisms then the selector chooses from all supportedMechanism
types.
-
-
Constructor Summary
Constructors Constructor Description SaslMechanismSelector()
SaslMechanismSelector(java.util.Collection<java.lang.String> allowed)
SaslMechanismSelector(java.util.Set<Symbol> allowed)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Mechanism
createMechanism(Symbol name, SaslCredentialsProvider credentials)
java.util.Set<Symbol>
getAllowedMechanisms()
protected boolean
isApplicable(Mechanism candidate, SaslCredentialsProvider credentials)
Tests a givenMechanism
instance to determine if it is applicable given the selector configuration and the provided credentials.Mechanism
select(Symbol[] serverMechs, SaslCredentialsProvider credentials)
Given a list of SASL mechanism names select a match from the supported types using the configured allowed list and the given credentials.
-
-
-
Constructor Detail
-
SaslMechanismSelector
public SaslMechanismSelector()
-
SaslMechanismSelector
public SaslMechanismSelector(java.util.Collection<java.lang.String> allowed)
- Parameters:
allowed
- ACollection
of SASL mechanism names that are allowed to be used when selecting a matching mechanism.
-
SaslMechanismSelector
public SaslMechanismSelector(java.util.Set<Symbol> allowed)
- Parameters:
allowed
- ASet
of SASL mechanism names that are allowed to be used when selecting a matching mechanism.
-
-
Method Detail
-
getAllowedMechanisms
public java.util.Set<Symbol> getAllowedMechanisms()
- Returns:
- the configured set of allowed SASL
Mechanism
names.
-
select
public Mechanism select(Symbol[] serverMechs, SaslCredentialsProvider credentials)
Given a list of SASL mechanism names select a match from the supported types using the configured allowed list and the given credentials.- Parameters:
serverMechs
- The list of mechanisms the server indicates it supports.credentials
- ASaslCredentialsProvider
used to choose an matching applicable SASLMechanism
.- Returns:
- a selected SASL
Mechanism
instance or null of no match is possible.
-
createMechanism
protected Mechanism createMechanism(Symbol name, SaslCredentialsProvider credentials)
Using the givenMechanism
name and the provided credentials create and configure aMechanism
for evaluation by the selector.- Parameters:
name
- A mechanism name that matches one of the supported offerings by the remotecredentials
- The provided credentials that will be used to perform authentication with the remote.- Returns:
- a new
Mechanism
instance or null the offered mechanism is unsupported.
-
isApplicable
protected boolean isApplicable(Mechanism candidate, SaslCredentialsProvider credentials)
Tests a givenMechanism
instance to determine if it is applicable given the selector configuration and the provided credentials.- Parameters:
candidate
- The SASL mechanism that matches both the allowed and the server offered lists.credentials
- The provided SASL credentials which will be used when authenticating with the remote.- Returns:
- true if the candidate
Mechanism
is applicable given the provide credentials.
-
-