Example usage for org.springframework.security.core.userdetails User User

List of usage examples for org.springframework.security.core.userdetails User User

Introduction

In this page you can find the example usage for org.springframework.security.core.userdetails User User.

Prototype

public User(String username, String password, Collection<? extends GrantedAuthority> authorities) 

Source Link

Document

Calls the more complex constructor with all boolean arguments set to true .

Usage

From source file:de.msg.security.CustomUserDetailsService.java

@Override
public UserDetails loadUserByUsername(String username) {
    List<GrantedAuthority> authorities = new ArrayList<>();
    SimpleGrantedAuthority authority = new SimpleGrantedAuthority("ROLE_USER");
    authorities.add(authority);/*www  .  java  2 s .  co m*/
    return new User(username, "password", authorities);
}

From source file:org.mitre.provenance.openid.OpenID2UserDetailsService.java

public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    Set<SimpleGrantedAuthority> authorities = new HashSet<SimpleGrantedAuthority>();
    authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
    return new User(username, "", authorities);
}

From source file:jp.pigumer.app.UserDetailsServiceImpl.java

@Override
public UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token) throws UsernameNotFoundException {
    LOG.info(Objects.toString(token, "null"));
    return new User(token.getName(), "<abc123>", token.getAuthorities());
}

From source file:com.mastercard.test.spring.security.SpringTestApplication.java

/**
 * Provide an instance of UserDetailsService to help test @WithUserDetails.
 * @return The instance of UserDetailsService.
 *///from w  ww. j  a  va  2s  .  co  m
@Bean
public UserDetailsService getUserDetailsService() {
    return new UserDetailsService() {
        @Override
        public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
            return new User(username, "password", new ArrayList<>());
        }
    };
}

From source file:com.greglturnquist.payroll.SpringDataJpaUserDetailsService.java

@Override
public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException {
    Manager manager = this.repository.findByName(name);
    return new User(manager.getName(), manager.getPassword(),
            AuthorityUtils.createAuthorityList(manager.getRoles()));
}

From source file:pl.com.softproject.diabetyk.web.services.UserServiceImpl.java

@Override
public void registerUser(String username, String password, String email) {
    List<GrantedAuthority> auth = Arrays
            .asList(new GrantedAuthority[] { new SimpleGrantedAuthority("ROLE_USER") });

    User user = new User(username, password, auth);
    userDetailsManager.createUser(user);
    UserData userData = new UserData(username, email);
    userData.setCreated(new Date());
    userDataDAO.save(userData);/*from   w  w  w .  ja v a 2  s.  c om*/
}

From source file:rzd.vivc.documentexamination.service.UserService.java

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    Account account = accountRepository.findByLogin(username);
    if (account != null) {
        List<GrantedAuthority> autiriries = new ArrayList<>();
        autiriries.add(new SimpleGrantedAuthority(account.getUserType().getAutority()));
        return new User(account.getLogin(), account.getPassword(), autiriries);

    }//from  w w  w. j a  v a  2  s .co m
    throw new UsernameNotFoundException(" " + username + "  .");
}

From source file:com.mastercard.test.spring.security.SpringTestApplicationWith2UserDetailsServiceBeans.java

/**
 * Provide an instance of UserDetailsService to help test @WithUserDetails.
 * @return The instance of UserDetailsService.
 *///from ww  w. ja v a2 s  .c om
@Bean
public UserDetailsService getUserDetailsService1() {
    return new UserDetailsService() {
        @Override
        public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
            return new User(username, "password", new ArrayList<>());
        }
    };
}

From source file:org.mitre.provenance.openid.OpenId2AuthenticationUserDetailsService.java

public UserDetails loadUserDetails(OpenIDAuthenticationToken auth) throws UsernameNotFoundException {
    Set<SimpleGrantedAuthority> authorities = new HashSet<SimpleGrantedAuthority>();
    authorities.add(new SimpleGrantedAuthority("ROLE_USER"));

    OpenIDAuthenticationToken oidToken = (OpenIDAuthenticationToken) auth;

    String oid2UniqueId = oidToken.getName();
    return new User(oid2UniqueId, "", authorities);
}

From source file:com.greenbird.mule.http.log.converter.UserNameConverterTest.java

@Test
public void doConvert_springPrincipalAvailable_userNameFound() throws Exception {
    Collection<? extends GrantedAuthority> emptyList = Collections.emptyList();
    String logOutput = logWithSession(UserNameConverter.CONVERSION_CHARACTER,
            securedSession(new User(TEST_USER, "pw", emptyList)));
    assertThat(logOutput, is(TEST_USER));
}