List of usage examples for java.lang Exception toString
public String toString()
From source file:com.tethrnet.manage.db.UserDB.java
/** * updates existing user/*from w ww .j a v a 2 s. c o m*/ * @param user user object */ public static void updateUserCredentials(User user) { Connection con = null; try { con = DBUtils.getConn(); String salt = EncryptionUtil.generateSalt(); PreparedStatement stmt = con.prepareStatement( "update users set email=?, username=?, user_type=?, password=?, salt=? where id=?"); stmt.setString(1, user.getEmail()); stmt.setString(2, user.getUsername()); stmt.setString(3, user.getUserType()); stmt.setString(4, EncryptionUtil.hash(user.getPassword() + salt)); stmt.setString(5, salt); stmt.setLong(6, user.getId()); stmt.execute(); DBUtils.closeStmt(stmt); if (User.ADMINISTRATOR.equals(user.getUserType())) { PublicKeyDB.deleteUnassignedKeysByUser(con, user.getId()); } } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); }
From source file:com.keybox.manage.db.SessionAuditDB.java
/** * insert new terminal history for user//w w w.j a va 2 s.co m * * @param sessionOutput output from session terminals * @return session id */ public static void insertTerminalLog(SessionOutput sessionOutput) { //get db connection Connection con = DBUtils.getConn(); try { insertTerminalLog(con, sessionOutput); } catch (Exception e) { log.error(e.toString(), e); } //close db connection DBUtils.closeConn(con); }
From source file:com.tethrnet.manage.db.UserDB.java
/** * returns user base on id/*from www . j a v a 2 s.c o m*/ * @param con DB connection * @param userId user id * @return user object */ public static User getUser(Connection con, Long userId) { User user = null; try { PreparedStatement stmt = con.prepareStatement("select * from users where id=?"); stmt.setLong(1, userId); ResultSet rs = stmt.executeQuery(); while (rs.next()) { user = new User(); user.setId(rs.getLong("id")); user.setEmail(rs.getString("email")); user.setUsername(rs.getString("username")); user.setPassword(rs.getString("password")); user.setAuthType(rs.getString("auth_type")); user.setUserType(rs.getString("user_type")); user.setSalt(rs.getString("salt")); user.setProfileList(UserProfileDB.getProfilesByUser(con, userId)); } DBUtils.closeRs(rs); DBUtils.closeStmt(stmt); } catch (Exception e) { log.error(e.toString(), e); } return user; }
From source file:com.keybox.manage.db.AuthDB.java
/** * returns user id based on auth token//from w ww . j a v a 2 s .c o m * * @param authToken auth token * @param con DB connection * @return user */ public static User getUserByAuthToken(Connection con, String authToken) { User user = null; try { PreparedStatement stmt = con .prepareStatement("select * from users where enabled=true and auth_token like ?"); stmt.setString(1, authToken); ResultSet rs = stmt.executeQuery(); if (rs.next()) { Long userId = rs.getLong("id"); user = UserDB.getUser(con, userId); } DBUtils.closeRs(rs); DBUtils.closeStmt(stmt); } catch (Exception e) { log.error(e.toString(), e); } return user; }
From source file:com.keybox.manage.db.AuthDB.java
/** * returns the shared secret based on user id * * @param userId user id/*from w w w . j a v a 2 s.c om*/ * @return auth object */ public static String getSharedSecret(Long userId) { String sharedSecret = null; Connection con = null; try { con = DBUtils.getConn(); PreparedStatement stmt = con.prepareStatement("select * from users where id like ?"); stmt.setLong(1, userId); ResultSet rs = stmt.executeQuery(); if (rs.next()) { sharedSecret = EncryptionUtil.decrypt(rs.getString("otp_secret")); } DBUtils.closeRs(rs); DBUtils.closeStmt(stmt); } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); return sharedSecret; }
From source file:com.keybox.manage.db.SessionAuditDB.java
/** * insert new session record for user// www . j av a 2s . c o m * * @param userId user id * @return session id */ public static Long createSessionLog(Long userId) { //get db connection Connection con = DBUtils.getConn(); Long sessionId = null; try { sessionId = createSessionLog(con, userId); } catch (Exception e) { log.error(e.toString(), e); } //close db connection DBUtils.closeConn(con); return sessionId; }
From source file:com.keybox.manage.db.SessionAuditDB.java
/** * returns terminal logs for user session for host system * * @param sessionId session id//from ww w . j a v a 2 s .c om * @param instanceId instance id for terminal session * @return session output for session */ public static List<SessionOutput> getTerminalLogsForSession(Long sessionId, Integer instanceId) { //get db connection Connection con = DBUtils.getConn(); List<SessionOutput> outputList = null; try { outputList = getTerminalLogsForSession(con, sessionId, instanceId); } catch (Exception e) { log.error(e.toString(), e); } //close db connection DBUtils.closeConn(con); return outputList; }
From source file:com.keybox.manage.db.UserDB.java
/** * returns user base on id//from w w w. ja v a 2s .c o m * @param userId user id * @return user object */ public static User getUser(Long userId) { User user = null; Connection con = null; try { con = DBUtils.getConn(); user = getUser(con, userId); } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); return user; }
From source file:com.keybox.manage.db.UserDB.java
/** * inserts new user//from w ww .j a va 2 s .co m * * @param user user object */ public static Long insertUser(User user) { Long userId = null; Connection con = null; try { con = DBUtils.getConn(); userId = insertUser(con, user); } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); return userId; }
From source file:com.qsoft.components.gallery.utils.GalleryUtils.java
private static InputStream OpenHttpConnection(String strURL) throws IOException { InputStream inputStream = null; URL url = new URL(strURL); URLConnection conn = url.openConnection(); try {/* w w w . j ava 2 s . c om*/ HttpURLConnection httpConn = (HttpURLConnection) conn; httpConn.setRequestMethod("GET"); httpConn.connect(); if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) { inputStream = httpConn.getInputStream(); } } catch (Exception ex) { Log.e("error", ex.toString()); } return inputStream; }