Search in sources :

Example 1 with SaslClientCallbackHandler

use of org.jgroups.auth.sasl.SaslClientCallbackHandler 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)

Aggregations

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 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 ClassConfigurator (org.jgroups.conf.ClassConfigurator)1 PropertyConverters (org.jgroups.conf.PropertyConverters)1