Search in sources :

Example 1 with SessionOutput

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);
        }
    }
}
Also used : SessionOutput(com.keybox.manage.model.SessionOutput) Connection(java.sql.Connection) Gson(com.google.gson.Gson)

Example 2 with SessionOutput

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;
}
Also used : AuditWrapper(com.keybox.manage.model.AuditWrapper) SessionOutput(com.keybox.manage.model.SessionOutput) UserSessionsOutput(com.keybox.manage.model.UserSessionsOutput)

Aggregations

SessionOutput (com.keybox.manage.model.SessionOutput)2 Gson (com.google.gson.Gson)1 AuditWrapper (com.keybox.manage.model.AuditWrapper)1 UserSessionsOutput (com.keybox.manage.model.UserSessionsOutput)1 Connection (java.sql.Connection)1