use of org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider in project infinispan by infinispan.
the class SecureRemoteCacheAdminTest method addHotRodServer.
@Override
protected HotRodServer addHotRodServer(ConfigurationBuilder builder) {
GlobalConfigurationBuilder gcb = GlobalConfigurationBuilder.defaultClusteredBuilder();
gcb.defaultCacheName("default");
gcb.addModule(PrivateGlobalConfigurationBuilder.class).serverMode(true);
gcb.security().authorization().enable().principalRoleMapper(new IdentityRoleMapper()).role("admin").permission(AuthorizationPermission.ALL);
gcb.serialization().addContextInitializer(contextInitializer());
ConfigurationBuilder template = new ConfigurationBuilder();
template.read(builder.build());
template.security().authorization().role("admin");
try {
EmbeddedCacheManager cm = Security.doPrivileged((PrivilegedExceptionAction<EmbeddedCacheManager>) () -> {
EmbeddedCacheManager cacheManager = addClusterEnabledCacheManager(gcb, builder);
cacheManager.defineConfiguration("template", builder.build());
cacheManager.defineConfiguration(DefaultTemplate.DIST_ASYNC.getTemplateName(), builder.build());
return cacheManager;
});
HotRodServerConfigurationBuilder serverBuilder = new HotRodServerConfigurationBuilder();
serverBuilder.adminOperationsHandler(new EmbeddedServerAdminOperationHandler());
SimpleServerAuthenticationProvider sap = new SimpleServerAuthenticationProvider();
sap.addUser("admin", "realm", "password".toCharArray(), "admin");
serverBuilder.authentication().enable().serverAuthenticationProvider(sap).serverName("localhost").addAllowedMech("CRAM-MD5");
HotRodServer server = Security.doPrivileged((PrivilegedExceptionAction<HotRodServer>) () -> HotRodClientTestingUtil.startHotRodServer(cm, serverBuilder));
servers.add(server);
return server;
} catch (PrivilegedActionException e) {
throw new RuntimeException(e);
}
}
use of org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider in project infinispan by infinispan.
the class SslAuthenticationTest method setup.
@Override
protected void setup() throws Exception {
Security.doAs(ADMIN, (PrivilegedExceptionAction<Object>) () -> {
cacheManager = createCacheManager();
if (cache == null)
cache = cacheManager.getCache();
return null;
});
HotRodServerConfigurationBuilder serverBuilder = HotRodTestingUtil.getDefaultHotRodConfiguration();
ClassLoader cl = SslAuthenticationTest.class.getClassLoader();
SimpleServerAuthenticationProvider sap = new SimpleServerAuthenticationProvider();
serverBuilder.ssl().enable().requireClientAuth(true).keyStoreFileName(cl.getResource("keystore_server.p12").getPath()).keyStorePassword("secret".toCharArray()).keyStoreType("pkcs12").keyAlias("hotrod").trustStoreFileName(cl.getResource("ca.p12").getPath()).trustStorePassword("secret".toCharArray()).trustStoreType("pkcs12");
serverBuilder.authentication().enable().serverName("localhost").addAllowedMech("EXTERNAL").serverAuthenticationProvider(sap);
Security.doAs(ADMIN, (PrivilegedExceptionAction<Object>) () -> {
hotrodServer = HotRodTestingUtil.startHotRodServer(cacheManager, serverBuilder);
return null;
});
log.info("Started server on port: " + hotrodServer.getPort());
ConfigurationBuilder clientBuilder = HotRodClientTestingUtil.newRemoteConfigurationBuilder();
clientBuilder.addServer().host("127.0.0.1").port(hotrodServer.getPort()).socketTimeout(3000).connectionPool().maxActive(1).security().authentication().enable().saslMechanism("EXTERNAL").ssl().enable().keyStoreFileName(cl.getResource("keystore_client.p12").getPath()).keyStorePassword("secret".toCharArray()).keyStoreType("pkcs12").keyAlias("client1").trustStoreFileName(cl.getResource("ca.p12").getPath()).trustStorePassword("secret".toCharArray()).trustStoreType("pkcs12");
remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
}
use of org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider in project infinispan by infinispan.
the class SecureExecTest method createAuthenticationProvider.
@Override
protected SimpleServerAuthenticationProvider createAuthenticationProvider() {
SimpleServerAuthenticationProvider sap = new SimpleServerAuthenticationProvider();
sap.addUser("RWEuser", "realm", "password".toCharArray(), null);
sap.addUser("RWuser", "realm", "password".toCharArray(), null);
return sap;
}
use of org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider in project infinispan by infinispan.
the class SecureListenerTest method createAuthenticationProvider.
@Override
protected SimpleServerAuthenticationProvider createAuthenticationProvider() {
SimpleServerAuthenticationProvider sap = new SimpleServerAuthenticationProvider();
sap.addUser("RWLuser", "realm", "password".toCharArray(), null);
sap.addUser("RWuser", "realm", "password".toCharArray(), null);
return sap;
}
use of org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider in project infinispan by infinispan.
the class AuthenticationTest method createAuthenticationProvider.
@Override
protected SimpleServerAuthenticationProvider createAuthenticationProvider() {
SimpleServerAuthenticationProvider sap = new SimpleServerAuthenticationProvider();
sap.addUser("user", "realm", "password".toCharArray());
return sap;
}
Aggregations