Search in sources :

Example 6 with SystemNotice

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();
}
Also used : PaxLoggingEvent(org.ops4j.pax.logging.spi.PaxLoggingEvent) Event(org.osgi.service.event.Event) SystemNotice(org.codice.ddf.system.alerts.SystemNotice)

Example 7 with SystemNotice

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));
}
Also used : Event(org.osgi.service.event.Event) Collection(java.util.Collection) SystemNotice(org.codice.ddf.system.alerts.SystemNotice) Test(org.junit.Test)

Example 8 with SystemNotice

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()));
    }
}
Also used : ArrayList(java.util.ArrayList) Event(org.osgi.service.event.Event) SystemNotice(org.codice.ddf.system.alerts.SystemNotice)

Example 9 with SystemNotice

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);
}
Also used : Instant(java.time.Instant) SystemNotice(org.codice.ddf.system.alerts.SystemNotice) DateTimeFormatter(java.time.format.DateTimeFormatter) HashSet(java.util.HashSet)

Example 10 with SystemNotice

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);
}
Also used : Event(org.osgi.service.event.Event) DERIA5String(org.bouncycastle.asn1.DERIA5String) SystemNotice(org.codice.ddf.system.alerts.SystemNotice) HashSet(java.util.HashSet)

Aggregations

SystemNotice (org.codice.ddf.system.alerts.SystemNotice)10 Event (org.osgi.service.event.Event)9 HashSet (java.util.HashSet)6 Test (org.junit.Test)5 PersistentItem (org.codice.ddf.persistence.PersistentItem)3 Collection (java.util.Collection)2 Alert (org.codice.ddf.system.alerts.Alert)2 Instant (java.time.Instant)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DERIA5String (org.bouncycastle.asn1.DERIA5String)1 PaxLoggingEvent (org.ops4j.pax.logging.spi.PaxLoggingEvent)1