Search in sources :

Example 1 with AMAuditEventBuilder

use of org.forgerock.openam.audit.AMAuditEventBuilder in project OpenAM by OpenRock.

the class LogWriter method logToAuditService.

private static void logToAuditService(int type, String msgid, String[] msgdata, SSOToken ssoToken, LogMessageProvider msgProvider, SSOToken adminSSOToken) throws Exception {
    String operation = msgid.substring(msgid.indexOf('_') + 1);
    LogMessageID logMessageID = msgProvider.getAllHashMessageIDs().get(msgid);
    if (logMessageID == null) {
        DEBUG.error("Attempted audit logging for unknown message ID {}", msgid);
        return;
    }
    List<String> fields = logMessageID.getDataColumns();
    AMAuditEventBuilder builder;
    String topic;
    if ("LOGIN".equals(operation) && !msgid.startsWith("ATTEMPT")) {
        builder = authenticationEventBuilder(type, msgid, fields, msgdata);
        topic = AuditConstants.AUTHENTICATION_TOPIC;
    } else if (!"LOGIN".equals(operation)) {
        builder = accessEventBuilder(type, msgid, msgdata, operation, fields);
        topic = AuditConstants.ACCESS_TOPIC;
    } else {
        return;
    }
    JsonValue eventJson = builder.transactionId(CommandManager.TRANSACTION_ID.getValue()).timestamp(System.currentTimeMillis()).userId(ssoToken.getPrincipal().getName()).trackingIdFromSSOToken(ssoToken).component(AuditConstants.Component.SSOADM).toEvent().getValue();
    String sessionId = adminSSOToken.getTokenID().toString();
    sendEvent(topic, eventJson, sessionId, new SessionID(sessionId).getSessionServerURL());
}
Also used : JsonValue(org.forgerock.json.JsonValue) AMAuditEventBuilder(org.forgerock.openam.audit.AMAuditEventBuilder) SessionID(com.iplanet.dpro.session.SessionID) LogMessageID(com.sun.identity.log.messageid.LogMessageID)

Aggregations

SessionID (com.iplanet.dpro.session.SessionID)1 LogMessageID (com.sun.identity.log.messageid.LogMessageID)1 JsonValue (org.forgerock.json.JsonValue)1 AMAuditEventBuilder (org.forgerock.openam.audit.AMAuditEventBuilder)1