Example usage for com.amazonaws.services.s3.model Grantee getIdentifier

List of usage examples for com.amazonaws.services.s3.model Grantee getIdentifier

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model Grantee getIdentifier.

Prototype

public String getIdentifier();

Source Link

Document

Gets the identifier for this grantee.

Usage

From source file:alluxio.underfs.s3a.S3AUtils.java

License:Apache License

private static boolean isUserIdInGrantee(Grantee grantee, String userId) {
    return grantee.getIdentifier().equals(userId) || grantee.equals(GroupGrantee.AllUsers)
            || grantee.equals(GroupGrantee.AuthenticatedUsers);
}

From source file:com.emc.ecs.sync.util.AwsS3Util.java

License:Open Source License

public static SyncAcl syncAclFromS3Acl(AccessControlList s3Acl) {
    SyncAcl syncAcl = new SyncAcl();
    syncAcl.setOwner(s3Acl.getOwner().getId());
    for (Grant grant : s3Acl.getGrantsAsList()) {
        Grantee grantee = grant.getGrantee();
        if (grantee instanceof GroupGrantee || grantee.getTypeIdentifier().equals(AwsS3Util.ACL_GROUP_TYPE))
            syncAcl.addGroupGrant(grantee.getIdentifier(), grant.getPermission().toString());
        else if (grantee instanceof CanonicalGrantee
                || grantee.getTypeIdentifier().equals(AwsS3Util.ACL_CANONICAL_USER_TYPE))
            syncAcl.addUserGrant(grantee.getIdentifier(), grant.getPermission().toString());
    }/*from w w  w .ja  va  2s  .  c o m*/
    return syncAcl;
}

From source file:org.apache.manifoldcf.authorities.authorities.amazons3.AmazonS3Authority.java

License:Apache License

private String[] getUsers(Collection<Set<Grant>> collection) {
    Set<String> users = new HashSet<String>();// no duplicates
    for (Collection c : collection) {
        Set<Grant> c1 = (Set<Grant>) c;
        for (Grant grant : c1) {
            if (grant != null && grant.getGrantee() != null) {
                Grantee grantee = grant.getGrantee();

                if (grantee instanceof CanonicalGrantee) {
                    users.add(((CanonicalGrantee) grantee).getDisplayName());
                } else {
                    users.add(grantee.getIdentifier());
                }//from  w  w w  .j  av  a  2 s  .  co  m
            }
        }
    }

    return users.toArray(new String[users.size()]);
}

From source file:org.apache.manifoldcf.crawler.connectors.amazons3.AmazonS3Connector.java

License:Apache License

/**
 * Get users has the the access the to artifact
 * @param grants available for artifact//from  ww w .ja v a2  s.c o m
 * @return
 */
private String[] getUsers(Set<Grant> grants) {
    Set<String> users = new HashSet<String>();// no duplicates
    for (Grant grant : grants) {
        if (grant != null && grant.getGrantee() != null) {
            Grantee grantee = grant.getGrantee();

            if (grantee instanceof CanonicalGrantee) {
                users.add(((CanonicalGrantee) grantee).getDisplayName());
            } else {
                users.add(grantee.getIdentifier());
            }
        }
    }

    return users.toArray(new String[users.size()]);
}

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  w  w w  . j  a va2 s .  c  o m
 * @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;
}