Class AuthenticationTokenContext<T>
- java.lang.Object
-
- jenkins.authentication.tokens.api.AuthenticationTokenContext<T>
-
- Type Parameters:
T
- the type of token
@ThreadSafe public final class AuthenticationTokenContext<T> extends Object
The context within which an authentication token will be used.- Since:
- 1.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AuthenticationTokenContext.Builder<T>
A non-thread safe builder ofAuthenticationTokenContext
instances.
-
Constructor Summary
Constructors Constructor Description AuthenticationTokenContext(Class<T> tokenClass)
Creates a basic context for any purpose.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> AuthenticationTokenContext.Builder<T>
builder(Class<T> tokenClass)
Creates aAuthenticationTokenContext.Builder
for contexts of the specified token type.boolean
canHave(Object purpose, Object... validValues)
Checks if the context specifies the supplied purpose and matches against the valid values.Class<T>
getTokenClass()
Returns the type of token.boolean
mustHave(Object purpose, Object... validValues)
Ensures the context specifies the supplied purpose matching against the valid values.
-
-
-
Method Detail
-
builder
public static <T> AuthenticationTokenContext.Builder<T> builder(@NonNull Class<T> tokenClass)
Creates aAuthenticationTokenContext.Builder
for contexts of the specified token type.- Type Parameters:
T
- the type of token.- Parameters:
tokenClass
- the type of token.- Returns:
- a
AuthenticationTokenContext.Builder
instance.
-
getTokenClass
@NonNull public Class<T> getTokenClass()
Returns the type of token.- Returns:
- the type of token.
-
canHave
public boolean canHave(@NonNull Object purpose, Object... validValues)
Checks if the context specifies the supplied purpose and matches against the valid values.- Parameters:
purpose
- the purpose.validValues
- the valid values that the purpose must match if specified.- Returns:
true
if either the purpose is not specified or the purpose is specified and is equal to one of the specified values.
-
mustHave
public boolean mustHave(@NonNull Object purpose, Object... validValues)
Ensures the context specifies the supplied purpose matching against the valid values.- Parameters:
purpose
- the purpose.validValues
- the valid values that the purpose must match.- Returns:
true
if and only if the purpose is specified and is equal to one of the specified values.
-
-