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 ofSCMHeadMixinthat this authority provides trust information for.R- the specialization ofSCMRevisionthat 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
Constructors -
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 ofSCMHeadAuthorityDescriptorinstances applicable to the supplied criteria.static DescriptorExtensionList<SCMHeadAuthority<?,?, ?>, SCMHeadAuthorityDescriptor> all()Returns a list of allSCMHeadAuthorityDescriptorinstances.protected abstract booleancheckTrusted(S request, H head) SPI: checks if the suppliedSCMHeadis trusted in the context of the suppliedSCMSourceRequest.protected booleancheckTrusted(S request, R revision) SPI: checks if the suppliedSCMRevisionis trusted in the context of the suppliedSCMSourceRequest.final booleanisApplicableTo(SCMHead head) Checks if this authority is relevant to the suppliedSCMHead.final booleanisApplicableTo(SCMRevision revision) Checks if this authority is relevant to the suppliedSCMRevision.final booleanisApplicableTo(SCMSourceRequest request) Checks if this authority is relevant to the suppliedSCMSourceRequest.final booleanisTrusted(SCMSourceRequest request, SCMHead head) Checks if the suppliedSCMHeadis trusted in the context of the specifiedSCMSourceRequest.final booleanisTrusted(SCMSourceRequest request, SCMRevision revision) Checks if the suppliedSCMRevisionis 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:
trueif 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:
trueif 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:
trueif 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 suppliedSCMHeadis trusted in the context of the specifiedSCMSourceRequest.- Parameters:
request- theSCMSourceRequest.head- theSCMHead.- Returns:
trueif 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 suppliedSCMRevisionis trusted in the context of the specifiedSCMSourceRequest.- Parameters:
request- theSCMSourceRequest.revision- theSCMRevision.- Returns:
trueif 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 suppliedSCMHeadis trusted in the context of the suppliedSCMSourceRequest.- Parameters:
request- theSCMSourceRequest.head- theSCMHead.- Returns:
trueif 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 suppliedSCMRevisionis trusted in the context of the suppliedSCMSourceRequest. Default implementation just callscheckTrusted(SCMSourceRequest, SCMHeadMixin)withSCMRevision.getHead().- Parameters:
request- theSCMSourceRequest.revision- theSCMRevision.- Returns:
trueif 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:
getDescriptorin interfaceDescribable<S extends SCMSourceRequest>- Overrides:
getDescriptorin classAbstractDescribableImpl<SCMHeadAuthority<?,?, ?>>
-
all
Returns a list of allSCMHeadAuthorityDescriptorinstances.- Returns:
- a list of all
SCMHeadAuthorityDescriptorinstances.
-
_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 ofSCMHeadAuthorityDescriptorinstances applicable to the supplied criteria.- Parameters:
requestClass- theSCMSourceRequestclass (ornullto match any).headClass- theSCMHeadMixinclass (ornullto match any).revisionClass- theSCMRevisionclass (ornullto match any).origins- theSCMHeadOrigininstances.- Returns:
- the list of matching
SCMHeadAuthorityDescriptorinstances.
-