Examples of TestingAuthenticationToken


Examples of org.springframework.security.authentication.TestingAuthenticationToken

        authorizeTag.setIfAnyGranted(null);
        authorizeTag.setIfNotGranted(null);
        authorizeTag.setIfAllGranted("ROLE_ADMIN");
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        authorities.add(new GrantedAuthorityImpl("ROLE_TEST"));
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("abc", "123", authorities));
        assertEquals("Expected to not be authorized", Tag.SKIP_BODY, authorizeTag.doStartTag());
    }
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

    }

    @Test
    public void testOperationWhenPrincipalIsAString() throws JspException {
        SecurityContextHolder.getContext().setAuthentication(
                new TestingAuthenticationToken("rodAsString", "koala", AuthorityUtils.NO_AUTHORITIES ));

        authenticationTag.setProperty("principal");
        assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag());
        assertEquals(Tag.EVAL_PAGE, authenticationTag.doEndTag());
        assertEquals("rodAsString", authenticationTag.getLastMessage());
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

    }

    @Test
    public void testOperationWhenPrincipalIsNull() throws JspException {
        SecurityContextHolder.getContext().setAuthentication(
                new TestingAuthenticationToken(null, "koala", AuthorityUtils.NO_AUTHORITIES ));

        authenticationTag.setProperty("principal");
        assertEquals(Tag.SKIP_BODY, authenticationTag.doStartTag());
        assertEquals(Tag.EVAL_PAGE, authenticationTag.doEndTag());
    }
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

        }
    }

    @Test
    public void htmlEscapingIsUsedByDefault() throws Exception {
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("<>& ", ""));
        authenticationTag.setProperty("name");
        authenticationTag.doStartTag();
        authenticationTag.doEndTag();
        assertEquals("&lt;&gt;&amp;&#32;", authenticationTag.getLastMessage());
    }
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

        assertEquals("&lt;&gt;&amp;&#32;", authenticationTag.getLastMessage());
    }

    @Test
    public void settingHtmlEscapeToFalsePreventsEscaping() throws Exception {
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("<>& ", ""));
        authenticationTag.setProperty("name");
        authenticationTag.setHtmlEscape("false");
        authenticationTag.doStartTag();
        authenticationTag.doEndTag();
        assertEquals("<>& ", authenticationTag.getLastMessage());
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

     * abstract parent enforces that logic, which is extensively tested separately.
     */
    @Test
    public void testSuccessfulInvocation() throws Throwable {
        // Setup a Context
        Authentication token = new TestingAuthenticationToken("Test", "Password", "NOT_USED");
        SecurityContextHolder.getContext().setAuthentication(token);

        FilterInvocation fi = createinvocation();

        when(ods.getAttributes(fi)).thenReturn(SecurityConfig.createList("MOCK_OK"));
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

        verify(publisher, never()).publishEvent(any(AuthorizedEvent.class));
    }

    @Test
    public void afterInvocationIsNotInvokedIfExceptionThrown() throws Exception {
        Authentication token = new TestingAuthenticationToken("Test", "Password", "NOT_USED");
        SecurityContextHolder.getContext().setAuthentication(token);

        FilterInvocation fi = createinvocation();
        FilterChain chain = fi.getChain();
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

    // SEC-1967
    @Test
    @SuppressWarnings("unchecked")
    public void finallyInvocationIsInvokedIfExceptionThrown() throws Exception {
        SecurityContext ctx = SecurityContextHolder.getContext();
        Authentication token = new TestingAuthenticationToken("Test", "Password", "NOT_USED");
        token.setAuthenticated(true);
        ctx.setAuthentication(token);

        RunAsManager runAsManager = mock(RunAsManager.class);
        when(runAsManager.buildRunAs(eq(token), any(), anyCollection())).thenReturn(new RunAsUserToken("key", "someone", "creds", token.getAuthorities(), token.getClass()));
        interceptor.setRunAsManager(runAsManager);

        FilterInvocation fi = createinvocation();
        FilterChain chain = fi.getChain();
View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

     * SEC-655
     */
    @Test
    @Transactional
    public void childrenAreClearedFromCacheWhenParentIsUpdated() throws Exception {
        Authentication auth = new TestingAuthenticationToken("ben", "ignored","ROLE_ADMINISTRATOR");
        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);

        ObjectIdentity parentOid = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(104));
        ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(105));

View Full Code Here

Examples of org.springframework.security.authentication.TestingAuthenticationToken

     * SEC-655
     */
    @Test
    @Transactional
    public void childrenAreClearedFromCacheWhenParentisUpdated2() throws Exception {
        Authentication auth = new TestingAuthenticationToken("system", "secret","ROLE_IGNORED");
        SecurityContextHolder.getContext().setAuthentication(auth);
        ObjectIdentityImpl rootObject = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(1));

        MutableAcl parent = jdbcMutableAclService.createAcl(rootObject);
        MutableAcl child = jdbcMutableAclService.createAcl(new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(2)));
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.