Exemplo n.º 1
0
  @Transactional(readOnly = true)
  @Override
  public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException {

    com.oguchok.isite.persistence.model.User user = userRepository.findByUsername(username);
    if (user == null) {
      throw new UsernameNotFoundException("No user found with username: " + username);
    }

    List<GrantedAuthority> authorities = buildUserAuthority(user.getRoles());

    return buildUserForAuthentication(user, authorities);
  }
Exemplo n.º 2
0
  private void confirmRegistration(OnRegistrationCompleteEvent event) {
    User user = event.getUser();
    String token = UUID.randomUUID().toString();
    service.createVerificationToken(user, token);

    String recipientAddress = user.getEmail();
    String subject = "Registration Confirmation";
    String confirmationUrl = event.getAppUrl() + "/registrationConfirm.html?token=" + token;
    String message = messages.getMessage("message.regSucc", null, event.getLocale());
    SimpleMailMessage email = new SimpleMailMessage();
    email.setTo(recipientAddress);
    email.setSubject(subject);
    email.setText(message + " \r\n" + "http://localhost:8080" + confirmationUrl);
    mailSender.send(email);
  }
Exemplo n.º 3
0
 private User buildUserForAuthentication(
     com.oguchok.isite.persistence.model.User user, List<GrantedAuthority> authorities) {
   return new User(
       user.getUsername(), user.getPassword(), user.isEnabled(), true, true, true, authorities);
 }