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()");
}
Aggregations