use of org.apache.archiva.redback.system.check.EnvironmentCheck in project archiva by apache.
the class SecuritySynchronization method executeEnvironmentChecks.
private void executeEnvironmentChecks() throws ArchivaException {
if ((checkers == null) || CollectionUtils.isEmpty(checkers.values())) {
throw new ArchivaException("Unable to initialize the Redback Security Environment, " + "no Environment Check components found.");
}
StopWatch stopWatch = new StopWatch();
stopWatch.reset();
stopWatch.start();
List<String> violations = new ArrayList<>();
for (Entry<String, EnvironmentCheck> entry : checkers.entrySet()) {
EnvironmentCheck check = entry.getValue();
List<String> v = new ArrayList<>();
check.validateEnvironment(v);
log.info("Environment Check: {} -> {} violation(s)", entry.getKey(), v.size());
for (String s : v) {
violations.add("[" + entry.getKey() + "] " + s);
}
}
if (CollectionUtils.isNotEmpty(violations)) {
StringBuilder msg = new StringBuilder();
msg.append("EnvironmentCheck Failure.\n");
msg.append("======================================================================\n");
msg.append(" ENVIRONMENT FAILURE !! \n");
msg.append("\n");
for (String violation : violations) {
msg.append(violation).append("\n");
}
msg.append("\n");
msg.append("======================================================================");
log.error(msg.toString());
throw new ArchivaException("Unable to initialize Redback Security Environment, [" + violations.size() + "] violation(s) encountered, See log for details.");
}
stopWatch.stop();
log.info("time to execute all EnvironmentCheck: {} ms", stopWatch.getTime());
}
Aggregations