diff --git a/spring-vault-core/src/main/java/org/springframework/vault/core/VaultTokenOperations.java b/spring-vault-core/src/main/java/org/springframework/vault/core/VaultTokenOperations.java
index d5af8a7b..9520047d 100644
--- a/spring-vault-core/src/main/java/org/springframework/vault/core/VaultTokenOperations.java
+++ b/spring-vault-core/src/main/java/org/springframework/vault/core/VaultTokenOperations.java
@@ -72,7 +72,7 @@ public interface VaultTokenOperations {
* @param vaultToken must not be {@literal null}.
* @return a {@link VaultTokenResponse}
* @see POST
- * /auth/token/renew/{token}
+ * /auth/token/renew
*/
VaultTokenResponse renew(VaultToken vaultToken);
@@ -81,7 +81,7 @@ public interface VaultTokenOperations {
*
* @param vaultToken must not be {@literal null}.
* @see POST
- * /auth/token/revoke/{token}
+ * /auth/token/revoke
*/
void revoke(VaultToken vaultToken);
@@ -90,7 +90,7 @@ public interface VaultTokenOperations {
*
* @param vaultToken must not be {@literal null}.
* @see POST
- * /auth/token/revoke-orphan/{token}
+ * /auth/token/revoke-orphan
*/
void revokeOrphan(VaultToken vaultToken);
}
diff --git a/spring-vault-core/src/main/java/org/springframework/vault/core/VaultTokenTemplate.java b/spring-vault-core/src/main/java/org/springframework/vault/core/VaultTokenTemplate.java
index 9ad697fb..3449e511 100644
--- a/spring-vault-core/src/main/java/org/springframework/vault/core/VaultTokenTemplate.java
+++ b/spring-vault-core/src/main/java/org/springframework/vault/core/VaultTokenTemplate.java
@@ -15,6 +15,8 @@
*/
package org.springframework.vault.core;
+import java.util.Collections;
+
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
@@ -80,9 +82,7 @@ public class VaultTokenTemplate implements VaultTokenOperations {
Assert.notNull(vaultToken, "VaultToken must not be null");
- return writeAndReturn(
- String.format("auth/token/renew/%s", vaultToken.getToken()), null,
- VaultTokenResponse.class);
+ return writeAndReturn("auth/token/renew", vaultToken, VaultTokenResponse.class);
}
@Override
@@ -90,8 +90,7 @@ public class VaultTokenTemplate implements VaultTokenOperations {
Assert.notNull(vaultToken, "VaultToken must not be null");
- write(String.format("auth/token/revoke/%s", vaultToken.getToken()),
- VaultTokenResponse.class);
+ writeToken("auth/token/revoke", vaultToken, VaultTokenResponse.class);
}
@Override
@@ -99,8 +98,7 @@ public class VaultTokenTemplate implements VaultTokenOperations {
Assert.notNull(vaultToken, "VaultToken must not be null");
- write(String.format("auth/token/revoke-orphan/%s", vaultToken.getToken()),
- VaultTokenResponse.class);
+ writeToken("auth/token/revoke-orphan", vaultToken, VaultTokenResponse.class);
}
private > T writeAndReturn(String path,
@@ -126,21 +124,23 @@ public class VaultTokenTemplate implements VaultTokenOperations {
return response;
}
- private void write(String path, Class> responseType) {
+ @Nullable
+ private void writeToken(String path, VaultToken token, Class> responseType) {
Assert.hasText(path, "Path must not be empty");
vaultOperations.doWithSession(restOperations -> {
try {
- restOperations.exchange(path, HttpMethod.POST, HttpEntity.EMPTY,
+ restOperations.exchange(path, HttpMethod.POST, new HttpEntity<>(
+ Collections.singletonMap("token", token.getToken())),
responseType);
+
+ return null;
}
catch (HttpStatusCodeException e) {
throw VaultResponses.buildException(e, path);
}
-
- return null;
});
}
}