Gets S3 Public-Read ACL - Java AWS

Java examples for AWS:S3

Description

Gets S3 Public-Read ACL

Demo Code

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

public class Main {
    /**/*  ww  w .j  a v a 2 s  . co m*/
     * Gets Public-Read ACL
     * 
     * @param selfId
     * @return
     */
    public static String getACLTemplatePublicRead(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("</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("</AccessControlList>");
        acl.append("</AccessControlPolicy>");

        return acl.toString();
    }
}

Related Tutorials