Search in sources :

Example 11 with AccessControlEntry

use of com.enonic.xp.security.acl.AccessControlEntry 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();
}
Also used : ArrayList(java.util.ArrayList) IdProviderAccessControlEntry(com.enonic.xp.security.acl.IdProviderAccessControlEntry) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry) IdProviderAccessControlEntry(com.enonic.xp.security.acl.IdProviderAccessControlEntry)

Example 12 with AccessControlEntry

use of com.enonic.xp.security.acl.AccessControlEntry 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();
}
Also used : ArrayList(java.util.ArrayList) IdProviderAccessControlEntry(com.enonic.xp.security.acl.IdProviderAccessControlEntry) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry) IdProviderAccessControlEntry(com.enonic.xp.security.acl.IdProviderAccessControlEntry)

Example 13 with AccessControlEntry

use of com.enonic.xp.security.acl.AccessControlEntry 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();
}
Also used : ArrayList(java.util.ArrayList) IdProviderAccessControlEntry(com.enonic.xp.security.acl.IdProviderAccessControlEntry) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry) IdProviderAccessControlEntry(com.enonic.xp.security.acl.IdProviderAccessControlEntry)

Example 14 with AccessControlEntry

use of com.enonic.xp.security.acl.AccessControlEntry in project xp by enonic.

the class SecurityInitializer method initializeIdProviderParentFolder.

private void initializeIdProviderParentFolder() {
    final NodePath idProviderParentNodePath = IdProviderNodeTranslator.getIdProvidersParentPath();
    LOG.info("Initializing [" + idProviderParentNodePath.toString() + "] folder");
    final AccessControlEntry userManagerFullAccess = AccessControlEntry.create().allowAll().principal(RoleKeys.USER_MANAGER_ADMIN).build();
    final ChildOrder childOrder = ChildOrder.create().add(FieldOrderExpr.create(NodeIndexPath.NAME, OrderExpr.Direction.ASC)).build();
    nodeService.create(CreateNodeParams.create().parent(idProviderParentNodePath.getParentPath()).name(idProviderParentNodePath.getLastElement().toString()).permissions(AccessControlList.create().addAll(SystemConstants.SYSTEM_REPO_DEFAULT_ACL.getEntries()).add(userManagerFullAccess).build()).inheritPermissions(false).childOrder(childOrder).build());
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) IdProviderAccessControlEntry(com.enonic.xp.security.acl.IdProviderAccessControlEntry) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry) NodePath(com.enonic.xp.node.NodePath)

Example 15 with AccessControlEntry

use of com.enonic.xp.security.acl.AccessControlEntry in project xp by enonic.

the class ContentAuditLogSupportImpl method doApplyPermissions.

private void doApplyPermissions(final ApplyContentPermissionsParams params, final ApplyContentPermissionsResult result, final Context rootContext) {
    final PropertyTree data = new PropertyTree();
    final PropertySet paramsSet = data.addSet("params");
    final PropertySet resultSet = data.addSet("result");
    paramsSet.addString("contentId", nullToNull(params.getContentId()));
    paramsSet.addBoolean("inheritPermissions", params.isInheritPermissions());
    paramsSet.addBoolean("overwriteChildPermissions", params.isOverwriteChildPermissions());
    if (params.getPermissions() != null) {
        paramsSet.addStrings("permissions", params.getPermissions().getEntries().stream().map(AccessControlEntry::toString).collect(Collectors.toList()));
    }
    addContents(resultSet, result.getSkippedContents(), "skippedContents");
    addContents(resultSet, result.getSucceedContents(), "succeedContents");
    log("system.content.applyPermissions", data, result.getSucceedContents(), rootContext);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry)

Aggregations

AccessControlEntry (com.enonic.xp.security.acl.AccessControlEntry)16 PropertyTree (com.enonic.xp.data.PropertyTree)4 AccessControlList (com.enonic.xp.security.acl.AccessControlList)4 IdProviderAccessControlEntry (com.enonic.xp.security.acl.IdProviderAccessControlEntry)4 ArrayList (java.util.ArrayList)4 PropertySet (com.enonic.xp.data.PropertySet)3 PrincipalKey (com.enonic.xp.security.PrincipalKey)3 IndexConfig (com.enonic.xp.index.IndexConfig)2 AttachedBinary (com.enonic.xp.node.AttachedBinary)2 Permission (com.enonic.xp.security.acl.Permission)2 Test (org.junit.jupiter.api.Test)2 ContentId (com.enonic.xp.content.ContentId)1 Value (com.enonic.xp.data.Value)1 ChildOrder (com.enonic.xp.index.ChildOrder)1 IndexValueProcessor (com.enonic.xp.index.IndexValueProcessor)1 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)1 NodePath (com.enonic.xp.node.NodePath)1 NodeVersion (com.enonic.xp.node.NodeVersion)1 IndexItem (com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexItem)1 IndexItemString (com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexItemString)1