use of java.util.Objects in project caffeine by ben-manes.
the class LoadingCacheProxy method loadAll.
@Override
public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, CompletionListener completionListener) {
requireNotClosed();
keys.forEach(Objects::requireNonNull);
CompletionListener listener = (completionListener == null) ? NullCompletionListener.INSTANCE : completionListener;
executor.execute(() -> {
try {
if (replaceExistingValues) {
int[] ignored = { 0 };
Map<K, V> loaded = cacheLoader.get().loadAll(keys);
for (Map.Entry<? extends K, ? extends V> entry : loaded.entrySet()) {
putNoCopyOrAwait(entry.getKey(), entry.getValue(), /* publishToWriter */
false, ignored);
}
} else {
getAll(keys, /* updateAccessTime */
false);
}
listener.onCompletion();
} catch (Exception e) {
listener.onException(e);
} finally {
dispatcher.ignoreSynchronous();
}
});
}
use of java.util.Objects in project cas by apereo.
the class AbstractCRLRevocationChecker method check.
@Override
public void check(final X509Certificate cert) throws GeneralSecurityException {
if (cert == null) {
throw new IllegalArgumentException("Certificate cannot be null.");
}
LOGGER.debug("Evaluating certificate revocation status for [{}]", CertUtils.toString(cert));
final Collection<X509CRL> crls = getCRLs(cert);
if (crls == null || crls.isEmpty()) {
LOGGER.warn("CRL data is not available for [{}]", CertUtils.toString(cert));
this.unavailableCRLPolicy.apply(null);
return;
}
final List<X509CRL> expiredCrls = new ArrayList<>();
final List<X509CRLEntry> revokedCrls;
crls.stream().filter(CertUtils::isExpired).forEach(crl -> {
LOGGER.warn("CRL data expired on [{}]", crl.getNextUpdate());
expiredCrls.add(crl);
});
if (crls.size() == expiredCrls.size()) {
LOGGER.warn("All CRLs retrieved have expired. Applying CRL expiration policy...");
for (final X509CRL crl : expiredCrls) {
this.expiredCRLPolicy.apply(crl);
}
} else {
crls.removeAll(expiredCrls);
LOGGER.debug("Valid CRLs [{}] found that are not expired yet", crls);
revokedCrls = crls.stream().map(crl -> crl.getRevokedCertificate(cert)).filter(Objects::nonNull).collect(Collectors.toList());
if (revokedCrls.size() == crls.size()) {
final X509CRLEntry entry = revokedCrls.get(0);
LOGGER.warn("All CRL entries have been revoked. Rejecting the first entry [{}]", entry);
throw new RevokedCertificateException(entry);
}
}
}
use of java.util.Objects in project cas by apereo.
the class CRLDistributionPointRevocationChecker method getDistributionPoints.
/**
* Gets the distribution points.
*
* @param cert the cert
* @return the url distribution points
*/
private URI[] getDistributionPoints(final X509Certificate cert) {
final List<DistributionPoint> points;
try {
points = new ExtensionReader(cert).readCRLDistributionPoints();
} catch (final RuntimeException e) {
LOGGER.error("Error reading CRLDistributionPoints extension field on [{}]", CertUtils.toString(cert), e);
return new URI[0];
}
final List<URI> urls = new ArrayList<>();
if (points != null) {
points.stream().map(DistributionPoint::getDistributionPoint).filter(Objects::nonNull).forEach(pointName -> {
final ASN1Sequence nameSequence = ASN1Sequence.getInstance(pointName.getName());
IntStream.range(0, nameSequence.size()).mapToObj(i -> GeneralName.getInstance(nameSequence.getObjectAt(i))).forEach(name -> {
LOGGER.debug("Found CRL distribution point [{}].", name);
try {
addURL(urls, DERIA5String.getInstance(name.getName()).getString());
} catch (final RuntimeException e) {
LOGGER.warn("[{}] not supported. String or GeneralNameList expected.", pointName);
}
});
});
}
return urls.toArray(new URI[urls.size()]);
}
use of java.util.Objects in project robo4j by Robo4J.
the class TestClientImageController method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
SimpleLoggingUtil.print(getClass(), "camera client init");
Map<String, String> parameters = new HashMap<>();
//64
parameters.put(KEY_WIDTH, configuration.getString(KEY_WIDTH, "320"));
//45
parameters.put(KEY_HEIGHT, configuration.getString(KEY_HEIGHT, "240"));
StringBuilder sb = new StringBuilder(RASPI_CAMERA).append(SPACE).append(parameters.entrySet().stream().map(e -> {
StringBuilder c = new StringBuilder();
if (raspistillProperties.containsKey(e.getKey())) {
return c.append(raspistillProperties.get(e.getKey())).append(SPACE).append(e.getValue()).toString();
}
return null;
}).filter(Objects::nonNull).collect(Collectors.joining(SPACE))).append(SPACE).append(DEFAULT_SETUP);
cameraCommand = sb.toString();
SimpleLoggingUtil.print(getClass(), "camera cameraCommand: " + cameraCommand);
targetOut = configuration.getString("targetOut", null);
String tmpClient = configuration.getString("client", null);
if (tmpClient == null || targetOut == null) {
throw ConfigurationException.createMissingConfigNameException("targetOut, client");
}
try {
InetAddress inetAddress = InetAddress.getByName(tmpClient);
String clientPort = configuration.getString("clientPort", null);
client = clientPort == null ? inetAddress.getHostAddress() : inetAddress.getHostAddress().concat(":").concat(clientPort);
clientUri = configuration.getString("clientUri", Constants.EMPTY_STRING);
} catch (UnknownHostException e) {
SimpleLoggingUtil.error(getClass(), "unknown ip address", e);
throw ConfigurationException.createMissingConfigNameException("unknown ip address");
}
}
use of java.util.Objects in project robo4j by Robo4J.
the class PersistenceDescriptorFactory method scanForEntities.
private List<String> scanForEntities(ClassLoader loader, String... entityPackages) {
ReflectionScan scan = new ReflectionScan(loader);
List<String> classesNames = processClassesWithAnnotation(loader, scan.scanForEntities(entityPackages));
registeredClasses = classesNames.stream().map(cn -> {
try {
return RoboClassLoader.getInstance().getClassLoader().loadClass(cn);
} catch (ClassNotFoundException e) {
SimpleLoggingUtil.error(getClass(), "failed to load class: ", e);
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toList());
return classesNames;
}
Aggregations