AccessKeyCredential.php 1.3 KB

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