public function load($filename)
 {
     $json = file_get_contents($filename);
     $data = json_decode($json, true);
     $policy = new Policy();
     if (isset($data['Version'])) {
         $policy->setVersion($data['Version']);
     }
     foreach ($data['Statement'] as $sData) {
         $statement = new Statement();
         if (isset($sData['Sid'])) {
             $statement->setId($sData['Sid']);
         }
         $statement->setEffect($sData['Effect']);
         foreach ($sData['Action'] as $aData) {
             $action = new Action($aData);
             $statement->addAction($action);
         }
         if (isset($sData['Resource'])) {
             foreach ($sData['Resource'] as $rData) {
                 $resource = new Resource($rData);
                 $statement->addResource($resource);
             }
         }
         if (isset($sData['Principal'])) {
             $pData = $sData['Principal'];
             foreach ($pData as $key => $value) {
                 $principal = new Principal($key, $value);
                 $statement->setPrincipal($principal);
             }
         }
         $policy->addStatement($statement);
     }
     return $policy;
 }
 public function testPolicies()
 {
     $policy = new Policy();
     $statement = new Statement();
     $action = new Action('s3', 'Get*');
     $statement->addAction($action);
     $action = new Action('s3', 'List*');
     $statement->addAction($action);
     $resource = new Resource('xrn:aws:s3:eu-west-1::some-bucket');
     $statement->addResource($resource);
     $principal = new Principal('AWS');
     $principal->addKey('xrn:aws:iam::AWS-account-ID:user/bob');
     $principal->addKey('xrn:aws:iam::AWS-account-ID:user/alice');
     $statement->setPrincipal($principal);
     $policy->addStatement($statement);
     $serializer = new JsonPolicySerializer();
     $json = $serializer->serialize($policy);
     //echo $json;
 }