LTI Integration Library 5.2.0
PHP class library for building LTI integrations
 
All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Loading...
Searching...
No Matches
ceLTIc\LTI\Platform Class Reference

Class to represent a platform. More...

+ Inheritance diagram for ceLTIc\LTI\Platform:

Public Member Functions

 __construct (?DataConnector $dataConnector=null)
 Class constructor.
 
void initialize ()
 Initialise the platform.
 
void initialise ()
 Initialise the platform.
 
bool save ()
 Save the platform to the database.
 
bool delete ()
 Delete the platform from the database.
 
string null getId ()
 Get the platform ID.
 
string getFamilyCode ()
 Get platform family code (as reported by last platform connection).
 
DataConnector null getDataConnector ()
 Get the data connector.
 
AccessToken null getAccessToken ()
 Get the authorization access token.
 
void setAccessToken (AccessToken $accessToken)
 Set the authorization access token.
 
bool getIsAvailable ()
 Is the platform available to accept launch requests?
 
bool hasToolSettingsService ()
 Check if the Tool Settings service is supported.
 
array bool getToolSettings (bool $simple=true)
 Get Tool Settings.
 
bool setToolSettings (array $settings=[])
 Set Tool Settings.
 
array getTools ()
 Get an array of defined tools.
 
bool hasAccessTokenService ()
 Check if the Access Token service is supported.
 
array null getMessageParameters ()
 Get the message parameters.
 
void handleRequest (bool $generateWarnings=false)
 Process an incoming request.
 
- Public Member Functions inherited from ceLTIc\LTI\System
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 Platform fromConsumerKey (?string $key=null, ?DataConnector $dataConnector=null, bool $autoEnable=false)
 Load the platform from the database by its consumer key.
 
static Platform fromPlatformId (string $platformId, ?string $clientId, ?string $deploymentId, ?DataConnector $dataConnector=null, bool $autoEnable=false)
 Load the platform from the database by its platform, client and deployment IDs.
 
static Platform fromRecordId (int|string $id, DataConnector $dataConnector)
 Load the platform from the database by its record ID.
 
static string getStorageJS ()
 Get the JavaScript for handling storage postMessages from a tool.
 
- Static Public Member Functions inherited from ceLTIc\LTI\System
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.
 
- Static Public Member Functions inherited from ceLTIc\LTI\ApiHook\ApiHook
static void registerApiHook (string $hookName, string $familyCode, string $className)
 Register the availability of an API hook.
 

Public Attributes

string $platformId = null
 Platform ID.
 
string $clientId = null
 Client ID.
 
string $deploymentId = null
 Deployment ID.
 
string $authorizationServerId = null
 Authorization server ID.
 
string $authenticationUrl = null
 Login authentication URL.
 
string $accessTokenUrl = null
 Access Token service URL.
 
string $consumerName = null
 Name of platform (as reported by last platform connection).
 
string $consumerVersion = null
 Platform version (as reported by last platform connection).
 
object $profile = null
 The platform profile data.
 
string $toolProxy = null
 The tool proxy.
 
string $consumerGuid = null
 Platform GUID (as reported by first platform connection).
 
string $cssPath = null
 Optional CSS path (as reported by last platform connection).
 
bool $protected = false
 Whether the platform instance is protected by matching the consumer_guid value in incoming requests.
 
string $defaultEmail = ''
 Default email address (or email domain) to use when no email address is provided for a user.
 
HttpMessage $lastServiceRequest = null
 HttpMessage object for last service request.
 
- Public Attributes inherited from ceLTIc\LTI\System
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.
 

Static Public Attributes

static array $MESSAGE_TYPES
 List of supported incoming message types.
 
static string $browserStorageFrame = null
 Name of browser storage frame.
 
- Static Public Attributes inherited from ceLTIc\LTI\ApiHook\ApiHook
static string $USER_ID_HOOK = "UserId"
 User Id hook name.
 
static string $CONTEXT_ID_HOOK = "ContextId"
 Context Id hook name.
 
static string $GROUPS_SERVICE_HOOK = "Groups"
 Course Groups service hook name.
 
static string $MEMBERSHIPS_SERVICE_HOOK = "Memberships"
 Memberships service hook name.
 
static string $OUTCOMES_SERVICE_HOOK = "Outcomes"
 Outcomes service hook name.
 
static string $TOOL_SETTINGS_SERVICE_HOOK = "ToolSettings"
 Tool Settings service hook name.
 
static string $ACCESS_TOKEN_SERVICE_HOOK = "AccessToken"
 Access Token service hook name.
 

Protected Member Functions

void onInitiateLogin (string &$url, string &$loginHint, ?string &$ltiMessageHint, array $params)
 Save the hint and message parameters when sending an initiate login request.
 
void onAuthenticate ()
 Check the hint and recover the message parameters for an authentication request.
 
