• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I get the acl of a bucket/object

#1
[eluser]Unknown[/eluser]
I am trying to show the acl of the bucket/object using s3.class.php.
but I am not getting any info from the s3, from which I can show the acl to read or edit.
I have cold fusion code to do this but I need to do this using php.
The cold fusion code is attached
<cffunction name="getBucketACL" access="public" output="false" returntype="any"
description="Gets the ACL of a bucket">
<cfargument name="bucketName" type="string" required="yes">
$var signature = "">
$var thisOwner = "">
$var thisGrantee = "">
$var data = "">
$var dateTimeString = GetHTTPTimeString(Now())>
&lt;!--- Create a canonical string to send ---&gt;
$var cs = "GET\n\n\n#dateTimeString#\n/#urlencodedformat(arguments.bucketName)#/?acl">
&lt;!--- Replace "\n" with "chr(10) to get a correct digest ---&gt;
$var fixedData = replace(cs,"\n","#chr(10)#","all")>
&lt;!--- Calculate the hash of the information ---&gt;
<cf_hmac hash_function="sha1" data="#fixedData#" key="#variables.secretAccessKey#">
&lt;!--- fix the returned data to be a proper signature ---&gt;
$signature = ToBase64(Hex2Bin("#digest#"))>
<cfhttp method="GET" url="http://s3.amazonaws.com/#urlencodedformat(arguments.bucketName)#/?acl">
<cfhttpparam type="header" name="Date" value="#dateTimeString#">
<cfhttpparam type="header" name="Authorization" value="AWS #variables.accessKeyId#:#signature#">
</cfhttp>
<cftry>
<cfif #cfhttp.statusCode# eq '200 OK'>
$data = xmlParse(cfhttp.FileContent)>
$users = structnew()>
$users["All Users"] = structnew()>
$users["All Users"].Group = 'Group'>
$users["All Users"].ID = 'http://acs.amazonaws.com/groups/global/AllUsers'>
$users["All Users"].full_control = FALSE>
$users["All Users"].write_acp = FALSE>
$users["All Users"].read_acp = FALSE>
$users["All Users"].write = FALSE>
$users["All Users"].read = FALSE>
$users["Authenticated Users"] = structnew()>
$users["Authenticated Users"].Group = 'Group'>
$users["Authenticated Users"].ID = 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers'>
$users["Authenticated Users"].full_control = FALSE>
$users["Authenticated Users"].write_acp = FALSE>
$users["Authenticated Users"].read_acp = FALSE>
$users["Authenticated Users"].write = FALSE>
$users["Authenticated Users"].read = FALSE>
$grants = xmlSearch(data, "//:Grant")>
<cfloop index="x" from="1" to="#arrayLen(grants)#">
$grant = grants[x]>
<cfif isDefined("grant.Grantee.URI.xmltext") and #grant.Grantee.URI.xmltext# eq 'http://acs.amazonaws.com/groups/global/AllUsers'>
$users["All Users"].ID = '#grant.Grantee.URI.xmltext#'>
$users["All Users"].Group = 'Group'>
<cfif #grant.Permission.xmltext# eq 'FULL_CONTROL'>
$users["All Users"].full_control = TRUE>
$users["All Users"].write_acp = TRUE>
$users["All Users"].read_acp = TRUE>
$users["All Users"].write = TRUE>
$users["All Users"].read = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE_ACP'>
$users["All Users"].write_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ_ACP'>
$users["All Users"].read_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE'>
$users["All Users"].write = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ'>
$users["All Users"].read = TRUE>
</cfif>
<cfelseif isDefined("grant.Grantee.URI.xmltext") and #grant.Grantee.URI.xmltext# eq 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers'>
$users["Authenticated Users"].ID = '#grant.Grantee.URI.xmltext#'>
$users["Authenticated Users"].Group = 'Group'>
<cfif #grant.Permission.xmltext# eq 'FULL_CONTROL'>
$users["Authenticated Users"].full_control = TRUE>
$users["Authenticated Users"].write_acp = TRUE>
$users["Authenticated Users"].read_acp = TRUE>
$users["Authenticated Users"].write = TRUE>
$users["Authenticated Users"].read = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE_ACP'>
$users["Authenticated Users"].write_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ_ACP'>
$users["Authenticated Users"].read_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE'>
$users["Authenticated Users"].write = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ'>
$users["Authenticated Users"].read = TRUE>
</cfif>
<cfelseif isDefined("grant.Grantee.ID.xmltext") and isDefined("grant.Grantee.DisplayName.xmltext")>
<cfif NOT StructKeyExists(users, "#grant.Grantee.DisplayName.xmltext#")>
$users["#grant.Grantee.DisplayName.xmltext#"] = structnew()>
$users["#grant.Grantee.DisplayName.xmltext#"].ID = "#grant.Grantee.ID.xmltext#">
$users["#grant.Grantee.DisplayName.xmltext#"].Group = 'CanonicalUser'>
$users["#grant.Grantee.DisplayName.xmltext#"].DisplayName = '#grant.Grantee.DisplayName.xmltext#'>
$users["#grant.Grantee.DisplayName.xmltext#"].full_control = FALSE>
$users["#grant.Grantee.DisplayName.xmltext#"].write_acp = FALSE>
$users["#grant.Grantee.DisplayName.xmltext#"].read_acp = FALSE>
$users["#grant.Grantee.DisplayName.xmltext#"].write = FALSE>
$users["#grant.Grantee.DisplayName.xmltext#"].read = FALSE>
</cfif>
<cfif #grant.Permission.xmltext# eq 'FULL_CONTROL'>
$users["#grant.Grantee.DisplayName.xmltext#"].full_control = TRUE>
$users["#grant.Grantee.DisplayName.xmltext#"].write_acp = TRUE>
$users["#grant.Grantee.DisplayName.xmltext#"].read_acp = TRUE>
$users["#grant.Grantee.DisplayName.xmltext#"].write = TRUE>
$users["#grant.Grantee.DisplayName.xmltext#"].read = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE_ACP'>
$users["#grant.Grantee.DisplayName.xmltext#"].write_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ_ACP'>
$users["#grant.Grantee.DisplayName.xmltext#"].read_acp = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'WRITE'>
$users["#grant.Grantee.DisplayName.xmltext#"].write = TRUE>
<cfelseif #grant.Permission.xmltext# eq 'READ'>
$users["#grant.Grantee.DisplayName.xmltext#"].read = TRUE>
</cfif>
<cfelse>


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.