@@ -43,13 +43,21 @@ protected Auth getVaultAuth(@NonNull Vault vault) {
43
43
}
44
44
45
45
/**
46
- * Retrieves a new token with specific policies if a list of requested policies is provided.
46
+ * Should be implemented by classes that support creating child tokens.
47
+ * @return true if child tokens can be used, false otherwise
48
+ */
49
+ protected boolean supportsChildTokens () {
50
+ return false ;
51
+ }
52
+
53
+ /**
54
+ * Retrieves a new child token with specific policies if a list of requested policies is provided.
47
55
* @param vault the vault instance
48
56
* @param policies the policies list
49
57
* @return the new token or null if no policies are defined
50
58
*/
51
- protected String getTokenWithPolicies (Vault vault , List <String > policies ) {
52
- if (policies == null || policies .isEmpty ()) {
59
+ protected String getChildToken (Vault vault , List <String > policies ) {
60
+ if (! supportsChildTokens () || policies == null || policies .isEmpty ()) {
53
61
return null ;
54
62
}
55
63
Auth auth = getVaultAuth (vault );
@@ -90,7 +98,7 @@ public Vault authorizeWithVault(VaultConfig config, List<String> policies) {
90
98
config .token (tokenCache .get (cacheKey ));
91
99
92
100
// After current token is configured, try to retrieve a new child token with limited policies
93
- String childToken = getTokenWithPolicies (vault , policies );
101
+ String childToken = getChildToken (vault , policies );
94
102
if (childToken != null ) {
95
103
// A new token was generated, put it in the cache and configure vault
96
104
tokenCache .put (cacheKey , childToken );
0 commit comments