@Test public void saveInternal() { CasEvent event = new CasEvent(1L, "Auth", "principalId", "creationTime", Map.of("timestamp", "1")); SyncopeWAEventRepository eventRepository = new SyncopeWAEventRepository(CasEventRepositoryFilter.noOp(), getWaRestClient()); eventRepository.saveInternal(event); verify(loggerService).create(any(AuditEntry.class)); }
@Override public void saveInternal(final CasEvent event) { SyncopeClient syncopeClient = waRestClient.getSyncopeClient(); if (syncopeClient == null) { LOG.debug("Syncope client is not yet ready to store audit record"); return; } LOG.info("Saving Cas events"); try { Map<String, String> properties = new HashMap<>(); if (event.getGeoLocation() != null) { put(properties, "geoLatitude", event.getGeoLocation().getLatitude()); put(properties, "geoLongitude", event.getGeoLocation().getLongitude()); put(properties, "geoAccuracy", event.getGeoLocation().getAccuracy()); put(properties, "geoTimestamp", event.getGeoLocation().getTimestamp()); } put(properties, "clientIpAddress", event.getClientIpAddress()); put(properties, "serverIpAddress", event.getServerIpAddress()); String output = OBJECT_MAPPER.writeValueAsString(properties); AuditEntry auditEntry = new AuditEntry(); auditEntry.setWho(event.getPrincipalId()); if (event.getTimestamp() != null) { auditEntry.setDate(new Date(event.getTimestamp())); } auditEntry.setOutput(output); AuditLoggerName auditLogger = new AuditLoggerName(AuditElements.EventCategoryType.WA, "LoggerLogic", event.getType().toUpperCase(), String.valueOf(event.getId()), AuditElements.Result.SUCCESS); auditEntry.setLogger(auditLogger); syncopeClient.getService(LoggerService.class).create(auditEntry); } catch (JsonProcessingException e) { LOG.error("During serialization", e); } }
SyncopeWAEventRepository extends AbstractCasEventRepository { @Override public void saveInternal(final CasEvent event) { SyncopeClient syncopeClient = waRestClient.getSyncopeClient(); if (syncopeClient == null) { LOG.debug("Syncope client is not yet ready to store audit record"); return; } LOG.info("Saving Cas events"); try { Map<String, String> properties = new HashMap<>(); if (event.getGeoLocation() != null) { put(properties, "geoLatitude", event.getGeoLocation().getLatitude()); put(properties, "geoLongitude", event.getGeoLocation().getLongitude()); put(properties, "geoAccuracy", event.getGeoLocation().getAccuracy()); put(properties, "geoTimestamp", event.getGeoLocation().getTimestamp()); } put(properties, "clientIpAddress", event.getClientIpAddress()); put(properties, "serverIpAddress", event.getServerIpAddress()); String output = OBJECT_MAPPER.writeValueAsString(properties); AuditEntry auditEntry = new AuditEntry(); auditEntry.setWho(event.getPrincipalId()); if (event.getTimestamp() != null) { auditEntry.setDate(new Date(event.getTimestamp())); } auditEntry.setOutput(output); AuditLoggerName auditLogger = new AuditLoggerName(AuditElements.EventCategoryType.WA, "LoggerLogic", event.getType().toUpperCase(), String.valueOf(event.getId()), AuditElements.Result.SUCCESS); auditEntry.setLogger(auditLogger); syncopeClient.getService(LoggerService.class).create(auditEntry); } catch (JsonProcessingException e) { LOG.error("During serialization", e); } } }
SyncopeWAEventRepository extends AbstractCasEventRepository { @Override public void saveInternal(final CasEvent event) { SyncopeClient syncopeClient = waRestClient.getSyncopeClient(); if (syncopeClient == null) { LOG.debug("Syncope client is not yet ready to store audit record"); return; } LOG.info("Saving Cas events"); try { Map<String, String> properties = new HashMap<>(); if (event.getGeoLocation() != null) { put(properties, "geoLatitude", event.getGeoLocation().getLatitude()); put(properties, "geoLongitude", event.getGeoLocation().getLongitude()); put(properties, "geoAccuracy", event.getGeoLocation().getAccuracy()); put(properties, "geoTimestamp", event.getGeoLocation().getTimestamp()); } put(properties, "clientIpAddress", event.getClientIpAddress()); put(properties, "serverIpAddress", event.getServerIpAddress()); String output = OBJECT_MAPPER.writeValueAsString(properties); AuditEntry auditEntry = new AuditEntry(); auditEntry.setWho(event.getPrincipalId()); if (event.getTimestamp() != null) { auditEntry.setDate(new Date(event.getTimestamp())); } auditEntry.setOutput(output); AuditLoggerName auditLogger = new AuditLoggerName(AuditElements.EventCategoryType.WA, "LoggerLogic", event.getType().toUpperCase(), String.valueOf(event.getId()), AuditElements.Result.SUCCESS); auditEntry.setLogger(auditLogger); syncopeClient.getService(LoggerService.class).create(auditEntry); } catch (JsonProcessingException e) { LOG.error("During serialization", e); } } SyncopeWAEventRepository(final CasEventRepositoryFilter eventRepositoryFilter,
            final WARestClient restClient); }
