Examples of AnonymousAuthenticationToken


Examples of org.springframework.security.authentication.AnonymousAuthenticationToken

        assertFalse(token1.equals(token2));
    }

    public void testNotEqualsDueToDifferentAuthenticationClass() {
        AnonymousAuthenticationToken token1 = new AnonymousAuthenticationToken("key", "Test", ROLES_12);
        UsernamePasswordAuthenticationToken token2 = new UsernamePasswordAuthenticationToken("Test", "Password", ROLES_12);

        assertFalse(token1.equals(token2));
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationToken

        assertFalse(token1.equals(token2));
    }

    public void testNotEqualsDueToKey() {
        AnonymousAuthenticationToken token1 = new AnonymousAuthenticationToken("key", "Test", ROLES_12);

        AnonymousAuthenticationToken token2 = new AnonymousAuthenticationToken("DIFFERENT_KEY", "Test", ROLES_12);

        assertFalse(token1.equals(token2));
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationToken

        assertFalse(token1.equals(token2));
    }

    public void testSetAuthenticatedIgnored() {
        AnonymousAuthenticationToken token = new AnonymousAuthenticationToken("key", "Test", ROLES_12);
        assertTrue(token.isAuthenticated());
        token.setAuthenticated(false);
        assertTrue(!token.isAuthenticated());
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationToken

    }
    List<GrantedAuthority> anonymousAuthorities = new ArrayList<GrantedAuthority>();
    anonymousAuthorities.addAll(springSecurityAnonymousAuthorities);
    anonymousAuthorities.addAll(jamwikiAnonymousAuthorities);
    // replace the existing anonymous authentication object with the new authentication array
    AnonymousAuthenticationToken jamwikiAuth = new AnonymousAuthenticationToken(this.getKey(), auth.getPrincipal(), anonymousAuthorities);
    jamwikiAuth.setDetails(auth.getDetails());
    jamwikiAuth.setAuthenticated(auth.isAuthenticated());
    SecurityContextHolder.getContext().setAuthentication(jamwikiAuth);
  }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationToken

  @Test(expected = InsufficientAuthenticationException.class)
  public void testAnonymousUser() throws Exception {
    AccessTokenProviderChain chain = new AccessTokenProviderChain(Arrays.asList(new StubAccessTokenProvider()));
    SecurityContextHolder.getContext().setAuthentication(
        new AnonymousAuthenticationToken("foo", "bar", user.getAuthorities()));
    AccessTokenRequest request = new DefaultAccessTokenRequest();
    OAuth2AccessToken token = chain.obtainAccessToken(resource, request);
    assertNotNull(token);
  }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationToken

                        " anonymous authentication enabled. This is almost certainly an error.");
                return;
            }

            // Simulate an anonymous access with the supplied attributes.
            AnonymousAuthenticationToken token = new AnonymousAuthenticationToken("key", anonPF.getUserAttribute().getPassword(),
                            anonPF.getUserAttribute().getAuthorities());
            try {
                fsi.getAccessDecisionManager().decide(token, new Object(), fids.lookupAttributes(loginPage, "POST"));
            } catch (Exception e) {
                logger.warn("Anonymous access to the login page doesn't appear to be enabled. This is almost certainly " +
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationToken

    protected boolean applyAnonymousForThisRequest(HttpServletRequest request) {
        return true;
    }

    protected Authentication createAuthentication(HttpServletRequest request) {
        AnonymousAuthenticationToken auth = new AnonymousAuthenticationToken(key, userAttribute.getPassword(),
                userAttribute.getAuthorities());
        auth.setDetails(authenticationDetailsSource.buildDetails(request));

        return auth;
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationToken

    }

    @Test
    public void testAlreadyAuthenticatedWithAnonymousToken() throws Exception {
        try {
            Authentication existingAuth = new AnonymousAuthenticationToken("test", "mike",
                    AuthorityUtils.createAuthorityList("ROLE_TEST"));
            SecurityContextHolder.getContext().setAuthentication(existingAuth);
            everythingWorks();
        } finally {
            SecurityContextHolder.clearContext();
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationToken

        if (authorities != null) {
            for (String authority : authorities) {
                grantedAuthorities.add(new GrantedAuthorityImpl(authority));
            }

            Authentication auth = new AnonymousAuthenticationToken(UUID.randomUUID().toString(),
                req.getUserPrincipal(), grantedAuthorities);

            SecurityContextHolder.getContext().setAuthentication(auth);
        }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationToken

    protected Authentication createAuthentication(HttpServletRequest request) {
        GeoServerUser anonymous = GeoServerUser.createAnonymous();
        List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>();
        roles.addAll(anonymous.getAuthorities());
        AnonymousAuthenticationToken auth = new AnonymousAuthenticationToken("geoserver",
                anonymous.getUsername(),roles);
        auth.setDetails(authenticationDetailsSource.buildDetails(request));
        return auth;
    }
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.