LTI Integration Library 5.2.0
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
ceLTIc\LTI\OAuth\OAuthRequest Class Reference

Class to represent an OAuth request. More...

Public Member Functions

 __construct (string $http_method, string $http_url, ?array $parameters=null)
 Class constructor.
 
void set_parameter (string $name, string $value, bool $allow_duplicates=true)
 Set a parameter.
 
string array null get_parameter (string $name)
 Get a parameter.
 
array get_parameters ()
 Get request parameters.
 
void unset_parameter (string $name)
 Delete a parameter.
 
string get_signable_parameters ()
 The request parameters, sorted and concatenated into a normalized string.
 
string get_signature_base_string ()
 Returns the base string of this request.
 
string get_normalized_http_method ()
 Just uppercases the http method.
 
string get_normalized_http_url ()
 Parses the url and rebuilds it to be scheme://host/path.
 
string to_url ()
 Builds a url usable for a GET request.
 
string to_postdata ()
 Builds the data one would send in a POST request.
 
string to_header (?string $realm=null)
 Builds the Authorization: header.
 
string __toString ()
 Convert object to a string.
 
void sign_request (OAuthSignatureMethod $signature_method, OAuthConsumer $consumer, ?OAuthToken $token)
 Sign the request.
 
string build_signature (OAuthSignatureMethod $signature_method, OAuthConsumer $consumer, ?OAuthToken $token)
 Build the signature.
 

Static Public Member Functions

static OAuthRequest from_request (?string $http_method=null, ?string $http_url=null, ?array $parameters=null)
 Attempt to build up a request from what was passed to the server.
 
static OAuthRequest from_consumer_and_token (OAuthConsumer $consumer, ?OAuthToken $token, string $http_method, string $http_url, ?array $parameters=null)
 Pretty much a helper function to set up the request.
 

Public Attributes

string $base_string
 Base string.
 

Static Public Attributes

static string $version = '1.0'
 Version.
 
static string $POST_INPUT = 'php://input'
 Access to POST data.
 

Protected Attributes

array $parameters
 Request parameters.
 
string $http_method
 HTTP method.
 
string $http_url
 HTTP URL.
 

Detailed Description

Class to represent an OAuth request.

Version
2008-08-04
Licence: https://opensource.org/licenses/MIT The MIT License

Constructor & Destructor Documentation

◆ __construct()

ceLTIc\LTI\OAuth\OAuthRequest::__construct ( string $http_method,
string $http_url,
?array $parameters = null )

Class constructor.

Parameters
string$http_methodHTTP method
string$http_urlHTTP URL
array | null$parametersRequest parameters

Member Function Documentation

◆ __toString()

string ceLTIc\LTI\OAuth\OAuthRequest::__toString ( )

Convert object to a string.

Returns
string

◆ build_signature()

string ceLTIc\LTI\OAuth\OAuthRequest::build_signature ( OAuthSignatureMethod $signature_method,
OAuthConsumer $consumer,
?OAuthToken $token )

Build the signature.

Parameters
OAuthSignatureMethod$signature_methodSignature method
OAuthConsumer$consumerConsumer
OAuthToken | null$tokenToken
Returns
string

Referenced by to_header().

◆ from_consumer_and_token()

static OAuthRequest ceLTIc\LTI\OAuth\OAuthRequest::from_consumer_and_token ( OAuthConsumer $consumer,
?OAuthToken $token,
string $http_method,
string $http_url,
?array $parameters = null )
static

Pretty much a helper function to set up the request.

Parameters
OAuthConsumer$consumerConsumer
OAuthToken | null$tokenToken
string$http_methodHTTP method
string$http_urlHTTP URL
array | null$parametersRequest parameters
Returns
OAuthRequest

◆ from_request()

static OAuthRequest ceLTIc\LTI\OAuth\OAuthRequest::from_request ( ?string $http_method = null,
?string $http_url = null,
?array $parameters = null )
static

Attempt to build up a request from what was passed to the server.

Parameters
string | null$http_methodHTTP method
string | null$http_urlHTTP URL
array | null$parametersRequest parameters
Returns
OAuthRequest

References $http_method, $parameters, ceLTIc\LTI\OAuth\OAuthUtil\array_merge_recursive(), ceLTIc\LTI\OAuth\OAuthUtil\get_headers(), ceLTIc\LTI\OAuth\OAuthUtil\parse_parameters(), and ceLTIc\LTI\OAuth\OAuthUtil\split_header().

