Ejemplo n.º 1
0
 /**
  * Creates credentials from the result of an STS operations
  *
  * @param Result $result Result of an STS operation
  *
  * @return Credentials
  * @throws \InvalidArgumentException if the result contains no credentials
  */
 public function createCredentials(Result $result)
 {
     if (!$result->hasKey('Credentials')) {
         throw new \InvalidArgumentException('Result contains no credentials');
     }
     $c = $result['Credentials'];
     return new Credentials($c['AccessKeyId'], $c['SecretAccessKey'], isset($c['SessionToken']) ? $c['SessionToken'] : null, isset($c['Expiration']) && $c['Expiration'] instanceof \DateTimeInterface ? (int) $c['Expiration']->format('U') : null);
 }
Ejemplo n.º 2
0
 private function determineNextToken(Result $result)
 {
     if (!$this->config['output_token']) {
         return null;
     }
     if ($this->config['more_results'] && !$result->search($this->config['more_results'])) {
         return null;
     }
     $nextToken = is_scalar($this->config['output_token']) ? [$this->config['input_token'] => $this->config['output_token']] : array_combine($this->config['input_token'], $this->config['output_token']);
     return array_filter(array_map(function ($outputToken) use($result) {
         return $result->search($outputToken);
     }, $nextToken));
 }