use of org.codice.ddf.system.alerts.SystemNotice in project ddf by codice.
the class LogFailoverAlertAppender method doAppend.
@Override
public void doAppend(PaxLoggingEvent event) {
if (lastUpdated == null) {
lastUpdated = DateTime.now();
} else if (DateTime.now().isBefore(lastUpdated.plusSeconds(5))) {
// don't spam the admin console when multiple log messages come in at once
return;
}
SystemNotice notice = new SystemNotice(LogFailoverAlertAppender.class.toString(), NoticePriority.CRITICAL, "Audit Logging Failure", details);
eventAdmin.postEvent(new Event(SystemNotice.SYSTEM_NOTICE_BASE_TOPIC.concat("audit"), notice.getProperties()));
lastUpdated = DateTime.now();
}
use of org.codice.ddf.system.alerts.SystemNotice in project ddf by codice.
the class SolrAppenderTest method testHandleEvent.
@Test
public void testHandleEvent() throws Exception {
SystemNotice notice = new SystemNotice();
Event event = new Event("decanter/collect", notice.getProperties());
solrAppender.setBatchSize(0);
solrAppender.handleEvent(event);
verify(persistentStore).add(eq("decanter"), any(Collection.class));
}
use of org.codice.ddf.system.alerts.SystemNotice in project ddf by codice.
the class InsecureDefaultsCollector method run.
@Override
public void run() {
List<Alert> alerts = new ArrayList<>();
LOGGER.debug("Found {} validator(s)", validators.size());
for (Validator validator : validators) {
LOGGER.debug("{} is starting validation process.", validator.getClass().getSimpleName());
alerts.addAll(validator.validate());
LOGGER.debug("{} finished the validation process.", validator.getClass().getSimpleName());
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("There are {} total alert(s).", alerts.size());
for (Alert alert : alerts) {
LOGGER.debug("Alert: {}; {}", alert.getLevel(), alert.getMessage());
}
}
if (!alerts.isEmpty()) {
Set<String> alertMessages = alerts.stream().map(Alert::getMessage).collect(Collectors.toSet());
SystemNotice notice = new SystemNotice(this.getClass().getName(), NoticePriority.IMPORTANT, "Insecure Defaults Found", alertMessages);
eventAdmin.postEvent(new Event(SystemNotice.SYSTEM_NOTICE_BASE_TOPIC + "insecureDefaults", notice.getProperties()));
}
}
use of org.codice.ddf.system.alerts.SystemNotice in project ddf by codice.
the class UsersPropertiesCollector method createUsersPropertiesNotice.
public SystemNotice createUsersPropertiesNotice() {
Instant firstInstall = scheduler.installationDate();
Set<String> details = new HashSet<>();
String timestampTitle = "";
String timestampDetail = "";
if (firstInstall != null) {
Instant timestamp = firstInstall.plus(Duration.ofDays(3));
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault()).withZone(ZoneId.systemDefault());
String timestampString = formatter.format(timestamp);
timestampTitle = String.format("before %s ", timestampString);
timestampDetail = String.format(" on %s ", timestampString);
}
String title = String.format("USERS.PROPERTIES FILE FOUND WITH DEFAULT USERS! Follow the instructions below %sto prevent the system from locking down.", timestampTitle);
details.add(String.format("%s They will be automatically deleted%s. %s", FILE_FOUND_MSG, timestampDetail, FOLLOW_DOC_MSG));
return new SystemNotice(this.getClass().getName(), NoticePriority.CRITICAL, title, details);
}
use of org.codice.ddf.system.alerts.SystemNotice in project ddf by codice.
the class OcspChecker method postErrorEvent.
/**
* Posts and error message to the Admin Console.
*
* @param errorMessage - The reason for the error.
*/
private void postErrorEvent(String errorMessage) {
String title = "Problem checking the revocation status of the Certificate through OCSP.";
Set<String> details = new HashSet<>();
details.add("An error occurred while checking the revocation status of a Certificate against an Online Certificate Status Protocol (OCSP) server. " + "Please resolve the error to resume validating certificates against the OCSP server.");
details.add(errorMessage);
eventAdmin.postEvent(new Event(SystemNotice.SYSTEM_NOTICE_BASE_TOPIC + "crl", new SystemNotice(this.getClass().getName(), NoticePriority.CRITICAL, title, details).getProperties()));
securityLogger.audit(title);
securityLogger.audit(errorMessage);
LOGGER.debug(errorMessage);
}
Aggregations