Package org.springframework.security.access.vote

Examples of org.springframework.security.access.vote.UnanimousBased.decide()


        UnanimousBased mgr = makeDecisionManager();

        List<ConfigAttribute> config = SecurityConfig.createList(new String[]{"ROLE_1", "DENY_FOR_SURE"});

        try {
            mgr.decide(auth, new Object(), config);
            fail("Should have thrown AccessDeniedException");
        } catch (AccessDeniedException expected) {
            assertTrue(true);
        }
    }
View Full Code Here


        TestingAuthenticationToken auth = makeTestToken();
        UnanimousBased mgr = makeDecisionManager();

        List<ConfigAttribute> config = SecurityConfig.createList("ROLE_2");

        mgr.decide(auth, new Object(), config);
        assertTrue(true);
    }

    public void testOneDenyVoteTwoAbstainVotesDeniesAccess() throws Exception {
        TestingAuthenticationToken auth = makeTestToken();
View Full Code Here

        UnanimousBased mgr = makeDecisionManager();

        List<ConfigAttribute> config = SecurityConfig.createList("ROLE_WE_DO_NOT_HAVE");

        try {
            mgr.decide(auth, new Object(), config);
            fail("Should have thrown AccessDeniedException");
        } catch (AccessDeniedException expected) {
            assertTrue(true);
        }
    }
View Full Code Here

        TestingAuthenticationToken auth = makeTestTokenWithFooBarPrefix();
        UnanimousBased mgr = makeDecisionManagerWithFooBarPrefix();

        List<ConfigAttribute> config = SecurityConfig.createList(new String[]{"FOOBAR_1", "FOOBAR_2"});

        mgr.decide(auth, new Object(), config);
        assertTrue(true);
    }

    public void testThreeAbstainVotesDeniesAccessWithDefault() throws Exception {
        TestingAuthenticationToken auth = makeTestToken();
View Full Code Here

        assertTrue(!mgr.isAllowIfAllAbstainDecisions()); // check default

        List<ConfigAttribute> config = SecurityConfig.createList("IGNORED_BY_ALL");

        try {
            mgr.decide(auth, new Object(), config);
            fail("Should have thrown AccessDeniedException");
        } catch (AccessDeniedException expected) {
            assertTrue(true);
        }
    }
View Full Code Here

        mgr.setAllowIfAllAbstainDecisions(true);
        assertTrue(mgr.isAllowIfAllAbstainDecisions()); // check changed

        List<ConfigAttribute> config = SecurityConfig.createList("IGNORED_BY_ALL");

        mgr.decide(auth, new Object(), config);
        assertTrue(true);
    }

    public void testTwoAffirmativeVotesTwoAbstainVotesGrantsAccess() throws Exception {
        TestingAuthenticationToken auth = makeTestToken();
View Full Code Here

        TestingAuthenticationToken auth = makeTestToken();
        UnanimousBased mgr = makeDecisionManager();

        List<ConfigAttribute> config = SecurityConfig.createList(new String[]{"ROLE_1", "ROLE_2"});

        mgr.decide(auth, new Object(), config);
        assertTrue(true);
    }
}
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.