Search in sources :

Example 1 with UserTool

use of org.infinispan.cli.user.UserTool 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);
        }
    }
}
Also used : AuthorizationPermission(org.infinispan.security.AuthorizationPermission) UserTool(org.infinispan.cli.user.UserTool) TestUser(org.infinispan.server.test.api.TestUser)

Example 2 with UserTool

use of org.infinispan.cli.user.UserTool 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);
        }
    }
}
Also used : AuthorizationPermission(org.infinispan.security.AuthorizationPermission) UserTool(org.infinispan.cli.user.UserTool) TestUser(org.infinispan.server.test.api.TestUser)

Aggregations

UserTool (org.infinispan.cli.user.UserTool)2 AuthorizationPermission (org.infinispan.security.AuthorizationPermission)2 TestUser (org.infinispan.server.test.api.TestUser)2