Package org.springframework.security.crypto.password

Examples of org.springframework.security.crypto.password.PasswordEncoder


  public void testUpdateClientSecret() {

    BaseClientDetails clientDetails = new BaseClientDetails();
    clientDetails.setClientId("newClientIdWithNoDetails");

    service.setPasswordEncoder(new PasswordEncoder() {

      public boolean matches(CharSequence rawPassword,
          String encodedPassword) {
        return true;
      }
View Full Code Here


        User user = repo.findOne(iUserId);
        if (user == null) {
            throw new UserNotFoundEx(""+iUserId);
        }

        PasswordEncoder encoder = encoder(appContext);
    return updatePasswordWithNew(matchOldPassword, oldPassword, newPassword, user, encoder, repo);
  }
View Full Code Here

  }

  @Transactional
  public void createTestUsers() {
    PasswordEncoder encoder = injector.getInstance(PasswordEncoder.class);

    RoleEntity adminRole = new RoleEntity();
    adminRole.setRoleName("admin");

    UserEntity admin = new UserEntity();
    admin.setUserName("administrator");
    admin.setUserPassword(encoder.encode("admin"));

    Set<RoleEntity> roles = new HashSet<RoleEntity>();
    Set<UserEntity> users = new HashSet<UserEntity>();

    roles.add(adminRole);
    users.add(admin);

    admin.setRoleEntities(roles);
    adminRole.setUserEntities(users);

    userDAO.create(admin);
    roleDAO.create(adminRole);

    UserEntity userWithoutRoles = new UserEntity();
    userWithoutRoles.setUserName("userWithoutRoles");
    userWithoutRoles.setUserPassword(encoder.encode("test"));
    userDAO.create(userWithoutRoles);

  }
View Full Code Here

  }

  @Transactional
  public void createTestUsers() {
    PasswordEncoder encoder = injector.getInstance(PasswordEncoder.class);

    RoleEntity adminRole = new RoleEntity();
    adminRole.setRoleName("admin");

    UserEntity admin = new UserEntity();
    admin.setUserName("administrator");
    admin.setUserPassword(encoder.encode("admin"));

    Set<RoleEntity> roles = new HashSet<RoleEntity>();
    Set<UserEntity> users = new HashSet<UserEntity>();

    roles.add(adminRole);
    users.add(admin);

    admin.setRoleEntities(roles);
    adminRole.setUserEntities(users);

    userDAO.create(admin);
    roleDAO.create(adminRole);

    UserEntity userWithoutRoles = new UserEntity();
    userWithoutRoles.setUserName("userWithoutRoles");
    userWithoutRoles.setUserPassword(encoder.encode("test"));
    userDAO.create(userWithoutRoles);

  }
View Full Code Here

        }
    }

    private boolean verifyPassword(String username, String presentedPassword,
            String encodedPassword) {
        PasswordEncoder passwordEncoder = new StandardPasswordEncoder(username);
        if (passwordEncoder.matches(presentedPassword, encodedPassword)) {
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

        User user = userDao.findByCode(userId);
        if (user != null) {
            List<PwdLog> list = userPwdHistoryDao.findByUserCode(
                    user.getOid(), maxHistory);
            int i = 0;
            PasswordEncoder passwordEncoder = new StandardPasswordEncoder(
                    userId);
            for (PwdLog h : list) {
                // user status 不為 1 時,check change interval: 最近一次變更不得小於間隔
                if (i == 0 && !"1".equals(user.getStatus()) && !forcePwdChange) {
                    if (CapDate.calculateDays(Calendar.getInstance().getTime(),
                            h.getUpdateTime()) <= changeInteval) {
                        throw new CapMessageException(CapAppContext.getMessage(
                                "error.005", new Object[] { changeInteval }),
                                getClass());
                    }
                }
                if (passwordEncoder.matches(password, h.getPassword())) {
                    throw new CapMessageException(CapAppContext.getMessage(
                            "error.003", new Object[] { maxHistory }),
                            getClass());
                }
                i++;
View Full Code Here

    }// ;

    @Override
    public boolean validatePassword(String userId, String password) {
        User user = userDao.findByCode(userId);
        PasswordEncoder passwordEncoder = new StandardPasswordEncoder(userId);
        return passwordEncoder.matches(password, user.getPassword());
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.crypto.password.PasswordEncoder

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.