class RetryingEncryptionService {

  public String decrypt(final EncryptedValue encryptedValue)
    throws Exception {
    LOGGER.info("Attempting decrypt");
    return retryOnErrorWithRemappedKey(() -> {
      final EncryptionKey key = keySet.get(encryptedValue.getEncryptionKeyUuid());

      if (key == null) {
        throw new KeyNotFoundException(ErrorMessages.MISSING_ENCRYPTION_KEY);
      }
      return key.decrypt(encryptedValue.getEncryptedValue(), encryptedValue.getNonce());
    });
  }

  @Autowired public  RetryingEncryptionService(final EncryptionKeySet keySet);

}