Polishing.
Introduce convenience factory method to convert a VaultToken into LoginToken. See gh-159.
This commit is contained in:
@@ -163,6 +163,21 @@ public class LoginToken extends VaultToken {
|
||||
return new LoginToken(token, Duration.ofSeconds(leaseDurationSeconds), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new renewable {@link LoginToken} with a {@code leaseDurationSeconds}.
|
||||
*
|
||||
* @param token must not be {@literal null}.
|
||||
* @param leaseDuration the lease duration, must not be {@literal null} or negative.
|
||||
* @return the created {@link VaultToken}
|
||||
* @since 2.0
|
||||
*/
|
||||
public static LoginToken renewable(VaultToken token, Duration leaseDuration) {
|
||||
|
||||
Assert.notNull(token, "Token must not be null");
|
||||
|
||||
return renewable(token.toCharArray(), leaseDuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new renewable {@link LoginToken} with a {@code leaseDurationSeconds}.
|
||||
*
|
||||
|
||||
@@ -108,7 +108,7 @@ public class LoginTokenAdapter implements ClientAuthentication {
|
||||
}
|
||||
}
|
||||
|
||||
private static Duration getLeaseDuration(@Nullable Number ttl) {
|
||||
static Duration getLeaseDuration(@Nullable Number ttl) {
|
||||
return ttl == null ? Duration.ZERO : Duration.ofSeconds(ttl.longValue());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user