GenerateSessionAccessKey.php 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace AlibabaCloud\Credentials\Request;
  3. use AlibabaCloud\Credentials\Providers\Provider;
  4. use AlibabaCloud\Credentials\RsaKeyPairCredential;
  5. use AlibabaCloud\Credentials\Signature\ShaHmac256WithRsaSignature;
  6. /**
  7. * Use the RSA key pair to complete the authentication (supported only on Japanese site)
  8. */
  9. class GenerateSessionAccessKey extends Request
  10. {
  11. /**
  12. * GenerateSessionAccessKey constructor.
  13. *
  14. * @param RsaKeyPairCredential $credential
  15. */
  16. public function __construct(RsaKeyPairCredential $credential)
  17. {
  18. parent::__construct();
  19. $this->signature = new ShaHmac256WithRsaSignature();
  20. $this->credential = $credential;
  21. $this->uri = $this->uri->withHost('sts.ap-northeast-1.aliyuncs.com');
  22. $this->options['verify'] = false;
  23. $this->options['query']['Version'] = '2015-04-01';
  24. $this->options['query']['Action'] = 'GenerateSessionAccessKey';
  25. $this->options['query']['RegionId'] = 'cn-hangzhou';
  26. $this->options['query']['AccessKeyId'] = $credential->getPublicKeyId();
  27. $this->options['query']['PublicKeyId'] = $credential->getPublicKeyId();
  28. $this->options['query']['DurationSeconds'] = Provider::DURATION_SECONDS;
  29. }
  30. }