List of usage examples for com.amazonaws.services.s3.model Permission ReadAcp
Permission ReadAcp
To view the source code for com.amazonaws.services.s3.model Permission ReadAcp.
Click Source Link
From source file:org.apache.nifi.processors.aws.s3.AbstractS3Processor.java
License:Apache License
/** * Create AccessControlList if appropriate properties are configured. * * @param context ProcessContext//w ww . j av a 2s . c o m * @param flowFile FlowFile * @return AccessControlList or null if no ACL properties were specified */ protected final AccessControlList createACL(final ProcessContext context, final FlowFile flowFile) { // lazy-initialize ACL, as it should not be used if no properties were specified AccessControlList acl = null; final String ownerId = context.getProperty(OWNER).evaluateAttributeExpressions(flowFile).getValue(); if (!StringUtils.isEmpty(ownerId)) { final Owner owner = new Owner(); owner.setId(ownerId); if (acl == null) { acl = new AccessControlList(); } acl.setOwner(owner); } for (final Grantee grantee : createGrantees( context.getProperty(FULL_CONTROL_USER_LIST).evaluateAttributeExpressions(flowFile).getValue())) { if (acl == null) { acl = new AccessControlList(); } acl.grantPermission(grantee, Permission.FullControl); } for (final Grantee grantee : createGrantees( context.getProperty(READ_USER_LIST).evaluateAttributeExpressions(flowFile).getValue())) { if (acl == null) { acl = new AccessControlList(); } acl.grantPermission(grantee, Permission.Read); } for (final Grantee grantee : createGrantees( context.getProperty(WRITE_USER_LIST).evaluateAttributeExpressions(flowFile).getValue())) { if (acl == null) { acl = new AccessControlList(); } acl.grantPermission(grantee, Permission.Write); } for (final Grantee grantee : createGrantees( context.getProperty(READ_ACL_LIST).evaluateAttributeExpressions(flowFile).getValue())) { if (acl == null) { acl = new AccessControlList(); } acl.grantPermission(grantee, Permission.ReadAcp); } for (final Grantee grantee : createGrantees( context.getProperty(WRITE_ACL_LIST).evaluateAttributeExpressions(flowFile).getValue())) { if (acl == null) { acl = new AccessControlList(); } acl.grantPermission(grantee, Permission.WriteAcp); } return acl; }
From source file:org.springframework.integration.aws.s3.core.AmazonS3OperationsImpl.java
License:Apache License
/** * Gets the {@link AccessControlList} from the given {@link AmazonS3ObjectACL} * @param acl/*from ww w.j av a2 s . c om*/ * @return */ private AccessControlList getAccessControlList(String bucketName, String key, AmazonS3ObjectACL acl) { AccessControlList accessControlList = null; if (acl != null) { if (!acl.getGrants().isEmpty()) { accessControlList = client.getObjectAcl(bucketName, key); for (ObjectGrant objGrant : acl.getGrants()) { Grantee grantee = objGrant.getGrantee(); com.amazonaws.services.s3.model.Grantee awsGrantee; if (grantee.getGranteeType() == GranteeType.CANONICAL_GRANTEE_TYPE) { awsGrantee = new CanonicalGrantee(grantee.getIdentifier()); } else if (grantee.getGranteeType() == GranteeType.EMAIL_GRANTEE_TYPE) { awsGrantee = new EmailAddressGrantee(grantee.getIdentifier()); } else { awsGrantee = GroupGrantee.parseGroupGrantee(grantee.getIdentifier()); if (awsGrantee == null) { logger.warn("Group grantee with identifier: \"" + grantee.getIdentifier() + "\" not found. skipping this grant"); continue; } } ObjectPermissions perm = objGrant.getPermission(); Permission permission; if (perm == ObjectPermissions.READ) { permission = Permission.Read; } else if (perm == ObjectPermissions.READ_ACP) { permission = Permission.ReadAcp; } else permission = Permission.WriteAcp; accessControlList.grantPermission(awsGrantee, permission); } } } return accessControlList; }