public void addGrants( String ownerId, List<GrantInfo> grantInfos, AccessControlListType accessControlList) { ArrayList<Grant> grants = accessControlList.getGrants(); Grant foundGrant = null; globalRead = globalReadACP = false; globalWrite = globalWriteACP = false; if (grants.size() > 0) { for (Grant grant : grants) { String permission = grant.getPermission(); if (permission.equals("aws-exec-read")) { globalRead = globalReadACP = false; globalWrite = globalWriteACP = false; foundGrant = grant; } else if (permission.equals("public-read")) { globalRead = globalReadACP = true; globalWrite = globalWriteACP = false; foundGrant = grant; } else if (permission.equals("public-read-write")) { globalRead = globalReadACP = true; globalWrite = globalWriteACP = true; foundGrant = grant; } else if (permission.equals("authenticated-read")) { globalRead = globalReadACP = false; globalWrite = globalWriteACP = false; foundGrant = grant; } else if (grant.getGrantee().getGroup() != null) { String groupUri = grant.getGrantee().getGroup().getUri(); if (groupUri.equals(WalrusProperties.ALL_USERS_GROUP)) { if (permission.equals("FULL_CONTROL")) globalRead = globalReadACP = globalWrite = globalWriteACP = true; else if (permission.equals("READ")) globalRead = true; else if (permission.equals("READ_ACP")) globalReadACP = true; else if (permission.equals("WRITE")) globalWrite = true; else if (permission.equals("WRITE_ACP")) globalWriteACP = true; foundGrant = grant; } } } } if (foundGrant != null) { grants.remove(foundGrant); } GrantInfo.addGrants(ownerId, grantInfos, accessControlList); }
public void addGrants(List<Grant> newGrants) { for (Grant grant : newGrants) { boolean found = false; for (GrantInfo gInfo : grants) { if (grant.getGrantee().getCanonicalUser() != null) { if (grant.getGrantee().getCanonicalUser().equals(gInfo.getUserId())) found = true; } else { if (grant.getGrantee().getGroup().equals(gInfo.getGrantGroup())) found = true; if (WalrusProperties.ALL_USERS_GROUP.equals(gInfo.getGrantGroup())) { readAllUsers(grant.getPermission()); break; } } if (found) { gInfo.setPermission(grant.getPermission()); break; } } if (!found) { GrantInfo grantInfo = new GrantInfo(); if (grant.getGrantee().getCanonicalUser() != null) { grantInfo.setUserId(grant.getGrantee().getCanonicalUser().getDisplayName()); } else { grantInfo.setGrantGroup(grant.getGrantee().getGroup().getUri()); if (WalrusProperties.ALL_USERS_GROUP.equals(grantInfo.getGrantGroup())) { readAllUsers(grant.getPermission()); continue; } } String permission = grant.getPermission(); grantInfo.setPermission(permission); grants.add(grantInfo); } } }