Search in sources :

Example 1 with SaslClientFactory

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

the class FastSaslClientFactory method refresh.

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

Example 2 with SaslClientFactory

use of javax.security.sasl.SaslClientFactory 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 3 with SaslClientFactory

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

the class FastSaslClientFactory method refresh.

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

Aggregations

SaslClientFactory (javax.security.sasl.SaslClientFactory)3 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 SaslException (javax.security.sasl.SaslException)1 SaslServerFactory (javax.security.sasl.SaslServerFactory)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