LTI Integration Library 5.1.4
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
System Class Reference

Class to represent an LTI system. More...

+ Inheritance diagram for System:

Public Member Functions

int string null getRecordId ()
 Get the system record ID.
 
void setRecordId (int|string|null $id)
 Sets the system record ID.
 
string null getKey ()
 Get the consumer key.
 
void setKey (?string $key)
 Set the consumer key.
 
string null getSetting (string $name, ?string $default='')
 Get a setting value.
 
void setSetting (string $name, string|array|null $value=null)
 Set a setting value.
 
array getSettings ()
 Get an array of all setting values.
 
void setSettings (array $settings)
 Set an array of all setting values.
 
bool saveSettings ()
 Save setting values.
 
bool hasJwt ()
 Check whether a JWT exists.
 
ClientInterface getJwt ()
 Get the JWT.
 
array getRawParameters ()
 Get the raw POST parameters.
 
array getMessageClaims (bool $fullyQualified=false)
 Get the message claims.
 
array string signParameters (string $url, string $type, string $ltiVersionString, array $params)
 Add the signature to an LTI message.
 
array string signMessage (string &$url, string $type, string $ltiVersionString, array $params, ?string $loginHint=null, ?string $ltiMessageHint=null)
 Add the signature to an LTI message.
 
string sendMessage (string $url, string $type, array $messageParams, string $target='', ?string $userId=null, ?string $hint=null)
 Generate a web page containing an auto-submitted form of LTI message parameters.
 
array string signServiceRequest (string $url, string $method, string $type, array|string|null $data=null)
 Generates the headers for an LTI service request.
 
HttpMessage doServiceRequest (ServiceDefinition $service, string $method, string $format, array|string $data)
 Perform a service request.
 
bool useOAuth1 ()
 Determine whether this consumer is using the OAuth 1 security model.
 
array string addSignature (string $endpoint, array|string|null $data, string $method='POST', ?string $type=null, ?string $nonce='', ?string $hash=null, ?int $timestamp=null)
 Add the signature to an array of message parameters or to a header string.
 
string null getBaseString ()
 Get the last signature base string.
 
bool checkMessage (bool $generateWarnings=false)
 Verify the required properties of an LTI message.
 
bool verifySignature ()
 Verify the signature of a message.
 
bool setReason (string $reason)
 Set the error reason.
 

Static Public Member Functions

static array parseRoles (array|string $roles, LtiVersion $ltiVersion=LtiVersion::V1, bool $addPrincipalRole=false)
 Parse a set of roles to comply with a specified version of LTI.
 

Public Attributes

bool $ok = true
 True if the last request was successful.
 
LtiVersion $ltiVersion = null
 LTI version.
 
string $name = null
 Local name of platform/tool.
 
string $secret = null
 Shared secret.
 
string $signatureMethod = 'HMAC-SHA1'
 Method used for signing messages.
 
string $encryptionMethod = ''
 Algorithm used for encrypting messages.
 
DataConnector $dataConnector = null
 Data connector object.
 
string $rsaKey = null
 RSA key in PEM or JSON format.
 
array $requiredScopes = []
 Scopes to request when obtaining an access token.
 
string $kid = null
 Key ID.
 
string $jku = null
 Endpoint for public key.
 
string $reason = null
 Error message for last request processed.
 
array $details = []
 Details for error message relating to last request processed.
 
array $warnings = []
 Warnings relating to last request processed.
 
bool $debugMode = false
 Whether debug level messages are to be reported.
 
bool $enabled = false
 Whether the system instance is enabled to accept connection requests.
 
int $enableFrom = null
 Timestamp from which the the system instance is enabled to accept connection requests.
 
int $enableUntil = null
 Timestamp until which the system instance is enabled to accept connection requests.
 
int $lastAccess = null
 Timestamp for date of last connection to this system.
 
int $created = null
 Timestamp for when the object was created.
 
int $updated = null
 Timestamp for when the object was last updated.
 
IdScope $idScope = IdScope::IdOnly
 Default scope to use when generating an Id value for a user.
 

Protected Attributes

ClientInterface $jwt = null
 JWT ClientInterface object.
 
array $rawParameters = null
 Raw message parameters.
 
array $messageParameters = null
 LTI message parameters.
 

Detailed Description

Class to represent an LTI system.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com
Licence: http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3

Member Function Documentation

◆ addSignature()

array string addSignature ( string $endpoint,
array|string|null $data,
string $method = 'POST',
?string $type = null,
?string $nonce = '',
?string $hash = null,
?int $timestamp = null )

Add the signature to an array of message parameters or to a header string.

Parameters
string$endpointURL to which message is being sent
array | string | null$dataData to be passed
string$methodHTTP method
string | null$typeContent type of data being passed
string | null$nonceNonce value for JWT
string | null$hashOAuth body hash value
int | null$timestampTimestamp
Returns
array|string Array of signed message parameters or header string

◆ checkMessage()

bool checkMessage ( bool $generateWarnings = false)

Verify the required properties of an LTI message.

Parameters
bool$generateWarningsTrue if warning messages should be generated
Returns
bool True if it is a valid LTI message

◆ doServiceRequest()

HttpMessage doServiceRequest ( ServiceDefinition $service,
string $method,
string $format,
array|string $data )

