Examples of BaseUser


Examples of org.opentides.bean.user.BaseUser

       
    }
 
  @Test
    public void testLoadByEmailAddress() {
      BaseUser user = coreUserDAO.loadByEmailAddress("admin@ideyatech.com");
      assertEquals("SuperAdmin", user.getFirstName());
        assertEquals("User", user.getLastName());     
    }
View Full Code Here

Examples of org.opentides.bean.user.BaseUser

 
    @Test
  public void testFindByUsergroupName() {
   
        // a user can be member of multiple user group
        user = new BaseUser();
        user.addGroup(group1);
        user.addGroup(group2);
        user.setEmailAddress("multiple@unittest.com");
        UserCredential userAccount = new UserCredential();
        userAccount.setPassword("test");
View Full Code Here

Examples of org.opentides.bean.user.BaseUser

    }
 
  @Test
  public void testUniqueUsernameConstraints() {
    try {
      BaseUser user = new BaseUser();
      user.addGroup(group1);
      user.setFirstName("SuperUser");
      user.setLastName("Duplicate");
      user.setEmailAddress("duplicate@unittest.com");
      UserCredential userAccount = new UserCredential();
      userAccount.setPassword("unittest");
      userAccount.setUsername("admin");
      userAccount.setUser(user);
      user.setCredential(userAccount);
      coreUserDAO.saveEntityModel(user);
      fail("Failed to throw exception on duplicate username");
    } catch (Exception e) {
      // success
    }
View Full Code Here

Examples of org.opentides.bean.user.BaseUser

  }
 
  @Test
  public void testUniqueEmailConstraints() {
    try {
      BaseUser user = new BaseUser();
      user.addGroup(group1);
      user.setFirstName("SuperUser");
      user.setLastName("Duplicate");
      user.setEmailAddress("admin@ideyatech.com");
      UserCredential userAccount = new UserCredential();
      userAccount.setPassword("unittest");
      userAccount.setUsername("admin");
      userAccount.setUser(user);
      user.setCredential(userAccount);
      coreUserDAO.saveEntityModel(user);
      fail("Failed to throw exception on duplicate email");
    } catch (Exception e) {
     
    }
View Full Code Here

Examples of org.opentides.bean.user.BaseUser

    actual.setStatus(PasswordReset.STATUS_USED);
    passwordResetDAO.saveEntityModel(actual);

    // now reset the password
    UserDAO userDAO = (UserDAO) getDao();
    BaseUser user = userDAO.loadByEmailAddress(passwd.getEmailAddress());
    user.getCredential().setPassword(passwd.getPassword());
    userDAO.saveEntityModel(user);

    return true;
  }
View Full Code Here

Examples of org.opentides.bean.user.BaseUser

    UserDAO userDAO = (UserDAO) getDao();
    if (userDAO.countAll() > 0)
      exist = true;
    else {
      // if none, let's create admin user
      BaseUser user = new BaseUser();
      UserCredential cred = new UserCredential();
      cred.setUsername("admin");
      cred.setPassword("ideyatech");
      cred.setEnabled(true);
      cred.setUser(user);
      user.setCredential(cred);
      user.setEmailAddress("admin@ideyatech.com");
      user.setFirstName("SuperAdmin");
      user.setLastName("User");

      // create usergroup for user
      UserGroup userGroup = new UserGroup();
      userGroup.setName("Super User");
      userGroup.setDescription("With all roles");

      // Let's super user role
      List<String> roleNames = new ArrayList<String>();
      roleNames.add("SUPER_USER");
      roleNames.add("ACCESS_ALL");
      userGroup.setRoleNames(roleNames);
      userGroupDAO.saveEntityModel(userGroup);

      user.addGroup(userGroup);
      userDAO.saveEntityModel(user);
      _log.info("New installation detected, inserted admin/ideyatech user to database.");
    }
    return !exist;
  }
View Full Code Here

