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
ConstructorsModifierConstructorDescriptionprotectedAuthenticationTokenSource(Class<T> tokenClass, Class<C> credentialsClass) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanconsumes(com.cloudbees.plugins.credentials.Credentials credentials) Checks if this source consumes the specificCredentialsinstance.final <C extends com.cloudbees.plugins.credentials.Credentials>
booleanChecks if this source consumesCredentialsof the specified type.abstract TConverts the specified credentials into a token.final booleanfits(AuthenticationTokenContext<?> context) Checks if this source fits the specified context.protected booleanisFit(AuthenticationTokenContext<? super T> context) Checks if this source fits the specified context, override this methodcom.cloudbees.plugins.credentials.CredentialsMatchermatcher()Produces aCredentialsMatcherfor this specificAuthenticationTokenSource.final <T> booleanChecks 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 aCredentialsMatcherfor 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 ifUsernamePasswordCredentialsare 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 specificCredentialsMatcherin order to avoidconvert(Credentials)having to throw anAuthenticationTokenException.- Returns:
- the
CredentialsMatcherfor this source.
-
produces
Checks if this source produces the specified token type.- Type Parameters:
T- the token type.- Parameters:
tokenClass- the token type.- Returns:
trueif 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 consumesCredentialsof the specified type.- Type Parameters:
C- the credential type.- Parameters:
credentialsClass- the credential type.- Returns:
trueif 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 specificCredentialsinstance.- Parameters:
credentials- the credentials.- Returns:
trueif 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:
trueif 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:
trueif and only if this source fits the specified context.- Since:
- 1.2
-