Examples of TestingAuthenticationToken


Examples of org.springframework.security.authentication.TestingAuthenticationToken

        }
    }

    @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

Examples of org.springframework.security.authentication.TestingAuthenticationToken

        }
    }

    @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

Examples of org.springframework.security.authentication.TestingAuthenticationToken

        }
    }

    @Test
    public void updatedAceValuesAreCorrectlyReflectedInAcl() throws Exception {
        Authentication auth = new TestingAuthenticationToken("ben", "ignored","ROLE_GENERAL");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);
        MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, false, new PrincipalSid("joe"));
        MockAclService service = new MockAclService();

        acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER_READ"), true);
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

        assertEquals(acl.getEntries().get(2).getPermission(), BasePermission.READ);
    }

    @Test
    public void auditableEntryFlagsAreUpdatedCorrectly() throws Exception {
        Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_AUDITING", "ROLE_GENERAL");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);
        MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null, false, new PrincipalSid("joe"));
        MockAclService service = new MockAclService();

        acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER_READ"), true);
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

        assertTrue(((AuditableAccessControlEntry) acl.getEntries().get(1)).isAuditSuccess());
    }

    @Test
    public void gettersAndSettersAreConsistent() throws Exception {
        Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_GENERAL");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);
        ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, (100));
        ObjectIdentity identity2 = new ObjectIdentityImpl(TARGET_CLASS, (101));
        MutableAcl acl = new AclImpl(identity, 1, authzStrategy, pgs, null, null, true, new PrincipalSid("joe"));
        MutableAcl parentAcl = new AclImpl(identity2, 2, authzStrategy, pgs, null, null, true, new PrincipalSid("joe"));
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

                    return null;
                }
            }
        });
        svc.afterPropertiesSet();
        UserDetails result1 = svc.loadUserDetails(new TestingAuthenticationToken("dummy", "dummy"));
        assertEquals("Result doesn't match original user", user, result1);
        UserDetails result2 = svc.loadUserDetails(new TestingAuthenticationToken("dummy2", "dummy"));
        assertNull("Result should have been null", result2);
    }
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

    private static class CustomUserPrincipal {}

    private void setAuthenticationPrincipal(Object principal) {
        this.expectedPrincipal = principal;
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken(expectedPrincipal, "password", "ROLE_USER"));
    }
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

    SecurityContextChannelInterceptor interceptor;

    @Before
    public void setup() {
        authentication = new TestingAuthenticationToken("user","pass", "ROLE_USER");
        messageBuilder = MessageBuilder.withPayload("payload");

        interceptor = new SecurityContextChannelInterceptor();
    }
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

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

    @Before
    public void setUp() throws Exception {
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("abc", "123", "ROLE_SUPERVISOR", "ROLE_RESTRICTED"));
    }
View Full Code Here

Examples of org.springframework.security.providers.TestingAuthenticationToken

    /**
     * Creates an Acegi SecureContext and stores it on the ContextHolder
     */
    private void createSecureContext() {

        TestingAuthenticationToken auth = new TestingAuthenticationToken(
                username,
                username,
                new GrantedAuthority[] {
                        new GrantedAuthorityImpl("ROLE_TELLER"),
                        new GrantedAuthorityImpl("ROLE_PERMISSION_LIST") });
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.