List of usage examples for org.springframework.security.core.authority AuthorityUtils createAuthorityList
public static List<GrantedAuthority> createAuthorityList(String... roles)
From source file:com.banco.security.CurrentUser.java
public CurrentUser(User user) { super(user.getUsername(), user.getPassword(), AuthorityUtils.createAuthorityList(user.getRole().toString())); this.user = user; }
From source file:com.changeme.security.SecurityUtils.java
/** * Configures the Spring Security {@link SecurityContext} to be authenticated as the user with the given username and * password as well as the given granted authorities. * /* w w w .j a v a2 s . c o m*/ * @param username must not be {@literal null} or empty. * @param password must not be {@literal null} or empty. * @param roles */ public static void runAs(String username, String password, String... roles) { Assert.notNull(username, "Username must not be null!"); Assert.notNull(password, "Password must not be null!"); SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(username, password, AuthorityUtils.createAuthorityList(roles))); }
From source file:com.clz.share.sec.util.SignInUtils.java
private static Principal signinPrivate(String userId) { Authentication authentication = new UsernamePasswordAuthenticationToken("user", "pass", AuthorityUtils.createAuthorityList("ROLE_USER")); SecurityContextHolder.getContext().setAuthentication(authentication); return (Principal) authentication.getPrincipal(); }
From source file:business.security.CustomAuthenticationProvider.java
public static List<GrantedAuthority> getAuthorityList(User user) { List<GrantedAuthority> authorityList = new ArrayList<GrantedAuthority>(); for (Role r : user.getRoles()) { authorityList.add(AuthorityUtils.createAuthorityList("ROLE_" + r.getName()).get(0)); }/*from w w w .ja v a 2 s . c om*/ return authorityList; }
From source file:com.example.session.domain.service.userdetails.AccountDetails.java
public AccountDetails(Account account) { super(account.getEmail(), account.getEncodedPassword(), AuthorityUtils.createAuthorityList("ROLE_USER")); this.account = account; }
From source file:com.example.security.domain.service.userdetails.SampleUserDetails.java
public SampleUserDetails(Account account) { // (3)/* www. j a v a 2s .c om*/ super(account.getUsername(), account.getPassword(), AuthorityUtils.createAuthorityList("ROLE_USER")); // (4) this.account = account; }
From source file:fr.lepellerin.ecole.bean.security.CurrentUser.java
/** * Constructeur./*from w ww . j ava 2 s. c o m*/ * @param user : l'utilisateur */ public CurrentUser(User user) { super(user.getUsername(), user.getPassword(), AuthorityUtils.createAuthorityList(user.getRole().toString())); this.user = user; }
From source file:com.kazuki43zoo.jpetstore.service.AccountUserDetails.java
AccountUserDetails(Account account) { super(account.getUsername(), account.getPassword(), AuthorityUtils.createAuthorityList("ROLE_USER")); this.account = account; }
From source file:de.chclaus.examples.ExampleUserDetailsService.java
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { return new User(username, "passwd", AuthorityUtils.createAuthorityList("ROLE_USER")); }
From source file:springchat.service.UserDetailsServiceImpl.java
@Override public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException { return new User(name, "", AuthorityUtils.createAuthorityList("ROLE_CHATUSER")); }