SyncopeWAEventRepository extends AbstractCasEventRepository { @Override public void saveInternal(final CasEvent event) { SyncopeClient syncopeClient = waRestClient.getSyncopeClient(); if (syncopeClient == null) { LOG.debug("Syncope client is not yet ready to store audit record"); return; } LOG.info("Saving Cas events"); try { Map<String, String> properties = new HashMap<>(); if (event.getGeoLocation() != null) { put(properties, "geoLatitude", event.getGeoLocation().getLatitude()); put(properties, "geoLongitude", event.getGeoLocation().getLongitude()); put(properties, "geoAccuracy", event.getGeoLocation().getAccuracy()); put(properties, "geoTimestamp", event.getGeoLocation().getTimestamp()); } put(properties, "clientIpAddress", event.getClientIpAddress()); put(properties, "serverIpAddress", event.getServerIpAddress()); String output = OBJECT_MAPPER.writeValueAsString(properties); AuditEntry auditEntry = new AuditEntry(); auditEntry.setWho(event.getPrincipalId()); if (event.getTimestamp() != null) { auditEntry.setDate(new Date(event.getTimestamp())); } auditEntry.setOutput(output); AuditLoggerName auditLogger = new AuditLoggerName(AuditElements.EventCategoryType.WA, "LoggerLogic", event.getType().toUpperCase(), String.valueOf(event.getId()), AuditElements.Result.SUCCESS); auditEntry.setLogger(auditLogger); syncopeClient.getService(LoggerService.class).create(auditEntry); } catch (JsonProcessingException e) { LOG.error("During serialization", e); } } SyncopeWAEventRepository(final CasEventRepositoryFilter eventRepositoryFilter,
            final WARestClient restClient); void put(final Map<String, String> properties, final String key, final String value); @Override void saveInternal(final CasEvent event); @Override Collection<? extends CasEvent> load(); }
SyncopeWAEventRepository extends AbstractCasEventRepository { @Override public void saveInternal(final CasEvent event) { SyncopeClient syncopeClient = waRestClient.getSyncopeClient(); if (syncopeClient == null) { LOG.debug("Syncope client is not yet ready to store audit record"); return; } LOG.info("Saving Cas events"); try { Map<String, String> properties = new HashMap<>(); if (event.getGeoLocation() != null) { put(properties, "geoLatitude", event.getGeoLocation().getLatitude()); put(properties, "geoLongitude", event.getGeoLocation().getLongitude()); put(properties, "geoAccuracy", event.getGeoLocation().getAccuracy()); put(properties, "geoTimestamp", event.getGeoLocation().getTimestamp()); } put(properties, "clientIpAddress", event.getClientIpAddress()); put(properties, "serverIpAddress", event.getServerIpAddress()); String output = OBJECT_MAPPER.writeValueAsString(properties); AuditEntry auditEntry = new AuditEntry(); auditEntry.setWho(event.getPrincipalId()); if (event.getTimestamp() != null) { auditEntry.setDate(new Date(event.getTimestamp())); } auditEntry.setOutput(output); AuditLoggerName auditLogger = new AuditLoggerName(AuditElements.EventCategoryType.WA, "LoggerLogic", event.getType().toUpperCase(), String.valueOf(event.getId()), AuditElements.Result.SUCCESS); auditEntry.setLogger(auditLogger); syncopeClient.getService(LoggerService.class).create(auditEntry); } catch (JsonProcessingException e) { LOG.error("During serialization", e); } } SyncopeWAEventRepository(final CasEventRepositoryFilter eventRepositoryFilter,
            final WARestClient restClient); void put(final Map<String, String> properties, final String key, final String value); @Override void saveInternal(final CasEvent event); @Override Collection<? extends CasEvent> load();  }