Search in sources :

Example 1 with AuditWrapper

use of com.keybox.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(com.keybox.manage.model.AuditWrapper) JsonObject(com.google.gson.JsonObject) Date(java.util.Date)

Example 2 with AuditWrapper

use of com.keybox.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) {
    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

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