Search in sources :

Example 11 with UserInfo

use of org.vcell.util.document.UserInfo in project vcell by virtualcell.

the class UserDbDriver method sendLostPassword.

public void sendLostPassword(Connection con, String userid) throws SQLException, DataAccessException, ObjectNotFoundException {
    User user = getUserFromUserid(con, userid);
    if (user == null) {
        throw new ObjectNotFoundException("User name " + userid + " not found.");
    }
    UserInfo userInfo = getUserInfo(con, user.getID());
    String clearTextPassword = randomPassword();
    try {
        // Reset User Password
        updatePasswords(con, userInfo.id, clearTextPassword);
        // Send new password to user
        PropertyLoader.loadProperties();
        BeanUtils.sendSMTP(PropertyLoader.getRequiredProperty(PropertyLoader.vcellSMTPHostName), new Integer(PropertyLoader.getRequiredProperty(PropertyLoader.vcellSMTPPort)).intValue(), PropertyLoader.getRequiredProperty(PropertyLoader.vcellSMTPEmailAddress), userInfo.email, "re: VCell Info", "Your password has been reset to '" + clearTextPassword + "'.  Login with the new password and change your password as soon as possible.");
    } catch (Exception e) {
        e.printStackTrace();
        throw new DataAccessException("Error sending lost password\n" + e.getMessage(), e);
    }
}
Also used : User(org.vcell.util.document.User) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) UserInfo(org.vcell.util.document.UserInfo) DataAccessException(org.vcell.util.DataAccessException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) SQLException(java.sql.SQLException) DataAccessException(org.vcell.util.DataAccessException)

Example 12 with UserInfo

use of org.vcell.util.document.UserInfo in project vcell by virtualcell.

the class UserDbDriver method getUserInfo.

/**
 * getModel method comment.
 */
public UserInfo getUserInfo(Connection con, KeyValue key) throws SQLException, DataAccessException, ObjectNotFoundException {
    if (lg.isTraceEnabled()) {
        lg.trace("UserDbDriver.getUserInfo(key=" + key + ")");
    }
    String sql;
    sql = " SELECT " + " * " + " FROM " + userTable.getTableName() + " WHERE " + userTable.id + " = " + key;
    // System.out.println(sql);
    // Connection con = conFact.getConnection();
    Statement stmt = con.createStatement();
    UserInfo userInfo = null;
    try {
        ResultSet rset = stmt.executeQuery(sql);
        // }
        if (rset.next()) {
            userInfo = userTable.getUserInfo(rset);
        }
    } finally {
        // Release resources include resultset
        stmt.close();
    }
    if (userInfo == null) {
        throw new org.vcell.util.ObjectNotFoundException("UserInfo with id = '" + key + "' not found");
    }
    return userInfo;
}
Also used : Statement(java.sql.Statement) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) ResultSet(java.sql.ResultSet) UserInfo(org.vcell.util.document.UserInfo)

Example 13 with UserInfo

use of org.vcell.util.document.UserInfo in project vcell by virtualcell.

the class UserTable method getUserInfo.

/**
 * This method was created in VisualAge.
 * @return UserInfo
 * @param resultSet java.sql.ResultSet
 */
public UserInfo getUserInfo(ResultSet rset) throws SQLException {
    UserInfo userInfo = new UserInfo();
    userInfo.id = new KeyValue(rset.getBigDecimal(id.toString()));
    userInfo.userid = rset.getString(userid.toString());
    userInfo.digestedPassword0 = UserLoginInfo.DigestedPassword.createAlreadyDigested((rset.getString(digestPW.toString())));
    userInfo.email = rset.getString(email.toString());
    userInfo.wholeName = rset.getString(dbWholeName.toString());
    userInfo.title = rset.getString(title.toString());
    if (rset.wasNull()) {
        userInfo.title = null;
    }
    userInfo.company = rset.getString(companyName.toString());
    if (rset.wasNull()) {
        userInfo.company = null;
    }
    userInfo.country = rset.getString(country.toString());
    String notifyS = rset.getString(notify.toString());
    if (rset.wasNull()) {
        userInfo.notify = false;
    } else {
        userInfo.notify = notifyS.equals(UserTable.NOTIFY_TRUE);
    }
    // 
    // Format Date
    // 
    java.sql.Date DBDate = rset.getDate(insertDate.toString());
    java.sql.Time DBTime = rset.getTime(insertDate.toString());
    try {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss", java.util.Locale.US);
        userInfo.insertDate = sdf.parse(DBDate + " " + DBTime);
    } catch (java.text.ParseException e) {
        throw new java.sql.SQLException(e.getMessage());
    }
    return userInfo;
}
Also used : SQLException(java.sql.SQLException) KeyValue(org.vcell.util.document.KeyValue) UserInfo(org.vcell.util.document.UserInfo)

