You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Builder-style class for use with {@link #createToken(TokenRequest)}
29
+
*
30
+
* <p>All properties are optional and can be <code>null</code>.</p>
31
+
*/
32
+
publicstaticclassTokenRequest {
33
+
/**
34
+
* (optional) The ID of the client token. Can only be specified by a root token. Otherwise, the token ID is a randomly generated UUID.
35
+
*/
36
+
UUIDid;
37
+
38
+
/**
39
+
* (optional) A list of policies for the token. This must be a subset of the policies belonging to the token making the request, unless root. If not specified, defaults to all the policies of the calling token.
40
+
*/
41
+
List<String> polices;
42
+
43
+
/**
44
+
* (optional) A map of string to string valued metadata. This is passed through to the audit backends.
45
+
*/
46
+
Map<String, String> meta;
47
+
48
+
/**
49
+
* (optional) If true and set by a root caller, the token will not have the parent token of the caller. This creates a token with no parent.
50
+
*/
51
+
BooleannoParent;
52
+
53
+
/**
54
+
* (optional) If <code>true</code> the default policy will not be a part of this token's policy set.
55
+
*/
56
+
BooleannoDefaultPolicy;
57
+
58
+
/**
59
+
* (optional) The TTL period of the token, provided as "1h", where hour is the largest suffix. If not provided, the token is valid for the default lease TTL, or indefinitely if the root policy is used.
60
+
*/
61
+
Stringttl;
62
+
63
+
/**
64
+
* (optional) The display name of the token. Defaults to "token".
65
+
*/
66
+
StringdisplayName;
67
+
68
+
/**
69
+
* (optional) The maximum uses for the given token. This can be used to create a one-time-token or limited use token. Defaults to 0, which has no limit to the number of uses.
70
+
*/
71
+
LongnumUses;
72
+
73
+
/**
74
+
* (optional) The role the token will be created with. Default is no role.
@@ -56,7 +244,9 @@ public Auth(final VaultConfig config) {
56
244
* @param numUses (optional) The maximum uses for the given token. This can be used to create a one-time-token or limited use token. Defaults to 0, which has no limit to the number of uses.
57
245
* @return The auth token
58
246
* @throws VaultException If any error occurs, or unexpected response received from Vault
247
+
* @deprecated Use {@link #createToken(TokenRequest)}
59
248
*/
249
+
@Deprecated
60
250
publicAuthResponsecreateToken(
61
251
finalUUIDid,
62
252
finalList<String> policies,
@@ -67,32 +257,63 @@ public AuthResponse createToken(
67
257
finalStringdisplayName,
68
258
finalLongnumUses
69
259
) throwsVaultException {
260
+
returncreateToken(
261
+
newTokenRequest()
262
+
.withId(id)
263
+
.withPolices(policies)
264
+
.withMeta(meta)
265
+
.withNoParent(noParent)
266
+
.withNoDefaultPolicy(noDefaultPolicy)
267
+
.withTtl(ttl)
268
+
.withDisplayName(displayName)
269
+
.withNumUses(numUses));
270
+
}
271
+
272
+
273
+
/**
274
+
* <p>Operation to create an authentication token. Relies on another token already being present in
275
+
* the <code>VaultConfig</code> instance. Example usage:</p>
276
+
*
277
+
* <blockquote>
278
+
* <pre>{@code
279
+
* final VaultConfig config = new VaultConfig(address, rootToken);
280
+
* final Vault vault = new Vault(config);
281
+
* final AuthResponse response = vault.auth().createToken(new TokenRequest().withTtl("1h"));
282
+
*
283
+
* final String token = response.getAuthClientToken();
0 commit comments