mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-19 21:03:44 -07:00
spaces.php
This commit is contained in:
parent
7755490b81
commit
eefa32741e
845 changed files with 50409 additions and 0 deletions
91
aws/Aws/Credentials/Credentials.php
Normal file
91
aws/Aws/Credentials/Credentials.php
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
namespace Aws\Credentials;
|
||||
|
||||
/**
|
||||
* Basic implementation of the AWS Credentials interface that allows callers to
|
||||
* pass in the AWS Access Key and AWS Secret Access Key in the constructor.
|
||||
*/
|
||||
class Credentials implements CredentialsInterface, \Serializable
|
||||
{
|
||||
private $key;
|
||||
private $secret;
|
||||
private $token;
|
||||
private $expires;
|
||||
|
||||
/**
|
||||
* Constructs a new BasicAWSCredentials object, with the specified AWS
|
||||
* access key and AWS secret key
|
||||
*
|
||||
* @param string $key AWS access key ID
|
||||
* @param string $secret AWS secret access key
|
||||
* @param string $token Security token to use
|
||||
* @param int $expires UNIX timestamp for when credentials expire
|
||||
*/
|
||||
public function __construct($key, $secret, $token = null, $expires = null)
|
||||
{
|
||||
$this->key = trim($key);
|
||||
$this->secret = trim($secret);
|
||||
$this->token = $token;
|
||||
$this->expires = $expires;
|
||||
}
|
||||
|
||||
public static function __set_state(array $state)
|
||||
{
|
||||
return new self(
|
||||
$state['key'],
|
||||
$state['secret'],
|
||||
$state['token'],
|
||||
$state['expires']
|
||||
);
|
||||
}
|
||||
|
||||
public function getAccessKeyId()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function getSecretKey()
|
||||
{
|
||||
return $this->secret;
|
||||
}
|
||||
|
||||
public function getSecurityToken()
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
public function getExpiration()
|
||||
{
|
||||
return $this->expires;
|
||||
}
|
||||
|
||||
public function isExpired()
|
||||
{
|
||||
return $this->expires !== null && time() >= $this->expires;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
'key' => $this->key,
|
||||
'secret' => $this->secret,
|
||||
'token' => $this->token,
|
||||
'expires' => $this->expires
|
||||
];
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return json_encode($this->toArray());
|
||||
}
|
||||
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$data = json_decode($serialized, true);
|
||||
|
||||
$this->key = $data['key'];
|
||||
$this->secret = $data['secret'];
|
||||
$this->token = $data['token'];
|
||||
$this->expires = $data['expires'];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue