use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class AbstractAuthorization method addClientBuilders.
protected void addClientBuilders(TestUser user) {
ConfigurationBuilder hotRodBuilder = new ConfigurationBuilder();
hotRodBuilder.security().authentication().saslMechanism(System.getProperty(HOTROD_CLIENT_SASL_MECHANISM, "SCRAM-SHA-1")).serverName("infinispan").realm("default").username(user.getUser()).password(user.getPassword());
hotRodBuilders.put(user, hotRodBuilder);
RestClientConfigurationBuilder restBuilder = new RestClientConfigurationBuilder();
restBuilder.security().authentication().mechanism("AUTO").username(user.getUser()).password(user.getPassword());
restBuilders.put(user, restBuilder);
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class AuthorizationCertIT method addClientBuilders.
@Override
protected void addClientBuilders(TestUser user) {
ConfigurationBuilder hotRodBuilder = new ConfigurationBuilder();
SERVERS.getServerDriver().applyTrustStore(hotRodBuilder, "ca");
if (user == TestUser.ANONYMOUS) {
SERVERS.getServerDriver().applyKeyStore(hotRodBuilder, "server");
} else {
SERVERS.getServerDriver().applyKeyStore(hotRodBuilder, user.getUser());
}
hotRodBuilder.security().authentication().saslMechanism("EXTERNAL").serverName("infinispan").realm("default");
hotRodBuilders.put(user, hotRodBuilder);
RestClientConfigurationBuilder restBuilder = new RestClientConfigurationBuilder();
SERVERS.getServerDriver().applyTrustStore(restBuilder, "ca");
if (user == TestUser.ANONYMOUS) {
SERVERS.getServerDriver().applyKeyStore(restBuilder, "server");
} else {
SERVERS.getServerDriver().applyKeyStore(restBuilder, user.getUser());
}
restBuilder.security().authentication().ssl().sniHostName("infinispan").hostnameVerifier((hostname, session) -> true).connectionTimeout(120_000).socketTimeout(120_000);
restBuilders.put(user, restBuilder);
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class GracefulShutdownRestartIT method testGracefulShutdownRestart.
@Test
public void testGracefulShutdownRestart() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC).persistence().addSingleFileStore().segmented(false);
RemoteCache<Object, Object> hotRod = SERVER_TEST.hotrod().withServerConfiguration(builder).create();
for (int i = 0; i < 100; i++) {
hotRod.put(String.format("k%03d", i), String.format("v%03d", i));
}
RestClientConfigurationBuilder restClientBuilder = new RestClientConfigurationBuilder().socketTimeout(RestClientConfigurationProperties.DEFAULT_SO_TIMEOUT * 60).connectionTimeout(RestClientConfigurationProperties.DEFAULT_CONNECT_TIMEOUT * 60);
RestClient rest = SERVER_TEST.rest().withClientConfiguration(restClientBuilder).get();
sync(rest.cluster().stop(), 5, TimeUnit.MINUTES);
ContainerInfinispanServerDriver serverDriver = (ContainerInfinispanServerDriver) SERVER.getServerDriver();
Eventually.eventually("Cluster did not shutdown within timeout", () -> (!serverDriver.isRunning(0) && !serverDriver.isRunning(1)), serverDriver.getTimeout(), 1, TimeUnit.SECONDS);
serverDriver.restartCluster();
for (int i = 0; i < 100; i++) {
assertEquals(String.format("v%03d", i), hotRod.get(String.format("k%03d", i)));
}
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class RestAuthentication method testRestReadWrite.
@Test
public void testRestReadWrite() {
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
if (!mechanism.isEmpty()) {
builder.protocol(protocol).security().authentication().mechanism(mechanism).realm("default").username("all_user").password("all");
}
if (mechanism.isEmpty()) {
Exceptions.expectException(SecurityException.class, () -> SERVER_TEST.rest().withClientConfiguration(builder).create());
} else {
RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).create();
RestResponse response = sync(client.cache(SERVER_TEST.getMethodName()).post("k1", "v1"));
assertEquals(204, response.getStatus());
assertEquals(protocol, response.getProtocol());
response = sync(client.cache(SERVER_TEST.getMethodName()).get("k1"));
assertEquals(200, response.getStatus());
assertEquals(protocol, response.getProtocol());
assertEquals("v1", response.getBody());
}
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class AuthenticationMultiEndpointIT method testRest.
private void testRest() {
Protocol proto = Protocol.valueOf(protocol);
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder().followRedirects(false);
if (useAuth) {
builder.protocol(proto).security().authentication().mechanism(mechanism).realm(realm).username(userPrefix + "all_user").password("all");
}
try {
RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).withPort(port).create();
validateSuccess();
RestResponse response = sync(client.cache(SERVER_TEST.getMethodName()).post("k1", "v1"));
assertEquals(204, response.getStatus());
assertEquals(proto, response.getProtocol());
response = sync(client.cache(SERVER_TEST.getMethodName()).get("k1"));
assertEquals(200, response.getStatus());
assertEquals(proto, response.getProtocol());
assertEquals("v1", response.getBody());
response = sync(client.raw().get("/"));
assertEquals(isAdmin ? 307 : 404, response.getStatus());
response = sync(client.server().info());
assertEquals(isAdmin ? 200 : 404, response.getStatus());
} catch (SecurityException e) {
validateException(e);
}
}
Aggregations