Example usage for org.springframework.security.authentication UsernamePasswordAuthenticationToken UsernamePasswordAuthenticationToken

List of usage examples for org.springframework.security.authentication UsernamePasswordAuthenticationToken UsernamePasswordAuthenticationToken

Introduction

In this page you can find the example usage for org.springframework.security.authentication UsernamePasswordAuthenticationToken UsernamePasswordAuthenticationToken.

Prototype

public UsernamePasswordAuthenticationToken(Object principal, Object credentials,
        Collection<? extends GrantedAuthority> authorities) 

Source Link

Document

This constructor should only be used by AuthenticationManager or AuthenticationProvider implementations that are satisfied with producing a trusted (i.e.

Usage

From source file:com.greglturnquist.spring.social.ecobee.SignInUtils.java

public static void signin(String userId) {
    SecurityContextHolder.getContext()//  w w w . j  a  v  a2 s. c  om
            .setAuthentication(new UsernamePasswordAuthenticationToken(userId, null, null));
}

From source file:com.faujnet.utils.SignInUtils.java

/**
 * Programmatically signs in the user with the given the user ID.
 *///from  ww  w.ja v  a2s .  c om
public static void signin(String userId) {

    SecurityContextHolder.getContext()
            .setAuthentication(new UsernamePasswordAuthenticationToken(userId, null, null));
}

From source file:com.notemyweb.spring.security.SignInUtils.java

/**
 * Programmatically signs in the user with the given the user ID.
 * @return //  w  w  w.ja  v a  2s  .co  m
 */
public static Authentication signin(String userId) {
    UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userId, null,
            null);
    SecurityContextHolder.getContext().setAuthentication(authentication);
    return authentication;
}

From source file:org.easit.core.controllers.signin.SignInUtils.java

/**
 * Programmatically signs in the user with the given the user ID.
 *    //Depercated//from   www. ja  v  a  2  s  .c o  m
 */
public static Authentication signin(String userId) {
    SecurityContextHolder.getContext()
            .setAuthentication(new UsernamePasswordAuthenticationToken(userId, null, null));
    return SecurityContextHolder.getContext().getAuthentication();
}

From source file:com.project.companyprofile.admin.misc.SignInUtils.java

/**
 * Programmatically signs in the user with the given the user ID.
 */// w w  w .  j a  va2s. c  o  m
public static void signin(LoginVo loginVo, List<GrantedAuthority> roles) {
    logger.info("Signin util fired!");

    SecurityContextHolder.getContext()
            .setAuthentication(new UsernamePasswordAuthenticationToken(loginVo, null, roles));
}

From source file:com.folion.social.SignInUtils.java

public static void signIn(String userIdentifier, SocialAccountService socialAccountService) {

    Account account = socialAccountService.getAccount(userIdentifier);
    List<GrantedAuthority> grantedAuthorities = createAuthorities(account.getAccountRole());
    SecurityContextHolder.getContext().setAuthentication(
            new UsernamePasswordAuthenticationToken(userIdentifier, null, grantedAuthorities));
}

From source file:com.clz.share.sec.util.SignInUtils.java

/**
 * Programmatically signs in the user with the given the user ID.
 *//*from  w  w  w.j  a  v a 2 s.  com*/
public static void signin(String userId) {
    SecurityContextHolder.getContext()
            .setAuthentication(new UsernamePasswordAuthenticationToken(userId, null, null));
}

From source file:eu.gyza.eap.service.HelloService.java

public HelloService() {
    SecurityContextHolder.getContext()
            .setAuthentication(new UsernamePasswordAuthenticationToken("deslos@yahoo.com", null, null));
}

From source file:org.cloudbyexample.dc.service.util.SecurityContextUtil.java

public static void createSystemUser() {
    SecurityContext context = SecurityContextHolder.getContext();

    // Set the granted authorities so that the user is not authenticated again
    List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
    grantedAuthorities.add(new SimpleGrantedAuthority("ROLE_SYSTEM"));

    UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("system", "",
            grantedAuthorities);/* w  w w . j  av a2s  .  co  m*/

    context.setAuthentication(token);
}

From source file:com.lateralthoughts.commons.security.SecurityUtils.java

/**
 * Programmatically signs in the user with the given the user ID.
 *//* w ww.ja v  a2 s  . c  o  m*/
static void signin(AccountWrapper userDetailsPrincipal) {
    SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
            userDetailsPrincipal, null, userDetailsPrincipal.getAuthorities()));
}