Package org.kohsuke.stapler
Interface DispatchValidator
public interface DispatchValidator
Validates dispatch requests. This validator is configured through
WebApp.setDispatchValidator(DispatchValidator)
and is automatically used by dispatchers created through Facet.createValidatingDispatcher(AbstractTearOff, ScriptExecutor)
.
Extends facet dispatchers to provide validation
of views before they dispatch, thus allowing a final veto before dispatch begins writing any response body to the
client.- Since:
- TODO
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final DispatchValidator
Default validator implementation that explicitly allows all dispatch requests to proceed. -
Method Summary
Modifier and TypeMethodDescriptionvoid
allowDispatch
(StaplerRequest2 req, StaplerResponse2 rsp) Allows the given request to be dispatched.isDispatchAllowed
(StaplerRequest2 req, StaplerResponse2 rsp) Checks if the given request and response should be allowed to dispatch.default Boolean
isDispatchAllowed
(StaplerRequest2 req, StaplerResponse2 rsp, String viewName, Object node) Checks if the given request and response should be allowed to dispatch a view on an optionally present node object.default void
Throws aCancelRequestHandlingException
if the given request is not allowed.
-
Field Details
-
DEFAULT
Default validator implementation that explicitly allows all dispatch requests to proceed.
-
-
Method Details
-
isDispatchAllowed
@CheckForNull Boolean isDispatchAllowed(@NonNull StaplerRequest2 req, @NonNull StaplerResponse2 rsp) Checks if the given request and response should be allowed to dispatch. Returnsnull
to indicate an unknown or neutral result.- Parameters:
req
- the HTTP request to validatersp
- the HTTP response- Returns:
- true if the request should be dispatched, false if not, or null if unknown or neutral
-
isDispatchAllowed
@CheckForNull default Boolean isDispatchAllowed(@NonNull StaplerRequest2 req, @NonNull StaplerResponse2 rsp, @NonNull String viewName, @CheckForNull Object node) Checks if the given request and response should be allowed to dispatch a view on an optionally present node object. Returnsnull
to indicate an unknown or neutral result.- Parameters:
req
- the HTTP request to validatersp
- the HTTP responseviewName
- the name of the view to dispatchnode
- the node being dispatched if present- Returns:
- true if the view should be allowed to dispatch, false if it should not, or null if unknown
-
allowDispatch
Allows the given request to be dispatched. Further calls toisDispatchAllowed(StaplerRequest2, StaplerResponse2)
should return true for the same request. -
requireDispatchAllowed
default void requireDispatchAllowed(@NonNull StaplerRequest2 req, @NonNull StaplerResponse2 rsp) throws CancelRequestHandlingException Throws aCancelRequestHandlingException
if the given request is not allowed.- Throws:
CancelRequestHandlingException
-