use of com.enonic.xp.security.acl.IdProviderAccessControlEntry in project xp by enonic.
the class IdProviderNodeTranslator method idProviderPermissionsFromNode.
static IdProviderAccessControlList idProviderPermissionsFromNode(final Node idProviderNode, final Node usersNode, final Node groupsNode) {
final IdProviderAccessControlList.Builder acl = IdProviderAccessControlList.create();
final AccessControlList idProviderPermissions = idProviderNode.getPermissions();
final AccessControlList usersPermissions = usersNode.getPermissions();
final AccessControlList groupsPermissions = groupsNode.getPermissions();
final PrincipalKeys principals = PrincipalKeys.from(idProviderPermissions.getAllPrincipals(), usersPermissions.getAllPrincipals(), groupsPermissions.getAllPrincipals());
for (PrincipalKey principal : principals) {
if (idProviderPermissions.isAllowedFor(principal, READ, CREATE, MODIFY, DELETE, PUBLISH, READ_PERMISSIONS, WRITE_PERMISSIONS) && usersPermissions.isAllowedFor(principal, READ, CREATE, MODIFY, DELETE, PUBLISH, READ_PERMISSIONS, WRITE_PERMISSIONS) && groupsPermissions.isAllowedFor(principal, READ, CREATE, MODIFY, DELETE, PUBLISH, READ_PERMISSIONS, WRITE_PERMISSIONS)) {
final IdProviderAccessControlEntry access = IdProviderAccessControlEntry.create().principal(principal).access(ADMINISTRATOR).build();
acl.add(access);
} else if (usersPermissions.isAllowedFor(principal, READ, CREATE, MODIFY, DELETE) && groupsPermissions.isAllowedFor(principal, READ, CREATE, MODIFY, DELETE)) {
final IdProviderAccessControlEntry access = IdProviderAccessControlEntry.create().principal(principal).access(ID_PROVIDER_MANAGER).build();
acl.add(access);
} else if (usersPermissions.isAllowedFor(principal, READ, CREATE, MODIFY, DELETE)) {
final IdProviderAccessControlEntry access = IdProviderAccessControlEntry.create().principal(principal).access(WRITE_USERS).build();
acl.add(access);
} else if (usersPermissions.isAllowedFor(principal, CREATE)) {
final IdProviderAccessControlEntry access = IdProviderAccessControlEntry.create().principal(principal).access(CREATE_USERS).build();
acl.add(access);
} else if (usersPermissions.isAllowedFor(principal, READ)) {
final IdProviderAccessControlEntry access = IdProviderAccessControlEntry.create().principal(principal).access(IdProviderAccess.READ).build();
acl.add(access);
}
}
return acl.build();
}
use of com.enonic.xp.security.acl.IdProviderAccessControlEntry in project xp by enonic.
the class IdProviderNodeTranslator method idProviderPermissionsToUsersNodePermissions.
static AccessControlList idProviderPermissionsToUsersNodePermissions(final IdProviderAccessControlList idProviderPermissions) {
final List<AccessControlEntry> entries = new ArrayList<>();
for (IdProviderAccessControlEntry entry : idProviderPermissions) {
final AccessControlEntry ace;
switch(entry.getAccess()) {
case CREATE_USERS:
ace = AccessControlEntry.create().principal(entry.getPrincipal()).allow(CREATE).build();
entries.add(ace);
break;
case WRITE_USERS:
ace = AccessControlEntry.create().principal(entry.getPrincipal()).allow(READ, CREATE, MODIFY, DELETE).build();
entries.add(ace);
break;
case ID_PROVIDER_MANAGER:
ace = AccessControlEntry.create().principal(entry.getPrincipal()).allow(READ, CREATE, MODIFY, DELETE).build();
entries.add(ace);
break;
case ADMINISTRATOR:
ace = AccessControlEntry.create().principal(entry.getPrincipal()).allow(READ, CREATE, MODIFY, DELETE, PUBLISH, READ_PERMISSIONS, WRITE_PERMISSIONS).build();
entries.add(ace);
break;
case READ:
ace = AccessControlEntry.create().principal(entry.getPrincipal()).allow(READ).build();
entries.add(ace);
break;
}
}
return AccessControlList.create().addAll(entries).build();
}
use of com.enonic.xp.security.acl.IdProviderAccessControlEntry in project xp by enonic.
the class IdProviderNodeTranslator method idProviderPermissionsToGroupsNodePermissions.
static AccessControlList idProviderPermissionsToGroupsNodePermissions(final IdProviderAccessControlList idProviderPermissions) {
final List<AccessControlEntry> entries = new ArrayList<>();
for (IdProviderAccessControlEntry entry : idProviderPermissions) {
final AccessControlEntry ace;
switch(entry.getAccess()) {
case ID_PROVIDER_MANAGER:
ace = AccessControlEntry.create().principal(entry.getPrincipal()).allow(READ, CREATE, MODIFY, DELETE).build();
entries.add(ace);
break;
case ADMINISTRATOR:
ace = AccessControlEntry.create().principal(entry.getPrincipal()).allow(READ, CREATE, MODIFY, DELETE, PUBLISH, READ_PERMISSIONS, WRITE_PERMISSIONS).build();
entries.add(ace);
break;
}
}
return AccessControlList.create().addAll(entries).build();
}
use of com.enonic.xp.security.acl.IdProviderAccessControlEntry in project xp by enonic.
the class IdProviderNodeTranslator method idProviderPermissionsToIdProviderNodePermissions.
static AccessControlList idProviderPermissionsToIdProviderNodePermissions(final IdProviderAccessControlList idProviderPermissions) {
final List<AccessControlEntry> entries = new ArrayList<>();
for (IdProviderAccessControlEntry entry : idProviderPermissions) {
if (entry.getAccess() == ADMINISTRATOR) {
final AccessControlEntry ace = AccessControlEntry.create().principal(entry.getPrincipal()).allow(READ, CREATE, MODIFY, DELETE, PUBLISH, READ_PERMISSIONS, WRITE_PERMISSIONS).build();
entries.add(ace);
}
}
return AccessControlList.create().addAll(entries).build();
}
Aggregations