I'm asking if there any way to get user's permissions inherited from his assigned roles and groups.
When I assign a permission to a specific role and assign one user to this role I'm unable to get permissions inherited from its role.
User john = new User("john");
john.setEmail("john@acme.com");
john.setFirstName("John");
john.setLastName("Smith");
IdentityManager identityManager = this.partitionManager.createIdentityManager();
identityManager.add(john);
identityManager.updateCredential(john, new Password("demo"));
Role superuser = new Role("superuser");
identityManager.add(superuser);
Role superuser = new Role("superuser");
identityManager.add(superuser);
// Create group "sales"
Group sales = new Group("sales");
identityManager.add(sales);
RelationshipManager relationshipManager = this.partitionManager.createRelationshipManager();
PermissionManager permissionManager = partitionManager.createPermissionManager();
// Make john a member of the "sales" group
addToGroup(relationshipManager, john, sales);
// Make mary a manager of the "sales" group
grantGroupRole(relationshipManager, john, superuser, sales);
// Grant the "superuser" application role to john
grantRole(relationshipManager, john, superuser);
// permissionManager.grantPermission(john, "ticket", "read");
//permissionManager.grantPermission(sales,"ticket", "read");
permissionManager.grantPermission(sales,"ticket", "read");
List<Permission> permissionsList=permissionManager.listPermissions(john);
if (permissionsList==null || permissionsList.isEmpty())
System.err.println("User John doesn't have a permission list");
for (Permission per:permissionsList){
System.out.println("User John permitted: "+per.getOperation()+" on "+per.getResource());
}
This is the output:
11:38:07,102 ERROR [stderr] (ServerService Thread Pool -- 110) User John doesn't have a permission list
Is there any API to resolve this?