Examples of SidRetrievalStrategy


Examples of org.springframework.security.acls.model.SidRetrievalStrategy

       
        /*
         * Initialize required objects
         */
       
        SidRetrievalStrategy sidRetrievalStrategy = getBeanOfType(applicationContext, SidRetrievalStrategy.class);
        if (sidRetrievalStrategy == null) {
            sidRetrievalStrategy = new SidRetrievalStrategyImpl();
        }

        ObjectIdentityRetrievalStrategy objectIdentityRetrievalStrategy = getBeanOfType(applicationContext, ObjectIdentityRetrievalStrategy.class);
        if (objectIdentityRetrievalStrategy == null) {
            objectIdentityRetrievalStrategy = new ObjectIdentityRetrievalStrategyImpl();
        }
       

        /*
         * Compute permissions
         */
       
        if ((null == permissions) || permissions.isEmpty()) {
           
            if (logger.isTraceEnabled()) {
                logger.trace("[THYMELEAF][{}] Permissions are null or empty. Access is DENIED. ",
                        new Object[] {TemplateEngine.threadIndex()});
            }
           
            return false;
           
        }

        if (domainObject == null) {
            if (logger.isTraceEnabled()) {
                logger.trace("[THYMELEAF][{}] Domain object for resolved to null. Access by " +
                    "Access Control List is GRANTED.", new Object[] {TemplateEngine.threadIndex()});
            }
            // Access to null object is considered always true
            return true;
        }

        final List<Sid> sids =
                sidRetrievalStrategy.getSids(SecurityContextHolder.getContext().getAuthentication());
       
        final ObjectIdentity oid =
                objectIdentityRetrievalStrategy.getObjectIdentity(domainObject);

        try {
View Full Code Here

Examples of org.springframework.security.acls.model.SidRetrievalStrategy

    @Test
    public void eagerlyLoadsRequiredAcls() throws Exception {
        AclService service = mock(AclService.class);
        AclPermissionCacheOptimizer pco = new AclPermissionCacheOptimizer(service);
        ObjectIdentityRetrievalStrategy oidStrat = mock(ObjectIdentityRetrievalStrategy.class);
        SidRetrievalStrategy sidStrat = mock(SidRetrievalStrategy.class);
        pco.setObjectIdentityRetrievalStrategy(oidStrat);
        pco.setSidRetrievalStrategy(sidStrat);
        Object[] dos = {new Object(), null, new Object()};
        ObjectIdentity[] oids = {new ObjectIdentityImpl("A", "1"), new ObjectIdentityImpl("A", "2")};
        when(oidStrat.getObjectIdentity(dos[0])).thenReturn(oids[0]);
View Full Code Here

Examples of org.springframework.security.acls.model.SidRetrievalStrategy

    @Test
    public void ignoresEmptyCollection() {
        AclService service = mock(AclService.class);
        AclPermissionCacheOptimizer pco = new AclPermissionCacheOptimizer(service);
        ObjectIdentityRetrievalStrategy oids = mock(ObjectIdentityRetrievalStrategy.class);
        SidRetrievalStrategy sids = mock(SidRetrievalStrategy.class);
        pco.setObjectIdentityRetrievalStrategy(oids);
        pco.setSidRetrievalStrategy(sids);

        pco.cachePermissionsFor(mock(Authentication.class), Collections.emptyList());
View Full Code Here

Examples of org.springframework.security.acls.model.SidRetrievalStrategy

    //~ Methods ========================================================================================================

    @Test
    public void correctSidsAreRetrieved() throws Exception {
        SidRetrievalStrategy retrStrategy = new SidRetrievalStrategyImpl();
        List<Sid> sids = retrStrategy.getSids(authentication);

        assertNotNull(sids);
        assertEquals(4, sids.size());
        assertNotNull(sids.get(0));
        assertTrue(sids.get(0) instanceof PrincipalSid);
View Full Code Here

Examples of org.springframework.security.acls.model.SidRetrievalStrategy

    @Test
    public void roleHierarchyIsUsedWhenSet() throws Exception {
        RoleHierarchy rh =  mock(RoleHierarchy.class);
        List rhAuthorities = AuthorityUtils.createAuthorityList("D");
        when(rh.getReachableGrantedAuthorities(anyCollection())).thenReturn(rhAuthorities);
        SidRetrievalStrategy strat = new SidRetrievalStrategyImpl(rh);

        List<Sid> sids = strat.getSids(authentication);
        assertEquals(2, sids.size());
        assertNotNull(sids.get(0));
        assertTrue(sids.get(0) instanceof PrincipalSid);
        assertEquals("D", ((GrantedAuthoritySid) sids.get(1)).getGrantedAuthority());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.