use of uk.gov.ida.eventemitter.EventDetailsKey in project verify-hub by alphagov.
the class AttributeQueryRequestRunnable method logAndAuditMessageError.
private void logAndAuditMessageError(Exception e, AttributeQueryContainerDto attributeQueryContainerDto, SessionId sessionId) {
String errorMessage = MatchingServiceRequestExceptionErrorMessageMapper.getErrorMessageForException(e);
Map<EventDetailsKey, String> details = new HashMap<>();
UUID errorId = UUID.randomUUID();
details.put(idp_entity_id, attributeQueryContainerDto.getIssuer());
details.put(message, errorMessage + e.getMessage());
details.put(error_id, errorId.toString());
EventSinkHubEvent hubEvent = new EventSinkHubEvent(serviceInfo, sessionId, EventSinkHubEventConstants.EventTypes.ERROR_EVENT, details);
eventSinkProxy.logHubEvent(hubEvent);
eventEmitter.record(hubEvent);
if (attributeQueryContainerDto.isOnboarding()) {
LOG.warn(LogFormatter.formatLog(errorId, e.getMessage()), e);
} else {
LOG.error(LogFormatter.formatLog(errorId, e.getMessage()), e);
}
}
use of uk.gov.ida.eventemitter.EventDetailsKey in project verify-hub by alphagov.
the class HealthCheckEventLogger method logException.
public void logException(ApplicationException exception, String message) {
LOG.warn(message, exception);
if (exception.isAudited() || !exception.requiresAuditing()) {
return;
}
Map<EventDetailsKey, String> details = Map.of(downstream_uri, exception.getUri().orElse(URI.create("uri-not-present")).toASCIIString(), EventDetailsKey.message, exception.getMessage());
EventSinkHubEvent hubEvent = new EventSinkHubEvent(serviceInfo, NO_SESSION_CONTEXT_IN_ERROR, ERROR_EVENT, details);
eventSinkProxy.logHubEvent(hubEvent);
eventEmitter.record(hubEvent);
}
use of uk.gov.ida.eventemitter.EventDetailsKey in project verify-hub by alphagov.
the class HubEventLogger method logRequestFromHub.
public void logRequestFromHub(SessionId sessionId, String transactionEntityId) {
Map<EventDetailsKey, String> details = new HashMap<>();
details.put(hub_event_type, RECEIVED_AUTHN_REQUEST_FROM_HUB);
details.put(transaction_entity_id, transactionEntityId);
EventSinkHubEvent eventSinkHubEvent = new EventSinkHubEvent(serviceInfo, sessionId, HUB_EVENT, details);
eventSinkProxy.logHubEvent(eventSinkHubEvent);
eventEmitter.record(eventSinkHubEvent);
}
use of uk.gov.ida.eventemitter.EventDetailsKey in project verify-hub by alphagov.
the class HubEventLogger method logSessionTimeoutEvent.
public void logSessionTimeoutEvent(SessionId sessionId, DateTime sessionExpiryTimestamp, String transactionEntityId, String requestId) {
Map<EventDetailsKey, String> details = new HashMap<>();
details.put(session_event_type, SESSION_TIMEOUT);
details.put(session_expiry_time, sessionExpiryTimestamp.toString());
details.put(transaction_entity_id, transactionEntityId);
details.put(request_id, requestId);
EventSinkHubEvent eventSinkHubEvent = new EventSinkHubEvent(serviceInfo, sessionId, SESSION_EVENT, details);
eventSinkProxy.logHubEvent(eventSinkHubEvent);
eventEmitter.record(eventSinkHubEvent);
}
use of uk.gov.ida.eventemitter.EventDetailsKey in project verify-hub by alphagov.
the class HealthCheckEventLoggerTest method shouldLogToEventSinkIfTheExceptionIsUnaudited.
@Test
public void shouldLogToEventSinkIfTheExceptionIsUnaudited() {
URI uri = URI.create("uri-geller");
ApplicationException unauditedException = ApplicationException.createUnauditedException(ExceptionType.INVALID_SAML, UUID.randomUUID(), uri);
Map<EventDetailsKey, String> details = Map.of(downstream_uri, unauditedException.getUri().orElse(URI.create("uri-not-present")).toASCIIString(), message, unauditedException.getMessage());
EventSinkHubEvent event = new EventSinkHubEvent(serviceInfo, NO_SESSION_CONTEXT_IN_ERROR, ERROR_EVENT, details);
eventLogger.logException(unauditedException, "test error message");
ArgumentCaptor<EventSinkHubEvent> eventSinkCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
ArgumentCaptor<EventSinkHubEvent> eventEmitterCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
verify(eventSinkProxy, times(1)).logHubEvent(eventSinkCaptor.capture());
verify(eventEmitter, times(1)).record(eventEmitterCaptor.capture());
assertThat(event).isEqualToComparingOnlyGivenFields(eventSinkCaptor.getValue(), "originatingService", "sessionId", "eventType", "details");
assertThat(event).isEqualToComparingOnlyGivenFields(eventEmitterCaptor.getValue(), "originatingService", "sessionId", "eventType", "details");
}
Aggregations