Search in sources :

Example 1 with SaslServerFactory

use of javax.security.sasl.SaslServerFactory in project drill by apache.

the class FastSaslServerFactory method refresh.

// used in initialization, and for testing
private void refresh() {
    final Enumeration<SaslServerFactory> factories = Sasl.getSaslServerFactories();
    final Map<String, List<SaslServerFactory>> map = Maps.newHashMap();
    while (factories.hasMoreElements()) {
        final SaslServerFactory factory = factories.nextElement();
        // instantiating a server are what really matter. See createSaslServer.
        for (final String mechanismName : factory.getMechanismNames(null)) {
            if (!map.containsKey(mechanismName)) {
                map.put(mechanismName, new ArrayList<SaslServerFactory>());
            }
            map.get(mechanismName).add(factory);
        }
    }
    serverFactories = ImmutableMap.copyOf(map);
    if (logger.isDebugEnabled()) {
        logger.debug("Registered sasl server factories: {}", serverFactories.keySet());
    }
}
Also used : SaslServerFactory(javax.security.sasl.SaslServerFactory) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with SaslServerFactory

use of javax.security.sasl.SaslServerFactory in project Openfire by igniterealtime.

the class SASLAuthentication method getImplementedMechanisms.

/**
     * Returns a collection of mechanism names for which the JVM has an implementation available.
     * <p/>
     * 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.
     *
     * @return a collection of SASL mechanism names (never null, possibly empty)
     */
public static Set<String> getImplementedMechanisms() {
    final Set<String> result = new HashSet<>();
    final Enumeration<SaslServerFactory> saslServerFactories = Sasl.getSaslServerFactories();
    while (saslServerFactories.hasMoreElements()) {
        final SaslServerFactory saslServerFactory = saslServerFactories.nextElement();
        Collections.addAll(result, saslServerFactory.getMechanismNames(null));
    }
    return result;
}
Also used : SaslServerFactory(javax.security.sasl.SaslServerFactory)

Example 3 with SaslServerFactory

use of javax.security.sasl.SaslServerFactory in project JGroups by belaban.

the class SASL method init.

@Override
public void init() throws Exception {
    super.init();
    saslServerFactory = SaslUtils.getSaslServerFactory(mech, sasl_props);
    saslClientFactory = SaslUtils.getSaslClientFactory(mech, sasl_props);
    char[] client_password_chars = client_password == null ? new char[] {} : client_password.toCharArray();
    if (client_callback_handler == null) {
        client_callback_handler = client_password == null ? Void -> {
        } : new SaslClientCallbackHandler(client_name, client_password_chars);
    }
    if (server_callback_handler == null) {
        server_callback_handler = Void -> {
        };
    }
    if (server_subject == null && login_module_name != null) {
        LoginContext lc = new LoginContext(login_module_name);
        lc.login();
        server_subject = lc.getSubject();
    }
    if (client_subject == null && login_module_name != null) {
        LoginContext lc = new LoginContext(login_module_name, new SaslClientCallbackHandler(client_name, client_password_chars));
        lc.login();
        client_subject = lc.getSubject();
    }
}
Also used : SaslServerFactory(javax.security.sasl.SaslServerFactory) SaslClientContext(org.jgroups.auth.sasl.SaslClientContext) HashMap(java.util.HashMap) SaslException(javax.security.sasl.SaslException) LoginContext(javax.security.auth.login.LoginContext) SaslServerContext(org.jgroups.auth.sasl.SaslServerContext) GmsHeader(org.jgroups.protocols.pbcast.GMS.GmsHeader) CallbackHandler(javax.security.auth.callback.CallbackHandler) Map(java.util.Map) Address(org.jgroups.Address) SaslUtils(org.jgroups.auth.sasl.SaslUtils) Property(org.jgroups.annotations.Property) Protocol(org.jgroups.stack.Protocol) MessageBatch(org.jgroups.util.MessageBatch) Event(org.jgroups.Event) SaslClientCallbackHandler(org.jgroups.auth.sasl.SaslClientCallbackHandler) GMS(org.jgroups.protocols.pbcast.GMS) Subject(javax.security.auth.Subject) PropertyConverters(org.jgroups.conf.PropertyConverters) JoinRsp(org.jgroups.protocols.pbcast.JoinRsp) Message(org.jgroups.Message) SaslContext(org.jgroups.auth.sasl.SaslContext) MBean(org.jgroups.annotations.MBean) ClassConfigurator(org.jgroups.conf.ClassConfigurator) SaslClientFactory(javax.security.sasl.SaslClientFactory) LoginContext(javax.security.auth.login.LoginContext) SaslClientCallbackHandler(org.jgroups.auth.sasl.SaslClientCallbackHandler)

Example 4 with SaslServerFactory

use of javax.security.sasl.SaslServerFactory in project drill by axbaretto.

the class FastSaslServerFactory method refresh.

// used in initialization, and for testing
private void refresh() {
    final Enumeration<SaslServerFactory> factories = Sasl.getSaslServerFactories();
    final Map<String, List<SaslServerFactory>> map = Maps.newHashMap();
    while (factories.hasMoreElements()) {
        final SaslServerFactory factory = factories.nextElement();
        // instantiating a server are what really matter. See createSaslServer.
        for (final String mechanismName : factory.getMechanismNames(null)) {
            if (!map.containsKey(mechanismName)) {
                map.put(mechanismName, new ArrayList<SaslServerFactory>());
            }
            map.get(mechanismName).add(factory);
        }
    }
    serverFactories = ImmutableMap.copyOf(map);
    if (logger.isDebugEnabled()) {
        logger.debug("Registered sasl server factories: {}", serverFactories.keySet());
    }
}
Also used : SaslServerFactory(javax.security.sasl.SaslServerFactory) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

SaslServerFactory (javax.security.sasl.SaslServerFactory)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Subject (javax.security.auth.Subject)1 CallbackHandler (javax.security.auth.callback.CallbackHandler)1 LoginContext (javax.security.auth.login.LoginContext)1 SaslClientFactory (javax.security.sasl.SaslClientFactory)1 SaslException (javax.security.sasl.SaslException)1 Address (org.jgroups.Address)1 Event (org.jgroups.Event)1 Message (org.jgroups.Message)1 MBean (org.jgroups.annotations.MBean)1 Property (org.jgroups.annotations.Property)1 SaslClientCallbackHandler (org.jgroups.auth.sasl.SaslClientCallbackHandler)1 SaslClientContext (org.jgroups.auth.sasl.SaslClientContext)1 SaslContext (org.jgroups.auth.sasl.SaslContext)1 SaslServerContext (org.jgroups.auth.sasl.SaslServerContext)1 SaslUtils (org.jgroups.auth.sasl.SaslUtils)1