Search in sources :

Example 11 with BucketACL

use of com.emc.storageos.model.object.BucketACL in project coprhd-controller by CoprHD.

the class BucketACLUtility method verifyBucketACL.

public void verifyBucketACL(BucketACLUpdateParams param) {
    BucketACL bucketAcl = null;
    // Add Payload
    bucketAcl = param.getAclToAdd();
    validateBucketACL(bucketAcl, BucketACLOperationType.ADD);
    reportErrors(param, BucketACLOperationType.ADD);
    // Modify Payload
    bucketAcl = param.getAclToModify();
    validateBucketACL(bucketAcl, BucketACLOperationType.MODIFY);
    reportErrors(param, BucketACLOperationType.MODIFY);
    // Delete Payload
    bucketAcl = param.getAclToDelete();
    validateBucketACL(bucketAcl, BucketACLOperationType.DELETE);
    reportErrors(param, BucketACLOperationType.DELETE);
}
Also used : ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL) BucketACL(com.emc.storageos.model.object.BucketACL)

Example 12 with BucketACL

use of com.emc.storageos.model.object.BucketACL in project coprhd-controller by CoprHD.

the class BucketACLUtility method reportDeleteErrors.

private void reportDeleteErrors(BucketACLUpdateParams param) {
    String opName = BucketACLOperationType.DELETE.name();
    // Report Add ACL Errors
    BucketACL bucketACL = param.getAclToDelete();
    if (bucketACL == null || bucketACL.getBucketACL().isEmpty()) {
        return;
    }
    List<BucketACE> bucketACELits = bucketACL.getBucketACL();
    for (BucketACE bucketACE : bucketACELits) {
        if (!bucketACE.canProceedToNextStep()) {
            BucketACLOperationErrorType error = bucketACE.getErrorType();
            switch(error) {
                case USER_AND_GROUP_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), bucketACE.getGroup(), bucketACE.getCustomGroup());
                    }
                case USER_AND_GROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), bucketACE.getGroup(), null);
                    }
                case USER_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), null, bucketACE.getCustomGroup());
                    }
                case GROUP_AND_CUSTOMGROUP_PROVIDED:
                    {
                        throw APIException.badRequests.userGroupAndCustomGroupInACLFound(null, bucketACE.getGroup(), bucketACE.getCustomGroup());
                    }
                case USER_OR_GROUP_OR_CUSTOMGROUP_NOT_PROVIDED:
                    {
                        throw APIException.badRequests.missingUserOrGroupOrCustomGroupInACE(opName);
                    }
                case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP_CUSTOMGROUP:
                    {
                        String userOrGroupOrCustomgroup = bucketACE.getUser();
                        if (userOrGroupOrCustomgroup == null) {
                            userOrGroupOrCustomgroup = bucketACE.getGroup() != null ? bucketACE.getGroup() : bucketACE.getCustomGroup();
                        }
                        throw APIException.badRequests.multipleACLsWithUserOrGroupOrCustomGroupFound(opName, userOrGroupOrCustomgroup);
                    }
                case MULTIPLE_DOMAINS_FOUND:
                    {
                        String domain1 = bucketACE.getDomain();
                        String userOrGroupOrCustomgroup = bucketACE.getUser();
                        if (userOrGroupOrCustomgroup == null) {
                            userOrGroupOrCustomgroup = bucketACE.getGroup() != null ? bucketACE.getGroup() : bucketACE.getCustomGroup();
                        }
                        String domain2 = userOrGroupOrCustomgroup.substring(0, userOrGroupOrCustomgroup.indexOf("\\"));
                        throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
                    }
                case ACL_NOT_FOUND:
                    {
                        throw APIException.badRequests.bucketACLNotFound(opName, bucketACE.toString());
                    }
                default:
                    break;
            }
        }
    }
}
Also used : BucketACLOperationErrorType(com.emc.storageos.model.object.BucketACLUpdateParams.BucketACLOperationErrorType) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL) BucketACL(com.emc.storageos.model.object.BucketACL) BucketACE(com.emc.storageos.model.object.BucketACE)

Example 13 with BucketACL

use of com.emc.storageos.model.object.BucketACL in project coprhd-controller by CoprHD.

the class BucketService method getBucketACL.

/**
 * Gets the ACL settings for bucket
 *
 * @param id
 * @brief Get ACLs for a bucket
 * @return BucketACL
 * @throws InternalException
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BucketACL getBucketACL(@PathParam("id") URI id) throws InternalException {
    _log.info("Request recieved to get Bucket ACL with Id: {}", id);
    // Validate the Bucket
    Bucket bucket = null;
    ArgValidator.checkFieldUriType(id, Bucket.class, "id");
    bucket = _dbClient.queryObject(Bucket.class, id);
    ArgValidator.checkEntity(bucket, id, isIdEmbeddedInURL(id));
    if (bucket.getVersion() == null) {
        syncBucketACL(bucket);
    }
    BucketACL bucketAcl = new BucketACL();
    BucketACLUtility bucketACLUtil = new BucketACLUtility(_dbClient, bucket.getName(), bucket.getId());
    List<BucketACE> bucketAces = bucketACLUtil.queryExistingBucketACL();
    _log.info("Number of existing ACLs found : {} ", bucketAces.size());
    if (!bucketAces.isEmpty()) {
        bucketAcl.setBucketACL(bucketAces);
    }
    return bucketAcl;
}
Also used : BucketACL(com.emc.storageos.model.object.BucketACL) BucketACLUtility(com.emc.storageos.api.service.impl.resource.utils.BucketACLUtility) Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket) BucketACE(com.emc.storageos.model.object.BucketACE) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

BucketACL (com.emc.storageos.model.object.BucketACL)13 BucketACE (com.emc.storageos.model.object.BucketACE)10 ObjectBucketACL (com.emc.storageos.db.client.model.ObjectBucketACL)7 ObjectBucketACLUpdateParams (com.emc.storageos.model.object.ObjectBucketACLUpdateParams)4 ECSBucketACL (com.emc.storageos.ecs.api.ECSBucketACL)3 BucketACLUpdateParams (com.emc.storageos.model.object.BucketACLUpdateParams)3 BucketACLOperationErrorType (com.emc.storageos.model.object.BucketACLUpdateParams.BucketACLOperationErrorType)3 ECSApi (com.emc.storageos.ecs.api.ECSApi)2 ECSException (com.emc.storageos.ecs.api.ECSException)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 FlashException (controllers.util.FlashException)2 MapBucket (com.emc.storageos.api.mapper.functions.MapBucket)1 BucketACLUtility (com.emc.storageos.api.service.impl.resource.utils.BucketACLUtility)1 Bucket (com.emc.storageos.db.client.model.Bucket)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 Gson (com.google.gson.Gson)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1