Class AuthenticationTokenSource<T,C extends com.cloudbees.plugins.credentials.Credentials>
java.lang.Object
jenkins.authentication.tokens.api.AuthenticationTokenSource<T,C>
- All Implemented Interfaces:
ExtensionPoint
public abstract class AuthenticationTokenSource<T,C extends com.cloudbees.plugins.credentials.Credentials>
extends Object
implements ExtensionPoint
Converts
Credentials
into authentication tokens- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
ModifierConstructorDescriptionprotected
AuthenticationTokenSource
(Class<T> tokenClass, Class<C> credentialsClass) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
consumes
(com.cloudbees.plugins.credentials.Credentials credentials) Checks if this source consumes the specificCredentials
instance.final <C extends com.cloudbees.plugins.credentials.Credentials>
booleanChecks if this source consumesCredentials
of the specified type.abstract T
Converts the specified credentials into a token.final boolean
fits
(AuthenticationTokenContext<?> context) Checks if this source fits the specified context.protected boolean
isFit
(AuthenticationTokenContext<? super T> context) Checks if this source fits the specified context, override this methodcom.cloudbees.plugins.credentials.CredentialsMatcher
matcher()
Produces aCredentialsMatcher
for this specificAuthenticationTokenSource
.final <T> boolean
Checks if this source produces the specified token type.
-
Constructor Details
-
AuthenticationTokenSource
Constructor.- Parameters:
tokenClass
- the type of token produced.credentialsClass
- the type of credentials consumed.
-
-
Method Details
-
convert
Converts the specified credentials into a token.- Parameters:
credential
- the credentials to convert.- Returns:
- the corresponding token.
- Throws:
AuthenticationTokenException
- if the specific credentials could not be converted.
-
matcher
@NonNull @OverrideMustInvoke(ANYTIME) public com.cloudbees.plugins.credentials.CredentialsMatcher matcher()Produces aCredentialsMatcher
for this specificAuthenticationTokenSource
. Implementations only need to override this method when they can only process a sub-set of the credential class that they convert. For example ifUsernamePasswordCredentials
are converted into a specific authentication token, but only for those cases where there is a password and the username is between 3 and 8 lowercase letters then the specific source implementation would likely override this method and return a more specificCredentialsMatcher
in order to avoidconvert(Credentials)
having to throw anAuthenticationTokenException
.- Returns:
- the
CredentialsMatcher
for this source.
-
produces
Checks if this source produces the specified token type.- Type Parameters:
T
- the token type.- Parameters:
tokenClass
- the token type.- Returns:
true
if and only if this source can produce tokens of the specified type.
-
consumes
public final <C extends com.cloudbees.plugins.credentials.Credentials> boolean consumes(@NonNull Class<C> credentialsClass) Checks if this source consumesCredentials
of the specified type.- Type Parameters:
C
- the credential type.- Parameters:
credentialsClass
- the credential type.- Returns:
true
if and only if this source can consume credentials of the specified type.
-
consumes
public final boolean consumes(@NonNull com.cloudbees.plugins.credentials.Credentials credentials) Checks if this source consumes the specificCredentials
instance.- Parameters:
credentials
- the credentials.- Returns:
true
if and only if this source can consume credentials of the specified type.
-
fits
Checks if this source fits the specified context.- Parameters:
context
- the context that an authentication token is required in.- Returns:
true
if and only if this source fits the specified context.- Since:
- 1.2
-
isFit
Checks if this source fits the specified context, override this method- Parameters:
context
- the context that an authentication token is required in.- Returns:
true
if and only if this source fits the specified context.- Since:
- 1.2
-