Search in sources :

Example 6 with AuthorizationResourceAction

use of com.sequenceiq.authorization.resource.AuthorizationResourceAction in project cloudbreak by hortonworks.

the class ResourceNameAuthorizationFactory method doGetAuthorization.

@Override
public Optional<AuthorizationRule> doGetAuthorization(CheckPermissionByResourceName methodAnnotation, String userCrn, ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature) {
    AuthorizationResourceAction action = methodAnnotation.action();
    String resourceName = commonPermissionCheckingUtils.getParameter(proceedingJoinPoint, methodSignature, ResourceName.class, String.class);
    LOGGER.debug("Getting authorization rule to authorize user [{}] for action [{}] over resource [{}]", userCrn, action, resourceName);
    return calcAuthorization(resourceName, action);
}
Also used : AuthorizationResourceAction(com.sequenceiq.authorization.resource.AuthorizationResourceAction)

Example 7 with AuthorizationResourceAction

use of com.sequenceiq.authorization.resource.AuthorizationResourceAction in project cloudbreak by hortonworks.

the class AccountAuthorizationService method authorize.

public void authorize(CheckPermissionByAccount methodAnnotation, String userCrn) {
    AuthorizationResourceAction action = methodAnnotation.action();
    LOGGER.debug("Authorize {} action for user {} on account level.", action, userCrn);
    commonPermissionCheckingUtils.checkPermissionForUser(action, userCrn);
}
Also used : AuthorizationResourceAction(com.sequenceiq.authorization.resource.AuthorizationResourceAction)

Example 8 with AuthorizationResourceAction

use of com.sequenceiq.authorization.resource.AuthorizationResourceAction in project cloudbreak by hortonworks.

the class ResourceCrnAthorizationFactory method doGetAuthorization.

@Override
public Optional<AuthorizationRule> doGetAuthorization(CheckPermissionByResourceCrn methodAnnotation, String userCrn, ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature) {
    String resourceCrn = commonPermissionCheckingUtils.getParameter(proceedingJoinPoint, methodSignature, ResourceCrn.class, String.class);
    crnAccountValidator.validateSameAccount(userCrn, resourceCrn);
    AuthorizationResourceAction action = methodAnnotation.action();
    LOGGER.debug("Getting authorization rule to authorize user [{}] for action [{}] over resource [{}]", userCrn, action, resourceCrn);
    return calcAuthorization(resourceCrn, action);
}
Also used : AuthorizationResourceAction(com.sequenceiq.authorization.resource.AuthorizationResourceAction)

Example 9 with AuthorizationResourceAction

use of com.sequenceiq.authorization.resource.AuthorizationResourceAction in project cloudbreak by hortonworks.

the class ResourceNameListAuthorizationFactory method doGetAuthorization.

@Override
public Optional<AuthorizationRule> doGetAuthorization(CheckPermissionByResourceNameList methodAnnotation, String userCrn, ProceedingJoinPoint proceedingJoinPoint, MethodSignature methodSignature) {
    AuthorizationResourceAction action = methodAnnotation.action();
    Collection<String> resourceNames = commonPermissionCheckingUtils.getParameter(proceedingJoinPoint, methodSignature, ResourceNameList.class, Collection.class);
    LOGGER.debug("Getting authorization rule to authorize user [{}] for action [{}] over resources [{}]", userCrn, action, Joiner.on(",").join(resourceNames));
    return calcAuthorization(resourceNames, action);
}
Also used : AuthorizationResourceAction(com.sequenceiq.authorization.resource.AuthorizationResourceAction)

Aggregations

AuthorizationResourceAction (com.sequenceiq.authorization.resource.AuthorizationResourceAction)9 AuthorizationResourceType (com.sequenceiq.authorization.resource.AuthorizationResourceType)2 AuthorizationVariableType (com.sequenceiq.authorization.resource.AuthorizationVariableType)2 Lists (com.google.api.client.util.Lists)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Sets (com.google.common.collect.Sets)1 EnforceAuthorizationTestUtil.validateMethodByFunction (com.sequenceiq.authorization.EnforceAuthorizationTestUtil.validateMethodByFunction)1 CheckPermissionByCompositeRequestProperty (com.sequenceiq.authorization.annotation.CheckPermissionByCompositeRequestProperty)1 CheckPermissionByRequestProperty (com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty)1 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CheckPermissionByResourceCrnList (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrnList)1 CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)1 CheckPermissionByResourceNameList (com.sequenceiq.authorization.annotation.CheckPermissionByResourceNameList)1 RequestObject (com.sequenceiq.authorization.annotation.RequestObject)1 CRN (com.sequenceiq.authorization.resource.AuthorizationVariableType.CRN)1 CRN_LIST (com.sequenceiq.authorization.resource.AuthorizationVariableType.CRN_LIST)1 NAME (com.sequenceiq.authorization.resource.AuthorizationVariableType.NAME)1 NAME_LIST (com.sequenceiq.authorization.resource.AuthorizationVariableType.NAME_LIST)1 AuthorizationEnvironmentCrnListProvider (com.sequenceiq.authorization.service.AuthorizationEnvironmentCrnListProvider)1 AuthorizationEnvironmentCrnProvider (com.sequenceiq.authorization.service.AuthorizationEnvironmentCrnProvider)1