public abstract class PrivilegeResourceProvider<T> extends AbstractAuthorizedResourceProvider
AbstractResourceProvider.Command<T>
Modifier and Type | Field and Description |
---|---|
static String |
PERMISSION_LABEL |
static String |
PERMISSION_LABEL_PROPERTY_ID |
static String |
PERMISSION_NAME |
static String |
PERMISSION_NAME_PROPERTY_ID |
protected static PermissionDAO |
permissionDAO
Data access object used to obtain permission entities.
|
static String |
PRINCIPAL_NAME |
static String |
PRINCIPAL_NAME_PROPERTY_ID |
static String |
PRINCIPAL_TYPE |
static String |
PRINCIPAL_TYPE_PROPERTY_ID |
static String |
PRIVILEGE_ID |
static String |
PRIVILEGE_ID_PROPERTY_ID |
static String |
PRIVILEGE_INFO |
static String |
TYPE_PROPERTY_ID |
static String |
VERSION_PROPERTY_ID |
keyPropertyIds, LOG, PROPERTIES_ATTRIBUTES_REGEX
Constructor and Description |
---|
PrivilegeResourceProvider(Set<String> propertyIds,
Map<Resource.Type,String> keyPropertyIds,
Resource.Type resourceType)
Construct a privilege resource provider.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkResourceTypes(PrivilegeEntity entity)
Check to see if the given privilege entity's permission is allowable for the
resource type.
|
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 |
deleteResourcesAuthorized(Request request,
Predicate predicate)
Delete the resources selected by the given predicate if the authenticated user is authorized
to do so.
|
protected PermissionEntity |
getPermission(String permissionName,
ResourceEntity resourceEntity) |
protected Set<String> |
getPKPropertyIds()
Get the set of property ids that uniquely identify the resources
of this provider.
|
abstract Map<Long,T> |
getResourceEntities(Map<String,Object> properties)
Get the entities for the owning resources from the given properties.
|
abstract Long |
getResourceEntityId(Predicate predicate)
Get the id for the resource specified by predicate.
|
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. |
static void |
init(PrivilegeDAO privDAO,
UserDAO usrDAO,
GroupDAO grpDAO,
PrincipalDAO prinDAO,
PermissionDAO permDAO,
ResourceDAO resDAO)
Static initialization.
|
protected PrivilegeEntity |
toEntity(Map<String,Object> properties,
Long resourceId)
Convert the given map of properties to a privilege entity for the resource
identified by the given id.
|
protected Resource |
toResource(PrivilegeEntity privilegeEntity,
Map<Long,UserEntity> userEntities,
Map<Long,GroupEntity> groupEntities,
Map<Long,PermissionEntity> roleEntities,
Map<Long,T> resourceEntities,
Set<String> requestedIds)
Convert the given privilege entity into a Resource.
|
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.
|
createResources, deleteResources, getRequiredCreateAuthorizations, getRequiredDeleteAuthorizations, getRequiredGetAuthorizations, getRequiredUpdateAuthorizations, getResourceId, getResources, getResourceType, isAuthorizedToCreateResources, isAuthorizedToDeleteResources, isAuthorizedToGetResources, isAuthorizedToUpdateResources, setRequiredCreateAuthorizations, setRequiredDeleteAuthorizations, setRequiredGetAuthorizations, setRequiredUpdateAuthorizations, updateResources
addObserver, createResources, getConfigurationRequests, getKeyPropertyIds, 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
protected static PermissionDAO permissionDAO
public static final String PRIVILEGE_INFO
public static final String PRIVILEGE_ID_PROPERTY_ID
public static final String PERMISSION_NAME_PROPERTY_ID
public static final String PERMISSION_LABEL_PROPERTY_ID
public static final String PRINCIPAL_NAME_PROPERTY_ID
public static final String PRINCIPAL_TYPE_PROPERTY_ID
public static final String VERSION_PROPERTY_ID
public static final String TYPE_PROPERTY_ID
public static final String PRIVILEGE_ID
public static final String PERMISSION_NAME
public static final String PERMISSION_LABEL
public static final String PRINCIPAL_NAME
public static final String PRINCIPAL_TYPE
public PrivilegeResourceProvider(Set<String> propertyIds, Map<Resource.Type,String> keyPropertyIds, Resource.Type resourceType)
public static void init(PrivilegeDAO privDAO, UserDAO usrDAO, GroupDAO grpDAO, PrincipalDAO prinDAO, PermissionDAO permDAO, ResourceDAO resDAO)
privDAO
- the privilege data access objectusrDAO
- the user data access objectgrpDAO
- the group data access objectprinDAO
- the principal data access objectpermDAO
- the permission data access objectresDAO
- the resource data access objectpublic abstract Map<Long,T> getResourceEntities(Map<String,Object> properties) throws org.apache.ambari.server.AmbariException
properties
- the set of propertiesorg.apache.ambari.server.AmbariException
- if resource entities were not foundpublic abstract Long getResourceEntityId(Predicate predicate)
predicate
- predicatepublic RequestStatus createResourcesAuthorized(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException
AbstractAuthorizedResourceProvider
AbstractAuthorizedResourceProvider.createResources(Request)
is not overwritten.createResourcesAuthorized
in class AbstractAuthorizedResourceProvider
request
- the request object which defines the set of properties for the resources to be createdSystemException
- an internal system exception occurredAuthorizationException
- if the authenticated user is not authorized to perform this operationUnsupportedPropertyException
- the request contains unsupported property idsResourceAlreadyExistsException
- attempted to create a resource which already existsNoSuchParentResourceException
- a parent resource of the resource to create doesn't existAbstractAuthorizedResourceProvider.createResources(Request)
public Set<Resource> getResourcesAuthorized(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
AbstractAuthorizedResourceProvider
resources
based on the given request and predicate
information if the authenticated user is authorized to do so.
This method must be overwritten if AbstractAuthorizedResourceProvider.getResources(Request, Predicate)
is not overwritten.getResourcesAuthorized
in class AbstractAuthorizedResourceProvider
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 occurredAuthorizationException
- if the authenticated user is not authorized to perform this operationUnsupportedPropertyException
- the request contains unsupported property idsNoSuchResourceException
- the requested resource instance doesn't existNoSuchParentResourceException
- a parent resource of the requested resource doesn't existAbstractAuthorizedResourceProvider.getResources(Request, Predicate)
public RequestStatus updateResourcesAuthorized(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
AbstractAuthorizedResourceProvider
AbstractAuthorizedResourceProvider.updateResources(Request, Predicate)
is not overwritten.updateResourcesAuthorized
in class AbstractAuthorizedResourceProvider
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 occurredAuthorizationException
- if the authenticated user is not authorized to perform this operationUnsupportedPropertyException
- the request contains unsupported property idsNoSuchResourceException
- the resource instance to be updated doesn't existNoSuchParentResourceException
- a parent resource of the resource doesn't existAbstractAuthorizedResourceProvider.updateResources(Request, Predicate)
public RequestStatus deleteResourcesAuthorized(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
AbstractAuthorizedResourceProvider
ResourceProvider.deleteResources(Request, Predicate)
is not overwritten.deleteResourcesAuthorized
in class AbstractAuthorizedResourceProvider
predicate
- the predicate object which can be used to filter which resources are deletedSystemException
- an internal system exception occurredAuthorizationException
- if the authenticated user is not authorized to perform this operationUnsupportedPropertyException
- the request contains unsupported property idsNoSuchResourceException
- the resource instance to be deleted doesn't existNoSuchParentResourceException
- a parent resource of the resource doesn't existResourceProvider.deleteResources(Request, Predicate)
protected Set<String> getPKPropertyIds()
AbstractResourceProvider
getPKPropertyIds
in class AbstractResourceProvider
protected boolean checkResourceTypes(PrivilegeEntity entity) throws org.apache.ambari.server.AmbariException
entity
- the privilege entityorg.apache.ambari.server.AmbariException
- if the the privilege permission is not allowable for the resource typeprotected Resource toResource(PrivilegeEntity privilegeEntity, Map<Long,UserEntity> userEntities, Map<Long,GroupEntity> groupEntities, Map<Long,PermissionEntity> roleEntities, Map<Long,T> resourceEntities, Set<String> requestedIds)
privilegeEntity
- the privilege entity to be converteduserEntities
- the map of user entities keyed by resource idgroupEntities
- the map of group entities keyed by resource idroleEntities
- the map of role entities keyed by resource idresourceEntities
- the map of resource entities keyed by resource idrequestedIds
- the requested property idsprotected PrivilegeEntity toEntity(Map<String,Object> properties, Long resourceId) throws org.apache.ambari.server.AmbariException
properties
- the property mapresourceId
- the resource idorg.apache.ambari.server.AmbariException
protected PermissionEntity getPermission(String permissionName, ResourceEntity resourceEntity) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
Copyright © 2022 Apache Software Foundation. All rights reserved.