void onContentItem ()
 Process a valid content-item message.
 
void onLtiStartAssessment ()
 Process a valid start assessment message.
 
void onError ()
 Process a response to an invalid message.
 

Additional Inherited Members

- Protected Attributes inherited from ceLTIc\LTI\System
ClientInterface $jwt = null
 JWT ClientInterface object.
 
array $rawParameters = null
 Raw message parameters.
 
array $messageParameters = null
 LTI message parameters.
 

Detailed Description

Class to represent a platform.

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

Constructor & Destructor Documentation

◆ __construct()

ceLTIc\LTI\Platform::__construct ( ?DataConnector $dataConnector = null)

Class constructor.

Parameters
DataConnector | null$dataConnectorA data connector object

Member Function Documentation

◆ delete()

bool ceLTIc\LTI\Platform::delete ( )

Delete the platform from the database.

Returns
bool True if the object was successfully deleted

References $consumerVersion.

◆ fromConsumerKey()

static Platform ceLTIc\LTI\Platform::fromConsumerKey ( ?string $key = null,
?DataConnector $dataConnector = null,
bool $autoEnable = false )
static

Load the platform from the database by its consumer key.

Parameters
string | null$keyConsumer key
DataConnector$dataConnectorA data connector object
bool$autoEnableTrue if the platform is to be enabled automatically (optional, default is false)
Returns
Platform The platform object

◆ fromPlatformId()

static Platform ceLTIc\LTI\Platform::fromPlatformId ( string $platformId,
?string $clientId,
?string $deploymentId,
?DataConnector $dataConnector = null,
bool $autoEnable = false )
static

Load the platform from the database by its platform, client and deployment IDs.

Parameters
string$platformIdThe platform ID
string | null$clientIdThe client ID
string | null$deploymentIdThe deployment ID
DataConnector$dataConnectorA data connector object
bool$autoEnableTrue if the platform is to be enabled automatically (optional, default is false)
Returns
Platform The platform object

◆ fromRecordId()

static Platform ceLTIc\LTI\Platform::fromRecordId ( int|string $id,
DataConnector $dataConnector )
static

Load the platform from the database by its record ID.

Parameters
int | string$idThe platform record ID
DataConnector$dataConnectorA data connector object
Returns
Platform The platform object

◆ getAccessToken()

AccessToken null ceLTIc\LTI\Platform::getAccessToken ( )

Get the authorization access token.

Returns
AccessToken|null Access token

References getFamilyCode(), and ceLTIc\LTI\System\getSetting().

◆ getDataConnector()

DataConnector null ceLTIc\LTI\Platform::getDataConnector ( )

Get the data connector.

Returns
DataConnector|null Data connector object or string

References ceLTIc\LTI\System\$ok.

◆ getFamilyCode()

string ceLTIc\LTI\Platform::getFamilyCode ( )

Get platform family code (as reported by last platform connection).

Returns
string Family code

Referenced by getAccessToken(), and hasToolSettingsService().

◆ getId()

string null ceLTIc\LTI\Platform::getId ( )

Get the platform ID.

The ID will be the consumer key if one exists, otherwise a concatenation of the platform/client/deployment IDs

Returns
string|null Platform ID value

References ceLTIc\LTI\System\$dataConnector.

◆ getIsAvailable()

bool ceLTIc\LTI\Platform::getIsAvailable ( )

Is the platform available to accept launch requests?

Returns
bool True if the platform is enabled and within any date constraints

References ceLTIc\LTI\System\$ok, and ceLTIc\LTI\System\getSetting().

◆ getMessageParameters()

array null ceLTIc\LTI\Platform::getMessageParameters ( )

Get the message parameters.

Returns
array|null The message parameter array

◆ getStorageJS()

static string ceLTIc\LTI\Platform::getStorageJS ( )
static

Get the JavaScript for handling storage postMessages from a tool.

Returns
string The JavaScript to handle storage postMessages

◆ getTools()

array ceLTIc\LTI\Platform::getTools ( )

Get an array of defined tools.

Returns
array Array of Tool objects

References ceLTIc\LTI\Util\$logLevel, and ceLTIc\LTI\Util\getRequestParameters().

◆ getToolSettings()

array bool ceLTIc\LTI\Platform::getToolSettings ( bool $simple = true)

Get Tool Settings.

Parameters
bool$simpleTrue if all the simple media type is to be used (optional, default is true)
Returns
array|bool The array of settings if successful, otherwise false

References ceLTIc\LTI\System\$ok.

◆ handleRequest()

void ceLTIc\LTI\Platform::handleRequest ( bool $generateWarnings = false)

Process an incoming request.

Parameters
bool$generateWarningsTrue if warning messages should be generated (optional, default is false)

References ceLTIc\LTI\System\$dataConnector, and ceLTIc\LTI\System\$ok.

