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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations