Package org.jivesoftware.openfire.sasl
Class SaslMechanismCatalog
java.lang.Object
org.jivesoftware.openfire.sasl.SaslMechanismCatalog
The SASL mechanisms that this server can offer, and the configuration that governs them.
Three distinct sets are involved, and they narrow in this order:
- The enabled mechanisms, from the
sasl.mechsproperty. This is what an administrator has chosen to allow, and is the only one of the three that is stored. - The implemented mechanisms, for which some registered JCA provider supplies a
SaslServer. - The supported mechanisms: those that are both enabled and implemented, and whose additional requirements this deployment meets, such as an AuthProvider that can supply the necessary credentials, or an available channel-binding implementation.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddSupportedMechanism(String mechanismName) Adds a new SASL mechanism to the list of supported SASL mechanisms by the server.Returns a collection of SASL mechanism names that forms the source pool from which the mechanisms that are eventually being offered to peers are obtained.Returns a collection of mechanism names for which the JVM has an implementation available.Returns the list of supported SASL mechanisms by the server.static voidForces this class to be initialized, which registers Openfire's SASL provider with the Java security context and loads the configured mechanism names.static booleanReturnstrueif configuration allows the given mechanism to be used.static voidremoveSupportedMechanism(String mechanismName) Removes a SASL mechanism from the list of supported SASL mechanisms by the server.static voidsetEnabledMechanisms(List<String> mechanisms) Sets the collection of mechanism names that the system administrator allows to be used.
-
Method Details
-
initialize
public static void initialize()Forces this class to be initialized, which registers Openfire's SASL provider with the Java security context and loads the configured mechanism names. Callers that go on to use this class need not invoke this method; class initialization takes care of it. It exists for the benefit of code that depends on the provider being registered without otherwise consulting the catalog. -
isEnabled
Returnstrueif configuration allows the given mechanism to be used. This says nothing about whether the mechanism is implemented, or whether this deployment meets its requirements; seegetSupportedMechanisms()for that.- Parameters:
mechanismName- the SASL mechanism name to check, upper-cased (cannot be null)- Returns:
trueif the mechanism is enabled by configuration
-
addSupportedMechanism
Adds a new SASL mechanism to the list of supported SASL mechanisms by the server. The new mechanism will be offered to clients and connection managers as stream features.Note: this method simply registers the SASL mechanism to be advertised as a supported mechanism by Openfire. Actual SASL handling is done by Java itself, so you must add the provider to Java.
- Parameters:
mechanismName- the name of the new SASL mechanism (cannot be null or an empty String).
-
removeSupportedMechanism
Removes a SASL mechanism from the list of supported SASL mechanisms by the server.- Parameters:
mechanismName- the name of the SASL mechanism to remove (cannot be null or empty, not case-sensitive).
-
getSupportedMechanisms
Returns the list of supported SASL mechanisms by the server. Note that Java may have support for more mechanisms but some of them may not be returned since a special setup is required that might be missing. UseaddSupportedMechanism(String)to add new SASL mechanisms.- Returns:
- the set of supported SASL mechanisms by the server.
-
getImplementedMechanisms
Returns a collection of mechanism names for which the JVM has an implementation available.Note that this need not (and likely will not) correspond with the list of mechanisms that is offered to XMPP peer entities, which is provided by #getSupportedMechanisms.
- Returns:
- a collection of SASL mechanism names (never null, possibly empty)
-
getEnabledMechanisms
Returns a collection of SASL mechanism names that forms the source pool from which the mechanisms that are eventually being offered to peers are obtained. When a mechanism is not returned by this method, it will never be offered, but when a mechanism is returned by this method, there is no guarantee that it will be offered. Apart from being returned in this method, an implementation must be available (seegetImplementedMechanisms()and configuration or other characteristics of this server must not prevent a particular mechanism from being used (see @{linkgetSupportedMechanisms()}.- Returns:
- A collection of mechanisms that are considered for use in this instance of Openfire.
-
setEnabledMechanisms
Sets the collection of mechanism names that the system administrator allows to be used.- Parameters:
mechanisms- A collection of mechanisms that are considered for use in this instance of Openfire. Null to reset the default setting.- See Also:
-