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);
}
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;
}
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();
}
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;
}
});
}
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);
}
Aggregations