LTI Integration Library 4.10.3
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:
Platform Tool ToolConsumer ToolProvider

Public Member Functions

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

Static Public Member Functions

static parseRoles ($roles, $ltiVersion=Util::LTI_VERSION1, $addPrincipalRole=false)
 Parse a set of roles to comply with a specified version of LTI.
 

Data Fields

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

Protected Attributes

 $jwt = null
 JWT ClientInterface object.
 
 $rawParameters = null
 Raw message parameters.
 
 $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

Definition at line 21 of file System.php.

Member Function Documentation

◆ addSignature()

addSignature (   $endpoint,
  $data,
  $method = 'POST',
  $type = null,
  $nonce = '',
  $hash = null,
  $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

Definition at line 1024 of file System.php.

◆ checkMessage()

checkMessage ( )

Verify the required properties of an LTI message.

Returns
bool True if it is a valid LTI message

Definition at line 1038 of file System.php.

References Util\$LTI_VERSIONS.

◆ doServiceRequest()

doServiceRequest (   $service,
  $method,
  $format,
  $data 
)

Perform a service request.

Parameters
object$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

Definition at line 986 of file System.php.

References Util\jsonDecode().

◆ getJwt()

getJwt ( )

Get the JWT.

Returns
ClientInterface The JWT

Definition at line 352 of file System.php.

References System\$jwt.

◆ getKey()

getKey ( )

Get the consumer key.

Returns
string|null Consumer key value

Definition at line 248 of file System.php.

◆ getMessageClaims()

getMessageClaims (   $fullyQualified = false)

Get the message claims.

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

Definition at line 378 of file System.php.

References System\$messageParameters, System\$ok, Util\jsonDecode(), Util\JWT_CLAIM_MAPPING, Util\JWT_CLAIM_PREFIX, and Util\MESSAGE_TYPE_MAPPING.

◆ getRawParameters()

getRawParameters ( )

Get the raw POST parameters.

Returns
array The POST parameter array

Definition at line 362 of file System.php.

References OAuthRequest\$POST_INPUT, and System\$rawParameters.

◆ getRecordId()

getRecordId ( )

Get the system record ID.

Returns
int|string|null System record ID value

Definition at line 228 of file System.php.

◆ getSetting()

getSetting (   $name,
  $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

Definition at line 271 of file System.php.

References System\$name.

Referenced by Platform\getToolSettings(), Platform\hasAccessTokenService(), Platform\hasToolSettingsService(), System\setSetting(), and Platform\setToolSettings().

◆ getSettings()

getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

Definition at line 306 of file System.php.

◆ hasJwt()

hasJwt ( )

Check whether a JWT exists.

Returns
bool True if a JWT exists

Definition at line 342 of file System.php.

◆ parseRoles()

static parseRoles (   $roles,
  $ltiVersion = Util::LTI_VERSION1,
  $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
string$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

Definition at line 568 of file System.php.

References Util\LTI_VERSION1, Util\LTI_VERSION1P3, and Util\LTI_VERSION2.

Referenced by ResourceLink\getMemberships().

◆ saveSettings()

saveSettings ( )

Save setting values.

Returns
bool True if the settings were successfully saved

Definition at line 326 of file System.php.

References System\$ok.

◆ sendMessage()

sendMessage (   $url,
  $type,
  $messageParams,
  $target = '',
  $userId = null,
  $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

Definition at line 948 of file System.php.

References Util\sendForm().

◆ setKey()

setKey (   $key)

Set the consumer key.

Parameters
string | null$keyConsumer key value

Definition at line 258 of file System.php.

Referenced by ToolConsumer\__construct().

◆ setRecordId()

setRecordId (   $id)

Sets the system record ID.

Parameters
int | string | null$idSystem record ID value

Definition at line 238 of file System.php.

Referenced by ToolConsumer\__construct().

◆ setSetting()

setSetting (   $name,
  $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)

Definition at line 288 of file System.php.

References System\$name, and System\getSetting().

◆ setSettings()

setSettings (   $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

Definition at line 316 of file System.php.

◆ signMessage()

signMessage ( $url,
  $type,
  $version,
  $params,
  $loginHint = null,
  $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$versionLTI 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

Definition at line 889 of file System.php.

References Tool\$defaultTool, and Util\LTI_VERSION1P3.

◆ signParameters()

signParameters (   $url,
  $type,
  $version,
  $params 
)

Add the signature to an LTI message.

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

Definition at line 861 of file System.php.

◆ signServiceRequest()

signServiceRequest (   $url,
  $method,
  $type,
  $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

Definition at line 966 of file System.php.

◆ useOAuth1()

useOAuth1 ( )

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

Returns
bool True if OAuth 1 security model should be used

Definition at line 1006 of file System.php.

◆ verifySignature()

verifySignature ( )

Verify the signature of a message.

Returns
bool True if the signature is valid

Definition at line 1095 of file System.php.

References Tool\$defaultTool.

Field Documentation

◆ $created

int null $created = null

Timestamp for when the object was created.

Definition at line 165 of file System.php.

◆ $dataConnector

◆ $debugMode

bool $debugMode = false

Whether debug level messages are to be reported.

Definition at line 130 of file System.php.

◆ $details

array $details = array()

Details for error message relating to last request processed.

Definition at line 116 of file System.php.

◆ $enabled

bool $enabled = false

Whether the system instance is enabled to accept connection requests.

Definition at line 137 of file System.php.

Referenced by Platform\getIsAvailable(), and Tool\getRegistrationResponsePage().

◆ $enableFrom

int null $enableFrom = null

Timestamp from which the the system instance is enabled to accept connection requests.

Definition at line 144 of file System.php.

◆ $enableUntil

int null $enableUntil = null

Timestamp until which the system instance is enabled to accept connection requests.

Definition at line 151 of file System.php.

◆ $encryptionMethod

string $encryptionMethod = ''

Algorithm used for encrypting messages.

Definition at line 64 of file System.php.

◆ $jku

string null $jku = null

Endpoint for public key.

Definition at line 102 of file System.php.

Referenced by Tool\getConfiguration().

◆ $jwt

ClientInterface null $jwt = null
protected

JWT ClientInterface object.

Definition at line 179 of file System.php.

Referenced by System\getJwt().

◆ $kid

string null $kid = null

Key ID.

Definition at line 95 of file System.php.

◆ $lastAccess

int null $lastAccess = null

Timestamp for date of last connection to this system.

Definition at line 158 of file System.php.

◆ $ltiVersion

string null $ltiVersion = null

LTI version.

Definition at line 36 of file System.php.

◆ $messageParameters

array null $messageParameters = null
protected

LTI message parameters.

Definition at line 193 of file System.php.

Referenced by System\getMessageClaims(), Tool\getMessageParameters(), and Platform\getMessageParameters().

◆ $name

string null $name = null

Local name of platform/tool.

Definition at line 43 of file System.php.

Referenced by Tool\getConfiguration(), System\getSetting(), Tool\setParameterConstraint(), and System\setSetting().

◆ $ok

◆ $rawParameters

array null $rawParameters = null
protected

Raw message parameters.

Definition at line 186 of file System.php.

Referenced by System\getRawParameters().

◆ $reason

string null $reason = null

Error message for last request processed.

Definition at line 109 of file System.php.

◆ $requiredScopes

array $requiredScopes = array()

Scopes to request when obtaining an access token.

Definition at line 88 of file System.php.

◆ $rsaKey

string null $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.

Definition at line 81 of file System.php.

◆ $secret

string null $secret = null

Shared secret.

Definition at line 50 of file System.php.

Referenced by Tool\doToolProxyService().

◆ $signatureMethod

string $signatureMethod = 'HMAC-SHA1'

Method used for signing messages.

Definition at line 57 of file System.php.

◆ $updated

int null $updated = null

Timestamp for when the object was last updated.

Definition at line 172 of file System.php.

◆ $warnings

array $warnings = array()

Warnings relating to last request processed.

Definition at line 123 of file System.php.


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