APISonar


org.infinispan.configuration.global.GlobalConfigurationBuilder.security

> org > infinispan > configuration > global > GlobalConfigurationBuilder > security
org APIs infinispan APIs configuration APIs global APIs GlobalConfigurationBuilder APIs security APIs

Example 1
protected void createCacheManagers() throws Throwable {
      final GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
      final ConfigurationBuilder builder = getDefaultClusteredCacheConfig(getCacheMode());
      global.security().authorization().enable()
            .principalRoleMapper(new IdentityRoleMapper()).role("admin").permission(AuthorizationPermission.ALL);
      builder.security().authorization().enable().role("admin");
      Security.doAs(ADMIN, (PrivilegedExceptionAction<Void>) () -> {
         createCluster(global, builder, 2);
         waitForClusterToForm();
         return null;
      });
   }
Example 2
public void testGlobalAuthorization() throws IOException {
      GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder().clusteredDefault();
      builder.security().authorization().principalRoleMapper(new DummyRoleMapper()).create();

      String toJSON = jsonWriter.toJSON(builder.build());

      JsonNode node = new ObjectMapper().readTree(toJSON);
      JsonNode authz = node.get("infinispan").get("cache-container").get("security").get("authorization");

      assertEquals(DummyRoleMapper.class.getName(), authz.get("custom-role-mapper").get("class").asText());
   }
Example 3
protected EmbeddedCacheManager createCacheManager() throws Exception {
      GlobalConfigurationBuilder global = new GlobalConfigurationBuilder();
      GlobalAuthorizationConfigurationBuilder globalRoles = global.security().authorization().enable()
            .principalRoleMapper(new IdentityRoleMapper()).auditLogger(LOGGER);
      ConfigurationBuilder config = TestCacheManagerFactory.getDefaultCacheConfiguration(true);
      AuthorizationConfigurationBuilder authConfig = config.security().authorization().enable();

      globalRoles.role(ADMIN_ROLE).permission(AuthorizationPermission.ALL).role(READER_ROLE)
            .permission(AuthorizationPermission.READ);
      authConfig.role(ADMIN_ROLE).role(READER_ROLE);
      return TestCacheManagerFactory.createCacheManager(global, config);
   }
Example 4
protected GlobalConfigurationBuilder defaultGlobalConfigurationForSite(int siteIndex) {
      GlobalConfigurationBuilder builder = super.defaultGlobalConfigurationForSite(siteIndex);

      GlobalAuthorizationConfigurationBuilder globalRoles = builder.security().authorization().enable().principalRoleMapper(new IdentityRoleMapper());
      for (AuthorizationPermission perm : AuthorizationPermission.values()) {
         globalRoles.role(perm.toString()).permission(perm);
      }
      return builder;
   }