|
51 | 51 | import java.io.File; |
52 | 52 | import java.io.IOException; |
53 | 53 | import java.security.PrivilegedActionException; |
| 54 | +import java.text.SimpleDateFormat; |
54 | 55 | import java.util.ArrayList; |
55 | 56 | import java.util.Collection; |
56 | 57 | import java.util.Collections; |
|
66 | 67 |
|
67 | 68 | public class ElasticSearchAuditDestination extends AuditDestination { |
68 | 69 | private static final Logger LOG = LoggerFactory.getLogger(ElasticSearchAuditDestination.class); |
| 70 | + private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; |
69 | 71 |
|
70 | 72 | public static final String CONFIG_URLS = "urls"; |
71 | 73 | public static final String CONFIG_PORT = "port"; |
@@ -300,7 +302,14 @@ Map<String, Object> toDoc(AuthzAuditEvent auditEvent) { |
300 | 302 | doc.put("resType", auditEvent.getResourceType()); |
301 | 303 | doc.put("reason", auditEvent.getResultReason()); |
302 | 304 | doc.put("action", auditEvent.getAction()); |
303 | | - doc.put("evtTime", auditEvent.getEventTime()); |
| 305 | + Date eventTime = auditEvent.getEventTime(); |
| 306 | + if (eventTime != null) { |
| 307 | + SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); |
| 308 | + dateFormat.setTimeZone(java.util.TimeZone.getTimeZone("UTC")); |
| 309 | + doc.put("evtTime", dateFormat.format(eventTime)); |
| 310 | + } else { |
| 311 | + doc.put("evtTime", null); |
| 312 | + } |
304 | 313 | doc.put("seq_num", auditEvent.getSeqNum()); |
305 | 314 | doc.put("event_count", auditEvent.getEventCount()); |
306 | 315 | doc.put("event_dur_ms", auditEvent.getEventDurationMS()); |
|
0 commit comments