use of com.emc.storageos.model.object.BucketACE in project coprhd-controller by CoprHD.
the class ECSObjectStorageDevice method persistDefaultBucketACEInDb.
private void persistDefaultBucketACEInDb(String bucketOwner, Bucket bucket, ObjectDeviceInputOutput args) {
_log.info("Persisting bucket owner as default ACE", bucketOwner);
BucketACLUpdateParams param = new BucketACLUpdateParams();
BucketACL acl = new BucketACL();
BucketACE defaultAce = new BucketACE();
String full_control = "full_control";
List<BucketACE> aclToAdd = Lists.newArrayList();
String[] userDomain = bucketOwner.split("@");
if (userDomain.length > 1) {
defaultAce.setUser(userDomain[0]);
defaultAce.setDomain(userDomain[1]);
} else {
defaultAce.setUser(bucketOwner);
}
defaultAce.setPermissions(full_control);
aclToAdd.add(defaultAce);
acl.setBucketACL(aclToAdd);
param.setAclToAdd(acl);
updateBucketACLInDB(param, args, bucket);
}
use of com.emc.storageos.model.object.BucketACE in project coprhd-controller by CoprHD.
the class ObjectBuckets method deleteAcl.
/**
* This method called When user selects ACLs and hit delete button.
*
* @param aclURL
* URL of the file system share.
* @param ids
* ids of the selected ACL
*/
@FlashException(value = "buckets")
public static void deleteAcl(String bucketId, @As(",") String[] ids) {
BucketACL aclsToDelete = new BucketACL();
List<BucketACE> bucketAcl = Lists.newArrayList();
if (ids != null && ids.length > 0) {
for (String id : ids) {
String type = BucketACLForm.extractTypeFromId(id);
String name = BucketACLForm.extractNameFromId(id);
String domain = BucketACLForm.extractDomainFromId(id);
BucketACE ace = new BucketACE();
if (GROUP.equalsIgnoreCase(type)) {
ace.setGroup(name);
} else if (CUSTOMGROUP.equalsIgnoreCase(type)) {
ace.setCustomGroup(name);
} else {
ace.setUser(name);
}
if (domain != null && !"".equals(domain) && !"null".equals(domain)) {
ace.setDomain(domain);
}
bucketAcl.add(ace);
}
aclsToDelete.setBucketACL(bucketAcl);
ObjectBucketACLUpdateParams input = new ObjectBucketACLUpdateParams();
input.setAclToDelete(aclsToDelete);
ViPRCoreClient client = BourneUtil.getViprClient();
client.objectBuckets().updateBucketACL(uri(bucketId), input);
}
flash.success(MessagesUtils.get(DELETED));
listBucketACL(bucketId);
}
use of com.emc.storageos.model.object.BucketACE in project coprhd-controller by CoprHD.
the class ObjectBuckets method saveBucketAce.
@FlashException(keep = true, referrer = { "editBucketAce" })
public static void saveBucketAce(BucketACLForm bucketACL) {
String name = params.get("name");
String type = params.get("type");
String domain = params.get("domain");
String bucketId = params.get("bucketId");
Set<String> permissions = bucketACL.permissions;
String strPer = "";
for (String permission : permissions) {
strPer = strPer + permission + "|";
}
if (strPer.length() > 0) {
strPer = strPer.substring(0, strPer.length() - 1);
}
List<BucketACE> acl = Lists.newArrayList();
BucketACE ace = new BucketACE();
BucketACL aclToModify = new BucketACL();
if (GROUP.equalsIgnoreCase(type)) {
ace.setGroup(name);
} else if (CUSTOMGROUP.equalsIgnoreCase(type)) {
ace.setCustomGroup(name);
} else {
ace.setUser(name);
}
ace.setPermissions(strPer);
if (domain != null && !domain.isEmpty()) {
ace.setDomain(domain);
}
acl.add(ace);
aclToModify.setBucketACL(acl);
ObjectBucketACLUpdateParams updateParam = new ObjectBucketACLUpdateParams();
updateParam.setAclToModify(aclToModify);
ViPRCoreClient client = BourneUtil.getViprClient();
client.objectBuckets().updateBucketACL(uri(bucketId), updateParam);
listBucketACL(bucketId);
}
use of com.emc.storageos.model.object.BucketACE in project coprhd-controller by CoprHD.
the class BucketACLUtility method verifyAddBucketACL.
private void verifyAddBucketACL(List<BucketACE> bucketACEList) {
if (bucketACEList == null) {
return;
}
_log.info("Number of bucket ACE(s) to add {} ", bucketACEList.size());
for (BucketACE ace : bucketACEList) {
ace.proceedToNextStep();
_log.info("Verifying ACL {}", ace.toString());
// Are there same user or group found in other acls. If so, report
// error
verifyUserGroupCustomgroup(ace);
if (!ace.canProceedToNextStep()) {
break;
}
validatePermissions(ace);
if (!ace.canProceedToNextStep()) {
break;
}
// Verify with existing ACL
ObjectBucketACL dbBucketAcl = getExistingACL(ace);
// If same acl exists, don't allow to add again.
if (dbBucketAcl != null) {
_log.error("Duplicate ACL in add request. User/group/customgroup in ACL for bucket already exists: {}", dbBucketAcl);
ace.cancelNextStep(BucketACLOperationErrorType.ACL_EXISTS);
break;
} else // If not found proceed for further verifications.
{
if (ace.canProceedToNextStep()) {
_log.info("No existing ACL found in DB {}", ace);
}
}
}
}
use of com.emc.storageos.model.object.BucketACE in project coprhd-controller by CoprHD.
the class BucketACLUtility method reportAddErrors.
private void reportAddErrors(BucketACLUpdateParams param) {
String opName = BucketACLOperationType.ADD.name();
// Report Add ACL Errors
BucketACL bucketAcl = param.getAclToAdd();
if (bucketAcl == null || bucketAcl.getBucketACL().isEmpty()) {
return;
}
List<BucketACE> bucketACEList = bucketAcl.getBucketACL();
for (BucketACE bucketACE : bucketACEList) {
if (!bucketACE.canProceedToNextStep()) {
BucketACLOperationErrorType error = bucketACE.getErrorType();
switch(error) {
case INVALID_PERMISSIONS:
{
if (bucketACE.getPermissions() != null) {
throw APIException.badRequests.invalidPermissionForBucketACL(bucketACE.getPermissions());
} else {
throw APIException.badRequests.missingValueInACE(opName, REQUEST_PARAM_PERMISSIONS);
}
}
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_EXISTS:
{
throw APIException.badRequests.bucketACLAlreadyExists(opName, bucketACE.toString());
}
// case ACL_NOT_FOUND:
default:
break;
}
}
}
}
Aggregations