Class AuthenticationTokens
- java.lang.Object
-
- jenkins.authentication.tokens.api.AuthenticationTokens
-
public final class AuthenticationTokens extends Object
Utility class for manipulating authentication tokens.- Since:
- 1.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,C extends com.cloudbees.plugins.credentials.Credentials>
Tconvert(Class<T> type, C credentials)
Converts the supplied credentials into the specified token.static <T,C extends com.cloudbees.plugins.credentials.Credentials>
Tconvert(AuthenticationTokenContext<T> context, C credentials)
Converts the supplied credentials into the specified token.static <T,C extends com.cloudbees.plugins.credentials.Credentials>
Tconvert(AuthenticationTokenContext<T> context, C... credentials)
Converts the best match of the supplied credentials into the specified token.static <T,C extends com.cloudbees.plugins.credentials.Credentials>
Tconvert(AuthenticationTokenContext<T> context, List<C> credentials)
Converts the best match of the supplied credentials into the specified token.static <T> com.cloudbees.plugins.credentials.CredentialsMatcher
matcher(Class<T> tokenClass)
Builds a matcher for credentials that can be converted into the supplied token type.static <T> com.cloudbees.plugins.credentials.CredentialsMatcher
matcher(AuthenticationTokenContext<T> context)
Builds a matcher for credentials that can be converted into the supplied token type.
-
-
-
Method Detail
-
matcher
public static <T> com.cloudbees.plugins.credentials.CredentialsMatcher matcher(Class<T> tokenClass)
Builds a matcher for credentials that can be converted into the supplied token type.- Type Parameters:
T
- the type of token- Parameters:
tokenClass
- the type of token- Returns:
- a matcher for the type of token
-
matcher
public static <T> com.cloudbees.plugins.credentials.CredentialsMatcher matcher(AuthenticationTokenContext<T> context)
Builds a matcher for credentials that can be converted into the supplied token type.- Type Parameters:
T
- the type of token.- Parameters:
context
- the context that an authentication token is required in.- Returns:
- a matcher for the type of token.
- Since:
- 1.2
-
convert
@CheckForNull public static <T,C extends com.cloudbees.plugins.credentials.Credentials> T convert(@NonNull Class<T> type, @CheckForNull C credentials)
Converts the supplied credentials into the specified token.- Type Parameters:
T
- the type of token to convert to.C
- the type of credentials to convert,- Parameters:
type
- the type of token to convert to.credentials
- the credentials instance to convert.- Returns:
- the token or
null
if the credentials could not be converted.
-
convert
@CheckForNull public static <T,C extends com.cloudbees.plugins.credentials.Credentials> T convert(@NonNull AuthenticationTokenContext<T> context, @CheckForNull C credentials)
Converts the supplied credentials into the specified token.- Type Parameters:
T
- the type of token to convert to.C
- the type of credentials to convert,- Parameters:
context
- the context that an authentication token is required in.credentials
- the credentials instance to convert.- Returns:
- the token or
null
if the credentials could not be converted. - Since:
- 1.2
-
convert
@CheckForNull public static <T,C extends com.cloudbees.plugins.credentials.Credentials> T convert(@NonNull AuthenticationTokenContext<T> context, @NonNull C... credentials)
Converts the best match of the supplied credentials into the specified token.- Type Parameters:
T
- the type of token to convert to.C
- the type of credentials to convert,- Parameters:
context
- the context that an authentication token is required in.credentials
- the credentials instances to try and convert.- Returns:
- the token or
null
if the credentials could not be converted. - Since:
- 1.2
-
convert
@CheckForNull public static <T,C extends com.cloudbees.plugins.credentials.Credentials> T convert(@NonNull AuthenticationTokenContext<T> context, @NonNull List<C> credentials)
Converts the best match of the supplied credentials into the specified token.- Type Parameters:
T
- the type of token to convert to.C
- the type of credentials to convert,- Parameters:
context
- the context that an authentication token is required in.credentials
- the credentials instances to try and convert.- Returns:
- the token or
null
if the credentials could not be converted. - Since:
- 1.2
-
-