Java 类com.amazonaws.services.s3.model.EmailAddressGrantee 实例源码

项目:aws-doc-sdk-examples    文件:SetAcl.java   
public static void setBucketAcl(String bucket_name, String email, String access)
{
    System.out.format("Setting %s access for %s\n", access, email);
    System.out.println("on bucket: " + bucket_name);

    final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
    try {
        // get the current ACL
        AccessControlList acl = s3.getBucketAcl(bucket_name);
        // set access for the grantee
        EmailAddressGrantee grantee = new EmailAddressGrantee(email);
        Permission permission = Permission.valueOf(access);
        acl.grantPermission(grantee, permission);
        s3.setBucketAcl(bucket_name, acl);
    } catch (AmazonServiceException e) {
        System.err.println(e.getErrorMessage());
        System.exit(1);
    }
}
项目:aws-doc-sdk-examples    文件:SetAcl.java   
public static void setObjectAcl(String bucket_name, String object_key, String email, String access)
{
    System.out.format("Setting %s access for %s\n", access, email);
    System.out.println("for object: " + object_key);
    System.out.println(" in bucket: " + bucket_name);

    final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
    try {
        // get the current ACL
        AccessControlList acl = s3.getObjectAcl(bucket_name, object_key);
        // set access for the grantee
        EmailAddressGrantee grantee = new EmailAddressGrantee(email);
        Permission permission = Permission.valueOf(access);
        acl.grantPermission(grantee, permission);
        s3.setObjectAcl(bucket_name, object_key, acl);
    } catch (AmazonServiceException e) {
        System.err.println(e.getErrorMessage());
        System.exit(1);
    }
}
项目:ibm-cos-sdk-java    文件:AclXmlFactory.java   
/**
 * Returns an XML fragment representing the specified Grantee.
 *
 * @param grantee
 *            The grantee to convert to an XML representation that can be
 *            sent to Amazon S3 as part of a request.
 * @param xml
 *            The XmlWriter to which to concatenate this node to.
 *
 * @return The given XmlWriter containing the specified grantee.
 *
 * @throws SdkClientException
 *             If the specified grantee type isn't recognized.
 */
protected XmlWriter convertToXml(Grantee grantee, XmlWriter xml) throws SdkClientException {
    if (grantee instanceof CanonicalGrantee) {
        return convertToXml((CanonicalGrantee)grantee, xml);
    } else if (grantee instanceof EmailAddressGrantee) {
        return convertToXml((EmailAddressGrantee)grantee, xml);
    } else if (grantee instanceof GroupGrantee) {
        return convertToXml((GroupGrantee)grantee, xml);
    } else {
        throw new SdkClientException("Unknown Grantee type: " + grantee.getClass().getName());
    }
}
项目:ibm-cos-sdk-java    文件:AclXmlFactory.java   
/**
 * Returns an XML fragment representing the specified email address grantee.
 *
 * @param grantee
 *            The email address grantee to convert to an XML representation
 *            that can be sent to Amazon S3 as part of request.
 * @param xml
 *            The XmlWriter to which to concatenate this node to.
 *
 * @return The given XmlWriter containing the specified email address grantee
 */
protected XmlWriter convertToXml(EmailAddressGrantee grantee, XmlWriter xml) {
    xml.start("Grantee", new String[] {"xmlns:xsi" , "xsi:type"},
            new String[] {"http://www.w3.org/2001/XMLSchema-instance", "AmazonCustomerByEmail"});
    xml.start("EmailAddress").value(grantee.getIdentifier()).end();
    xml.end();

    return xml;
}