Examples of AnonymousAuthenticationProvider


Examples of org.springframework.security.authentication.AnonymousAuthenticationProvider

    @Marker( SpringSecurityServices.class )
    public final AuthenticationProvider buildAnonymousAuthenticationProvider(
            @Inject @Value( "${spring-security.anonymous.key}" ) final String anonymousKey ) throws Exception {

        final AnonymousAuthenticationProvider provider = new AnonymousAuthenticationProvider(anonymousKey);
        provider.afterPropertiesSet();
        return provider;
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationProvider

    @Marker( SpringSecurityServices.class )
    public final AuthenticationProvider buildAnonymousAuthenticationProvider(
            @Inject @Value( "${spring-security.anonymous.key}" ) final String anonymousKey ) throws Exception {

        final AnonymousAuthenticationProvider provider = new AnonymousAuthenticationProvider(anonymousKey);
        provider.afterPropertiesSet();
        return provider;
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationProvider

    }

    @Override
    public void init(H http) throws Exception {
        if(authenticationProvider == null) {
            authenticationProvider = new AnonymousAuthenticationProvider(getKey());
        }
        if(authenticationFilter == null) {
            authenticationFilter = new AnonymousAuthenticationFilter(getKey(), principal, authorities);
        }
        authenticationProvider = postProcess(authenticationProvider);
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationProvider

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

    @Test
    public void testDetectsAnInvalidKey() throws Exception {
        AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider();
        aap.setKey("qwerty");

        AnonymousAuthenticationToken token = new AnonymousAuthenticationToken("WRONG_KEY", "Test",
                AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));

        try {
            aap.authenticate(token);
            fail("Should have thrown BadCredentialsException");
        } catch (BadCredentialsException expected) {
        }
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationProvider

        }
    }

    @Test
    public void testDetectsMissingKey() throws Exception {
        AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider();

        try {
            aap.afterPropertiesSet();
            fail("Should have thrown IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
            assertTrue(true);
        }
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationProvider

        }
    }

    @Test
    public void testGettersSetters() throws Exception {
        AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider();
        aap.setKey("qwerty");
        aap.afterPropertiesSet();
        assertEquals("qwerty", aap.getKey());
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationProvider

        assertEquals("qwerty", aap.getKey());
    }

    @Test
    public void testIgnoresClassesItDoesNotSupport() throws Exception {
        AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider();
        aap.setKey("qwerty");

        TestingAuthenticationToken token = new TestingAuthenticationToken("user", "password", "ROLE_A");
        assertFalse(aap.supports(TestingAuthenticationToken.class));

        // Try it anyway
        assertNull(aap.authenticate(token));
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationProvider

        assertNull(aap.authenticate(token));
    }

    @Test
    public void testNormalOperation() throws Exception {
        AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider();
        aap.setKey("qwerty");

        AnonymousAuthenticationToken token = new AnonymousAuthenticationToken("qwerty", "Test",
                AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));

        Authentication result = aap.authenticate(token);

        assertEquals(result, token);
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationProvider

        assertEquals(result, token);
    }

    @Test
    public void testSupports() {
        AnonymousAuthenticationProvider aap = new AnonymousAuthenticationProvider();
        assertTrue(aap.supports(AnonymousAuthenticationToken.class));
        assertFalse(aap.supports(TestingAuthenticationToken.class));
    }
View Full Code Here

Examples of org.springframework.security.authentication.AnonymousAuthenticationProvider

  @EnableResourceServer
  @EnableWebSecurity
  protected static class ResourceServerContext {
    @Autowired
    protected void init(AuthenticationManagerBuilder builder) {
      builder.authenticationProvider(new AnonymousAuthenticationProvider("default"));
    }
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.