Interface AccessContext
- All Known Implementing Classes:
EndpointAccessContext,RouteAccessContext
public interface AccessContext
This class provides the context information to
AccessEvaluators, either
for a route or an entpoint.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe currently supported types of targets for which access can be controlled. -
Method Summary
Modifier and TypeMethodDescriptiondefault EndpointAccessContextCasts this access context to aEndpointAccessContextwhich provides more information that is specific to this target type.default RouteAccessContextCasts this access context to aRouteAccessContextwhich provides more information that is specific to this target type.<A extends Annotation>
Optional<A>findAnnotation(Class<A> annotationType) A convenience method that allows to find the first matching annotation of a certain type, looking in locations and in an order that makes the most sense for the target type of this access context.The type of the target for which to check access; either a route or and endpoint.default booleanReturns whether this is an endpoint access context, i.e.default booleanisRoute()Returns whether this is a route access context, i.e.
-
Method Details
-
getTargetType
AccessContext.TargetType getTargetType()The type of the target for which to check access; either a route or and endpoint.- Returns:
- type of the target for which to check access
-
findAnnotation
A convenience method that allows to find the first matching annotation of a certain type, looking in locations and in an order that makes the most sense for the target type of this access context. This method does support meta-annotations.- Type Parameters:
A- the annotation type- Parameters:
annotationType- the annotation type- Returns:
- the first matching annotation
-
isRoute
default boolean isRoute()Returns whether this is a route access context, i.e. whetherasRouteAccessContext()can be safely called.- Returns:
- whether this is a route access context
-
asRouteAccessContext
Casts this access context to aRouteAccessContextwhich provides more information that is specific to this target type. Check thetypebefore calling this method to see if this is possible.- Returns:
- this access context as a
RouteAccessContext
-
isEndpoint
default boolean isEndpoint()Returns whether this is an endpoint access context, i.e. whetherasEndpointAccessContext()can be safely called.- Returns:
- whether this is an endpoint access context
-
asEndpointAccessContext
Casts this access context to aEndpointAccessContextwhich provides more information that is specific to this target type. Check thetypebefore calling this method to see if this is possible.- Returns:
- this access context as a
EndpointAccessContext
-