Home Package Class Method

Examples of UsernamePasswordAuthenticationToken


Examples of org.acegisecurity.providers.UsernamePasswordAuthenticationToken

public class AcegiWorkflowContextHandlerInterceptorTests extends AbstractWorkflowContextHandlerInterceptorTests {


  protected MockHttpServletRequest getMockRequest(String userName) {
    User user = new User(userName, "dummy", true, true, true, true, new GrantedAuthority[]{});
    Authentication auth = new UsernamePasswordAuthenticationToken(user, null);
    SecurityContext context = new SecurityContextImpl();
    context.setAuthentication(auth);
    SecurityContextHolder.setContext(context);

    return new MockHttpServletRequest();
View Full Code Here

Examples of org.springframework.security.authentication.UsernamePasswordAuthenticationToken

    }

    private void login(String username) throws UsernameNotFoundException {
        MDC.putUsername(username);
        UserDetails user = userDetailsService.loadUserByUsername(username);
        Authentication auth = new UsernamePasswordAuthenticationToken(user, user.getPassword(), user.getAuthorities());
        SecurityContextHolder.getContext().setAuthentication(auth);
        log.info("Logged in as {}", quote(username));
    }
View Full Code Here

Examples of org.springframework.security.authentication.UsernamePasswordAuthenticationToken

  public static void reauthenticate(final String username, final String password) {
    UserDetailsService userDetailsService = getBean("userDetailsService");
    UserCache userCache = getBean("userCache");

    UserDetails userDetails = userDetailsService.loadUserByUsername(username);
    SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
        userDetails, password == null ? userDetails.getPassword() : password, userDetails.getAuthorities()));
    userCache.removeUserFromCache(username);
  }
View Full Code Here

Examples of org.springframework.security.authentication.UsernamePasswordAuthenticationToken

            return new LoginStatus(false, null, auth.getAuthorities());
        }
    }

    public LoginStatus login(String username, String password) {
        UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);
        logger.debug("Attempting login.");
        try {
            Authentication auth = authenticationManager.authenticate(token);
            logger.debug("Login succeeded!");
            SecurityContextHolder.getContext().setAuthentication(auth);
View Full Code Here

Examples of org.springframework.security.authentication.UsernamePasswordAuthenticationToken

  public void signin(Account account) {
    SecurityContextHolder.getContext().setAuthentication(authenticate(account));
  }
 
  private Authentication authenticate(Account account) {
    return new UsernamePasswordAuthenticationToken(createUser(account), null, Collections.singleton(createAuthority(account)));   
  }
View Full Code Here

Examples of org.springframework.security.authentication.UsernamePasswordAuthenticationToken

  public void testBasic() throws MalformedURLException {
    SecurityContext context = new SecurityContext() {

      @Override
      public Authentication getAuthentication() {
        Authentication auth = new UsernamePasswordAuthenticationToken("fred","barney");
        return auth;
      }

      @Override
      public void setAuthentication(Authentication arg0) {
View Full Code Here

Examples of org.springframework.security.authentication.UsernamePasswordAuthenticationToken

    final UserDetails ud = new GeoServerUser("fred");
    SecurityContext context = new SecurityContext() {

      @Override
      public Authentication getAuthentication() {
        Authentication auth = new UsernamePasswordAuthenticationToken(ud,"barney");
        return auth;
      }

      @Override
      public void setAuthentication(Authentication arg0) {
View Full Code Here

Examples of org.springframework.security.authentication.UsernamePasswordAuthenticationToken

            ResourceBundle rb = CommonUtil.getResourceBundle();
            String errorMessage = rb.getString("error.login.denied");
            throw new AuthenticationServiceException(errorMessage);
        }

        UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
                username, password);
        setDetails(request, authRequest);

        // return authRequest;
        return this.getAuthenticationManager().authenticate(authRequest);
View Full Code Here

Examples of org.springframework.security.authentication.UsernamePasswordAuthenticationToken

 
  /**
   * Programmatically signs in the user with the given the user ID.
   */
  public static void signin(String userId) {
    SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(userId, null, null))
  }
View Full Code Here

Examples of org.springframework.security.authentication.UsernamePasswordAuthenticationToken

 
  /**
   * Programmatically signs in the user with the given the user ID.
   */
  public static void signin(String userId) {
    SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(userId, null, null))
  }
View Full Code Here
TOP
Copyright © 2015 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.