Search in sources :

Example 1 with AuthorizationConfigurationBuilder

use of org.infinispan.configuration.cache.AuthorizationConfigurationBuilder in project infinispan by infinispan.

the class CustomAuditLoggerTest method createCacheManager.

@Override
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);
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) IdentityRoleMapper(org.infinispan.security.mappers.IdentityRoleMapper) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder)

Example 2 with AuthorizationConfigurationBuilder

use of org.infinispan.configuration.cache.AuthorizationConfigurationBuilder in project infinispan by infinispan.

the class BackupWithSecurityTest method defaultConfigurationForSite.

@Override
protected ConfigurationBuilder defaultConfigurationForSite(int siteIndex) {
    ConfigurationBuilder builder = super.defaultConfigurationForSite(siteIndex);
    AuthorizationConfigurationBuilder authConfig = builder.security().authorization().enable();
    for (AuthorizationPermission perm : AuthorizationPermission.values()) {
        authConfig.role(perm.toString());
    }
    return builder;
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder) AuthorizationPermission(org.infinispan.security.AuthorizationPermission) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder)

Example 3 with AuthorizationConfigurationBuilder

use of org.infinispan.configuration.cache.AuthorizationConfigurationBuilder in project infinispan by infinispan.

the class AbstractAuthorization method hotRodCreateAuthzCache.

private <K, V> RemoteCache<K, V> hotRodCreateAuthzCache(String... explicitRoles) {
    org.infinispan.configuration.cache.ConfigurationBuilder builder = new org.infinispan.configuration.cache.ConfigurationBuilder();
    AuthorizationConfigurationBuilder authorizationConfigurationBuilder = builder.clustering().cacheMode(CacheMode.DIST_SYNC).security().authorization().enable();
    if (explicitRoles != null) {
        for (String role : explicitRoles) {
            authorizationConfigurationBuilder.role(role);
        }
    }
    return getServerTest().hotrod().withClientConfiguration(hotRodBuilders.get(TestUser.ADMIN)).withServerConfiguration(builder).create();
}
Also used : RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder) ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder)

Example 4 with AuthorizationConfigurationBuilder

use of org.infinispan.configuration.cache.AuthorizationConfigurationBuilder in project infinispan by infinispan.

the class AbstractAuthentication method setupCache.

@Before
public void setupCache() throws Exception {
    // global setup
    globalConfig = new GlobalConfigurationBuilder();
    GlobalAuthorizationConfigurationBuilder globalRoles = globalConfig.security().authorization().enable().principalRoleMapper(getPrincipalRoleMapper());
    // cache setup
    cacheConfig = new ConfigurationBuilder();
    cacheConfig.transaction().lockingMode(LockingMode.PESSIMISTIC);
    cacheConfig.invocationBatching().enable();
    AuthorizationConfigurationBuilder authConfig = cacheConfig.security().authorization().enable();
    // authorization setup
    Map<String, AuthorizationPermission[]> rolePermissionMap = getRolePermissionMap();
    for (Entry<String, AuthorizationPermission[]> role : rolePermissionMap.entrySet()) {
        authConfig = authConfig.role(role.getKey());
        GlobalRoleConfigurationBuilder roleBuilder = globalRoles.role(role.getKey());
        for (AuthorizationPermission permission : role.getValue()) {
            roleBuilder = roleBuilder.permission(permission);
        }
    }
    Subject admin = getAdminSubject();
    Security.doAs(admin, new PrivilegedExceptionAction<Void>() {

        public Void run() {
            manager = new DefaultCacheManager(globalConfig.build());
            manager.defineConfiguration(CACHE_NAME, cacheConfig.build());
            secureCache = manager.getCache(CACHE_NAME);
            secureCache.put(TEST_ENTRY_KEY, TEST_ENTRY_VALUE);
            return null;
        }
    });
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) GlobalRoleConfigurationBuilder(org.infinispan.configuration.global.GlobalRoleConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) AuthorizationPermission(org.infinispan.security.AuthorizationPermission) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder) Subject(javax.security.auth.Subject) GlobalRoleConfigurationBuilder(org.infinispan.configuration.global.GlobalRoleConfigurationBuilder) Before(org.junit.Before)

Example 5 with AuthorizationConfigurationBuilder

use of org.infinispan.configuration.cache.AuthorizationConfigurationBuilder in project infinispan by infinispan.

the class RolePermissionTest method createCacheManager.

@Override
protected EmbeddedCacheManager createCacheManager() throws Exception {
    GlobalConfigurationBuilder global = new GlobalConfigurationBuilder();
    GlobalAuthorizationConfigurationBuilder globalRoles = global.security().authorization().enable().principalRoleMapper(new IdentityRoleMapper());
    ConfigurationBuilder config = TestCacheManagerFactory.getDefaultCacheConfiguration(true);
    AuthorizationConfigurationBuilder authConfig = config.security().authorization().enable();
    globalRoles.role("role1").permission(AuthorizationPermission.EXEC).role("role2").permission(AuthorizationPermission.EXEC).role("admin").permission(AuthorizationPermission.ALL);
    authConfig.role("role1").role("role2").role("admin");
    return TestCacheManagerFactory.createCacheManager(global, config);
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) IdentityRoleMapper(org.infinispan.security.mappers.IdentityRoleMapper) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) GlobalAuthorizationConfigurationBuilder(org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder)

Aggregations

AuthorizationConfigurationBuilder (org.infinispan.configuration.cache.AuthorizationConfigurationBuilder)14 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)12 GlobalAuthorizationConfigurationBuilder (org.infinispan.configuration.global.GlobalAuthorizationConfigurationBuilder)10 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)10 IdentityRoleMapper (org.infinispan.security.mappers.IdentityRoleMapper)6 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)2 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)2 GlobalAuthorizationConfiguration (org.infinispan.configuration.global.GlobalAuthorizationConfiguration)2 AuthorizationPermission (org.infinispan.security.AuthorizationPermission)2 CreatePermissionConfigurationBuilder (org.infinispan.security.impl.CreatePermissionConfigurationBuilder)2 Subject (javax.security.auth.Subject)1 CacheMode (org.infinispan.configuration.cache.CacheMode)1 GlobalRoleConfigurationBuilder (org.infinispan.configuration.global.GlobalRoleConfigurationBuilder)1 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 Before (org.junit.Before)1