@Test public void preHandleDoesNotAuditRequestWhenRequestLoggingDisabled() throws Exception { auditConfig.setRequestsLoggingEnabled(false); auditConfig.setRequestsLoggingHeadersEnabled(true); auditConfig.setRequestsLoggingCookiesEnabled(true); auditConfig.setRequestsLoggingBodyEnabled(true); replayAll(); interceptor.preHandle(mockRequest, null, null); verifyAll(); }
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { log.trace("Request audit interceptor called"); if (auditConfig.getRequestsLoggingEnabled()) { AuditEvent auditEvent = new AuditEvent(); auditEvent.setEventDate(new Date()); auditEvent.setIpAddress(MDC.get(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); auditEvent.setRequestId(UUID.fromString(MDC.get(MDCConstants.EVENT_MDC_REQUEST_ID_KEY))); auditEvent.setFullEventType(EVENT_TYPE); auditEvent.setEventResult(AuditConstants.EVENT_RESULT_SUCCESS); auditEvent.setObjectType(AuditConstants.EVENT_OBJECT_TYPE_WEB_REQUEST); auditEvent.setStatus(AuditConstants.EVENT_STATUS_COMPLETE); auditEvent.setUserId(MDC.get(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY) != null ? MDC.get(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY) : AuditConstants.USER_ID_ANONYMOUS); auditEvent.setEventProperties(getEventProperties(request)); log.trace("Request created AuditEvent: {}", auditEvent.toString()); getAuditService().audit(auditEvent); } return true; }
AcmAuditRequestInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { log.trace("Request audit interceptor called"); if (auditConfig.getRequestsLoggingEnabled()) { AuditEvent auditEvent = new AuditEvent(); auditEvent.setEventDate(new Date()); auditEvent.setIpAddress(MDC.get(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); auditEvent.setRequestId(UUID.fromString(MDC.get(MDCConstants.EVENT_MDC_REQUEST_ID_KEY))); auditEvent.setFullEventType(EVENT_TYPE); auditEvent.setEventResult(AuditConstants.EVENT_RESULT_SUCCESS); auditEvent.setObjectType(AuditConstants.EVENT_OBJECT_TYPE_WEB_REQUEST); auditEvent.setStatus(AuditConstants.EVENT_STATUS_COMPLETE); auditEvent.setUserId(MDC.get(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY) != null ? MDC.get(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY) : AuditConstants.USER_ID_ANONYMOUS); auditEvent.setEventProperties(getEventProperties(request)); log.trace("Request created AuditEvent: {}", auditEvent.toString()); getAuditService().audit(auditEvent); } return true; } }
AcmAuditRequestInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { log.trace("Request audit interceptor called"); if (auditConfig.getRequestsLoggingEnabled()) { AuditEvent auditEvent = new AuditEvent(); auditEvent.setEventDate(new Date()); auditEvent.setIpAddress(MDC.get(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); auditEvent.setRequestId(UUID.fromString(MDC.get(MDCConstants.EVENT_MDC_REQUEST_ID_KEY))); auditEvent.setFullEventType(EVENT_TYPE); auditEvent.setEventResult(AuditConstants.EVENT_RESULT_SUCCESS); auditEvent.setObjectType(AuditConstants.EVENT_OBJECT_TYPE_WEB_REQUEST); auditEvent.setStatus(AuditConstants.EVENT_STATUS_COMPLETE); auditEvent.setUserId(MDC.get(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY) != null ? MDC.get(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY) : AuditConstants.USER_ID_ANONYMOUS); auditEvent.setEventProperties(getEventProperties(request)); log.trace("Request created AuditEvent: {}", auditEvent.toString()); getAuditService().audit(auditEvent); } return true; }  }
AcmAuditRequestInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { log.trace("Request audit interceptor called"); if (auditConfig.getRequestsLoggingEnabled()) { AuditEvent auditEvent = new AuditEvent(); auditEvent.setEventDate(new Date()); auditEvent.setIpAddress(MDC.get(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); auditEvent.setRequestId(UUID.fromString(MDC.get(MDCConstants.EVENT_MDC_REQUEST_ID_KEY))); auditEvent.setFullEventType(EVENT_TYPE); auditEvent.setEventResult(AuditConstants.EVENT_RESULT_SUCCESS); auditEvent.setObjectType(AuditConstants.EVENT_OBJECT_TYPE_WEB_REQUEST); auditEvent.setStatus(AuditConstants.EVENT_STATUS_COMPLETE); auditEvent.setUserId(MDC.get(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY) != null ? MDC.get(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY) : AuditConstants.USER_ID_ANONYMOUS); auditEvent.setEventProperties(getEventProperties(request)); log.trace("Request created AuditEvent: {}", auditEvent.toString()); getAuditService().audit(auditEvent); } return true; }  @Override boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler); @Override void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex); AuditService getAuditService(); void setAuditService(AuditService auditService); AuditConfig getAuditConfig(); void setAuditConfig(AuditConfig auditConfig); }
AcmAuditRequestInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { log.trace("Request audit interceptor called"); if (auditConfig.getRequestsLoggingEnabled()) { AuditEvent auditEvent = new AuditEvent(); auditEvent.setEventDate(new Date()); auditEvent.setIpAddress(MDC.get(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); auditEvent.setRequestId(UUID.fromString(MDC.get(MDCConstants.EVENT_MDC_REQUEST_ID_KEY))); auditEvent.setFullEventType(EVENT_TYPE); auditEvent.setEventResult(AuditConstants.EVENT_RESULT_SUCCESS); auditEvent.setObjectType(AuditConstants.EVENT_OBJECT_TYPE_WEB_REQUEST); auditEvent.setStatus(AuditConstants.EVENT_STATUS_COMPLETE); auditEvent.setUserId(MDC.get(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY) != null ? MDC.get(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY) : AuditConstants.USER_ID_ANONYMOUS); auditEvent.setEventProperties(getEventProperties(request)); log.trace("Request created AuditEvent: {}", auditEvent.toString()); getAuditService().audit(auditEvent); } return true; }  @Override boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler); @Override void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex); AuditService getAuditService(); void setAuditService(AuditService auditService); AuditConfig getAuditConfig(); void setAuditConfig(AuditConfig auditConfig); static final String EVENT_TYPE; }