Search in sources :

Example 1 with KeyAccessDeniedException

use of org.apache.parquet.crypto.KeyAccessDeniedException in project parquet-mr by apache.

the class VaultClient method executeAndGetResponse.

private String executeAndGetResponse(String endPoint, Request request) {
    Response response = null;
    try {
        response = httpClient.newCall(request).execute();
        final String responseBody = response.body().string();
        if (response.isSuccessful()) {
            return responseBody;
        } else {
            if ((401 == response.code()) || (403 == response.code())) {
                throw new KeyAccessDeniedException(responseBody);
            }
            throw new IOException("Vault call [" + endPoint + "] didn't succeed: " + responseBody);
        }
    } catch (IOException e) {
        throw new ParquetCryptoRuntimeException("Vault call [" + request.url().toString() + endPoint + "] didn't succeed", e);
    } finally {
        if (null != response) {
            response.close();
        }
    }
}
Also used : Response(okhttp3.Response) ParquetCryptoRuntimeException(org.apache.parquet.crypto.ParquetCryptoRuntimeException) IOException(java.io.IOException) KeyAccessDeniedException(org.apache.parquet.crypto.KeyAccessDeniedException)

Aggregations

IOException (java.io.IOException)1 Response (okhttp3.Response)1 KeyAccessDeniedException (org.apache.parquet.crypto.KeyAccessDeniedException)1 ParquetCryptoRuntimeException (org.apache.parquet.crypto.ParquetCryptoRuntimeException)1