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
ConvertsCredentials
into authentication tokens- Since:
- 1.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AuthenticationTokenSource(Class<T> tokenClass, Class<C> credentialsClass)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
consumes(com.cloudbees.plugins.credentials.Credentials credentials)
Checks if this source consumes the specificCredentials
instance.<C extends com.cloudbees.plugins.credentials.Credentials>
booleanconsumes(Class<C> credentialsClass)
Checks if this source consumesCredentials
of the specified type.abstract T
convert(C credential)
Converts the specified credentials into a token.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
.<T> boolean
produces(Class<T> tokenClass)
Checks if this source produces the specified token type.
-
-
-
Method Detail
-
convert
@NonNull public abstract T convert(@NonNull C credential) throws AuthenticationTokenException
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
public final <T> boolean produces(@NonNull Class<T> tokenClass)
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
public final boolean fits(AuthenticationTokenContext<?> context)
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
protected boolean isFit(AuthenticationTokenContext<? super T> context)
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
-
-