use of org.keycloak.admin.client.resource.PoliciesResource in project keycloak by keycloak.
the class ResourcePermissionManagementTest method configureTest.
@Before
public void configureTest() {
super.configureTest();
RolesResource realmRoles = testRealmResource().roles();
realmRoles.create(new RoleRepresentation("Role A", "", false));
realmRoles.create(new RoleRepresentation("Role B", "", false));
RolePolicyRepresentation policyA = new RolePolicyRepresentation();
policyA.setName("Policy A");
policyA.addRole("Role A");
AuthorizationResource authorization = testRealmResource().clients().get(newClient.getId()).authorization();
PoliciesResource policies = authorization.policies();
RolePoliciesResource roles = policies.role();
roles.create(policyA);
RolePolicyRepresentation policyB = new RolePolicyRepresentation();
policyB.setName("Policy B");
policyB.addRole("Role B");
roles.create(policyB);
UserPolicyRepresentation policyC = new UserPolicyRepresentation();
policyC.setName("Policy C");
policyC.addUser("test");
policies.user().create(policyC).close();
ResourcesResource resources = authorization.resources();
resources.create(new ResourceRepresentation("Resource A"));
resources.create(new ResourceRepresentation("Resource B"));
}
use of org.keycloak.admin.client.resource.PoliciesResource in project keycloak by keycloak.
the class AggregatePolicyManagementTest method configureTest.
@Before
public void configureTest() {
super.configureTest();
RealmResource realmResource = testRealmResource();
RolesResource realmRoles = realmResource.roles();
realmRoles.create(new RoleRepresentation("Role A", "", false));
realmRoles.create(new RoleRepresentation("Role B", "", false));
UsersResource users = realmResource.users();
users.create(UserBuilder.create().username("user a").build());
ClientsResource clients = realmResource.clients();
clients.create(ClientBuilder.create().clientId("client a").build());
realmResource.groups().add(GroupBuilder.create().name("Group A").build());
RolePolicyRepresentation policyA = new RolePolicyRepresentation();
policyA.setName("Policy A");
policyA.addRole("Role A");
AuthorizationResource authorization = realmResource.clients().get(newClient.getId()).authorization();
PoliciesResource policies = authorization.policies();
RolePoliciesResource roles = policies.role();
roles.create(policyA);
RolePolicyRepresentation policyB = new RolePolicyRepresentation();
policyB.setName("Policy B");
policyB.addRole("Role B");
roles.create(policyB);
UserPolicyRepresentation policyC = new UserPolicyRepresentation();
policyC.setName("Policy C");
policyC.addUser("test");
policies.user().create(policyC).close();
}
Aggregations