Search in sources :

Example 1 with SimpleServerAuthenticationProvider

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);
    }
}
Also used : PrivateGlobalConfigurationBuilder(org.infinispan.configuration.internal.PrivateGlobalConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) IdentityRoleMapper(org.infinispan.security.mappers.IdentityRoleMapper) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) PrivateGlobalConfigurationBuilder(org.infinispan.configuration.internal.PrivateGlobalConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) HotRodServerConfigurationBuilder(org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder) PrivateGlobalConfigurationBuilder(org.infinispan.configuration.internal.PrivateGlobalConfigurationBuilder) EmbeddedServerAdminOperationHandler(org.infinispan.server.core.admin.embeddedserver.EmbeddedServerAdminOperationHandler) PrivilegedActionException(java.security.PrivilegedActionException) HotRodServer(org.infinispan.server.hotrod.HotRodServer) SimpleServerAuthenticationProvider(org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider) HotRodServerConfigurationBuilder(org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 2 with SimpleServerAuthenticationProvider

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());
}
Also used : ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) HotRodServerConfigurationBuilder(org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder) SimpleServerAuthenticationProvider(org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider) HotRodServerConfigurationBuilder(org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder)

Example 3 with SimpleServerAuthenticationProvider

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;
}
Also used : SimpleServerAuthenticationProvider(org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider)

Example 4 with SimpleServerAuthenticationProvider

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;
}
Also used : SimpleServerAuthenticationProvider(org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider)

Example 5 with SimpleServerAuthenticationProvider

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;
}
Also used : SimpleServerAuthenticationProvider(org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider)

Aggregations

SimpleServerAuthenticationProvider (org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider)8 HotRodServerConfigurationBuilder (org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder)5 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)3 HotRodServer (org.infinispan.server.hotrod.HotRodServer)2 PrivilegedActionException (java.security.PrivilegedActionException)1 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 PrivateGlobalConfigurationBuilder (org.infinispan.configuration.internal.PrivateGlobalConfigurationBuilder)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 SecurityConfigurationBuilder (org.infinispan.persistence.remote.configuration.SecurityConfigurationBuilder)1 IdentityRoleMapper (org.infinispan.security.mappers.IdentityRoleMapper)1 EmbeddedServerAdminOperationHandler (org.infinispan.server.core.admin.embeddedserver.EmbeddedServerAdminOperationHandler)1