use of com.artipie.asto.cache.DigestVerification in project maven-adapter by artipie.
the class CachedProxySlice method checksumControl.
/**
* Checksum cache control verification.
* @param header Checksum header
* @return Cache control with digest
*/
private static CacheControl checksumControl(final Header header) {
final Matcher matcher = CachedProxySlice.CHECKSUM_PATTERN.matcher(header.getKey());
final CacheControl res;
if (matcher.matches()) {
try {
res = new DigestVerification(new Digests.FromString(CachedProxySlice.DIGEST_NAMES.get(matcher.group(1).toLowerCase(Locale.US))).get(), Hex.decodeHex(header.getValue().toCharArray()));
} catch (final DecoderException err) {
throw new IllegalStateException("Invalid digest hex", err);
}
} else {
res = CacheControl.Standard.ALWAYS;
}
return res;
}
Aggregations