Package org.ngrinder.security

Examples of org.ngrinder.security.SecuredUser


      user.setUserName("TEST_USER");
      user.setEmail("TEST_USER@nhn.com");
      user.setPassword("123");
      user.setRole(Role.USER);

      SecuredUser securedUser = new SecuredUser(user, null);
      String encodePassword = passwordEncoder.encodePassword(user.getPassword(), saltSource.getSalt(securedUser));
      user.setPassword(encodePassword);

      userRepository.save(user);
    }
View Full Code Here


    }
    Object obj = auth.getPrincipal();
    if (!(obj instanceof SecuredUser)) {
      throw new AuthenticationCredentialsNotFoundException("Invalid authentication with " + obj);
    }
    SecuredUser securedUser = (SecuredUser) obj;
    return securedUser.getUser();
  }
View Full Code Here

   *
   * @param user user
   */
  public void encodePassword(User user) {
    if (StringUtils.isNotBlank(user.getPassword())) {
      SecuredUser securedUser = new SecuredUser(user, null);
      String encodePassword = passwordEncoder.encodePassword(user.getPassword(), saltSource.getSalt(securedUser));
      user.setPassword(encodePassword);
    }
  }
View Full Code Here

        .PROP_CONTROLLER_ADMIN_PASSWORD_RESET)) {
      final User admin = userRepository.findOneByUserId("admin");
      if (admin == null) {
        createUser("admin", "admin", Role.ADMIN, "admin", "admin@nhn.com");
      } else {
        SecuredUser securedUser = new SecuredUser(admin, null);
        Object salt = saltSource.getSalt(securedUser);
        admin.setRole(Role.ADMIN);
        admin.setPassword(passwordEncoder.encodePassword("admin", salt));
        userRepository.saveAndFlush(admin);
      }
View Full Code Here

   */
  private void createUser(String userId, String password, Role role, String userName, String email) {
    if (userRepository.findOneByUserId(userId) == null) {
      User user = new User();
      user.setUserId(userId);
      SecuredUser securedUser = new SecuredUser(user, null);
      Object salt = saltSource.getSalt(securedUser);
      user.setPassword(passwordEncoder.encodePassword(password, salt));
      user.setRole(role);
      user.setUserName(userName);
      user.setEmail(email);
View Full Code Here

TOP

Related Classes of org.ngrinder.security.SecuredUser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.