Package org.opentides.persistence

Examples of org.opentides.persistence.UserDAO


    UserServiceImpl.roles = roles;
  }

  @Override
  public void requestPasswordReset(String emailAddress) {
    UserDAO userDAO = (UserDAO) getDao();
    if (!userDAO.isRegisteredByEmail(emailAddress))
      throw new InvalidImplementationException(
          "Email ["
              + emailAddress
              + "] was not validated prior to calling this service. Please validate first.");
    PasswordReset passwd = new PasswordReset();
View Full Code Here


    PasswordReset actual = actuals.get(0);
    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

   */
  @Override
  public boolean setupAdminUser() {
    boolean exist = false;
    // let's check if there are users in the database
    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

   * history log.
   */
  @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());
View Full Code Here

    if (userObj instanceof SessionUser) {
      SessionUser sessionUser = (SessionUser) userObj;
      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);
View Full Code Here

TOP

Related Classes of org.opentides.persistence.UserDAO

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.