APISonar


org.infinispan.client.rest.configuration.RestClientConfigurationBuilder.security

> org > infinispan > client > rest > configuration > RestClientConfigurationBuilder > security
org APIs infinispan APIs client APIs rest APIs configuration APIs RestClientConfigurationBuilder APIs security APIs

Example 1
public void testUrlWithSSL() throws NoSuchAlgorithmException {
      RestConnector connector = new RestConnector();
      RestConnection connection = (RestConnection) connector.getConnection("https://localhost", null);
      RestClientConfigurationBuilder builder = connection.getBuilder();
      builder.security().ssl().sslContext(SSLContext.getDefault()).trustManagers(new TrustManager[]{new ZeroSecurityTrustManager()});
      RestClientConfiguration configuration = builder.build();
      assertEquals(443, configuration.servers().get(0).port());
      assertEquals("localhost", configuration.servers().get(0).host());
      assertFalse(configuration.security().authentication().enabled());
      assertTrue(configuration.security().ssl().enabled());
   }
Example 2
private final RestClientConfigurationBuilder builder;

   public void connect(String username, String password) throws IOException {
      builder.security().authentication().enable().username(username).password(password);
      client = RestClient.forConfiguration(builder.build());
      connectInternal();
   }
Example 3
public void testRestReadWrite() {
      String token = KEYCLOAK.getAccessTokenForCredentials("infinispan", "infinispan-client", "8a43581d-62d7-47dc-9aa4-cd3af24b6083", "admin", "adminPassword");

      RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
      builder.security().authentication()
            .mechanism("BEARER_TOKEN")
            .username(token);
      RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).create();
      RestResponse response = sync(client.cache(SERVER_TEST.getMethodName()).post("k1", "v1"));

      assertEquals(204, response.getStatus());
      response = sync(client.cache(SERVER_TEST.getMethodName()).get("k1"));
      assertEquals(200, response.getStatus());
      assertEquals("v1", response.getBody());
   }