◆ hasAccessTokenService()

bool ceLTIc\LTI\Platform::hasAccessTokenService ( )

Check if the Access Token service is supported.

Returns
bool True if this platform supports the Access Token service

◆ hasToolSettingsService()

bool ceLTIc\LTI\Platform::hasToolSettingsService ( )

Check if the Tool Settings service is supported.

Returns
bool True if this platform supports the Tool Settings service

References ceLTIc\LTI\System\$ok, getFamilyCode(), and ceLTIc\LTI\System\getSetting().

◆ initialise()

void ceLTIc\LTI\Platform::initialise ( )

Initialise the platform.

Synonym for initialize().

References $clientId.

◆ initialize()

void ceLTIc\LTI\Platform::initialize ( )

Initialise the platform.

References initialize().

Referenced by initialize().

◆ onAuthenticate()

void ceLTIc\LTI\Platform::onAuthenticate ( )
protected

Check the hint and recover the message parameters for an authentication request.

Override this method if the data has been saved elsewhere.

References onLtiStartAssessment().

◆ onContentItem()

void ceLTIc\LTI\Platform::onContentItem ( )
protected

Process a valid content-item message.

Referenced by onInitiateLogin().

◆ onError()

void ceLTIc\LTI\Platform::onError ( )
protected

Process a response to an invalid message.

◆ onInitiateLogin()

void ceLTIc\LTI\Platform::onInitiateLogin ( string & $url,
string & $loginHint,
?string & $ltiMessageHint,
array $params )
protected

Save the hint and message parameters when sending an initiate login request.

Override this method to save the data elsewhere.

Parameters
string$urlThe message URL
string$loginHintThe ID of the user
string | null$ltiMessageHintThe message hint being sent to the tool
array$paramsAn associative array of message parameters

References onContentItem().

◆ onLtiStartAssessment()

void ceLTIc\LTI\Platform::onLtiStartAssessment ( )
protected

Process a valid start assessment message.

Referenced by onAuthenticate().

◆ save()

bool ceLTIc\LTI\Platform::save ( )

Save the platform to the database.

Returns
bool True if the object was successfully saved

◆ setAccessToken()

void ceLTIc\LTI\Platform::setAccessToken ( AccessToken $accessToken)

Set the authorization access token.

Parameters
AccessToken$accessTokenAccess token

◆ setToolSettings()

bool ceLTIc\LTI\Platform::setToolSettings ( array $settings = [])

Set Tool Settings.

Parameters
array$settingsAn associative array of settings (optional, default is none)
Returns
bool True if action was successful, otherwise false

Member Data Documentation

◆ $accessTokenUrl

string ceLTIc\LTI\Platform::$accessTokenUrl = null

Access Token service URL.

◆ $authenticationUrl

string ceLTIc\LTI\Platform::$authenticationUrl = null

Login authentication URL.

◆ $authorizationServerId

string ceLTIc\LTI\Platform::$authorizationServerId = null

Authorization server ID.

◆ $browserStorageFrame

string ceLTIc\LTI\Platform::$browserStorageFrame = null
static

Name of browser storage frame.

◆ $clientId

string ceLTIc\LTI\Platform::$clientId = null

Client ID.

Referenced by initialise().

◆ $consumerGuid

string ceLTIc\LTI\Platform::$consumerGuid = null

Platform GUID (as reported by first platform connection).

◆ $consumerName

string ceLTIc\LTI\Platform::$consumerName = null

Name of platform (as reported by last platform connection).

◆ $consumerVersion

string ceLTIc\LTI\Platform::$consumerVersion = null

Platform version (as reported by last platform connection).

Referenced by delete().

◆ $cssPath

string ceLTIc\LTI\Platform::$cssPath = null

Optional CSS path (as reported by last platform connection).

◆ $defaultEmail

string ceLTIc\LTI\Platform::$defaultEmail = ''

Default email address (or email domain) to use when no email address is provided for a user.

◆ $deploymentId

string ceLTIc\LTI\Platform::$deploymentId = null

Deployment ID.

◆ $lastServiceRequest

HttpMessage ceLTIc\LTI\Platform::$lastServiceRequest = null

HttpMessage object for last service request.

◆ $MESSAGE_TYPES

array ceLTIc\LTI\Platform::$MESSAGE_TYPES
static
Initial value:
= [
'ContentItemSelection',
'LtiStartAssessment'
]

List of supported incoming message types.

◆ $platformId

string ceLTIc\LTI\Platform::$platformId = null

Platform ID.

◆ $profile

object ceLTIc\LTI\Platform::$profile = null

The platform profile data.

◆ $protected

bool ceLTIc\LTI\Platform::$protected = false

Whether the platform instance is protected by matching the consumer_guid value in incoming requests.

◆ $toolProxy

string ceLTIc\LTI\Platform::$toolProxy = null

The tool proxy.