This commit is contained in:
Anatoliy Sablin
2020-02-19 00:36:05 +03:00
parent 9b4aff58c7
commit b2f41d689b
12 changed files with 68 additions and 34 deletions

View File

@@ -31,6 +31,8 @@ public class HashDetailsHandler extends BasicHttpHandler {
for (HashingConfig.Algorithm algorithm : config.getAlgorithms()) {
algorithms.add(algorithm.name().toLowerCase());
}
} else {
algorithms.add(HashingConfig.Algorithm.none.name().toLowerCase());
}
response.add("algorithms", algorithms);
return response;

View File

@@ -67,10 +67,6 @@ public class HashLookupHandler extends LookupHandler implements ApiHandler {
log.info("Got bulk lookup request from {} with client {} - Is recursive? {}",
lookupRequest.getRequester(), lookupRequest.getUserAgent(), lookupRequest.isRecursive());
if (!hashManager.getConfig().isEnabled()) {
throw new InvalidParamException();
}
if (!hashManager.getHashEngine().getPepper().equals(input.getPepper())) {
throw new InvalidPepperException();
}
@@ -89,7 +85,7 @@ public class HashLookupHandler extends LookupHandler implements ApiHandler {
}
private void noneAlgorithm(HttpServerExchange exchange, HashLookupRequest request, ClientHashLookupRequest input) throws Exception {
if (!hashManager.getConfig().getAlgorithms().contains(HashingConfig.Algorithm.none)) {
if (hashManager.getConfig().isEnabled() && !hashManager.getConfig().getAlgorithms().contains(HashingConfig.Algorithm.none)) {
throw new InvalidParamException();
}