Class to represent an LTI Tool. More...
Public Member Functions | |
__construct (?DataConnector $dataConnector=null) | |
Class constructor. | |
void | initialize () |
Initialise the tool. | |
bool | save () |
Save the tool to the database. | |
bool | delete () |
Delete the tool from the database. | |
array null | getMessageParameters (?bool $strictMode=null, bool $disableCookieCheck=false, bool $generateWarnings=false) |
Get the message parameters. | |
handleRequest (?bool $strictMode=null, bool $disableCookieCheck=false, bool $generateWarnings=false) | |
Process an incoming request. | |
setParameterConstraint (string $name, bool $required=true, ?int $maxLength=null, ?array $messageTypes=null) | |
Add a parameter constraint to be checked on launch. | |
array | getPlatforms () |
Get an array of defined platforms. | |
ServiceDefinition bool | findService (string $format, array $methods) |
Find an offered service based on a media type and HTTP action(s) | |
bool | doToolProxyService () |
Send the tool proxy to the platform. | |
bool | hasCustomQueryParameters () |
Whether a tool has received custom parameters in the query string. | |
![]() | |
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 Tool | fromConsumerKey (?string $key=null, ?DataConnector $dataConnector=null, bool $autoEnable=false) |
Load the tool from the database by its consumer key. | |
static Tool | fromInitiateLoginUrl (string $initiateLoginUrl, ?DataConnector $dataConnector=null, bool $autoEnable=false) |
Load the tool from the database by its initiate login URL. | |
static Tool | fromRecordId (int $id, DataConnector $dataConnector) |
Load the tool from the database by its record ID. | |
![]() | |
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 void | registerApiHook (string $hookName, string $familyCode, string $className) |
Register the availability of an API hook. | |
Public Attributes | |
const | CONNECTION_ERROR_MESSAGE = 'Sorry, there was an error connecting you to the application.' |
Default connection error message. | |
Platform | $platform = null |
Platform object. | |
string | $returnUrl = null |
Return URL provided by platform. | |
UserResult | $userResult = null |
UserResult object. | |
ResourceLink | $resourceLink = null |
Resource link object. | |
Context | $context = null |
Context object. | |
string | $defaultEmail = '' |
Default email domain. | |
bool | $allowSharing = false |
Whether shared resource link arrangements are permitted. | |
string | $message = null |
Message for last request processed. | |
string | $baseUrl = null |
Base URL for tool service. | |
Profile Item | $vendor = null |
Vendor details. | |
Profile Item | $product = null |
Product details. | |
array | $requiredServices = null |
Services required by Tool. | |
array | $optionalServices = null |
Optional services used by Tool. | |
array | $resourceHandlers = null |
Resource handlers for Tool. | |
string | $messageUrl = null |
Message URL for Tool. | |
string | $initiateLoginUrl = null |
Initiate Login request URL for Tool. | |
array | $redirectionUris = null |
Redirection URIs for Tool. | |
![]() | |
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 bool | $allowCustomQueryParameters = false |
True if custom parameters can be passed in the query string. | |
static Tool | $defaultTool = null |
Default tool for use with service requests. | |
static bool | $authenticateUsingGet = false |
Use GET method for authentication request messages when true. | |
static int | $stateLife = 10 |
Life in seconds for the state value issued during the OIDC login process. | |
static int | $postMessageTimeoutDelay = 20 |
Period in milliseconds to wait for a response to a postMessage. | |
![]() | |
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 | onLaunch () |
Process a valid launch request. | |
void | onConfigure () |
Process a valid configure request. | |
void | onDashboard () |
Process a valid dashboard request. | |
void | onContentItem () |
Process a valid content-item request. | |
void | onContentItemUpdate () |
Process a valid content-item update request. | |
void | onSubmissionReview () |
Process a valid submission review request. | |
void | onRegistration () |
Process a dynamic registration request. | |
onLtiStartProctoring () | |
Process a valid start proctoring request. | |
void | onLtiEndAssessment () |
Process a valid end assessment request. | |
void | onInitiateLogin (array $requestParameters, array &$authParameters) |
Process a login initiation request. | |
void | onAuthenticate (string $state, string $nonce, bool $usePlatformStorage) |
Process response to an authentication request. | |
void | onResetSessionId () |
Process a change in the session ID. | |
void | onError () |
Process a response to an invalid request. | |
array null | getPlatformConfiguration () |
Fetch a platform's configuration data. | |
array | getConfiguration (array $platformConfig) |
Prepare the tool's configuration data. | |
array null | sendRegistration (array $platformConfig, array $toolConfig) |
Send the tool registration to the platform. | |
Platform | getPlatformToRegister (array $platformConfig, array $registrationConfig, bool $doSave=true) |
Initialise the platform to be registered. | |
void | getRegistrationResponsePage (array $toolConfig) |
Prepare the page to complete a registration request. | |
Protected Attributes | |
string | $redirectUrl = null |
URL to redirect user to on successful completion of the request. | |
array | $mediaTypes = null |
Media types accepted by the platform. | |
array | $contentTypes = null |
Content item types accepted by the platform. | |
array | $fileTypes = null |
File types accepted by the platform. | |
array | $documentTargets = null |
Document targets accepted by the platform. | |
string | $output = null |
Default HTML to be displayed on a successful completion of the request. | |
string | $errorOutput = null |
HTML to be displayed on an unsuccessful completion of the request and no return URL is available. | |
![]() | |
ClientInterface | $jwt = null |
JWT ClientInterface object. | |
array | $rawParameters = null |
Raw message parameters. | |
array | $messageParameters = null |
LTI message parameters. | |
Class to represent an LTI Tool.
ceLTIc\LTI\Tool::__construct | ( | ?DataConnector | $dataConnector = null | ) |
Class constructor.
DataConnector | $dataConnector | Object containing a database connection object |
bool ceLTIc\LTI\Tool::delete | ( | ) |
Delete the tool from the database.
bool ceLTIc\LTI\Tool::doToolProxyService | ( | ) |
Send the tool proxy to the platform.
References onError(), onLaunch(), and ceLTIc\LTI\System\setReason().
ServiceDefinition bool ceLTIc\LTI\Tool::findService | ( | string | $format, |
array | $methods ) |
Find an offered service based on a media type and HTTP action(s)
string | $format | Media type required |
array | $methods | Array of HTTP actions required |
References ceLTIc\LTI\System\$ok, ceLTIc\LTI\System\$secret, findService(), and ceLTIc\LTI\Util\getRandomString().
Referenced by findService().
|
static |
Load the tool from the database by its consumer key.
string | null | $key | Consumer key |
DataConnector | $dataConnector | A data connector object |
bool | $autoEnable | True if the tool is to be enabled automatically (optional, default is false) |
References ceLTIc\LTI\System\$dataConnector, fromRecordId(), and ceLTIc\LTI\System\setRecordId().
|
static |
Load the tool from the database by its initiate login URL.
string | $initiateLoginUrl | The initiate login URL |
DataConnector | $dataConnector | A data connector object |
bool | $autoEnable | True if the tool is to be enabled automatically (optional, default is false) |
References onError().
|
static |
Load the tool from the database by its record ID.
int | $id | The tool record ID |
DataConnector | $dataConnector | A data connector object |
Referenced by fromConsumerKey().
|
protected |
Prepare the tool's configuration data.
array | $platformConfig | Platform configuration data |
References $message.
Referenced by onDashboard().
array null ceLTIc\LTI\Tool::getMessageParameters | ( | ?bool | $strictMode = null, |
bool | $disableCookieCheck = false, | ||
bool | $generateWarnings = false ) |
Get the message parameters.
bool | null | $strictMode | True if full compliance with the LTI specification is required (optional, default is the Util::$strictMode setting) |
bool | $disableCookieCheck | True if no cookie check should be made (optional, default is false) |
bool | $generateWarnings | True if warning messages should be generated (optional, default is false) |
References ceLTIc\LTI\Util\$logLevel, ceLTIc\LTI\Util\$strictMode, getMessageParameters(), ceLTIc\LTI\Util\getRequestParameters(), ceLTIc\LTI\Util\logRequest(), onRegistration(), and ceLTIc\LTI\System\setReason().
Referenced by getMessageParameters().
|
protected |
Fetch a platform's configuration data.
References ceLTIc\LTI\System\setReason().
Referenced by onDashboard().
array ceLTIc\LTI\Tool::getPlatforms | ( | ) |
Get an array of defined platforms.
|
protected |
Initialise the platform to be registered.
array | $platformConfig | Platform configuration data |
array | $registrationConfig | Registration data |
bool | $doSave | True if the platform should be saved (optional, default is true) |
References ceLTIc\LTI\System\$enabled, and getRegistrationResponsePage().
Referenced by onContentItem().
|
protected |
Prepare the page to complete a registration request.
array | $toolConfig | Tool configuration data |
Referenced by getPlatformToRegister().
ceLTIc\LTI\Tool::handleRequest | ( | ?bool | $strictMode = null, |
bool | $disableCookieCheck = false, | ||
bool | $generateWarnings = false ) |
Process an incoming request.
bool | null | $strictMode | True if full compliance with the LTI specification is required (optional, default is the Util::$strictMode setting) |
bool | $disableCookieCheck | True if no cookie check should be made (optional, default is false) |
bool | $generateWarnings | True if warning messages should be generated (optional, default is false) |
bool ceLTIc\LTI\Tool::hasCustomQueryParameters | ( | ) |
Whether a tool has received custom parameters in the query string.
References onError(), and ceLTIc\LTI\System\setReason().
void ceLTIc\LTI\Tool::initialize | ( | ) |
Initialise the tool.
|
protected |
Process response to an authentication request.
string | $state | State value |
string | $nonce | Nonce value |
bool | $usePlatformStorage | True if platform storage is being used |
References onResetSessionId().
Referenced by onLtiEndAssessment().
|
protected |
Process a valid configure request.
References onError(), onSubmissionReview(), and ceLTIc\LTI\System\setReason().
|
protected |
Process a valid content-item request.
References getPlatformToRegister(), and sendRegistration().
|
protected |
Process a valid content-item update request.
References onError(), onLtiStartProctoring(), and ceLTIc\LTI\System\setReason().
Referenced by onLaunch().
|
protected |
Process a valid dashboard request.
References getConfiguration(), getPlatformConfiguration(), and onRegistration().
|
protected |
Process a response to an invalid request.
Referenced by doToolProxyService(), fromInitiateLoginUrl(), hasCustomQueryParameters(), onConfigure(), onContentItemUpdate(), onLaunch(), and onSubmissionReview().
|
protected |
Process a login initiation request.
array | $requestParameters | Request parameters |
array | $authParameters | Authentication request parameters |
References ceLTIc\LTI\System\setReason().
Referenced by onRegistration().
|
protected |
Process a valid launch request.
References onContentItemUpdate(), onError(), and ceLTIc\LTI\System\setReason().
Referenced by doToolProxyService().
|
protected |
Process a valid end assessment request.
References onAuthenticate(), and ceLTIc\LTI\Util\sendForm().
Referenced by onSubmissionReview().
|
protected |
Process a valid start proctoring request.
Referenced by onContentItemUpdate().
|
protected |
Process a dynamic registration request.
References onInitiateLogin().
Referenced by getMessageParameters(), and onDashboard().
|
protected |
Process a change in the session ID.
References ceLTIc\LTI\System\setReason().
Referenced by onAuthenticate().
|
protected |
Process a valid submission review request.
References onError(), onLtiEndAssessment(), and ceLTIc\LTI\System\setReason().
Referenced by onConfigure().
bool ceLTIc\LTI\Tool::save | ( | ) |
Save the tool to the database.
References ceLTIc\LTI\Util\$logLevel.
|
protected |
Send the tool registration to the platform.
array | $platformConfig | Platform configuration data |
array | $toolConfig | Tool configuration data |
Referenced by onContentItem().
ceLTIc\LTI\Tool::setParameterConstraint | ( | string | $name, |
bool | $required = true, | ||
?int | $maxLength = null, | ||
?array | $messageTypes = null ) |
Add a parameter constraint to be checked on launch.
string | $name | Name of parameter to be checked |
bool | $required | True if parameter is required (optional, default is true) |
int | null | $maxLength | Maximum permitted length of parameter value (optional, default is null) |
array | null | $messageTypes | Array of message types to which the constraint applies (optional, default is all) |
|
static |
True if custom parameters can be passed in the query string.
bool ceLTIc\LTI\Tool::$allowSharing = false |
Whether shared resource link arrangements are permitted.
|
static |
Use GET method for authentication request messages when true.
string ceLTIc\LTI\Tool::$baseUrl = null |
Base URL for tool service.
|
protected |
Content item types accepted by the platform.
Context ceLTIc\LTI\Tool::$context = null |
Context object.
string ceLTIc\LTI\Tool::$defaultEmail = '' |
Default email domain.
|
static |
Default tool for use with service requests.
Referenced by ceLTIc\LTI\AccessToken\hasScope(), and ceLTIc\LTI\AccessToken\load().
|
protected |
Document targets accepted by the platform.
|
protected |
HTML to be displayed on an unsuccessful completion of the request and no return URL is available.
|
protected |
File types accepted by the platform.
string ceLTIc\LTI\Tool::$initiateLoginUrl = null |
Initiate Login request URL for Tool.
|
protected |
Media types accepted by the platform.
string ceLTIc\LTI\Tool::$message = null |
Message for last request processed.
Referenced by getConfiguration().
|
static |
List of supported incoming message types.
string ceLTIc\LTI\Tool::$messageUrl = null |
Message URL for Tool.
array ceLTIc\LTI\Tool::$optionalServices = null |
Optional services used by Tool.
|
protected |
Default HTML to be displayed on a successful completion of the request.
Platform ceLTIc\LTI\Tool::$platform = null |
Platform object.
|
static |
Period in milliseconds to wait for a response to a postMessage.
Profile Item ceLTIc\LTI\Tool::$product = null |
Product details.
array ceLTIc\LTI\Tool::$redirectionUris = null |
Redirection URIs for Tool.
|
protected |
URL to redirect user to on successful completion of the request.
array ceLTIc\LTI\Tool::$requiredServices = null |
Services required by Tool.
array ceLTIc\LTI\Tool::$resourceHandlers = null |
Resource handlers for Tool.
ResourceLink ceLTIc\LTI\Tool::$resourceLink = null |
Resource link object.
string ceLTIc\LTI\Tool::$returnUrl = null |
Return URL provided by platform.
|
static |
Life in seconds for the state value issued during the OIDC login process.
UserResult ceLTIc\LTI\Tool::$userResult = null |
UserResult object.
Profile Item ceLTIc\LTI\Tool::$vendor = null |
Vendor details.
const ceLTIc\LTI\Tool::CONNECTION_ERROR_MESSAGE = 'Sorry, there was an error connecting you to the application.' |
Default connection error message.