public void good(String passwd) throws Exception { SimpleUserService.validatePassword(passwd); }
/** * Used only by command line for set-password * @param userName username of user whose password is being reset * @param password password * @throws IllegalArgumentException if user does not exist or password doesn't fit minimum requirements */ public void setPassword(String userName, String password) throws IllegalArgumentException { validatePassword(password); UserInfo info = findUserByUserName(userName); if (info == null) { throw new IllegalArgumentException(format("user %s does not exist", userName)); } info.setAuth(buildUserAuth(info.getConfig().getUid(), password)); userStore.put(info.getConfig().getUid(), info); }
public void bad(String passwd, String err) throws Exception { try { SimpleUserService.validatePassword(passwd); fail("Password '" + passwd + "' should not be accepted."); } catch (UserException e) { assertEquals("Expected a VALIDATION error but got " + e.getErrorType(), ErrorType.VALIDATION, e.getErrorType()); assertTrue("Unexpected error message", e.getOriginalMessage().contains(err)); } }
@Override public User createUser(final User userConfig, final String authKey) throws IOException, IllegalArgumentException { final String userName = userConfig.getUserName(); if (findUserByUserName(userName) != null) { throw UserException.validationError() .message("User [%s] already exists", userName) .build(logger); } validatePassword(authKey); UserConfig newUser = toUserConfig(userConfig) .setUid(new UID(UUID.randomUUID().toString())) .setCreatedAt(System.currentTimeMillis()) .setModifiedAt(userConfig.getCreatedAt()) .setTag(null); UserInfo userInfo = new UserInfo(); userInfo.setConfig(newUser); userInfo.setAuth(buildUserAuth(newUser.getUid(), authKey)); userStore.put(newUser.getUid(), userInfo); // Return the new state return fromUserConfig(newUser); }
validatePassword(authKey); info.setAuth(buildUserAuth(userConfig.getUid(), authKey)); } else {
@Override public User updateUser(final User userGroup, final String authKey) throws IOException, IllegalArgumentException, UserNotFoundException { UserConfig userConfig = toUserConfig(userGroup); final String userName = userConfig.getUserName(); final UserInfo oldUserInfo = findUserByUserName(userName); if (oldUserInfo == null) { throw new UserNotFoundException(userName); } merge(userConfig, oldUserInfo.getConfig()); userConfig.setModifiedAt(System.currentTimeMillis()); UserInfo newUserInfo = new UserInfo(); newUserInfo.setConfig(userConfig); if(authKey != null){ validatePassword(authKey); newUserInfo.setAuth(buildUserAuth(oldUserInfo.getConfig().getUid(), authKey)); } else { newUserInfo.setAuth(oldUserInfo.getAuth()); } userStore.put(userConfig.getUid(), newUserInfo); // Return the new state return fromUserConfig(userConfig); }