代码同步
This commit is contained in:
@@ -2,13 +2,16 @@
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\RsaKeyPairProvider;
|
||||
use AlibabaCloud\Credentials\Providers\RsaKeyPairCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use the RSA key pair to complete the authentication (supported only on Japanese site)
|
||||
*/
|
||||
class RsaKeyPairCredential implements CredentialsInterface
|
||||
@@ -19,6 +22,11 @@ class RsaKeyPairCredential implements CredentialsInterface
|
||||
*/
|
||||
private $publicKeyId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $privateKeyFile;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -42,7 +50,8 @@ class RsaKeyPairCredential implements CredentialsInterface
|
||||
Filter::privateKeyFile($private_key_file);
|
||||
|
||||
$this->publicKeyId = $public_key_id;
|
||||
$this->config = $config;
|
||||
$this->privateKeyFile = $private_key_file;
|
||||
$this->config = $config;
|
||||
try {
|
||||
$this->privateKey = file_get_contents($private_key_file);
|
||||
} catch (Exception $exception) {
|
||||
@@ -117,13 +126,17 @@ class RsaKeyPairCredential implements CredentialsInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StsCredential
|
||||
* @return AlibabaCloud\Credentials\Providers\Credentials
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function getSessionCredential()
|
||||
{
|
||||
return (new RsaKeyPairProvider($this))->get();
|
||||
$params = [
|
||||
'publicKeyId' => $this->publicKeyId,
|
||||
'privateKeyFile' => $this->privateKeyFile,
|
||||
];
|
||||
return (new RsaKeyPairCredentialsProvider($params))->getCredentials();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,4 +168,18 @@ class RsaKeyPairCredential implements CredentialsInterface
|
||||
{
|
||||
return $this->getSessionCredential()->getExpiration();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCredential()
|
||||
{
|
||||
$credentials = $this->getSessionCredential();
|
||||
return new CredentialModel([
|
||||
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||
'securityToken' => $credentials->getSecurityToken(),
|
||||
'type' => 'rsa_key_pair',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user