AccessKeyCredential.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace AlibabaCloud\Credentials;
  3. use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
  4. /**
  5. * Use the AccessKey to complete the authentication.
  6. */
  7. class AccessKeyCredential implements CredentialsInterface
  8. {
  9. /**
  10. * @var string
  11. */
  12. private $accessKeyId;
  13. /**
  14. * @var string
  15. */
  16. private $accessKeySecret;
  17. /**
  18. * AccessKeyCredential constructor.
  19. *
  20. * @param string $access_key_id Access key ID
  21. * @param string $access_key_secret Access Key Secret
  22. */
  23. public function __construct($access_key_id, $access_key_secret)
  24. {
  25. Filter::accessKey($access_key_id, $access_key_secret);
  26. $this->accessKeyId = $access_key_id;
  27. $this->accessKeySecret = $access_key_secret;
  28. }
  29. /**
  30. * @return string
  31. */
  32. public function getAccessKeyId()
  33. {
  34. return $this->accessKeyId;
  35. }
  36. /**
  37. * @return string
  38. */
  39. public function getAccessKeySecret()
  40. {
  41. return $this->accessKeySecret;
  42. }
  43. /**
  44. * @return string
  45. */
  46. public function __toString()
  47. {
  48. return "$this->accessKeyId#$this->accessKeySecret";
  49. }
  50. /**
  51. * @return ShaHmac1Signature
  52. */
  53. public function getSignature()
  54. {
  55. return new ShaHmac1Signature();
  56. }
  57. public function getSecurityToken()
  58. {
  59. return '';
  60. }
  61. }