DrupalOAuthServer.inc 923 B

123456789101112131415161718192021222324252627
  1. <?php
  2. class DrupalOAuthServer extends OAuthServer {
  3. public function __construct($context) {
  4. parent::__construct(new DrupalOAuthDataStore($context));
  5. if (isset($this->context->authorization_options['signature_methods'])) {
  6. $sig_methods = $this->context->authorization_options['signature_methods'];
  7. }
  8. else {
  9. $sig_methods = array('HMAC-SHA1', 'HMAC-SHA256', 'HMAC-SHA384', 'HMAC-SHA512');
  10. }
  11. foreach ($sig_methods as $signature_method) {
  12. if ($signature_method == 'PLAINTEXT') {
  13. $this->add_signature_method(new OAuthSignatureMethod_PLAINTEXT());
  14. }
  15. else {
  16. // Check if the system supports the hashing algorithm
  17. $algo = explode('-', $signature_method, 2);
  18. if ($algo[0] == 'HMAC' && in_array(strtolower($algo[1]), hash_algos())) {
  19. $this->add_signature_method(new OAuthSignatureMethod_HMAC($algo[1]));
  20. }
  21. }
  22. }
  23. }
  24. }