List of usage examples for org.springframework.security.core.userdetails User User
public User(String username, String password, Collection<? extends GrantedAuthority> authorities)
From source file:io.github.arven.rs.services.example.UserService.java
public UserDetails loadUserByUsername(String string) throws UsernameNotFoundException { Person data = blogService.getUser(string); if (data != null) { return new User(data.getId(), data.getPassword(), Arrays.asList(new SimpleGrantedAuthority("User"))); } else {/*from w w w. ja v a 2s .c o m*/ throw new UsernameNotFoundException("Name not found!"); } }
From source file:programacaovi.spring.security.FakeUserDetailsService.java
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { Pessoa person = personRepository.findByNome(username); if (person == null) { throw new UsernameNotFoundException("Username " + username + " no encontrado"); }//from w w w .j a v a2s .co m return new User(username, "password", getGrantedAuthorities(username)); }
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:com.futuretech.service.LoginService.java
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { Users user = userDao.findByUsername(username); if (user == null) { throw new UsernameNotFoundException("Oops!"); }//from w ww .ja v a 2s.c o m List<SimpleGrantedAuthority> authorities = Arrays.asList(new SimpleGrantedAuthority(user.getRole())); return new User(user.getUsername(), user.getPassword(), authorities); }
From source file:springchat.service.UserDetailsServiceImpl.java
@Override public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException { return new User(name, "", AuthorityUtils.createAuthorityList("ROLE_CHATUSER")); }
From source file:com.rd.adchallenge.security.OpenIdUserDetailsService.java
public UserDetails loadUserDetails(OpenIDAuthenticationToken token) throws UsernameNotFoundException { return new User(token.getName(), "", AuthorityUtils.createAuthorityList("ROLE_USER")); }
From source file:com.mec.Security.CustomAuthenticationProvider.java
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { Authentication auth = null;//www. ja v a2 s. c o m final String name = authentication.getName(); final String password = authentication.getCredentials().toString(); if (name != null && password != null) { Usuario u = userDAO.getUser(name, password); if (u != null) { final UserDetails principal = new User(u.getId() + ";" + name, password, u.getRoles()); auth = new UsernamePasswordAuthenticationToken(principal, password, u.getRoles()); } } return auth; }
From source file:authentication.DefaultUserDetails.java
@Override public UserDetails loadUserByUsername(final String name) throws UsernameNotFoundException { final UserSnack userSnack = userRepository.getByUsername(name); return new User(userSnack.getName(), userSnack.getPassword(), getAuthorities(userSnack)); }
From source file:capital.scalable.restdocs.example.security.CustomUserDetailsService.java
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { // Usually, you would consult a database, but for simplicity we hardcode a user // with username "test" and password "test". if ("test".equals(username)) { return new User(username, "test", Collections.<GrantedAuthority>emptyList()); } else {//from www. j av a 2s .c o m throw new UsernameNotFoundException(String.format("User %s does not exist!", username)); } }
From source file:jp.pigumer.security.ExampleUserDetailsServiceImpl.java
@Override public User loadUser(String username) { LOG.info("loadUser: " + username); List<GrantedAuthority> authorities = new ArrayList<>(); GrantedAuthority authority = new SimpleGrantedAuthority("ROLE_USER"); authorities.add(authority);/*from ww w . j a va 2 s . c o m*/ return new User(username, "<abc123>", authorities); }