LTI Integration Library 5.0.0-rc2
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

int null getRecordId ()
 Get the system record ID.
 
 setRecordId ($id)
 Sets the system record ID.
 
string getKey ()
 Get the consumer key.
 
 setKey ($key)
 Set the consumer key.
 
string getSetting ($name, $default='')
 Get a setting value.
 
 setSetting ($name, $value=null)
 Set a setting value.
 
array getSettings ()
 Get an array of all setting values.
 
 setSettings ($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 ($fullyQualified=false)
 Get the message claims.
 
array string signParameters ($url, $type, $version, $params)
 Add the signature to an LTI message.
 
array string signMessage (&$url, $type, $version, $params, $loginHint=null, $ltiMessageHint=null)
 Add the signature to an LTI message.
 
string sendMessage ($url, $type, $messageParams, $target='', $userId=null, $hint=null)
 Generate a web page containing an auto-submitted form of LTI message parameters.
 
string signServiceRequest ($url, $method, $type, $data=null)
 Generates the headers for an LTI service request.
 
HttpMessage doServiceRequest ($service, $method, $format, $data)
 Perform a service request.
 
bool useOAuth1 ()
 Determine whether this consumer is using the OAuth 1 security model.
 
mixed 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.
 
bool checkMessage ()
 Verify the required properties of an LTI message.
 
bool verifySignature ()
 Verify the signature of a message.
 

Static Public Member Functions

static array parseRoles ($roles, $ltiVersion=Util::LTI_VERSION1, $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.
 
string null $secret = null
 Shared secret.
 
string $signatureMethod = 'HMAC-SHA1'
 Method used for signing messages.
 
string $encryptionMethod = ''
 Algorithm used for encrypting messages.
 
DataConnector null $dataConnector = null
 Data connector object.
 
string null $rsaKey = null
 RSA key in PEM or JSON format.
 
array $requiredScopes = array()
 Scopes to request when obtaining an access token.
 
string null $kid = null
 Key ID.
 
string null $jku = null
 Endpoint for public key.
 
string null $reason = null
 Error message for last request processed.
 
array $details = array()
 Details for error message 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 null $enableFrom = null
 Timestamp from which the the system instance is enabled to accept connection requests.
 
int null $enableUntil = null
 Timestamp until which the system instance is enabled to accept connection requests.
 
int null $lastAccess = null
 Timestamp for date of last connection to this system.
 
int null $created = null
 Timestamp for when the object was created.
 
int null $updated = null
 Timestamp for when the object was last updated.
 

Protected Attributes

JWS null $jwt = null
 JWT object, if any.
 
array $rawParameters = null
 Raw message parameters.
 
array null $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()

mixed 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
mixed$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
mixed Array of signed message parameters or header string

◆ checkMessage()

bool checkMessage ( )

Verify the required properties of an LTI message.

Returns
bool True if it is a valid LTI message

◆ doServiceRequest()

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

Perform a service request.

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

◆ getJwt()

ClientInterface getJwt ( )

Get the JWT.

Returns
ClientInterface The JWT

◆ getKey()

string getKey ( )

Get the consumer key.

Returns
string Consumer key value

◆ getMessageClaims()

array 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

◆ getRawParameters()

array getRawParameters ( )

Get the raw POST parameters.

Returns
array The POST parameter array

◆ getRecordId()

int null getRecordId ( )

Get the system record ID.

Returns
int|null System record ID value

◆ getSetting()

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

Get a setting value.

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

Referenced by Platform\getTools().

◆ 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

◆ parseRoles()

static array parseRoles (   $roles,
  $ltiVersion = Util::LTI_VERSION1,
  $addPrincipalRole = false 
)
static

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

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

◆ saveSettings()

bool saveSettings ( )

Save setting values.

Returns
bool True if the settings were successfully saved

◆ sendMessage()

string 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$userIdID of user (optional)
string$hintLTI message hint (optional, use null for none)
Returns
string

◆ setKey()

setKey (   $key)

Set the consumer key.

Parameters
string$keyConsumer key value

Referenced by ToolConsumer\__construct().

◆ setRecordId()

setRecordId (   $id)

Sets the system record ID.

Parameters
int$idSystem record ID value

Referenced by ToolConsumer\__construct().

◆ setSetting()

setSetting (   $name,
  $value = null 
)

Set a setting value.

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

◆ setSettings()

setSettings (   $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

◆ signMessage()

array string 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$loginHintID of user (optional)
string$ltiMessageHintLTI message hint (optional, use null for none)
Returns
array|string Array of signed message parameters or request headers

◆ signParameters()

array string 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

◆ signServiceRequest()

string 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
string$dataData being passed in request body (optional)
Returns
string Headers to include with service request

◆ 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

◆ $created

int null $created = null

Timestamp for when the object was created.

$created

◆ $dataConnector

DataConnector null $dataConnector = null

◆ $debugMode

bool $debugMode = false

Whether debug level messages are to be reported.

$debugMode

◆ $details

array $details = array()

Details for error message relating to last request processed.

$details

◆ $enabled

bool $enabled = false

Whether the system instance is enabled to accept connection requests.

$enabled

Referenced by Tool\fromConsumerKey().

◆ $enableFrom

int null $enableFrom = null

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

$enableFrom

◆ $enableUntil

int null $enableUntil = null

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

$enableUntil

◆ $encryptionMethod

string $encryptionMethod = ''

Algorithm used for encrypting messages.

$encryptionMethod

◆ $jku

string null $jku = null

Endpoint for public key.

$jku

◆ $jwt

JWS null $jwt = null
protected

JWT object, if any.

$jwt

◆ $kid

string null $kid = null

Key ID.

$kid

◆ $lastAccess

int null $lastAccess = null

Timestamp for date of last connection to this system.

$lastAccess

◆ $messageParameters

array null $messageParameters = null
protected

LTI message parameters.

$messageParameters

◆ $ok

bool $ok = true

True if the last request was successful.

$ok

Referenced by Platform\fromPlatformId(), and Platform\getTools().

◆ $rawParameters

array $rawParameters = null
protected

Raw message parameters.

$rawParameters

◆ $reason

string null $reason = null

Error message for last request processed.

$reason

◆ $requiredScopes

array $requiredScopes = array()

Scopes to request when obtaining an access token.

$requiredScopes

◆ $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.

$rsaKey

◆ $secret

string null $secret = null

Shared secret.

$secret

◆ $signatureMethod

string $signatureMethod = 'HMAC-SHA1'

Method used for signing messages.

$signatureMethod

◆ $updated

int null $updated = null

Timestamp for when the object was last updated.

$updated


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