Check for "permission denied" without status code 403
This commit is contained in:
parent
b845e4b7ce
commit
30ac23203d
@ -14,7 +14,7 @@ Java Vault Connector is a connector library for [Vault](https://www.vaultproject
|
|||||||
* Write secrets
|
* Write secrets
|
||||||
* List secrets
|
* List secrets
|
||||||
* Connector Factory with builder pattern
|
* Connector Factory with builder pattern
|
||||||
* Tested against Vault 0.5.2
|
* Tested against Vault 0.6.0
|
||||||
|
|
||||||
**Usage Example**
|
**Usage Example**
|
||||||
|
|
||||||
|
@ -381,7 +381,14 @@ public class HTTPVaultConnector implements VaultConnector {
|
|||||||
InvalidResponseException ex = new InvalidResponseException("Invalid response code")
|
InvalidResponseException ex = new InvalidResponseException("Invalid response code")
|
||||||
.withStatusCode(response.getStatusLine().getStatusCode());
|
.withStatusCode(response.getStatusLine().getStatusCode());
|
||||||
try {
|
try {
|
||||||
throw ex.withResponse(IOUtils.toString(response.getEntity().getContent()));
|
/* Try to parse error response */
|
||||||
|
ErrorResponse er = jsonMapper.readValue(IOUtils.toString(response.getEntity().getContent()),
|
||||||
|
ErrorResponse.class);
|
||||||
|
/* Check for "permission denied" response */
|
||||||
|
if (er.getErrors().size() > 0 && er.getErrors().get(0).equals("permission denied"))
|
||||||
|
throw new PermissionDeniedException();
|
||||||
|
|
||||||
|
throw ex.withResponse(er.toString());
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
throw ex;
|
throw ex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user