Example 14 with UserInfo

use of org.vcell.util.document.UserInfo in project vcell by virtualcell.

the class PostgresConnectionFactory method validate.

private static boolean validate(Connection conn) {
    try {
        @SuppressWarnings("unused") DatabaseMetaData dmd = conn.getMetaData();
    } catch (Exception e) {
        System.out.println("testing metadata...failed");
        e.printStackTrace(System.out);
        return false;
    }
    try {
        conn.getAutoCommit();
    } catch (Exception e) {
        System.out.println("testing autocommit...failed");
        e.printStackTrace(System.out);
        return false;
    }
    try {
        String sql = "SELECT * from " + UserTable.table.getTableName() + " WHERE " + UserTable.table.id + "=0";
        Statement stmt = conn.createStatement();
        try {
            ResultSet rset = stmt.executeQuery(sql);
            if (rset.next()) {
                @SuppressWarnings("unused") UserInfo userInfo = UserTable.table.getUserInfo(rset);
            }
        } finally {
            stmt.close();
        }
    } catch (Exception e) {
        System.out.println("query user table...failed");
        e.printStackTrace(System.out);
        return false;
    }
    return true;
}
Also used : Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) UserInfo(org.vcell.util.document.UserInfo) DatabaseMetaData(java.sql.DatabaseMetaData) SQLException(java.sql.SQLException)

Example 15 with UserInfo

use of org.vcell.util.document.UserInfo in project vcell by virtualcell.

the class MathVerifier method createUsersFromUserids.

private User[] createUsersFromUserids(String[] scanUserids) throws Exception {
    User[] scanUsers = null;
    if (scanUserids == null) {
        UserInfo[] allUserInfos = adminDbServer.getUserInfos();
        scanUsers = new User[allUserInfos.length];
        for (int i = 0; i < allUserInfos.length; i++) {
            scanUsers[i] = new User(allUserInfos[i].userid, allUserInfos[i].id);
        }
    } else {
        scanUsers = new User[scanUserids.length];
        for (int i = 0; i < scanUserids.length; i++) {
            scanUsers[i] = adminDbServer.getUser(scanUserids[i]);
        }
    }
    return scanUsers;
}
Also used : User(org.vcell.util.document.User) UserInfo(org.vcell.util.document.UserInfo)

Aggregations

UserInfo (org.vcell.util.document.UserInfo)16 SQLException (java.sql.SQLException)10 User (org.vcell.util.document.User)7 DataAccessException (org.vcell.util.DataAccessException)6 File (java.io.File)3 ResultSet (java.sql.ResultSet)3 Statement (java.sql.Statement)3 UseridIDExistsException (org.vcell.util.UseridIDExistsException)3 IOException (java.io.IOException)2 Date (java.util.Date)2 ConnectionFactory (org.vcell.db.ConnectionFactory)2 KeyFactory (org.vcell.db.KeyFactory)2 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)2 ClientServerInfo (cbit.vcell.client.server.ClientServerInfo)1 ConnectionStatus (cbit.vcell.client.server.ConnectionStatus)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 RegistrationPanel (cbit.vcell.desktop.RegistrationPanel)1 VCDestination (cbit.vcell.message.VCDestination)1 VCMessage (cbit.vcell.message.VCMessage)1 VCMessagingDelegate (cbit.vcell.message.VCMessagingDelegate)1