get_policy_signature ()

Gets the JSON string with the whitespace removed.

Access

public

Returns

Type

Description

string

The Base64-encoded, signed JSON string.

Examples

Create a policy and get the policy signature.

// Instantiate S3
$s3 = new AmazonS3();

// Create a new S3 policy using an associative array
$policy = new s3Policy($s3, array(
	'Version' => '2008-10-17',
	'Statement' => array(
		array( // Statement #1
			'Sid' => 'AddPerm',
			'Effect' => 'Allow',
			'Principal' => array(
				'AWS' => '*'
			),
			'Action' => array('s3:ReadObject'),
			'Resource' => array('arn:aws:s3:::my-bucket/*')
		)
	)
));

// Success?
var_dump($policy->get_policy_signature());
Result:
string(56) "OWU3NzU4MGMxZmY5NDM0YmI1Mjk0Y2FkMWIzZWFjMDFiYzdkMjdlMg=="

Related Methods

Source

Method defined in utilities/policy.class.php | Toggle source view (4 lines) | View on GitHub

public function get_policy_signature()
{
    return base64_encode(hash_hmac('sha1', $this->get_policy(), $this->auth->secret_key));
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback