public class AuthorizationUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static com.google.common.base.Function<String,ResourceAction> |
DATASOURCE_READ_RA_GENERATOR
Function for the common pattern of generating a resource-action for reading from a datasource, using the
datasource name.
|
static com.google.common.base.Function<String,ResourceAction> |
DATASOURCE_WRITE_RA_GENERATOR
Function for the common pattern of generating a resource-action for reading from a datasource, using the
datasource name.
|
static com.google.common.base.Function<Resource,ResourceAction> |
RESOURCE_READ_RA_GENERATOR
Function for the pattern of generating a
ResourceAction for reading from a given Resource |
static com.google.common.base.Function<String,ResourceAction> |
VIEW_READ_RA_GENERATOR
Function for the common pattern of generating a resource-action for reading from a view, using the
view name.
|
| Constructor and Description |
|---|
AuthorizationUtils() |
| Modifier and Type | Method and Description |
|---|---|
static AuthenticationResult |
authenticationResultFromRequest(javax.servlet.http.HttpServletRequest request)
Returns the authentication information for a request.
|
static Access |
authorizeAllResourceActions(AuthenticationResult authenticationResult,
Iterable<ResourceAction> resourceActions,
AuthorizerMapper authorizerMapper)
Check a list of resource-actions to be performed by the identity represented by authenticationResult.
|
static Access |
authorizeAllResourceActions(javax.servlet.http.HttpServletRequest request,
Iterable<ResourceAction> resourceActions,
AuthorizerMapper authorizerMapper)
Check a list of resource-actions to be performed as a result of an HTTP request.
|
static Access |
authorizeResourceAction(javax.servlet.http.HttpServletRequest request,
ResourceAction resourceAction,
AuthorizerMapper authorizerMapper)
Check a resource-action using the authorization fields from the request.
|
static <ResType> Iterable<ResType> |
filterAuthorizedResources(AuthenticationResult authenticationResult,
Iterable<ResType> resources,
com.google.common.base.Function<? super ResType,Iterable<ResourceAction>> resourceActionGenerator,
AuthorizerMapper authorizerMapper)
Filter a collection of resources by applying the resourceActionGenerator to each resource, return an iterable
containing the filtered resources.
|
static <ResType> Iterable<ResType> |
filterAuthorizedResources(javax.servlet.http.HttpServletRequest request,
Iterable<ResType> resources,
com.google.common.base.Function<? super ResType,Iterable<ResourceAction>> resourceActionGenerator,
AuthorizerMapper authorizerMapper)
Filter a collection of resources by applying the resourceActionGenerator to each resource, return an iterable
containing the filtered resources.
|
static <KeyType,ResType> |
filterAuthorizedResources(javax.servlet.http.HttpServletRequest request,
Map<KeyType,List<ResType>> unfilteredResources,
com.google.common.base.Function<? super ResType,Iterable<ResourceAction>> resourceActionGenerator,
AuthorizerMapper authorizerMapper)
Given a map of resource lists, filter each resources list by applying the resource action generator to each
item in each resource list.
|
static List<ResourceAction> |
makeSuperUserPermissions()
This method constructs a 'superuser' set of permissions composed of
Action.READ and Action.WRITE
permissions for all known ResourceType.knownTypes() for any Authorizer implementation which is
built on pattern matching with a regex. |
public static final com.google.common.base.Function<String,ResourceAction> DATASOURCE_READ_RA_GENERATOR
public static final com.google.common.base.Function<String,ResourceAction> DATASOURCE_WRITE_RA_GENERATOR
public static final com.google.common.base.Function<String,ResourceAction> VIEW_READ_RA_GENERATOR
public static final com.google.common.base.Function<Resource,ResourceAction> RESOURCE_READ_RA_GENERATOR
ResourceAction for reading from a given Resourcepublic static Access authorizeResourceAction(javax.servlet.http.HttpServletRequest request, ResourceAction resourceAction, AuthorizerMapper authorizerMapper)
request - HTTP request to be authorizedresourceAction - A resource identifier and the action to be taken the resource.authorizerMapper - The singleton AuthorizerMapper instancepublic static AuthenticationResult authenticationResultFromRequest(javax.servlet.http.HttpServletRequest request)
request - http requestIllegalStateException - if the request was not authenticatedpublic static Access authorizeAllResourceActions(AuthenticationResult authenticationResult, Iterable<ResourceAction> resourceActions, AuthorizerMapper authorizerMapper)
authenticationResult - Authentication result representing identity of requesterresourceActions - An Iterable of resource-actions to authorizepublic static Access authorizeAllResourceActions(javax.servlet.http.HttpServletRequest request, Iterable<ResourceAction> resourceActions, AuthorizerMapper authorizerMapper)
request - HTTP request to be authorizedresourceActions - An Iterable of resource-actions to authorizepublic static <ResType> Iterable<ResType> filterAuthorizedResources(javax.servlet.http.HttpServletRequest request, Iterable<ResType> resources, com.google.common.base.Function<? super ResType,Iterable<ResourceAction>> resourceActionGenerator, AuthorizerMapper authorizerMapper)
request - HTTP request to be authorizedresources - resources to be processed into resource-actionsresourceActionGenerator - Function that creates an iterable of resource-actions from a resourceauthorizerMapper - authorizer mapperpublic static <ResType> Iterable<ResType> filterAuthorizedResources(AuthenticationResult authenticationResult, Iterable<ResType> resources, com.google.common.base.Function<? super ResType,Iterable<ResourceAction>> resourceActionGenerator, AuthorizerMapper authorizerMapper)
authenticationResult - Authentication result representing identity of requesterresources - resources to be processed into resource-actionsresourceActionGenerator - Function that creates an iterable of resource-actions from a resourceauthorizerMapper - authorizer mapperpublic static <KeyType,ResType> Map<KeyType,List<ResType>> filterAuthorizedResources(javax.servlet.http.HttpServletRequest request, Map<KeyType,List<ResType>> unfilteredResources, com.google.common.base.Function<? super ResType,Iterable<ResourceAction>> resourceActionGenerator, AuthorizerMapper authorizerMapper)
request - HTTP request to be authorizedunfilteredResources - Map of resource lists to be filteredresourceActionGenerator - Function that creates an iterable of resource-actions from a resourceauthorizerMapper - authorizer mapperpublic static List<ResourceAction> makeSuperUserPermissions()
Action.READ and Action.WRITE
permissions for all known ResourceType.knownTypes() for any Authorizer implementation which is
built on pattern matching with a regex.
Note that if any Resource exist that use custom types not registered with
ResourceType.registerResourceType(java.lang.String), those permissions will not be included in this list and will need to
be added manually.Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.