Search in sources :

Example 1 with VoidCallbackHandler

use of org.infinispan.client.hotrod.security.VoidCallbackHandler in project infinispan by infinispan.

the class AuthenticationConfigurationBuilder method create.

@Override
public AuthenticationConfiguration create() {
    String mech = saslMechanism == null ? DEFAULT_MECHANISM : saslMechanism;
    CallbackHandler cbh = callbackHandler;
    if (cbh == null) {
        if (OAUTHBEARER_MECH.equals(mech)) {
            cbh = new TokenCallbackHandler(token);
        } else if (username != null) {
            cbh = new BasicCallbackHandler(username, realm != null ? realm : DEFAULT_REALM, password);
        } else if (EXTERNAL_MECH.equals(mech) || GSSAPI_MECH.equals(mech) || GS2_KRB5_MECH.equals(mech)) {
            cbh = new VoidCallbackHandler();
        }
    }
    return new AuthenticationConfiguration(cbh, clientSubject, enabled, mech, saslProperties, serverName != null ? serverName : DEFAULT_SERVER_NAME);
}
Also used : TokenCallbackHandler(org.infinispan.client.hotrod.security.TokenCallbackHandler) CallbackHandler(javax.security.auth.callback.CallbackHandler) BasicCallbackHandler(org.infinispan.client.hotrod.security.BasicCallbackHandler) TokenCallbackHandler(org.infinispan.client.hotrod.security.TokenCallbackHandler) VoidCallbackHandler(org.infinispan.client.hotrod.security.VoidCallbackHandler) BasicCallbackHandler(org.infinispan.client.hotrod.security.BasicCallbackHandler) VoidCallbackHandler(org.infinispan.client.hotrod.security.VoidCallbackHandler)

Example 2 with VoidCallbackHandler

use of org.infinispan.client.hotrod.security.VoidCallbackHandler in project infinispan by infinispan.

the class AuthenticationKerberosIT method testHotRod.

public void testHotRod() {
    ConfigurationBuilder builder = new ConfigurationBuilder();
    if (!mechanism.isEmpty()) {
        builder.security().authentication().saslMechanism(mechanism).serverName("datagrid").callbackHandler(new VoidCallbackHandler()).clientSubject(Common.createSubject("admin", "INFINISPAN.ORG", "strongPassword".toCharArray()));
    }
    try {
        RemoteCache<String, String> cache = SERVER_TEST.hotrod().withClientConfiguration(builder).withCacheMode(CacheMode.DIST_SYNC).create();
        cache.put("k1", "v1");
        assertEquals(1, cache.size());
        assertEquals("v1", cache.get("k1"));
    } catch (HotRodClientException e) {
        // Rethrow if unexpected
        if (!mechanism.isEmpty())
            throw e;
    }
}
Also used : RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) HotRodClientException(org.infinispan.client.hotrod.exceptions.HotRodClientException) VoidCallbackHandler(org.infinispan.client.hotrod.security.VoidCallbackHandler)

Example 3 with VoidCallbackHandler

use of org.infinispan.client.hotrod.security.VoidCallbackHandler in project infinispan by infinispan.

the class AuthorizationKerberosIT method addClientBuilders.

@Override
protected void addClientBuilders(TestUser user) {
    ConfigurationBuilder hotRodBuilder = new ConfigurationBuilder();
    RestClientConfigurationBuilder restBuilder = new RestClientConfigurationBuilder();
    if (user != TestUser.ANONYMOUS) {
        Subject subject = Common.createSubject(user.getUser(), "INFINISPAN.ORG", user.getPassword().toCharArray());
        hotRodBuilder.security().authentication().saslMechanism("GSSAPI").serverName("datagrid").realm("default").callbackHandler(new VoidCallbackHandler()).clientSubject(subject);
        restBuilder.security().authentication().mechanism("SPNEGO").clientSubject(subject);
    }
    hotRodBuilders.put(user, hotRodBuilder);
    restBuilders.put(user, restBuilder);
}
Also used : ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) VoidCallbackHandler(org.infinispan.client.hotrod.security.VoidCallbackHandler) Subject(javax.security.auth.Subject)

Aggregations

VoidCallbackHandler (org.infinispan.client.hotrod.security.VoidCallbackHandler)3 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)2 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)2 Subject (javax.security.auth.Subject)1 CallbackHandler (javax.security.auth.callback.CallbackHandler)1 HotRodClientException (org.infinispan.client.hotrod.exceptions.HotRodClientException)1 BasicCallbackHandler (org.infinispan.client.hotrod.security.BasicCallbackHandler)1 TokenCallbackHandler (org.infinispan.client.hotrod.security.TokenCallbackHandler)1