Search in sources :

Example 1 with AuditWrapper

use of io.bastillion.manage.model.AuditWrapper 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) throws SQLException {
    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
            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));
            }
        }
    }
    return outputList;
}
Also used : AuditWrapper(io.bastillion.manage.model.AuditWrapper) SessionOutput(io.bastillion.manage.model.SessionOutput) UserSessionsOutput(io.bastillion.manage.model.UserSessionsOutput)

Example 2 with AuditWrapper

use of io.bastillion.manage.model.AuditWrapper in project KeyBox by skavanagh.

the class SessionOutputSerializer method serialize.

@Override
public JsonElement serialize(Object src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject object = new JsonObject();
    if (typeOfSrc.equals(AuditWrapper.class)) {
        AuditWrapper auditWrapper = (AuditWrapper) src;
        object.addProperty("user_id", auditWrapper.getUser().getId());
        object.addProperty("username", auditWrapper.getUser().getUsername());
        object.addProperty("user_type", auditWrapper.getUser().getUserType());
        object.addProperty("first_nm", auditWrapper.getUser().getFirstNm());
        object.addProperty("last_nm", auditWrapper.getUser().getLastNm());
        object.addProperty("email", auditWrapper.getUser().getEmail());
        object.addProperty("session_id", auditWrapper.getSessionOutput().getSessionId());
        object.addProperty("instance_id", auditWrapper.getSessionOutput().getInstanceId());
        object.addProperty("host_id", auditWrapper.getSessionOutput().getId());
        object.addProperty("host", auditWrapper.getSessionOutput().getDisplayLabel());
        object.addProperty("output", auditWrapper.getSessionOutput().getOutput().toString());
        object.addProperty("timestamp", new Date().getTime());
    }
    return object;
}
Also used : AuditWrapper(io.bastillion.manage.model.AuditWrapper) JsonObject(com.google.gson.JsonObject) Date(java.util.Date)

Aggregations

AuditWrapper (io.bastillion.manage.model.AuditWrapper)2 JsonObject (com.google.gson.JsonObject)1 SessionOutput (io.bastillion.manage.model.SessionOutput)1 UserSessionsOutput (io.bastillion.manage.model.UserSessionsOutput)1 Date (java.util.Date)1