@Override
public CompletableFuture<Map<String, ProvenanceVerification>> verify(String processIdentifier, String manifestId, Map<String, File> files) {
Objects.requireNonNull(processIdentifier);
Objects.requireNonNull(manifestId);
Objects.requireNonNull(files);
LOGGER.info("Verifying process id: " + processIdentifier);
CompletableFuture<AuthorizationInfo> authorizationTree = this.blockchain.getAuthorizationTree(processIdentifier);
return this.blockchain
.getProvenance(processIdentifier)
.thenCombine(authorizationTree, (provenanceElements, authorizationInfo) -> {
Map<String, ProvenanceVerification> map = null;
try {
if (authorizationInfo == null) {
LOGGER.info(NO_AUTHORIZATION_DATA);
map = new HashMap<>();
map.put(manifestId, NO_AUTHORIZATION_DATA_AVAILABLE);
} else {
map = this.validateBlockchainInput(provenanceElements, manifestId, files, authorizationInfo);
}
} catch (NoSuchAlgorithmException e) {
LOGGER.error("Could not find the hashing algorithm.", e);
} catch (IOException e) {
LOGGER.error("Could not transform file to byte array.", e);
} catch (SerializationException e) {
LOGGER.error("Could not deserialize stored manifest file.", e);
}
return map;
});
}