Perform a service request.

Parameters
ServiceDefinition$serviceService object to be executed
string$methodHTTP action
string$formatMedia type
array | string$dataArray of parameters or body string
Returns
HttpMessage HTTP object containing request and response details

◆ getBaseString()

string null getBaseString ( )

Get the last signature base string.

Returns
string|null Signature base string

◆ getJwt()

ClientInterface getJwt ( )

Get the JWT.

Returns
ClientInterface The JWT

◆ getKey()

string null getKey ( )

Get the consumer key.

Returns
string|null Consumer key value

◆ getMessageClaims()

array getMessageClaims ( bool $fullyQualified = false)

Get the message claims.

Parameters
bool$fullyQualifiedTrue if claims should be fully qualified rather than grouped (default is false)
Returns
array| null The message claim array

◆ getRawParameters()

array getRawParameters ( )

Get the raw POST parameters.

Returns
array The POST parameter array

◆ getRecordId()

int string null getRecordId ( )

◆ getSetting()

string null getSetting ( string $name,
?string $default = '' )

Get a setting value.

Parameters
string$nameName of setting
string | null$defaultValue to return if the setting does not exist (optional, default is an empty string)
Returns
string|null Setting value

Referenced by Platform\getIsAvailable().

◆ getSettings()

array getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

◆ hasJwt()

bool hasJwt ( )

Check whether a JWT exists.

Returns
bool True if a JWT exists

References Util\MESSAGE_TYPE_MAPPING.

◆ parseRoles()

static array parseRoles ( array|string $roles,
LtiVersion $ltiVersion = LtiVersion::V1,
bool $addPrincipalRole = false )
static

Parse a set of roles to comply with a specified version of LTI.

Parameters
array | string$rolesComma-separated list of roles or array of roles
LtiVersion$ltiVersionLTI version for roles being returned (optional, default is LTI-1p0)
bool$addPrincipalRoleAdd principal role when true (optional, default is false)
Returns
array Array of roles

◆ saveSettings()

bool saveSettings ( )

Save setting values.

Returns
bool True if the settings were successfully saved

◆ sendMessage()

string sendMessage ( string $url,
string $type,
array $messageParams,
string $target = '',
?string $userId = null,
?string $hint = null )

Generate a web page containing an auto-submitted form of LTI message parameters.

Parameters
string$urlURL to which the form should be submitted
string$typeLTI message type
array$messageParamsArray of form parameters
string$targetName of target (optional)
string | null$userIdID of user (optional)
string | null$hintLTI message hint (optional, use null for none)
Returns
string

References Util\jsonDecode().

◆ setKey()

void setKey ( ?string $key)

Set the consumer key.

Parameters
string | null$keyConsumer key value

◆ setReason()

bool setReason ( string $reason)

Set the error reason.

Parameters
string$reasonReason value
Returns
bool Returns false

◆ setRecordId()

void setRecordId ( int|string|null $id)

Sets the system record ID.

Parameters
int | string | null$idSystem record ID value

◆ setSetting()

void setSetting ( string $name,
string|array|null $value = null )

Set a setting value.

Parameters
string$nameName of setting
string | array | null$valueValue to set, use an empty value to delete a setting (optional, default is null)

◆ setSettings()

void setSettings ( array $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

References OAuthRequest\$POST_INPUT.

◆ signMessage()

array string signMessage ( string & $url,
string $type,
string $ltiVersionString,
array $params,
?string $loginHint = null,
?string $ltiMessageHint = null )

Add the signature to an LTI message.

If the message is being sent from a platform using LTI 1.3, then the parameters and URL will be saved and replaced with an initiate login request.

Parameters
string$urlURL for message request
string$typeLTI message type
string$ltiVersionStringLTI version
array$paramsMessage parameters
string | null$loginHintID of user (optional)
string | null$ltiMessageHintLTI message hint (optional, use null for none)
Returns
array|string Array of signed message parameters or request headers

◆ signParameters()

array string signParameters ( string $url,
string $type,
string $ltiVersionString,
array $params )

Add the signature to an LTI message.

Parameters
string$urlURL for message request
string$typeLTI message type
string$ltiVersionStringLTI version
array$paramsMessage parameters
Returns
array|string Array of signed message parameters or request headers

◆ signServiceRequest()

array string signServiceRequest ( string $url,
string $method,
string $type,
array|string|null $data = null )

Generates the headers for an LTI service request.

Parameters
string$urlURL for message request
string$methodHTTP method
string$typeMedia type
array | string | null$dataData being passed in request body (optional)
Returns
array|string Headers to include with service request

Referenced by AccessToken\hasScope().

◆ useOAuth1()

bool useOAuth1 ( )

Determine whether this consumer is using the OAuth 1 security model.

Returns
bool True if OAuth 1 security model should be used

◆ verifySignature()

bool verifySignature ( )

Verify the signature of a message.

Returns
bool True if the signature is valid

Member Data Documentation

◆ $rsaKey

string $rsaKey = null

RSA key in PEM or JSON format.

Set to the private key for signing outgoing messages and service requests, and to the public key for verifying incoming messages and service requests.

◆ $warnings

array $warnings = []

Warnings relating to last request processed.

Deprecated
Use Util::getMessages() instead