Search in sources :

Example 1 with TransactionId

use of org.forgerock.services.TransactionId in project OpenAM by OpenRock.

the class RadiusAuditLoggerEventBus method makeLogEntry.

/**
     * Makes an 'access' audit log entry.
     *
     * @param eventName - the name of the event.
     * @param accessRequestEvent - the access request event.
     */
public void makeLogEntry(EventName eventName, AcceptedRadiusEvent accessRequestEvent) {
    LOG.message("Entering RadiusAuditLoggerEventBus.makeLogEntry()");
    Set<String> trackingIds = new HashSet<String>();
    trackingIds.add(accessRequestEvent.getRequest().getContextHolderKey());
    // This sets the request context so that when the OpenAM auth chains etc call AuditRequestContext.get they
    // will use the same transaction id. This means log entries across the audit logs can be tied up.
    AuditRequestContext.set(new AuditRequestContext(new TransactionId(accessRequestEvent.getRequestId())));
    AMAccessAuditEventBuilder builder = auditEventFactory.accessEvent(accessRequestEvent.getRealm()).timestamp(accessRequestEvent.getTimeOfEvent()).transactionId(accessRequestEvent.getRequestId()).eventName(eventName).component(Component.RADIUS).trackingIds(trackingIds);
    String uid = accessRequestEvent.getUniversalId();
    if (!Strings.isNullOrEmpty(uid)) {
        builder.userId(uid);
    } else {
        LOG.message("Not setting authentication to universal Id. None available.");
    }
    setRequestDetails(builder, accessRequestEvent);
    try {
        setClientDetails(builder, accessRequestEvent.getRequestContext());
        RadiusResponse response = accessRequestEvent.getResponse();
        if (response.getResponsePacket() != null) {
            setResponseDetails(builder, response);
        }
    } catch (RadiusAuditLoggingException e) {
        LOG.warning("Failed to set client details on access audit event. Reason; {}", e.getMessage());
    }
    this.auditEventPublisher.tryPublish(AuditConstants.ACCESS_TOPIC, builder.toEvent());
    LOG.message("Leaving RadiusAuditLoggerEventBus.makeLogEntry()");
}
Also used : RadiusResponse(org.forgerock.openam.radius.server.RadiusResponse) AMAccessAuditEventBuilder(org.forgerock.openam.audit.AMAccessAuditEventBuilder) AuditRequestContext(org.forgerock.openam.audit.context.AuditRequestContext) HashSet(java.util.HashSet) TransactionId(org.forgerock.services.TransactionId)

Aggregations

HashSet (java.util.HashSet)1 AMAccessAuditEventBuilder (org.forgerock.openam.audit.AMAccessAuditEventBuilder)1 AuditRequestContext (org.forgerock.openam.audit.context.AuditRequestContext)1 RadiusResponse (org.forgerock.openam.radius.server.RadiusResponse)1 TransactionId (org.forgerock.services.TransactionId)1