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

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


    public void testEquals() {
        // same definition
        assertEquals(definition, new RestrictionDefinitionImpl(name, PropertyType.NAME, true, definition.getNamePathMapper()));

        // same def but different namepathmapper.
        RestrictionDefinition definition2 = new RestrictionDefinitionImpl(name, PropertyType.NAME, true, namePathMapper);
        assertFalse(definition.getJcrName().equals(definition2.getJcrName()));
        assertEquals(definition, definition2);
    }
View Full Code Here


        // - different name
        defs.add(new RestrictionDefinitionImpl("otherName", PropertyType.NAME, true, namePathMapper));
        // - different mandatory flag
        defs.add(new RestrictionDefinitionImpl(name, PropertyType.NAME, false, namePathMapper));
        // - different impl
        defs.add(new RestrictionDefinition() {
            @Override
            public String getName() {
                return name;
            }
            @Override
View Full Code Here

    private Map<String, RestrictionDefinition> supported;

    public RestrictionProviderImpl(NamePathMapper namePathMapper) {
        this.namePathMapper = namePathMapper;

        RestrictionDefinition glob = new RestrictionDefinitionImpl(REP_GLOB, PropertyType.STRING, false, namePathMapper);
        this.supported = ImmutableMap.of(REP_GLOB, glob);
    }
View Full Code Here

        if (oakPath == null) {
            throw new AccessControlException("Unsupported restriction: " + oakPath);
        }

        String oakName = namePathMapper.getOakName(jcrName);
        RestrictionDefinition definition = supported.get(oakName);
        if (definition == null) {
            throw new AccessControlException("Unsupported restriction: " + oakPath);
        }
        int requiredType = definition.getRequiredType();
        if (requiredType != PropertyType.UNDEFINED && requiredType != value.getType()) {
            throw new AccessControlException("Unsupported restriction: Expected value of type " + PropertyType.nameFromValue(definition.getRequiredType()));
        }
        PropertyState propertyState = PropertyStates.createProperty(oakName, value);
        return createRestriction(propertyState, definition.isMandatory());
    }
View Full Code Here

        } else {
            Set<Restriction> restrictions = new HashSet<Restriction>();
            for (PropertyState propertyState : getRestrictionsTree(aceTree).getProperties()) {
                String propName = propertyState.getName();
                if (isRestrictionProperty(propName) && supported.containsKey(propName)) {
                    RestrictionDefinition def = supported.get(propName);
                    if (def.getRequiredType() == propertyState.getType().tag()) {
                        restrictions.add(createRestriction(propertyState, def.isMandatory()));
                    }
                }
            }
            return restrictions;
        }
View Full Code Here

        if (oakPath == null && !restrictionProperties.isEmpty()) {
            throw new AccessControlException("Restrictions not supported with 'null' path.");
        }
        for (Map.Entry<String, PropertyState> entry : restrictionProperties.entrySet()) {
            String restrName = entry.getKey();
            RestrictionDefinition def = supported.get(restrName);
            if (def == null) {
                throw new AccessControlException("Unsupported restriction: " + restrName);
            }
            int type = entry.getValue().getType().tag();
            if (type != def.getRequiredType()) {
                throw new AccessControlException("Invalid restriction type '"+PropertyType.nameFromValue(type)+"'. Expected " + PropertyType.nameFromValue(def.getRequiredType()));
            }
        }
        for (RestrictionDefinition def : supported.values()) {
            if (def.isMandatory() && !restrictionProperties.containsKey(def.getName())) {
                throw new AccessControlException("Mandatory restriction " + def.getName() + " is missing.");
            }
        }
    }
View Full Code Here

TOP

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

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.