ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
IMSGlobal\LTI\OAuth\OAuthSignatureMethod Class Reference

Class to represent an OAuth Signature Method. More...

+ Inheritance diagram for IMSGlobal\LTI\OAuth\OAuthSignatureMethod:
+ Collaboration diagram for IMSGlobal\LTI\OAuth\OAuthSignatureMethod:

Public Member Functions

 get_name ()
 Needs to return the name of the Signature Method (ie HMAC-SHA1) More...
 
 build_signature ($request, $consumer, $token)
 Build up the signature NOTE: The output of this function MUST NOT be urlencoded. More...
 
 check_signature ($request, $consumer, $token, $signature)
 Verifies that a given signature is correct. More...
 

Detailed Description

Class to represent an OAuth Signature Method.

Version
2008-08-04 https://opensource.org/licenses/MIT The MIT License A class for implementing a Signature Method See section 9 ("Signing Requests") in the spec

Definition at line 16 of file OAuthSignatureMethod.php.

Member Function Documentation

◆ build_signature()

IMSGlobal\LTI\OAuth\OAuthSignatureMethod::build_signature (   $request,
  $consumer,
  $token 
)
abstract

Build up the signature NOTE: The output of this function MUST NOT be urlencoded.

the encoding is handled in OAuthRequest when the final request is serialized

Parameters
OAuthRequest$request
OAuthConsumer$consumer
OAuthToken$token
Returns
string

Referenced by IMSGlobal\LTI\OAuth\OAuthSignatureMethod\check_signature().

+ Here is the caller graph for this function:

◆ check_signature()

IMSGlobal\LTI\OAuth\OAuthSignatureMethod::check_signature (   $request,
  $consumer,
  $token,
  $signature 
)

Verifies that a given signature is correct.

Parameters
OAuthRequest$request
OAuthConsumer$consumer
OAuthToken$token
string$signature
Returns
bool

Definition at line 43 of file OAuthSignatureMethod.php.

References $consumer, $i, $result, and IMSGlobal\LTI\OAuth\OAuthSignatureMethod\build_signature().

43  {
44 
45  $built = $this->build_signature($request, $consumer, $token);
46 
47  // Check for zero length, although unlikely here
48  if (strlen($built) == 0 || strlen($signature) == 0) {
49  return false;
50  }
51 
52  if (strlen($built) != strlen($signature)) {
53  return false;
54  }
55 
56  // Avoid a timing leak with a (hopefully) time insensitive compare
57  $result = 0;
58  for ($i = 0; $i < strlen($signature); $i++) {
59  $result |= ord($built{$i}) ^ ord($signature{$i});
60  }
61 
62  return $result == 0;
63 
64  }
$result
build_signature($request, $consumer, $token)
Build up the signature NOTE: The output of this function MUST NOT be urlencoded.
$consumer
Definition: demo.php:30
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

◆ get_name()

IMSGlobal\LTI\OAuth\OAuthSignatureMethod::get_name ( )
abstract

Needs to return the name of the Signature Method (ie HMAC-SHA1)

Returns
string

The documentation for this class was generated from the following file: