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.
|
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.
|
public static com.google.common.base.Function<String,ResourceAction> DATASOURCE_READ_RA_GENERATOR
public static com.google.common.base.Function<String,ResourceAction> DATASOURCE_WRITE_RA_GENERATOR
public 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 mapperCopyright © 2011–2018. All rights reserved.