public abstract class AbstractAuthorizedResourceProvider extends AbstractResourceProvider
*ResourcesAuthorized
methods and set the required*Authorizations
properties. For more sophisticated authorization checks, the isAuthorizedTo*Resources
methods may be overwritten.
Additionally, the AuthorizationHelper.isAuthorized(ResourceType, Long, Set)
or
AuthorizationHelper.verifyAuthorization(ResourceType, Long, Set)
methods may be called
within the logic of the resource provider implementation to provide checks on particular resources.AuthorizationHelper
AbstractResourceProvider.Command<T>
keyPropertyIds, LOG, PROPERTIES_ATTRIBUTES_REGEX
Modifier and Type | Method and Description |
---|---|
RequestStatus |
createResources(Request request)
Create the resources defined by the properties in the given request object.
|
protected RequestStatus |
createResourcesAuthorized(Request request)
Create the resources defined by the properties in the given request object if authorization was
granted to the authenticated user.
|
RequestStatus |
deleteResources(Request request,
Predicate predicate)
Delete the resources selected by the given predicate.
|
protected RequestStatus |
deleteResourcesAuthorized(Request request,
Predicate predicate)
Delete the resources selected by the given predicate if the authenticated user is authorized
to do so.
|
Set<RoleAuthorization> |
getRequiredCreateAuthorizations()
Gets the authorizations for which one is needed to the grant access to create resources
or a particular resource.
|
Set<RoleAuthorization> |
getRequiredDeleteAuthorizations()
Gets the authorizations for which one is needed to the grant access to delete resources
or a particular resource.
|
Set<RoleAuthorization> |
getRequiredGetAuthorizations()
Gets the authorizations for which one is needed to the grant access to get resources
or a particular resource.
|
Set<RoleAuthorization> |
getRequiredUpdateAuthorizations()
Gets the authorizations for which one is needed to the grant access to update resources
or a particular resource.
|
protected Long |
getResourceId(Request request,
Predicate predicate)
Gets the identifier, relative to the the effected ResourceType that is effected by the relevant
request and predicate.
|
Set<Resource> |
getResources(Request request,
Predicate predicate)
Get a set of
resources based on the given request and predicate
information. |
protected Set<Resource> |
getResourcesAuthorized(Request request,
Predicate predicate)
Get a set of
resources based on the given request and predicate
information if the authenticated user is authorized to do so. |
protected ResourceType |
getResourceType(Request request,
Predicate predicate)
Gets the ResourceType that is effected by the relevant request and predicate.
|
protected boolean |
isAuthorizedToCreateResources(org.springframework.security.core.Authentication authentication,
Request request)
Tests authorization to create resources.
|
protected boolean |
isAuthorizedToDeleteResources(org.springframework.security.core.Authentication authentication,
Predicate predicate)
Tests authorization to delete resources.
|
protected boolean |
isAuthorizedToGetResources(org.springframework.security.core.Authentication authentication,
Request request,
Predicate predicate)
Tests authorization to get resources.
|
protected boolean |
isAuthorizedToUpdateResources(org.springframework.security.core.Authentication authentication,
Request request,
Predicate predicate)
Tests authorization to update resources
Implementations should override this method to perform a more sophisticated authorization routine.
|
void |
setRequiredCreateAuthorizations(Set<RoleAuthorization> requiredCreateAuthorizations)
Sets the authorizations for which one is needed to the grant access to create resources
or a particular resource.
|
void |
setRequiredDeleteAuthorizations(Set<RoleAuthorization> requiredDeleteAuthorizations)
Sets the authorizations for which one is needed to the grant access to delete resources
or a particular resource.
|
void |
setRequiredGetAuthorizations(Set<RoleAuthorization> requiredGetAuthorizations)
Sets the authorizations for which one is needed to the grant access to get resources
or a particular resource.
|
void |
setRequiredUpdateAuthorizations(Set<RoleAuthorization> requiredUpdateAuthorizations)
Sets the authorizations for which one is needed to the grant access to update resources
or a particular resource.
|
RequestStatus |
updateResources(Request request,
Predicate predicate)
Update the resources selected by the given predicate with the properties
from the given request object.
|
protected RequestStatus |
updateResourcesAuthorized(Request request,
Predicate predicate)
Update the resources selected by the given predicate with the properties from the given request
object if the authenticated user is authorized to do so.
|
addObserver, createResources, getConfigurationRequests, getKeyPropertyIds, getPKPropertyIds, getPropertyMaps, getPropertyMaps, getQueryParameterValue, getRequestStatus, getRequestStatus, getRequestStatus, getResources, modifyResources, notifyCreate, notifyDelete, notifyUpdate, parseProperties, updateObservers
checkCategory, checkConfigPropertyIds, checkPropertyIds, containsArguments, getCategoryIds, getPropertyIds, getRegexEntry, getRegexGroups, getRequestPropertyIds, isPatternKey, isPropertyCategoryRequested, isPropertyEntryRequested, isPropertyRequested, setResourceProperty
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkPropertyIds
public Set<RoleAuthorization> getRequiredCreateAuthorizations()
public void setRequiredCreateAuthorizations(Set<RoleAuthorization> requiredCreateAuthorizations)
requiredCreateAuthorizations
- a set of authorizationspublic Set<RoleAuthorization> getRequiredGetAuthorizations()
public void setRequiredGetAuthorizations(Set<RoleAuthorization> requiredGetAuthorizations)
requiredGetAuthorizations
- a set of authorizationspublic Set<RoleAuthorization> getRequiredUpdateAuthorizations()
public void setRequiredUpdateAuthorizations(Set<RoleAuthorization> requiredUpdateAuthorizations)
requiredUpdateAuthorizations
- a set of authorizationspublic Set<RoleAuthorization> getRequiredDeleteAuthorizations()
public void setRequiredDeleteAuthorizations(Set<RoleAuthorization> requiredDeleteAuthorizations)
requiredDeleteAuthorizations
- a set of authorizationspublic RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException
request
- the request object which defines the set of properties
for the resources to be createdSystemException
- an internal system exception occurredUnsupportedPropertyException
- the request contains unsupported property idsResourceAlreadyExistsException
- attempted to create a resource which already existsNoSuchParentResourceException
- a parent resource of the resource to create doesn't existAuthorizationException
- if the authenticated user is not authorized to perform this operationpublic Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
resources
based on the given request and predicate
information.
Note that it is not required for this resource provider to completely filter
the set of resources based on the given predicate. It may not be possible
since some of the properties involved may be provided by another
provider
. This partial filtering is allowed because
the predicate will always be applied by the calling cluster controller. The
predicate is made available at this level so that some pre-filtering can be done
as an optimization.
A simple implementation of a resource provider may choose to just return all of
the resources of a given type and allow the calling cluster controller to filter
based on the predicate.
This implementation attempts to authorize the authenticated user before performing the requested
operation. If authorization fails, an AuthorizationException will be thrown.
This method may be overwritten by implementing classes to avoid performing authorization checks
to get resources.request
- the request object which defines the desired set of propertiespredicate
- the predicate object which can be used to filter which
resources are returnedSystemException
- an internal system exception occurredUnsupportedPropertyException
- the request contains unsupported property idsNoSuchResourceException
- the requested resource instance doesn't existNoSuchParentResourceException
- a parent resource of the requested resource doesn't existAuthorizationException
- if the authenticated user is not authorized to perform this operationpublic RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
request
- the request object which defines the set of properties
for the resources to be updatedpredicate
- the predicate object which can be used to filter which
resources are updatedSystemException
- an internal system exception occurredUnsupportedPropertyException
- the request contains unsupported property idsNoSuchResourceException
- the resource instance to be updated doesn't existNoSuchParentResourceException
- a parent resource of the resource doesn't existAuthorizationException
- if the authenticated user is not authorized to perform this operationpublic RequestStatus deleteResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
request
- predicate
- the predicate object which can be used to filter which
resources are deletedSystemException
- an internal system exception occurredUnsupportedPropertyException
- the request contains unsupported property idsNoSuchResourceException
- the resource instance to be deleted doesn't existNoSuchParentResourceException
- a parent resource of the resource doesn't existAuthorizationException
- if the authenticated user is not authorized to perform this operationprotected RequestStatus createResourcesAuthorized(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException
createResources(Request)
is not overwritten.request
- the request object which defines the set of properties for the resources to be createdSystemException
- an internal system exception occurredUnsupportedPropertyException
- the request contains unsupported property idsResourceAlreadyExistsException
- attempted to create a resource which already existsNoSuchParentResourceException
- a parent resource of the resource to create doesn't existAuthorizationException
- if the authenticated user is not authorized to perform this operationcreateResources(Request)
protected boolean isAuthorizedToCreateResources(org.springframework.security.core.Authentication authentication, Request request) throws SystemException
authentication
- the authenticated user and associated access privilegesrequest
- the request object which defines the set of properties for the resources to be createdSystemException
- if an internal system exception occurredprotected Set<Resource> getResourcesAuthorized(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
resources
based on the given request and predicate
information if the authenticated user is authorized to do so.
This method must be overwritten if getResources(Request, Predicate)
is not overwritten.request
- the request object which defines the desired set of propertiespredicate
- the predicate object which can be used to filter which resources are returnedSystemException
- an internal system exception occurredUnsupportedPropertyException
- the request contains unsupported property idsNoSuchResourceException
- the requested resource instance doesn't existNoSuchParentResourceException
- a parent resource of the requested resource doesn't existAuthorizationException
- if the authenticated user is not authorized to perform this operationgetResources(Request, Predicate)
protected boolean isAuthorizedToGetResources(org.springframework.security.core.Authentication authentication, Request request, Predicate predicate) throws SystemException
authentication
- the authenticated user and associated access privilegesrequest
- the request object which defines the desired set of propertiespredicate
- the predicate object which can be used to filter which resources are returnedSystemException
- if an internal system exception occurredprotected RequestStatus updateResourcesAuthorized(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
updateResources(Request, Predicate)
is not overwritten.request
- the request object which defines the set of properties for the resources to be updatedpredicate
- the predicate object which can be used to filter which resources are updatedSystemException
- an internal system exception occurredUnsupportedPropertyException
- the request contains unsupported property idsNoSuchResourceException
- the resource instance to be updated doesn't existNoSuchParentResourceException
- a parent resource of the resource doesn't existAuthorizationException
- if the authenticated user is not authorized to perform this operationupdateResources(Request, Predicate)
protected boolean isAuthorizedToUpdateResources(org.springframework.security.core.Authentication authentication, Request request, Predicate predicate) throws SystemException
authentication
- the authenticated user and associated access privilegesrequest
- the request object which defines the desired set of propertiespredicate
- the predicate object which can be used to filter which resources are returnedSystemException
- if an internal system exception occurredprotected RequestStatus deleteResourcesAuthorized(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
ResourceProvider.deleteResources(Request, Predicate)
is not overwritten.request
- predicate
- the predicate object which can be used to filter which resources are deletedSystemException
- an internal system exception occurredUnsupportedPropertyException
- the request contains unsupported property idsNoSuchResourceException
- the resource instance to be deleted doesn't existNoSuchParentResourceException
- a parent resource of the resource doesn't existAuthorizationException
- if the authenticated user is not authorized to perform this operationResourceProvider.deleteResources(Request, Predicate)
protected boolean isAuthorizedToDeleteResources(org.springframework.security.core.Authentication authentication, Predicate predicate) throws SystemException
authentication
- the authenticated user and associated access privilegespredicate
- the predicate object which can be used to filter which resources are deletedSystemException
- if an internal system exception occurredprotected ResourceType getResourceType(Request request, Predicate predicate)
request
- the request object which defines the desired set of propertiespredicate
- the predicate object which can be used to indicate the filterprotected Long getResourceId(Request request, Predicate predicate)
request
- the request object which defines the desired set of propertiespredicate
- the predicate object which can be used to indicate the filterCopyright © 2022 Apache Software Foundation. All rights reserved.