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;
}
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;
}
Aggregations