Package org.apache.jackrabbit.oak.spi.security.authorization.restriction

Examples of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider


        }
    }

    @Test
    public void testInvalidRestrictionType() throws Exception {
        RestrictionProvider rp = new TestRestrictionProvider("restr", PropertyType.NAME, false);

        JackrabbitAccessControlList acl = createACL(getTestPath(), new ArrayList(), namePathMapper, rp);
        try {
            acl.addEntry(testPrincipal, testPrivileges, false, Collections.<String, Value>singletonMap("restr", getValueFactory().createValue(true)));
            fail("Invalid restriction type.");
View Full Code Here


        }
    }

    @Test
    public void testMandatoryRestrictions() throws Exception {
        RestrictionProvider rp = new TestRestrictionProvider("mandatory", PropertyType.NAME, true);

        JackrabbitAccessControlList acl = createACL(getTestPath(), new ArrayList(), namePathMapper, rp);
        try {
            acl.addEntry(testPrincipal, testPrivileges, false, Collections.<String, Value>emptyMap());
            fail("Mandatory restriction must be enforced.");
View Full Code Here

        assertFalse(acl.equals(new TestACL(getTestPath(), getRestrictionProvider(), Collections.<JackrabbitAccessControlEntry>emptyList())));
    }

    @Test
    public void testEquals() throws Exception {
        RestrictionProvider rp = getRestrictionProvider();
        ACE ace1 = new ACE(testPrincipal, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), false, null);
        ACE ace2 = new ACE(testPrincipal, testPrivileges, true, null);
        ACE ace2b = new ACE(testPrincipal, getAggregatedPrivileges(testPrivileges), true, null);

        JackrabbitAccessControlList acl = createACL(ace1, ace2);
View Full Code Here

        assertFalse(acl.equals(new TestACL(getTestPath(), rp, ace1, ace2)));
    }

    @Test
    public void testHashCode() throws Exception {
        RestrictionProvider rp = getRestrictionProvider();
        ACE ace1 = new ACE(testPrincipal, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), false, null);
        ACE ace2 = new ACE(testPrincipal, testPrivileges, true, null);
        ACE ace2b = new ACE(testPrincipal, getAggregatedPrivileges(testPrivileges), true, null);

        JackrabbitAccessControlList acl = createACL(ace1, ace2);
View Full Code Here

        }
    }

    private ACL createPolicy(@Nullable String path) {
        final PrincipalManager pm = getPrincipalManager();
        final RestrictionProvider rp = getRestrictionProvider();
        return new ACL(path, getNamePathMapper()) {
            @Override
            PrincipalManager getPrincipalManager() {
                return pm;
            }
View Full Code Here

    public Validator getRootValidator(NodeState before, NodeState after) {
        Tree rootBefore = new ImmutableTree(before);
        Tree rootAfter = new ImmutableTree(after);

        AccessControlConfiguration acConfig = securityProvider.getAccessControlConfiguration();
        RestrictionProvider restrictionProvider = acConfig.getRestrictionProvider(NamePathMapper.DEFAULT);

        Map<String, Privilege> privileges = getPrivileges(before, securityProvider.getPrivilegeConfiguration());
        ReadOnlyNodeTypeManager ntMgr = ReadOnlyNodeTypeManager.getInstance(before);

        return new AccessControlValidator(rootBefore, rootAfter, privileges, restrictionProvider, ntMgr);
View Full Code Here

    @Nullable
    private JackrabbitAccessControlList createPrincipalACL(@Nullable String oakPath,
                                                           @Nonnull Principal principal) throws RepositoryException {
        Result aceResult = searchAces(Collections.<Principal>singleton(principal));
        RestrictionProvider restrProvider = new PrincipalRestrictionProvider(restrictionProvider, namePathMapper);
        List<JackrabbitAccessControlEntry> entries = new ArrayList<JackrabbitAccessControlEntry>();
        for (ResultRow row : aceResult.getRows()) {
            Tree aceTree = root.getTree(row.getPath());
            if (AccessControlUtils.isACE(aceTree, ntMgr)) {
                String aclPath = Text.getRelativeParent(aceTree.getPath(), 1);
View Full Code Here

    @Nullable
    private JackrabbitAccessControlList createPrincipalACL(@Nullable String oakPath,
                                                           @Nonnull Principal principal) throws RepositoryException {
        Result aceResult = searchAces(Collections.<Principal>singleton(principal), root);
        RestrictionProvider restrProvider = new PrincipalRestrictionProvider(restrictionProvider);
        List<ACE> entries = new ArrayList<ACE>();
        for (ResultRow row : aceResult.getRows()) {
            Tree aceTree = root.getTree(row.getPath());
            if (Util.isACE(aceTree, ntMgr)) {
                String aclPath = Text.getRelativeParent(aceTree.getPath(), 1);
View Full Code Here

                                                           Result aceResult) throws RepositoryException {
        if (!(principal instanceof ItemBasedPrincipal)) {
            throw new IllegalArgumentException("Item based principal expected");
        }
        String principalPath = ((ItemBasedPrincipal) principal).getPath();
        RestrictionProvider restrProvider = new PrincipalRestrictionProvider(restrictionProvider, namePathMapper);

        List<JackrabbitAccessControlEntry> entries = null;
        if (aceResult != null) {
            entries = new ArrayList();
            for (ResultRow row : aceResult.getRows()) {
View Full Code Here

    }

    @Override
    protected AbstractAccessControlList createACL(String jcrPath, List<JackrabbitAccessControlEntry> entries, NamePathMapper namePathMapper) {
        String path = (jcrPath == null) ? null : namePathMapper.getOakPathKeepIndex(jcrPath);
        final RestrictionProvider rp = getRestrictionProvider();
        return new ACL(path, entries, namePathMapper) {
            @Nonnull
            @Override
            public RestrictionProvider getRestrictionProvider() {
                return rp;
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider

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.