Package org.springframework.security.authentication

Examples of org.springframework.security.authentication.AuthenticationManager


     */
    @Test
    public void testCorrectPass() throws Exception {

        Authentication token = new UsernamePasswordAuthenticationToken("user", "pass");
        AuthenticationManager manager = createMock(AuthenticationManager.class);
        processingFiler.setAuthenticationManager(manager);

        SAMLTestHelper.setLocalContextParameters(request, "/saml", null);

        final Capture<SAMLMessageContext> context = new Capture<SAMLMessageContext>();
        expect(request.getRequestURL()).andReturn(new StringBuffer("http://localhost:8081/spring-security-saml2-webapp/saml/SSO"));
        expect(processor.retrieveMessage(capture(context))).andAnswer(new IAnswer<SAMLMessageContext>() {
            public SAMLMessageContext answer() throws Throwable {
                context.getValue().setInboundSAMLBinding(org.opensaml.common.xml.SAMLConstants.SAML2_POST_BINDING_URI);
                return context.getValue();
            }
        });
        expect(manager.authenticate((Authentication) notNull())).andReturn(token);

        replay(manager);
        replayMock();
        Authentication authentication = processingFiler.attemptAuthentication(request, null);
        assertEquals(token, authentication);
View Full Code Here


    }

    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
      endpoints.authorizationCodeServices(authorizationCodeServices())
          .authenticationManager(new AuthenticationManager() {
            // TODO: unwind this workaround for Spring Boot issue (when 1.1.9 is out)
            @Override
            public Authentication authenticate(Authentication authentication)
                throws AuthenticationException {
              return auth.getOrBuild().authenticate(authentication);
View Full Code Here

    assertNull(authentication.getOAuth2Request().getRequestParameters().get("password"));
  }

  @Test
  public void testExtraParameters() {
    authenticationManager = new AuthenticationManager() {
      @Override
      public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        if (authentication instanceof UsernamePasswordAuthenticationToken) {
          UsernamePasswordAuthenticationToken user = (UsernamePasswordAuthenticationToken) authentication;
          user = new UsernamePasswordAuthenticationToken(user.getPrincipal(), "N/A",
View Full Code Here

    assertNull(authentication.getUserAuthentication().getDetails());
  }

  @Test(expected = InvalidGrantException.class)
  public void testBadCredentials() {
    ResourceOwnerPasswordTokenGranter granter = new ResourceOwnerPasswordTokenGranter(new AuthenticationManager() {
      public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        throw new BadCredentialsException("test");
      }
    }, providerTokenServices, clientDetailsService, requestFactory);
    granter.grant("password", tokenRequest);
View Full Code Here

    granter.grant("password", tokenRequest);
  }

  @Test(expected = InvalidGrantException.class)
  public void testAccountLocked() {
    ResourceOwnerPasswordTokenGranter granter = new ResourceOwnerPasswordTokenGranter(new AuthenticationManager() {
      public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        throw new LockedException("test");
      }
    }, providerTokenServices, clientDetailsService, requestFactory);
    granter.grant("password", tokenRequest);
View Full Code Here

  }

  @Override
  public void configure(HttpSecurity http) throws Exception {

    AuthenticationManager oauthAuthenticationManager = oauthAuthenticationManager(http);
    resourcesServerFilter = new OAuth2AuthenticationProcessingFilter();
    resourcesServerFilter.setAuthenticationManager(oauthAuthenticationManager);
    if (tokenExtractor != null) {
      resourcesServerFilter.setTokenExtractor(tokenExtractor);
    }
View Full Code Here

  private Authentication authentication;

  @Before
  public void init() {
    AuthenticationManager authenticationManager = this.context
        .getBean(AuthenticationManager.class);
    this.authentication = authenticationManager
        .authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
  }
View Full Code Here

    if (token == null)
      throw new LoginException("Insufficient information to login");
    // Attempt authentication.
    try
    {
      AuthenticationManager authenticationManager =
        ((SpringSecureWicketApplication) Application.get()).getAuthenticationManager();
      if (authenticationManager == null)
        throw new LoginException(
          "AuthenticationManager is not available, check if your spring config contains a property for the authenticationManager in your wicketApplication bean.");
      Authentication authResult = authenticationManager.authenticate(token);
      setAuthentication(authResult);
    }

    catch (RuntimeException e)
    {
View Full Code Here

    /*
     * This AuthenticationManagerBuilder is for the global AuthenticationManager
     */
    BootDefaultingAuthenticationConfigurerAdapter configurer = new BootDefaultingAuthenticationConfigurerAdapter();
    configurer.configure(auth);
    AuthenticationManager manager = configurer.getAuthenticationManagerBuilder()
        .getOrBuild();
    configurer.configureParent(auth);
    return manager;

  }
View Full Code Here

    public void onApplicationEvent(ContextRefreshedEvent event) {
      ApplicationContext context = event.getApplicationContext();
      if (context.getBeanNamesForType(AuthenticationManager.class).length == 0) {
        return;
      }
      AuthenticationManager manager = context.getBean(AuthenticationManager.class);
      if (manager instanceof ProviderManager) {
        ((ProviderManager) manager)
            .setAuthenticationEventPublisher(this.authenticationEventPublisher);
      }
    }
View Full Code Here

TOP

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

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.