use of com.keybox.manage.model.SessionOutput in project KeyBox by skavanagh.
the class SentOutputTask method run.
public void run() {
Gson gson = new Gson();
while (session.isOpen()) {
Connection con = DBUtils.getConn();
List<SessionOutput> outputList = SessionOutputUtil.getOutput(con, sessionId, user);
try {
if (outputList != null && !outputList.isEmpty()) {
String json = gson.toJson(outputList);
//send json to session
this.session.getBasicRemote().sendText(json);
}
Thread.sleep(25);
} catch (Exception ex) {
log.error(ex.toString(), ex);
} finally {
DBUtils.closeConn(con);
}
}
}
use of com.keybox.manage.model.SessionOutput in project KeyBox by skavanagh.
the class SessionOutputUtil method getOutput.
/**
* returns list of output lines
*
* @param sessionId session id object
* @param user user auth object
* @return session output list
*/
public static List<SessionOutput> getOutput(Connection con, Long sessionId, User user) {
List<SessionOutput> outputList = new ArrayList<>();
UserSessionsOutput userSessionsOutput = userSessionsOutputMap.get(sessionId);
if (userSessionsOutput != null) {
for (Integer key : userSessionsOutput.getSessionOutputMap().keySet()) {
//get output chars and set to output
try {
SessionOutput sessionOutput = userSessionsOutput.getSessionOutputMap().get(key);
if (sessionOutput != null && sessionOutput.getOutput() != null && StringUtils.isNotEmpty(sessionOutput.getOutput())) {
outputList.add(sessionOutput);
//send to audit logger
systemAuditLogger.info(gson.toJson(new AuditWrapper(user, sessionOutput)));
if (enableInternalAudit) {
SessionAuditDB.insertTerminalLog(con, sessionOutput);
}
userSessionsOutput.getSessionOutputMap().put(key, new SessionOutput(sessionId, sessionOutput));
}
} catch (Exception ex) {
log.error(ex.toString(), ex);
}
}
}
return outputList;
}
Aggregations