Examples of org.opentides.bean.user.BaseUser

  @Override
  public void updateLogin(
      AuthenticationSuccessEvent authenticationSuccessEvent) {
    UserDAO userDAO = (UserDAO) getDao();
    String username = authenticationSuccessEvent.getAuthentication().getName();
    BaseUser user = userDAO.loadByUsername(username);
    WebAuthenticationDetails details = (WebAuthenticationDetails) authenticationSuccessEvent.getAuthentication().getDetails();
    String address = details.getRemoteAddress();
    if (user.getTotalLoginCount()== null)
      user.setTotalLoginCount(1l);
    else
      user.setTotalLoginCount(user.getTotalLoginCount()+1);
    user.setPrevLoginIP(user.getLastLoginIP());
    user.setLastLoginIP(address);
    user.setLastLogin(new Date());
    user.setSkipAudit(true);   
    userDAO.saveEntityModel(user);
    // userDAO.updateLastLogin(username);

    // force the audit user details
    String completeName = user.getCompleteName() + " [" + username + "] ";
    user.setAuditUserId(user.getId());
    if (user.getOffice() != null)
      user.setAuditOfficeName(user.getOffice().getValue());
    user.setAuditUsername(username);
    user.setSkipAudit(false);
    String message = completeName + " has logged-in with IP: " + address;
    AuditLogDAOImpl.logEvent(message, message, user);

  }
View Full Code Here

Examples of org.opentides.bean.user.BaseUser

      String username = sessionUser.getUsername();
      String completeName = sessionUser.getCompleteName() + " ["
          + username + "] ";
      UserDAO userDAO = (UserDAO) getDao();
      // also add log to audit history log
      BaseUser user = userDAO.loadByUsername(username);
      // force the audit user details
      user.setAuditUserId(user.getId());
      if (user.getOffice() != null)
        user.setAuditOfficeName(user.getOffice().getValue());
      user.setAuditUsername(username);
      String message = completeName + " has logged-out.";
      AuditLogDAOImpl.logEvent(message, message, user);
    }
  }
View Full Code Here

Examples of org.opentides.bean.user.BaseUser

  public boolean supports(Class clazz) {
    return BaseUser.class.isAssignableFrom(clazz);
  }

  public void validate(Object object, Errors e) {
    BaseUser user = (BaseUser) object;

    ValidationUtils.rejectIfEmptyOrWhitespace(e, "firstName",
        "error.required", new Object[]{"First Name"},"First name is required.");

    ValidationUtils.rejectIfEmptyOrWhitespace(e, "lastName",
        "error.required", new Object[]{"Last Name"},"Last name is required.");

    ValidationUtils.rejectIfEmptyOrWhitespace(e, "credential.username",
        "error.required", new Object[]{"Username"},"Username is required.");
    if (isDuplicateUsername(user)) {
      e.reject("error.duplicate-field", new Object[]{user.getCredential().getUsername(), "username"}, "User name already exists.");
    }

    ValidationUtils.rejectIfEmptyOrWhitespace(e, "emailAddress",
        "error.required", new Object[]{"Email Address"},"Email address is required.");
    if (!ValidatorUtil.isEmail(user.getEmailAddress())) {
      e.rejectValue("emailAddress", "error.invalid-email-address",new Object[]{user.getEmailAddress()},"Email Address is invalid.");
    }
    if (isDuplicateEmail(user)) {
      e.reject("error.duplicate-field", new Object[]{user.getEmailAddress(),"email"}, "Email address already exists.");
    }

    if (user.getIsNew()) {
      ValidationUtils.rejectIfEmptyOrWhitespace(e, "credential.newPassword",
        "error.required", new Object[]{"Password"},"Password is required.");
      ValidationUtils.rejectIfEmptyOrWhitespace(e, "credential.confirmPassword",
        "error.required", new Object[]{"Confirm Password"},"Confirm password is required.");
    }
   
    if (!StringUtil.isEmpty(user.getCredential().getNewPassword()) &&
        !StringUtil.isEmpty(user.getCredential().getConfirmPassword()) &&
        !user.getCredential().getNewPassword().equals(user.getCredential().getConfirmPassword())) {
      e.reject("error.password-confirmation-did-not-match", "Password confirmation did not match.");
    }
  }
View Full Code Here

Examples of org.opentides.bean.user.BaseUser

   * @return boolean return true if duplicate username was found, false otherwise.
   */
  private boolean isDuplicateUsername(BaseUser user) {
    String userName = user.getCredential().getUsername();
    if (userName != null && !StringUtil.isEmpty(userName)){
      BaseUser userCheck = userDAO.loadByUsername(userName);
      if (userCheck != null && user.isNew())
        return true;   
      if (userCheck != null && !userCheck.getId().equals(user.getId()))
        return true;
    }
    return false;
  }
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.