Package org.springframework.security.acls.model

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


        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 {
           
            final Acl acl = aclService.readAclById(oid, sids);

View Full Code Here


    @SuppressWarnings("unchecked")
    public void hasPermissionReturnsTrueIfAclGrantsPermission() throws Exception {
        AclService service = mock(AclService.class);
        AclPermissionEvaluator pe = new AclPermissionEvaluator(service);
        ObjectIdentity oid = mock(ObjectIdentity.class);
        ObjectIdentityRetrievalStrategy oidStrategy = mock(ObjectIdentityRetrievalStrategy.class);
        when(oidStrategy.getObjectIdentity(anyObject())).thenReturn(oid);
        pe.setObjectIdentityRetrievalStrategy(oidStrategy);
        pe.setSidRetrievalStrategy(mock(SidRetrievalStrategy.class));
        Acl acl = mock(Acl.class);

        when(service.readAclById(any(ObjectIdentity.class), anyList())).thenReturn(acl);
View Full Code Here

    @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]);
        when(oidStrat.getObjectIdentity(dos[2])).thenReturn(oids[1]);

        pco.cachePermissionsFor(mock(Authentication.class), Arrays.asList(dos));

        // AclService should be invoked with the list of required Oids
        verify(service).readAclsById(eq(Arrays.asList(oids)), any(List.class));
View Full Code Here

    @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

    public void testObjectIdentityCreation() throws Exception {
        MockIdDomainObject domain = new MockIdDomainObject();
        domain.setId(Integer.valueOf(1));

        ObjectIdentityRetrievalStrategy retStrategy = new ObjectIdentityRetrievalStrategyImpl();
        ObjectIdentity identity = retStrategy.getObjectIdentity(domain);

        assertNotNull(identity);
        assertEquals(identity, new ObjectIdentityImpl(domain));
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.acls.model.ObjectIdentityRetrievalStrategy

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.