You are here

public function LingotekOAuthRequest::selectSignatureMethod in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.4 lib/oauth-php/library/LingotekOAuthRequest.php \LingotekOAuthRequest::selectSignatureMethod()
  2. 7.5 lib/oauth-php/library/LingotekOAuthRequest.php \LingotekOAuthRequest::selectSignatureMethod()
  3. 7.6 lib/oauth-php/library/LingotekOAuthRequest.php \LingotekOAuthRequest::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 LingotekOAuthRequest::selectSignatureMethod()
LingotekOAuthRequestSigner::sign in lib/oauth-php/library/LingotekOAuthRequestSigner.php
* Sign our message in the way the server understands. * Set the needed oauth_xxxx parameters. * *

File

lib/oauth-php/library/LingotekOAuthRequest.php, line 209

Class

LingotekOAuthRequest
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/LingotekOAuthSignatureMethod_' . $m2 . '.php')) {
          $method = $m;
          break;
        }
      }
      if (empty($method)) {
        throw new OAuthException2('None of the signing methods is supported.');
      }
    }
  }
  return $method;
}