Package org.springframework.security.authentication

Examples of org.springframework.security.authentication.TestingAuthenticationToken


        assertThat(getRoot().getAuthentication()).isSameAs(authentication);
    }

    @Test
    public void getRootObjectExplicitAuthenticationOverridesSecurityContextHolder() {
        TestingAuthenticationToken explicit = new TestingAuthenticationToken("explicit", "password", "ROLE_EXPLICIT");
        securityExtension = new SecurityEvaluationContextExtension(explicit);

        TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "password", "ROLE_USER");
        SecurityContextHolder.getContext().setAuthentication(authentication);

        assertThat(getRoot().getAuthentication()).isSameAs(explicit);
    }
View Full Code Here


        assertThat(element.getAllValues().get(0).getObjectValue()).isEqualTo(acl);
    }

    @Test
    public void putInCacheAclWithParent() throws Exception {
        Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_GENERAL");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);

        ObjectIdentity identityParent = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(2));
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
                new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"),
View Full Code Here

        assertThat(getRoot().getAuthentication()).isSameAs(explicit);
    }

    @Test
    public void getRootObjectExplicitAuthentication() {
        TestingAuthenticationToken explicit = new TestingAuthenticationToken("explicit", "password", "ROLE_EXPLICIT");
        securityExtension = new SecurityEvaluationContextExtension(explicit);

        assertThat(getRoot().getAuthentication()).isSameAs(explicit);
    }
View Full Code Here

        SecurityContextHolder.clearContext();
    }

    @Test
    public void testSecurityCheckNoACEs() throws Exception {
        Authentication auth = new TestingAuthenticationToken("user", "password","ROLE_GENERAL","ROLE_AUDITING","ROLE_OWNERSHIP");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);

        ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100));
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
                new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"),
View Full Code Here

    }

    @Test
    public void testSecurityCheckWithMultipleACEs() throws Exception {
        // Create a simple authentication with ROLE_GENERAL
        Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_GENERAL");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);

        ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, new Long(100));
        // Authorization strategy will require a different role for each access
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
View Full Code Here

    }

    @Test
    public void testSecurityCheckWithInheritableACEs() throws Exception {
        // Create a simple authentication with ROLE_GENERAL
        Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_GENERAL");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);

        ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, 100);
        // Authorization strategy will require a different role for each access
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
View Full Code Here

    }

    @SuppressWarnings("deprecation")
    @Test
    public void testSecurityCheckPrincipalOwner() throws Exception {
        Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_ONE");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);

        ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, 100);
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
                new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"),
View Full Code Here

    @Test
    public void cacheOperationsAclWithParent() throws Exception {
        Cache cache = getCache();
        Map realCache = (Map) cache.getNativeCache();

        Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_GENERAL");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);

        ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(1));
        ObjectIdentity identityParent = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(2));
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
View Full Code Here

        }
    }

    @Test
    public void isGrantingGrantsAccessForAclWithNoParent() throws Exception {
        Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_GENERAL","ROLE_GUEST");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);
        ObjectIdentity rootOid = new ObjectIdentityImpl(TARGET_CLASS, 100);

        // Create an ACL which owner is not the authenticated principal
        MutableAcl rootAcl = new AclImpl(rootOid, 1, authzStrategy, pgs, null, null, false, new PrincipalSid("joe"));
View Full Code Here

        }
    }

    @Test
    public void isGrantingGrantsAccessForInheritableAcls() throws Exception {
        Authentication auth = new TestingAuthenticationToken("ben", "ignored","ROLE_GENERAL");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);
        ObjectIdentity grandParentOid = new ObjectIdentityImpl(TARGET_CLASS, 100);
        ObjectIdentity parentOid1 = new ObjectIdentityImpl(TARGET_CLASS, 101);
        ObjectIdentity parentOid2 = new ObjectIdentityImpl(TARGET_CLASS, 102);
        ObjectIdentity childOid1 = new ObjectIdentityImpl(TARGET_CLASS, 103);
View Full Code Here

TOP

Related Classes of org.springframework.security.authentication.TestingAuthenticationToken

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.