Class SaslMechanismFinder

java.lang.Object
org.apache.qpid.jms.sasl.SaslMechanismFinder

public class SaslMechanismFinder extends Object
Used to find a SASL Mechanism that most closely matches the preferred set of Mechanisms supported by the remote peer. The Matching mechanism is chosen by first find all instances of SASL mechanism types that are supported on the remote peer, and then making a final selection based on the Mechanism in the found set that has the highest priority value.
  • Constructor Details

    • SaslMechanismFinder

      public SaslMechanismFinder()
  • Method Details

    • findMatchingMechanism

      public static Mechanism findMatchingMechanism(String username, String password, Principal localPrincipal, Set<String> mechRestrictions, String... remoteMechanisms) throws SaslSecurityRuntimeException
      Attempts to find a matching Mechanism implementation given a list of supported mechanisms from a remote peer. Can return null if no matching Mechanisms are found.
      Parameters:
      username - the user name, or null if there is none
      password - the password, or null if there is none
      localPrincipal - the Principal associated with the transport, or null if there is none
      mechRestrictions - The possible mechanism(s) to which the client should restrict its mechanism selection to if offered by the server, or null if there is no restriction
      remoteMechanisms - list of mechanism names that are supported by the remote peer.
      Returns:
      the best matching Mechanism for the supported remote set.
      Throws:
      SaslSecurityRuntimeException - if no matching mechanism can be identified
    • findMechanismFactory

      protected static MechanismFactory findMechanismFactory(String name)
      Searches for a MechanismFactory by using the scheme from the given name. The search first checks the local cache of mechanism factories before moving on to search in the classpath.
      Parameters:
      name - The name of the authentication mechanism to search for.
      Returns:
      a mechanism factory instance matching the name, or null if none was created.