public InputStream fetchKeyAndEncrypt(Document document, InputStream content) {
checkThatMessageCanBePreEncrypted(document);
try(CloseableHttpResponse encryptionKeyResponse = apiService.getEncryptionKey(document.getEncryptionKeyLink().getUri())){
checkResponse(encryptionKeyResponse);
EncryptionKey key = unmarshal(encryptionKeyContext, encryptionKeyResponse.getEntity().getContent(), EncryptionKey.class);
<BUG>return the(new DigipostPublicKey(key)).map(keyToEncrypter).orElse(FAIL_IF_TRYING_TO_ENCRYPT).encrypt(content);
} catch (IOException e) {</BUG>
throw new RuntimeException(e.getMessage(), e);
}
}

public InputStream fetchKeyAndEncrypt(Document document, InputStream content) {
checkThatMessageCanBePreEncrypted(document);
try(CloseableHttpResponse encryptionKeyResponse = apiService.getEncryptionKey(document.getEncryptionKeyLink().getUri())){
checkResponse(encryptionKeyResponse);
EncryptionKey key = unmarshal(encryptionKeyContext, encryptionKeyResponse.getEntity().getContent(), EncryptionKey.class);
return Encrypter.using(new DigipostPublicKey(key)).encrypt(content);
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
