Examples of PermissionEvaluator


Examples of org.springframework.security.access.PermissionEvaluator

    }

    @Test
    public void hasPermissionOnDomainObjectReturnsFalseIfPermissionEvaluatorDoes() throws Exception {
        final Object dummyDomainObject = new Object();
        final PermissionEvaluator pe = mock(PermissionEvaluator.class);
        ctx.setVariable("domainObject", dummyDomainObject);
        root.setPermissionEvaluator(pe);
        when(pe.hasPermission(user, dummyDomainObject, "ignored")).thenReturn(false);

        assertFalse(root.hasPermission(dummyDomainObject, "ignored"));

    }
View Full Code Here

Examples of org.springframework.security.access.PermissionEvaluator

    }

    @Test
    public void hasPermissionOnDomainObjectReturnsTrueIfPermissionEvaluatorDoes() throws Exception {
        final Object dummyDomainObject = new Object();
        final PermissionEvaluator pe = mock(PermissionEvaluator.class);
        ctx.setVariable("domainObject", dummyDomainObject);
        root.setPermissionEvaluator(pe);
        when(pe.hasPermission(user, dummyDomainObject, "ignored")).thenReturn(true);

        assertTrue(root.hasPermission(dummyDomainObject, "ignored"));
    }
View Full Code Here

Examples of org.springframework.security.access.PermissionEvaluator

    @Test
    public void hasPermissionOnDomainObjectWorksWithIntegerExpressions() throws Exception {
        final Object dummyDomainObject = new Object();
        ctx.setVariable("domainObject", dummyDomainObject);
        final PermissionEvaluator pe = mock(PermissionEvaluator.class);
        root.setPermissionEvaluator(pe);
        when(pe.hasPermission(eq(user), eq(dummyDomainObject), any(Integer.class))).thenReturn(true)
                .thenReturn(true)
                .thenReturn(false);

        Expression e = parser.parseExpression("hasPermission(#domainObject, 0xA)");
        // evaluator returns true
View Full Code Here

Examples of org.springframework.security.access.PermissionEvaluator

                return "x";
            }
        };
        root.setThis(targetObject);
        Integer i = 2;
        PermissionEvaluator pe = mock(PermissionEvaluator.class);
        root.setPermissionEvaluator(pe);
        when(pe.hasPermission(user, targetObject, i)).thenReturn(true)
                .thenReturn(false);
        when(pe.hasPermission(user, "x", i)).thenReturn(true);

        Expression e = parser.parseExpression("hasPermission(this, 2)");
        assertTrue(ExpressionUtils.evaluateAsBoolean(e, ctx));
        e = parser.parseExpression("hasPermission(this, 2)");
        assertFalse(ExpressionUtils.evaluateAsBoolean(e, ctx));
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.