Implement AutoCloseable

This commit is contained in:
2017-04-13 19:49:47 +02:00
parent e767c07a61
commit ed703f6e53
3 changed files with 10 additions and 2 deletions

View File

@ -67,7 +67,7 @@ public class HTTPVaultConnector implements VaultConnector {
private final String baseURL; /* Base URL of Vault */
private final SSLContext sslContext; /* Custom SSLSocketFactory */
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 String token; /* current token */
@ -610,6 +610,13 @@ public class HTTPVaultConnector implements VaultConnector {
return createTokenInternal(token, PATH_TOKEN + PATH_CREATE + "/" + role);
}
@Override
public void close() {
authorized = false;
token = null;
tokenTTL = 0;
}
/**
* Create token.
* Centralized method to handle different token creation requests.

View File

@ -30,7 +30,7 @@ import java.util.*;
* @author Stefan Kalscheuer
* @since 0.1
*/
public interface VaultConnector {
public interface VaultConnector extends AutoCloseable {
String PATH_SECRET = "secret";
/**