You are here

public function OAuthRequest::selectSignatureMethod in Lingotek Translation 7.2

Same name and namespace in other branches
  1. 7.3 lib/oauth-php/library/OAuthRequest.php \OAuthRequest::selectSignatureMethod()

* Select a signature method from the list of available methods. * We try to check the most secure methods first. * * @todo Let the signature method tell us how secure it is *

Parameters

array methods: * @exception OAuthException2 when we don't support any method in the list * @return string

1 call to OAuthRequest::selectSignatureMethod()
OAuthRequestSigner::sign in lib/oauth-php/library/OAuthRequestSigner.php
* Sign our message in the way the server understands. * Set the needed oauth_xxxx parameters. * *

File

lib/oauth-php/library/OAuthRequest.php, line 240

Class

OAuthRequest
Object to parse an incoming OAuth request or prepare an outgoing OAuth request

Code

public function selectSignatureMethod($methods) {
  if (in_array('HMAC-SHA1', $methods)) {
    $method = 'HMAC-SHA1';
  }
  else {
    if (in_array('MD5', $methods)) {
      $method = 'MD5';
    }
    else {
      $method = false;
      foreach ($methods as $m) {
        $m = strtoupper($m);
        $m2 = preg_replace('/[^A-Z0-9]/', '_', $m);
        if (file_exists(dirname(__FILE__) . '/signature_method/OAuthSignatureMethod_' . $m2 . '.php')) {
          $method = $m;
          break;
        }
      }
      if (empty($method)) {
        throw new OAuthException2('None of the signing methods is supported.');
      }
    }
  }
  return $method;
}