Referenced by ceLTIc\LTI\System\verifySignature().

◆ get_normalized_http_method()

string ceLTIc\LTI\OAuth\OAuthRequest::get_normalized_http_method ( )

Just uppercases the http method.

Returns
string

References ceLTIc\LTI\OAuth\OAuthUtil\build_http_query().

Referenced by get_parameters().

◆ get_normalized_http_url()

string ceLTIc\LTI\OAuth\OAuthRequest::get_normalized_http_url ( )

Parses the url and rebuilds it to be scheme://host/path.

Returns
string

References ceLTIc\LTI\OAuth\OAuthUtil\urlencode_rfc3986().

Referenced by get_parameters().

◆ get_parameter()

string array null ceLTIc\LTI\OAuth\OAuthRequest::get_parameter ( string $name)

Get a parameter.

Parameters
string$nameParameter name
Returns
string|array|null

Referenced by ceLTIc\LTI\OAuth\OAuthServer\add_signature_method(), ceLTIc\LTI\OAuth\OAuthServer\fetch_access_token(), and ceLTIc\LTI\OAuth\OAuthServer\verify_request().

◆ get_parameters()

array ceLTIc\LTI\OAuth\OAuthRequest::get_parameters ( )

Get request parameters.

Returns
array

References get_normalized_http_method(), get_normalized_http_url(), and get_signable_parameters().

◆ get_signable_parameters()

string ceLTIc\LTI\OAuth\OAuthRequest::get_signable_parameters ( )

The request parameters, sorted and concatenated into a normalized string.

Returns
string

Referenced by get_parameters().

◆ get_signature_base_string()

string ceLTIc\LTI\OAuth\OAuthRequest::get_signature_base_string ( )

Returns the base string of this request.

The base string defined as the method, the url and the parameters (normalized), each urlencoded and then concatenated with &.

Returns
string

◆ set_parameter()

void ceLTIc\LTI\OAuth\OAuthRequest::set_parameter ( string $name,
string $value,
bool $allow_duplicates = true )

Set a parameter.

Parameters
string$nameParameter name
string$valueParameter value
bool$allow_duplicatesTrue if duplicates are allowed

Referenced by to_header().

◆ sign_request()

void ceLTIc\LTI\OAuth\OAuthRequest::sign_request ( OAuthSignatureMethod $signature_method,
OAuthConsumer $consumer,
?OAuthToken $token )

Sign the request.

Parameters
OAuthSignatureMethod$signature_methodSignature method
OAuthConsumer$consumerConsumer
OAuthToken | null$tokenToken

◆ to_header()

string ceLTIc\LTI\OAuth\OAuthRequest::to_header ( ?string $realm = null)

Builds the Authorization: header.

Parameters
string | null$realmRealm
Returns
string
Exceptions
OAuthException

References build_signature(), ceLTIc\LTI\OAuth\OAuthSignatureMethod\get_name(), and set_parameter().

◆ to_postdata()

string ceLTIc\LTI\OAuth\OAuthRequest::to_postdata ( )

Builds the data one would send in a POST request.

Returns
string

References to_url().

◆ to_url()

string ceLTIc\LTI\OAuth\OAuthRequest::to_url ( )

Builds a url usable for a GET request.

Returns
string

Referenced by to_postdata().

◆ unset_parameter()

void ceLTIc\LTI\OAuth\OAuthRequest::unset_parameter ( string $name)

Delete a parameter.

Parameters
string$nameParameter name

Member Data Documentation

◆ $base_string

string ceLTIc\LTI\OAuth\OAuthRequest::$base_string

Base string.

◆ $http_method

string ceLTIc\LTI\OAuth\OAuthRequest::$http_method
protected

HTTP method.

Referenced by from_request().

◆ $http_url

string ceLTIc\LTI\OAuth\OAuthRequest::$http_url
protected

HTTP URL.

◆ $parameters

array ceLTIc\LTI\OAuth\OAuthRequest::$parameters
protected

Request parameters.

Referenced by from_request().

◆ $POST_INPUT

string ceLTIc\LTI\OAuth\OAuthRequest::$POST_INPUT = 'php://input'
static

Access to POST data.

Referenced by ceLTIc\LTI\Util\logError(), and ceLTIc\LTI\System\setSettings().

◆ $version

string ceLTIc\LTI\OAuth\OAuthRequest::$version = '1.0'
static

Version.