Examples of UserEntity


Examples of org.platformlayer.auth.UserEntity

  public UserEntity authenticate(String username, String password) throws AuthenticatorException {
    if (username == null || password == null) {
      return null;
    }

    UserEntity user;
    try {
      user = (UserEntity) repository.authenticateWithPassword(username, password);
    } catch (RepositoryException e) {
      throw new AuthenticatorException("Error while authenticating user", e);
    }
View Full Code Here

Examples of org.platformlayer.auth.UserEntity

    CryptoKey userSecret = authenticationSecrets.decryptSecretFromToken(tokenSecret);
    if (userSecret == null) {
      throw new AuthenticatorException("Authentication timed out");
    }

    UserEntity user;
    try {
      user = repository.findUserById(userId);
    } catch (RepositoryException e) {
      throw new AuthenticatorException("Error while authenticating user", e);
    }

    user.unlock(userSecret);

    // user.unlockWithToken(UserEntity.TOKEN_ID_DEFAULT, tokenSecret);

    if (user.isLocked()) {
      return null;
    }

    return user;
  }
View Full Code Here

Examples of org.platformlayer.auth.UserEntity

      log.debug("Checking publicKeyHash: " + publicKeyHash);

      byte[] hash = Hex.fromHex(publicKeyHash);

      UserEntity user;
      try {
        user = repository.findUserByPublicKey(hash);
      } catch (RepositoryException e) {
        throw new AuthenticatorException("Error while authenticating user", e);
      }
View Full Code Here

Examples of org.vosao.entity.UserEntity

  @Override
  public List<UserEntity> selectByGroup(final Long groupId) {
    List<UserGroupEntity> users = getUserGroupDao().selectByGroup(groupId);
    List<UserEntity> result = new ArrayList<UserEntity>();
    for (UserGroupEntity userGroup : users) {
      UserEntity user = getById(userGroup.getUserId());
      if (user != null) {
        result.add(user);
      }
    }
    return result;
View Full Code Here

Examples of org.vosao.entity.UserEntity

  implements UserBusiness {
 
  @Override
  public List<String> validateBeforeUpdate(final UserEntity user) {
    List<String> errors = new ArrayList<String>();
    UserEntity foundUser = getDao().getUserDao().getByEmail(user.getEmail());
    if (user.getId() == null) {
      if (foundUser != null) {
        errors.add(Messages.get("user_already_exists"));
      }
    }
    else {
      if (foundUser != null && !foundUser.getId().equals(user.getId())) {
        errors.add(Messages.get("user_already_exists"));
      }
    }
    if (StringUtils.isEmpty(user.getEmail())) {
      errors.add(Messages.get("email_is_empty"));
View Full Code Here

Examples of org.vosao.entity.UserEntity

    }
  }

  @Override
  public void forgotPassword(String email) {
    UserEntity user = getDao().getUserDao().getByEmail(email);
    if (user == null) {
      return;
    }
    String key = HashUtil.getMD5(email
        + String.valueOf((new Date()).getTime()));
    user.setForgotPasswordKey(key);
    getDao().getUserDao().save(user);
    String template = "";
    try {
      template = StreamUtil.getTextResource(
          "org/vosao/resources/html/forgot-letter.html");
View Full Code Here

Examples of org.vosao.entity.UserEntity

    return getDao().getUserDao().getById(id);
  }

  @Override
  public ServiceResponse save(Map<String, String> vo) {
    UserEntity user = null;
    if (!StringUtils.isEmpty(vo.get("id"))) {
      user = getDao().getUserDao().getById(Long.valueOf(vo.get("id")));
    }
    if (user == null) {
      user = new UserEntity();
    }
    user.setName(vo.get("name"));
    if (!StringUtils.isEmpty(vo.get("email"))) {
      user.setEmail(vo.get("email").toLowerCase());
    }
    if (!StringUtils.isEmpty(vo.get("password"))) {
      user.setPassword(BCrypt.hashpw(vo.get("password"),
          BCrypt.gensalt()));
    }
    if (!StringUtils.isEmpty(vo.get("role"))) {
      user.setRole(UserRole.valueOf(vo.get("role")));
    }
    if (!StringUtils.isEmpty(vo.get("timezone"))) {
      user.setTimezone(vo.get("timezone"));
    }
    if (!StringUtils.isEmpty(vo.get("disabled"))) {
      user.setDisabled(ParamUtil.getBoolean(vo.get("disabled"), false));
    }
    List<String> errors = getBusiness().getUserBusiness()
        .validateBeforeUpdate(user);
    if (errors.isEmpty()) {
      getDao().getUserDao().save(user);
View Full Code Here

Examples of org.vosao.entity.UserEntity

        Long.valueOf(groupId)));
  }

  @Override
  public ServiceResponse disable(Long userId, boolean disable) {
    UserEntity user = getDao().getUserDao().getById(userId);
    if (user == null) {
      return ServiceResponse.createErrorResponse(Messages.get(
          "user_not_found"));
    }
    user.setDisabled(disable);
    getDao().getUserDao().save(user);
    return ServiceResponse.createSuccessResponse(Messages.get("success"));
  }
View Full Code Here

Examples of org.vosao.entity.UserEntity

    getDao().getFolderDao().save(folder);
    return folder;
  }
 
  private UserEntity addUser(String name, String email, UserRole role) {
    UserEntity user = new UserEntity(name, name, email, role);
    getDao().getUserDao().save(user);
    return user;
  }
View Full Code Here

Examples of org.vosao.entity.UserEntity

        perm, group.getId());
    getDao().getFolderPermissionDao().save(p);
  }
 
  public void testGetPermission() {
    UserEntity developer = addUser("alex","kinyelo@gmail.com", UserRole.USER);
    UserEntity admin = addUser("admin","admin@gmail.com", UserRole.ADMIN);
    UserEntity manager = addUser("test1","test1@gmail.com", UserRole.USER);
    UserEntity dev2 = addUser("test2","test2@gmail.com", UserRole.USER);
    GroupEntity guests = addGroup("guests");
    GroupEntity managers = addGroup("managers");
    GroupEntity developers = addGroup("developers");
    addUserGroup(developer, developers);
    addUserGroup(manager, managers);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.