{
*
* Reusing a cached token can lead to authentication failures if the credential
* expires.
- *
* @return a caching {@link CredentialSupplier}.
*/
default CredentialSupplier cached() {
@@ -53,4 +51,5 @@ public interface CredentialSupplier extends Supplier {
return () -> credential;
}
+
}
diff --git a/spring-vault-core/src/main/java/org/springframework/vault/authentication/CubbyholeAuthentication.java b/spring-vault-core/src/main/java/org/springframework/vault/authentication/CubbyholeAuthentication.java
index b8951865..e072433c 100644
--- a/spring-vault-core/src/main/java/org/springframework/vault/authentication/CubbyholeAuthentication.java
+++ b/spring-vault-core/src/main/java/org/springframework/vault/authentication/CubbyholeAuthentication.java
@@ -56,8 +56,7 @@ import static org.springframework.vault.authentication.AuthenticationSteps.HttpR
* wrapping_token_ttl: 0h10m0s
* wrapping_token_creation_time: 2016-09-18 20:29:48.652957077 +0200 CEST
* wrapped_accessor: 46b6aebb-187f-932a-26d7-4f3d86a68319
- *
- *
+ *
*
* Setup {@link CubbyholeAuthentication}
*
@@ -69,8 +68,7 @@ import static org.springframework.vault.authentication.AuthenticationSteps.HttpR
* .wrapped()
* .build();
* CubbyholeAuthentication authentication = new CubbyholeAuthentication(options, restOperations);
- *
- *
+ *
*
* Stored token response usage
Create a Token
*
@@ -96,8 +94,7 @@ import static org.springframework.vault.authentication.AuthenticationSteps.HttpR
*
* $ export VAULT_TOKEN=895cb88b-aef4-0e33-ba65-d50007290780
* $ vault write cubbyhole/token token=f9e30681-d46a-cdaf-aaa0-2ae0a9ad0819
- *
- *
+ *
*
* Setup {@link CubbyholeAuthentication}
*
@@ -109,8 +106,7 @@ import static org.springframework.vault.authentication.AuthenticationSteps.HttpR
* .path("cubbyhole/token")
* .build();
* CubbyholeAuthentication authentication = new CubbyholeAuthentication(options, restOperations);
- *
- *
+ *
*
* Remaining TTL/Renewability
*
@@ -135,8 +131,7 @@ import static org.springframework.vault.authentication.AuthenticationSteps.HttpR
* "https://www.vaultproject.io/docs/concepts/response-wrapping.html">Response
* Wrapping
*/
-public class CubbyholeAuthentication
- implements ClientAuthentication, AuthenticationStepsFactory {
+public class CubbyholeAuthentication implements ClientAuthentication, AuthenticationStepsFactory {
private static final Log logger = LogFactory.getLog(CubbyholeAuthentication.class);
@@ -147,12 +142,10 @@ public class CubbyholeAuthentication
/**
* Create a new {@link CubbyholeAuthentication} given
* {@link CubbyholeAuthenticationOptions} and {@link RestOperations}.
- *
* @param options must not be {@literal null}.
* @param restOperations must not be {@literal null}.
*/
- public CubbyholeAuthentication(CubbyholeAuthenticationOptions options,
- RestOperations restOperations) {
+ public CubbyholeAuthentication(CubbyholeAuthenticationOptions options, RestOperations restOperations) {
Assert.notNull(options, "CubbyholeAuthenticationOptions must not be null");
Assert.notNull(restOperations, "RestOperations must not be null");
@@ -164,13 +157,11 @@ public class CubbyholeAuthentication
/**
* Creates a {@link AuthenticationSteps} for cubbyhole authentication given
* {@link CubbyholeAuthenticationOptions}.
- *
* @param options must not be {@literal null}.
* @return {@link AuthenticationSteps} for cubbyhole authentication.
* @since 2.0
*/
- public static AuthenticationSteps createAuthenticationSteps(
- CubbyholeAuthenticationOptions options) {
+ public static AuthenticationSteps createAuthenticationSteps(CubbyholeAuthenticationOptions options) {
Assert.notNull(options, "CubbyholeAuthenticationOptions must not be null");
@@ -190,15 +181,14 @@ public class CubbyholeAuthentication
@Override
public VaultToken login() throws VaultException {
- String url = getRequestPath(options);
+ String url = getRequestPath(this.options);
VaultResponse data = lookupToken(url);
VaultToken tokenToUse = getToken(this.options, data, url);
if (shouldEnhanceTokenWithSelfLookup(tokenToUse)) {
- LoginTokenAdapter adapter = new LoginTokenAdapter(
- new TokenAuthentication(tokenToUse), restOperations);
+ LoginTokenAdapter adapter = new LoginTokenAdapter(new TokenAuthentication(tokenToUse), this.restOperations);
tokenToUse = adapter.login();
}
@@ -208,17 +198,17 @@ public class CubbyholeAuthentication
@Override
public AuthenticationSteps getAuthenticationSteps() {
- return createAuthenticationSteps(options);
+ return createAuthenticationSteps(this.options);
}
@Nullable
private VaultResponse lookupToken(String url) {
try {
- HttpMethod unwrapMethod = getRequestMethod(options);
- HttpEntity