Gets S3 Public-Read-Write ACL - Java AWS

Java examples for AWS:S3

Description

Gets S3 Public-Read-Write ACL

Demo Code

// Permission is hereby granted, free of charge, to any person obtaining a
//package com.java2s;

public class Main {
    /**/*from   www .j  av a2  s . c  om*/
     * Gets Public-Read-Write ACL
     * 
     * @param selfId
     * @return
     */
    public static String getACLTemplatePublicReadWrite(String selfId) {
        StringBuffer acl = new StringBuffer();
        acl.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        acl.append("<AccessControlPolicy xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">");
        acl.append("<Owner>");
        acl.append("<ID>" + selfId + "</ID>");
        acl.append("</Owner>");
        acl.append("<AccessControlList>");
        acl.append("<Grant>");
        acl.append("<Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\">");
        acl.append("<ID>" + selfId + "</ID>");
        acl.append("<DisplayName>duspense</DisplayName>");
        acl.append("</Grantee>");
        acl.append("<Permission>FULL_CONTROL</Permission>");
        acl.append("</Grant>");
        acl.append("<Grant>");
        acl.append("<Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"Group\">");
        acl.append("<URI>http://acs.amazonaws.com/groups/global/AllUsers</URI>");
        acl.append("</Grantee>");
        acl.append("<Permission>READ</Permission>");
        acl.append("</Grant>");
        acl.append("<Grant>");
        acl.append("<Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"Group\">");
        acl.append("<URI>http://acs.amazonaws.com/groups/global/AllUsers</URI>");
        acl.append("</Grantee>");
        acl.append("<Permission>WRITE</Permission>");
        acl.append("</Grant>");
        acl.append("</AccessControlList>");
        acl.append("</AccessControlPolicy>");

        return acl.toString();
    }
}

Related Tutorials