Package jenkins.scm.api.trait
Class SCMHeadAuthority<S extends SCMSourceRequest,H extends SCMHeadMixin,R extends SCMRevision>
java.lang.Object
hudson.model.AbstractDescribableImpl<SCMHeadAuthority<?,?,?>>
jenkins.scm.api.trait.SCMHeadAuthority<S,H,R>
- Type Parameters:
S
- the type ofSCMSourceRequest
.H
- the specialization ofSCMHeadMixin
that this authority provides trust information for.R
- the specialization ofSCMRevision
that this authority provides trust information for.
- All Implemented Interfaces:
Describable<SCMHeadAuthority<?,
?, ?>>
public abstract class SCMHeadAuthority<S extends SCMSourceRequest,H extends SCMHeadMixin,R extends SCMRevision>
extends AbstractDescribableImpl<SCMHeadAuthority<?,?,?>>
Abstraction to allow pluggable definitions of trust for
SCMHead
and SCMRevision
instances in the
context of a specific SCMSourceRequest
.
Note: there can be multiple authorities for the same types of head / revision active in the context of any one request. The ultimate trust state is determined by a logical OR operation, in other words if any one authority says that the head / revision is trusted then the head / revision is trusted.
- Since:
- 3.4.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<SCMHeadAuthorityDescriptor>
_for
(Class<? extends SCMSourceRequest> requestClass, Class<? extends SCMHeadMixin> headClass, Class<? extends SCMRevision> revisionClass, Class<? extends SCMHeadOrigin>... origins) Returns the subset ofSCMHeadAuthorityDescriptor
instances applicable to the supplied criteria.static DescriptorExtensionList<SCMHeadAuthority<?,
?, ?>, SCMHeadAuthorityDescriptor> all()
Returns a list of allSCMHeadAuthorityDescriptor
instances.protected abstract boolean
checkTrusted
(S request, H head) SPI: checks if the suppliedSCMHead
is trusted in the context of the suppliedSCMSourceRequest
.protected boolean
checkTrusted
(S request, R revision) SPI: checks if the suppliedSCMRevision
is trusted in the context of the suppliedSCMSourceRequest
.final boolean
isApplicableTo
(SCMHead head) Checks if this authority is relevant to the suppliedSCMHead
.final boolean
isApplicableTo
(SCMRevision revision) Checks if this authority is relevant to the suppliedSCMRevision
.final boolean
isApplicableTo
(SCMSourceRequest request) Checks if this authority is relevant to the suppliedSCMSourceRequest
.final boolean
isTrusted
(SCMSourceRequest request, SCMHead head) Checks if the suppliedSCMHead
is trusted in the context of the specifiedSCMSourceRequest
.final boolean
isTrusted
(SCMSourceRequest request, SCMRevision revision) Checks if the suppliedSCMRevision
is trusted in the context of the specifiedSCMSourceRequest
.
-
Constructor Details
-
SCMHeadAuthority
public SCMHeadAuthority()
-
-
Method Details
-
isApplicableTo
Checks if this authority is relevant to the suppliedSCMHead
.- Parameters:
head
- the suppliedSCMHead
.- Returns:
true
if and only if this authority can provide trust information for the supplied head.
-
isApplicableTo
Checks if this authority is relevant to the suppliedSCMRevision
.- Parameters:
revision
- the suppliedSCMRevision
.- Returns:
true
if and only if this authority can provide trust information for the supplied revision.
-
isApplicableTo
Checks if this authority is relevant to the suppliedSCMSourceRequest
.- Parameters:
request
- the suppliedSCMSourceRequest
.- Returns:
true
if and only if this authority can provide trust information for the supplied request.
-
isTrusted
public final boolean isTrusted(@NonNull SCMSourceRequest request, @NonNull SCMHead head) throws IOException, InterruptedException Checks if the suppliedSCMHead
is trusted in the context of the specifiedSCMSourceRequest
.- Parameters:
request
- theSCMSourceRequest
.head
- theSCMHead
.- Returns:
true
if the supplied head is trusted.- Throws:
IOException
- if there was an I/O error trying to establish the trust status.InterruptedException
- if interrupted while trying to establing the trust status.
-
isTrusted
public final boolean isTrusted(@NonNull SCMSourceRequest request, @CheckForNull SCMRevision revision) throws IOException, InterruptedException Checks if the suppliedSCMRevision
is trusted in the context of the specifiedSCMSourceRequest
.- Parameters:
request
- theSCMSourceRequest
.revision
- theSCMRevision
.- Returns:
true
if the supplied revision is trusted.- Throws:
IOException
- if there was an I/O error trying to establish the trust status.InterruptedException
- if interrupted while trying to establing the trust status.
-
checkTrusted
protected abstract boolean checkTrusted(@NonNull S request, @NonNull H head) throws IOException, InterruptedException SPI: checks if the suppliedSCMHead
is trusted in the context of the suppliedSCMSourceRequest
.- Parameters:
request
- theSCMSourceRequest
.head
- theSCMHead
.- Returns:
true
if trusted.- Throws:
IOException
- if there was an I/O error trying to establish the trust status.InterruptedException
- if interrupted while trying to establing the trust status.
-
checkTrusted
@OverrideMustInvoke protected boolean checkTrusted(@NonNull S request, @NonNull R revision) throws IOException, InterruptedException SPI: checks if the suppliedSCMRevision
is trusted in the context of the suppliedSCMSourceRequest
. Default implementation just callscheckTrusted(SCMSourceRequest, SCMHeadMixin)
withSCMRevision.getHead()
.- Parameters:
request
- theSCMSourceRequest
.revision
- theSCMRevision
.- Returns:
true
if trusted.- Throws:
IOException
- if there was an I/O error trying to establish the trust status.InterruptedException
- if interrupted while trying to establing the trust status.
-
getDescriptor
- Specified by:
getDescriptor
in interfaceDescribable<S extends SCMSourceRequest>
- Overrides:
getDescriptor
in classAbstractDescribableImpl<SCMHeadAuthority<?,
?, ?>>
-
all
Returns a list of allSCMHeadAuthorityDescriptor
instances.- Returns:
- a list of all
SCMHeadAuthorityDescriptor
instances.
-
_for
public static List<SCMHeadAuthorityDescriptor> _for(@CheckForNull Class<? extends SCMSourceRequest> requestClass, @CheckForNull Class<? extends SCMHeadMixin> headClass, @CheckForNull Class<? extends SCMRevision> revisionClass, Class<? extends SCMHeadOrigin>... origins) Returns the subset ofSCMHeadAuthorityDescriptor
instances applicable to the supplied criteria.- Parameters:
requestClass
- theSCMSourceRequest
class (ornull
to match any).headClass
- theSCMHeadMixin
class (ornull
to match any).revisionClass
- theSCMRevision
class (ornull
to match any).origins
- theSCMHeadOrigin
instances.- Returns:
- the list of matching
SCMHeadAuthorityDescriptor
instances.
-