Search in sources :

Example 41 with NodePath

use of com.enonic.xp.node.NodePath in project xp by enonic.

the class SecurityInitializer method initializeRoleFolder.

private void initializeRoleFolder() {
    final NodePath rolesNodePath = IdProviderNodeTranslator.getRolesNodePath();
    LOG.info("Initializing [" + rolesNodePath + "] folder");
    nodeService.create(CreateNodeParams.create().parent(rolesNodePath.getParentPath()).name(rolesNodePath.getLastElement().toString()).inheritPermissions(true).build());
}
Also used : NodePath(com.enonic.xp.node.NodePath)

Example 42 with NodePath

use of com.enonic.xp.node.NodePath 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 43 with NodePath

use of com.enonic.xp.node.NodePath in project xp by enonic.

the class SecurityServiceImpl method deleteIdProvider.

@Override
public void deleteIdProvider(final IdProviderKey idProviderKey) {
    removeRelationships(idProviderKey);
    final NodeIds deletedNodes = callWithContext(() -> {
        final NodePath idProviderNodePath = IdProviderNodeTranslator.toIdProviderNodePath(idProviderKey);
        final Node node = this.nodeService.getByPath(idProviderNodePath);
        if (node == null) {
            return null;
        }
        return this.nodeService.deleteById(node.id());
    });
    if (deletedNodes == null) {
        throw new IdProviderNotFoundException(idProviderKey);
    }
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) IdProviderNotFoundException(com.enonic.xp.security.IdProviderNotFoundException) NodePath(com.enonic.xp.node.NodePath)

Example 44 with NodePath

use of com.enonic.xp.node.NodePath in project xp by enonic.

the class PrincipalKeyTest method testToPath.

@Test
public void testToPath() throws Exception {
    final PrincipalKey anonymous = PrincipalKey.from("user:system:anonymous");
    final PrincipalKey user = PrincipalKey.from("user:myIdProvider:myUser");
    final PrincipalKey group = PrincipalKey.from("group:myIdProvider:mygroup");
    final PrincipalKey role = PrincipalKey.from("role:myrole");
    assertEquals(new NodePath("/identity/system/users/anonymous"), anonymous.toPath());
    assertEquals(new NodePath("/identity/roles/myrole"), role.toPath());
    assertEquals(new NodePath("/identity/myIdProvider/groups/mygroup"), group.toPath());
    assertEquals(new NodePath("/identity/myIdProvider/users/myUser"), user.toPath());
}
Also used : NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 45 with NodePath

use of com.enonic.xp.node.NodePath in project xp by enonic.

the class ApplicationRepoInitializer method initApplicationFolder.

private void initApplicationFolder() {
    final NodePath applicationsRootPath = ApplicationRepoServiceImpl.APPLICATION_PATH;
    LOG.info("Initializing [" + applicationsRootPath + "] folder");
    nodeService.create(CreateNodeParams.create().parent(applicationsRootPath.getParentPath()).name(applicationsRootPath.getLastElement().toString()).inheritPermissions(true).build());
}
Also used : NodePath(com.enonic.xp.node.NodePath)

Aggregations

NodePath (com.enonic.xp.node.NodePath)54 Node (com.enonic.xp.node.Node)27 Test (org.junit.jupiter.api.Test)20 NodeId (com.enonic.xp.node.NodeId)15 InternalContext (com.enonic.xp.repo.impl.InternalContext)12 Content (com.enonic.xp.content.Content)7 Event (com.enonic.xp.event.Event)7 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)4 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)4 NodeVersionId (com.enonic.xp.node.NodeVersionId)4 ChildOrder (com.enonic.xp.index.ChildOrder)3 NodeIds (com.enonic.xp.node.NodeIds)3 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)2 ContentId (com.enonic.xp.content.ContentId)2 ContentPath (com.enonic.xp.content.ContentPath)2 CreateContentParams (com.enonic.xp.content.CreateContentParams)2 Context (com.enonic.xp.context.Context)2 PropertyTree (com.enonic.xp.data.PropertyTree)2 MoveNodeParams (com.enonic.xp.node.MoveNodeParams)2 NodeVersion (com.enonic.xp.node.NodeVersion)2