use of org.infinispan.security.AuthorizationPermission in project infinispan by infinispan.
the class BackupWithSecurityTest method defaultGlobalConfigurationForSite.
@Override
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;
}
use of org.infinispan.security.AuthorizationPermission 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.security.AuthorizationPermission in project infinispan by infinispan.
the class AbstractInfinispanServerDriver method createUserFile.
protected void createUserFile(String realm) {
// Create users and groups for individual permissions
UserTool userTool = new UserTool(rootDir.getAbsolutePath());
for (AuthorizationPermission permission : AuthorizationPermission.values()) {
String name = permission.name().toLowerCase();
userTool.createUser(name + "_user", name, realm, UserTool.Encryption.DEFAULT, Collections.singletonList(name), null);
}
// Create users with composite roles
for (TestUser user : TestUser.values()) {
if (user != TestUser.ANONYMOUS) {
userTool.createUser(user.getUser(), user.getPassword(), realm, UserTool.Encryption.DEFAULT, user.getRoles(), null);
}
}
}
use of org.infinispan.security.AuthorizationPermission in project infinispan by infinispan.
the class SecurityRealmServerListener method before.
@Override
public void before(InfinispanServerDriver driver) {
UserTool userTool = new UserTool(driver.getRootDir().getAbsolutePath(), realm + "-users.properties", realm + "-groups.properties");
// Create users and groups for individual permissions
for (AuthorizationPermission permission : AuthorizationPermission.values()) {
String name = permission.name().toLowerCase();
userTool.createUser(username(name + "_user"), name, realm, UserTool.Encryption.DEFAULT, Collections.singletonList(name), null);
}
// Create users with composite roles
for (TestUser user : TestUser.values()) {
if (user != TestUser.ANONYMOUS) {
userTool.createUser(username(user.getUser()), user.getPassword(), realm, UserTool.Encryption.DEFAULT, user.getRoles(), null);
}
}
}
use of org.infinispan.security.AuthorizationPermission 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;
}
});
}
Aggregations