Package org.apache.jackrabbit.api.security.authorization

Examples of org.apache.jackrabbit.api.security.authorization.PrivilegeManager


                    (JackrabbitWorkspace) session.getWorkspace();

            NamespaceRegistry registry = workspace.getNamespaceRegistry();
            registry.registerNamespace("test", "http://www.example.org/");

            PrivilegeManager privilegeManager = workspace.getPrivilegeManager();
            privilegeManager.registerPrivilege("test:privilege", false, null);
            privilegeManager.registerPrivilege(
                    "test:aggregate", false, new String[] { "jcr:read", "test:privilege" });

            NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
            NodeTypeTemplate template = nodeTypeManager.createNodeTypeTemplate();
            template.setName("test:unstructured");
View Full Code Here


                        REP_INDEX_DEFINITION_MANAGEMENT, JCR_READ, JCR_MODIFY_PROPERTIES, JCR_WRITE, REP_WRITE});

        JackrabbitSession session = createAdminSession();
        try {
            JackrabbitWorkspace workspace = (JackrabbitWorkspace) session.getWorkspace();
            PrivilegeManager manager = workspace.getPrivilegeManager();
            Privilege[] privileges = manager.getRegisteredPrivileges();

            for (Privilege privilege : privileges) {
                if (privilege.isAggregate()) {
                    String[] expected = aggregatePrivileges.remove(privilege.getName());
                    if (expected != null) {
View Full Code Here

    public void verifyCustomPrivileges() throws Exception {
        JackrabbitSession session = createAdminSession();
        try {
            JackrabbitWorkspace workspace =
                    (JackrabbitWorkspace) session.getWorkspace();
            PrivilegeManager manager = workspace.getPrivilegeManager();

            Privilege privilege = manager.getPrivilege("test:privilege");
            assertNotNull(privilege);
            assertFalse(privilege.isAbstract());
            assertFalse(privilege.isAggregate());
            assertEquals(0, privilege.getDeclaredAggregatePrivileges().length);

            Privilege aggregate = manager.getPrivilege("test:aggregate");
            assertNotNull(aggregate);
            assertFalse(aggregate.isAbstract());
            assertTrue(aggregate.isAggregate());
            assertEquals(2, aggregate.getDeclaredAggregatePrivileges().length);
        } finally {
View Full Code Here

        String privName = "testCustomPrivilegeVisibleToNewSession";
        privilegeManager.registerPrivilege(privName, isAbstract, new String[0]);

        Session s2 = getAdminSession();
        try {
            PrivilegeManager pm = getPrivilegeManager(s2);
            Privilege priv = pm.getPrivilege(privName);
            assertEquals(privName, priv.getName());
            assertEquals(isAbstract, priv.isAbstract());
            assertFalse(priv.isAggregate());
        } finally {
            s2.logout();
View Full Code Here

     * @since oak
     */
    @Test
    public void testCustomPrivilegeVisibleAfterRefresh() throws RepositoryException {
        Session s2 = getAdminSession();
        PrivilegeManager pm = getPrivilegeManager(s2);
        try {
            boolean isAbstract = false;
            String privName = "testCustomPrivilegeVisibleAfterRefresh";
            privilegeManager.registerPrivilege(privName, isAbstract, new String[0]);

            // before refreshing: privilege not visible
            try {
                Privilege priv = pm.getPrivilege(privName);
                fail("Custom privilege will show up after Session#refresh()");
            } catch (AccessControlException e) {
                // success
            }

            // latest after refresh privilege manager must be updated
            s2.refresh(true);
            Privilege priv = pm.getPrivilege(privName);
            assertEquals(privName, priv.getName());
            assertEquals(isAbstract, priv.isAbstract());
            assertFalse(priv.isAggregate());
        } finally {
            s2.logout();
View Full Code Here

        }
    }

    private ACL createPolicy(@Nullable String path) {
        final PrincipalManager pm = getPrincipalManager(root);
        final PrivilegeManager pvMgr = getPrivilegeManager(root);
        final RestrictionProvider rp = getRestrictionProvider();
        return new ACL(path, null, getNamePathMapper()) {

            @Override
            ACE createACE(Principal principal, PrivilegeBits privilegeBits, boolean isAllow, Set<Restriction> restrictions) {
View Full Code Here

        String privName = "testCustomPrivilegeVisibleToNewSession";
        privilegeManager.registerPrivilege(privName, isAbstract, new String[0]);

        Session s2 = getAdminSession();
        try {
            PrivilegeManager pm = getPrivilegeManager(s2);
            Privilege priv = pm.getPrivilege(privName);
            assertEquals(privName, priv.getName());
            assertEquals(isAbstract, priv.isAbstract());
            assertFalse(priv.isAggregate());
        } finally {
            s2.logout();
View Full Code Here

     * @since oak
     */
    @Test
    public void testCustomPrivilegeVisibleAfterRefresh() throws RepositoryException {
        Session s2 = getAdminSession();
        PrivilegeManager pm = getPrivilegeManager(s2);
        try {
            boolean isAbstract = false;
            String privName = "testCustomPrivilegeVisibleAfterRefresh";
            privilegeManager.registerPrivilege(privName, isAbstract, new String[0]);

            // before refreshing: privilege not visible
            try {
                Privilege priv = pm.getPrivilege(privName);
                fail("Custom privilege will show up after Session#refresh()");
            } catch (AccessControlException e) {
                // success
            }

            // latest after refresh privilege manager must be updated
            s2.refresh(true);
            Privilege priv = pm.getPrivilege(privName);
            assertEquals(privName, priv.getName());
            assertEquals(isAbstract, priv.isAbstract());
            assertFalse(priv.isAggregate());
        } finally {
            s2.logout();
View Full Code Here

        }
    }

    private ACL createPolicy(@Nullable String path) {
        final PrincipalManager pm = getPrincipalManager(root);
        final PrivilegeManager pvMgr = getPrivilegeManager(root);
        final RestrictionProvider rp = getRestrictionProvider();
        return new ACL(path, null, getNamePathMapper()) {

            @Override
            ACE createACE(Principal principal, PrivilegeBits privilegeBits, boolean isAllow, Set<Restriction> restrictions) {
View Full Code Here

    @Test
    public void testAllAggregation() throws Exception {
        PrivilegeBits all = bitsProvider.getBits(JCR_ALL);

        PrivilegeManager pMgr = getSecurityProvider().getConfiguration(PrivilegeConfiguration.class).getPrivilegeManager(root, NamePathMapper.DEFAULT);
        Iterable<Privilege> declaredAggr = Arrays.asList(pMgr.getPrivilege(JCR_ALL).getDeclaredAggregatePrivileges());
        String[] allAggregates = Iterables.toArray(Iterables.transform(
                declaredAggr,
                new Function<Privilege, String>() {
                    @Override
                    public String apply(@Nullable Privilege privilege) {
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.api.security.authorization.PrivilegeManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.