Implement AutoCloseable
This commit is contained in:
parent
e767c07a61
commit
ed703f6e53
@ -2,6 +2,7 @@
|
|||||||
* [feature] Initialization from environment variables using `fromEnv()` in factory (#8)
|
* [feature] Initialization from environment variables using `fromEnv()` in factory (#8)
|
||||||
* [feature] Automatic authentication with `buildAndAuth()`
|
* [feature] Automatic authentication with `buildAndAuth()`
|
||||||
* [feature] Custom timeout and number of retries (#9)
|
* [feature] Custom timeout and number of retries (#9)
|
||||||
|
* [feature] Connector implements `AutoCloseable`
|
||||||
* [fix] `SecretResponse` does not throw NPE on `get(key)` and `getData()`
|
* [fix] `SecretResponse` does not throw NPE on `get(key)` and `getData()`
|
||||||
|
|
||||||
## 0.5.0 [2017-03-18]
|
## 0.5.0 [2017-03-18]
|
||||||
|
@ -67,7 +67,7 @@ public class HTTPVaultConnector implements VaultConnector {
|
|||||||
private final String baseURL; /* Base URL of Vault */
|
private final String baseURL; /* Base URL of Vault */
|
||||||
private final SSLContext sslContext; /* Custom SSLSocketFactory */
|
private final SSLContext sslContext; /* Custom SSLSocketFactory */
|
||||||
private final int retries; /* Number of retries on 5xx errors */
|
private final int retries; /* Number of retries on 5xx errors */
|
||||||
private final Integer timeout; /* Timeout in milliseconds */
|
private final Integer timeout; /* Timeout in milliseconds */
|
||||||
|
|
||||||
private boolean authorized = false; /* authorization status */
|
private boolean authorized = false; /* authorization status */
|
||||||
private String token; /* current token */
|
private String token; /* current token */
|
||||||
@ -610,6 +610,13 @@ public class HTTPVaultConnector implements VaultConnector {
|
|||||||
return createTokenInternal(token, PATH_TOKEN + PATH_CREATE + "/" + role);
|
return createTokenInternal(token, PATH_TOKEN + PATH_CREATE + "/" + role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
authorized = false;
|
||||||
|
token = null;
|
||||||
|
tokenTTL = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create token.
|
* Create token.
|
||||||
* Centralized method to handle different token creation requests.
|
* Centralized method to handle different token creation requests.
|
||||||
|
@ -30,7 +30,7 @@ import java.util.*;
|
|||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
* @since 0.1
|
* @since 0.1
|
||||||
*/
|
*/
|
||||||
public interface VaultConnector {
|
public interface VaultConnector extends AutoCloseable {
|
||||||
String PATH_SECRET = "secret";
|
String PATH_SECRET = "secret";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user