Search in sources :

Example 1 with SecurityConfigurationBuilder

use of org.infinispan.persistence.remote.configuration.SecurityConfigurationBuilder in project infinispan by infinispan.

the class RemoteStoreSSLTest method buildConfig.

@Override
protected Configuration buildConfig(ConfigurationBuilder builder) {
    serverCacheManager = TestCacheManagerFactory.createCacheManager(new GlobalConfigurationBuilder().defaultCacheName(REMOTE_CACHE), hotRodCacheConfiguration(builder));
    ClassLoader cl = RemoteStoreSSLTest.class.getClassLoader();
    // Unfortunately BaseNonBlockingStoreTest stops and restarts the store, which can start a second hrServer - prevent that
    if (hrServer == null) {
        serverCache = serverCacheManager.getCache(REMOTE_CACHE);
        TestingUtil.replaceComponent(serverCacheManager, TimeService.class, timeService, true);
        SimpleServerAuthenticationProvider sap = new SimpleServerAuthenticationProvider();
        HotRodServerConfigurationBuilder serverBuilder = HotRodTestingUtil.getDefaultHotRodConfiguration();
        serverBuilder.ssl().enable().requireClientAuth(true).keyStoreFileName(cl.getResource("keystore_server.jks").getPath()).keyStorePassword("secret".toCharArray()).keyAlias("hotrod").trustStoreFileName(cl.getResource("ca.jks").getPath()).trustStorePassword("secret".toCharArray());
        serverBuilder.authentication().enable().serverName("localhost").addAllowedMech("EXTERNAL").serverAuthenticationProvider(sap);
        hrServer = new HotRodServer();
        hrServer.start(serverBuilder.build(), serverCacheManager);
    }
    SecurityConfigurationBuilder remoteSecurity = builder.persistence().addStore(RemoteStoreConfigurationBuilder.class).remoteCacheName(REMOTE_CACHE).shared(true).segmented(false).remoteSecurity();
    remoteSecurity.ssl().enable().keyStoreFileName(cl.getResource("keystore_client.jks").getPath()).keyStorePassword("secret".toCharArray()).trustStoreFileName(cl.getResource("ca.jks").getPath()).trustStorePassword("secret".toCharArray()).addServer().host(hrServer.getHost()).port(hrServer.getPort());
    remoteSecurity.authentication().enable().saslMechanism("EXTERNAL");
    return builder.build();
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) HotRodServer(org.infinispan.server.hotrod.HotRodServer) SimpleServerAuthenticationProvider(org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider) SecurityConfigurationBuilder(org.infinispan.persistence.remote.configuration.SecurityConfigurationBuilder) HotRodServerConfigurationBuilder(org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder)

Aggregations

GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)1 SecurityConfigurationBuilder (org.infinispan.persistence.remote.configuration.SecurityConfigurationBuilder)1 SimpleServerAuthenticationProvider (org.infinispan.server.core.security.simple.SimpleServerAuthenticationProvider)1 HotRodServer (org.infinispan.server.hotrod.HotRodServer)1 HotRodServerConfigurationBuilder (org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder)1