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);
}
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;
}
}
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);
}
Aggregations