Class to represent an LTI system. More...
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. | |
Class to represent an LTI system.
array string ceLTIc\LTI\System::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 | $endpoint | URL to which message is being sent |
array | string | null | $data | Data to be passed |
string | $method | HTTP method |
string | null | $type | Content type of data being passed |
string | null | $nonce | Nonce value for JWT |
string | null | $hash | OAuth body hash value |
int | null | $timestamp | Timestamp |
References setReason().
Referenced by sendMessage().
bool ceLTIc\LTI\System::checkMessage | ( | bool | $generateWarnings = false | ) |
Verify the required properties of an LTI message.
bool | $generateWarnings | True if warning messages should be generated |
References $secret.
Referenced by useOAuth1().
HttpMessage ceLTIc\LTI\System::doServiceRequest | ( | ServiceDefinition | $service, |
string | $method, | ||
string | $format, | ||
array|string | $data ) |
Perform a service request.
ServiceDefinition | $service | Service object to be executed |
string | $method | HTTP action |
string | $format | Media type |
array | string | $data | Array of parameters or body string |
References useOAuth1().
Referenced by sendMessage().
string null ceLTIc\LTI\System::getBaseString | ( | ) |
Get the last signature base string.
ClientInterface ceLTIc\LTI\System::getJwt | ( | ) |
string null ceLTIc\LTI\System::getKey | ( | ) |
Get the consumer key.
References $name, getSetting(), and setSetting().
Referenced by ceLTIc\LTI\ResourceLink\getContextId().
array ceLTIc\LTI\System::getMessageClaims | ( | bool | $fullyQualified = false | ) |
Get the message claims.
bool | $fullyQualified | True if claims should be fully qualified rather than grouped (default is false) |
array ceLTIc\LTI\System::getRawParameters | ( | ) |
Get the raw POST parameters.
References $messageParameters.
Referenced by setSettings().
int string null ceLTIc\LTI\System::getRecordId | ( | ) |
Get the system record ID.
References $name, and getSetting().
Referenced by ceLTIc\LTI\DataConnector\DataConnector\deleteResourceLink(), ceLTIc\LTI\DataConnector\DataConnector_mysqli\getSharesResourceLink(), ceLTIc\LTI\DataConnector\DataConnector_oci8\getSharesResourceLink(), ceLTIc\LTI\DataConnector\DataConnector_pdo\getSharesResourceLink(), ceLTIc\LTI\DataConnector\DataConnector_pgsql\getSharesResourceLink(), ceLTIc\LTI\DataConnector\DataConnector_sql\getSharesResourceLink(), ceLTIc\LTI\DataConnector\DataConnector_mysqli\loadAccessToken(), ceLTIc\LTI\DataConnector\DataConnector_oci8\loadAccessToken(), ceLTIc\LTI\DataConnector\DataConnector_pdo\loadAccessToken(), ceLTIc\LTI\DataConnector\DataConnector_pgsql\loadAccessToken(), ceLTIc\LTI\DataConnector\DataConnector_sql\loadAccessToken(), ceLTIc\LTI\DataConnector\DataConnector\loadPlatformNonce(), ceLTIc\LTI\DataConnector\DataConnector_mysqli\loadPlatformNonce(), ceLTIc\LTI\DataConnector\DataConnector_oci8\loadPlatformNonce(), ceLTIc\LTI\DataConnector\DataConnector_pdo\loadPlatformNonce(), ceLTIc\LTI\DataConnector\DataConnector_pgsql\loadPlatformNonce(), ceLTIc\LTI\DataConnector\DataConnector_sql\loadPlatformNonce(), ceLTIc\LTI\DataConnector\DataConnector\savePlatformNonce(), ceLTIc\LTI\DataConnector\DataConnector_mysqli\savePlatformNonce(), and ceLTIc\LTI\DataConnector\DataConnector_sql\savePlatformNonce().
string null ceLTIc\LTI\System::getSetting | ( | string | $name, |
?string | $default = '' ) |
Get a setting value.
string | $name | Name of setting |
string | null | $default | Value to return if the setting does not exist (optional, default is an empty string) |
Referenced by ceLTIc\LTI\Platform\getAccessToken(), ceLTIc\LTI\Platform\getIsAvailable(), getKey(), getRecordId(), and ceLTIc\LTI\Platform\hasToolSettingsService().
array ceLTIc\LTI\System::getSettings | ( | ) |
Get an array of all setting values.
bool ceLTIc\LTI\System::hasJwt | ( | ) |
Check whether a JWT exists.
References $messageParameters, and ceLTIc\LTI\Util\MESSAGE_TYPE_MAPPING.
|
static |
Parse a set of roles to comply with a specified version of LTI.
array | string | $roles | Comma-separated list of roles or array of roles |
LtiVersion | $ltiVersion | LTI version for roles being returned (optional, default is LTI-1p0) |
bool | $addPrincipalRole | Add principal role when true (optional, default is false) |
References $ltiVersion.
bool ceLTIc\LTI\System::saveSettings | ( | ) |
Save setting values.
Referenced by setSetting().
string ceLTIc\LTI\System::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.
string | $url | URL to which the form should be submitted |
string | $type | LTI message type |
array | $messageParams | Array of form parameters |
string | $target | Name of target (optional) |
string | null | $userId | ID of user (optional) |
string | null | $hint | LTI message hint (optional, use null for none) |
References addSignature(), doServiceRequest(), and ceLTIc\LTI\Util\jsonDecode().
void ceLTIc\LTI\System::setKey | ( | ?string | $key | ) |
Set the consumer key.
string | null | $key | Consumer key value |
bool ceLTIc\LTI\System::setReason | ( | string | $reason | ) |
Set the error reason.
string | $reason | Reason value |
Referenced by addSignature(), ceLTIc\LTI\Tool\doToolProxyService(), ceLTIc\LTI\Tool\getMessageParameters(), ceLTIc\LTI\Tool\getPlatformConfiguration(), ceLTIc\LTI\Tool\hasCustomQueryParameters(), ceLTIc\LTI\Tool\onConfigure(), ceLTIc\LTI\Tool\onContentItemUpdate(), ceLTIc\LTI\Tool\onInitiateLogin(), ceLTIc\LTI\Tool\onLaunch(), ceLTIc\LTI\Tool\onResetSessionId(), ceLTIc\LTI\Tool\onSubmissionReview(), and useOAuth1().
void ceLTIc\LTI\System::setRecordId | ( | int|string|null | $id | ) |
Sets the system record ID.
int | string | null | $id | System record ID value |
Referenced by ceLTIc\LTI\Tool\fromConsumerKey().
void ceLTIc\LTI\System::setSetting | ( | string | $name, |
string|array|null | $value = null ) |
Set a setting value.
string | $name | Name of setting |
string | array | null | $value | Value to set, use an empty value to delete a setting (optional, default is null) |
References $ok, and saveSettings().
Referenced by getKey().
void ceLTIc\LTI\System::setSettings | ( | array | $settings | ) |
Set an array of all setting values.
array | $settings | Associative array of setting values |
References ceLTIc\LTI\OAuth\OAuthRequest\$POST_INPUT, getRawParameters(), and ceLTIc\LTI\OAuth\OAuthUtil\parse_parameters().
array string ceLTIc\LTI\System::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.
string | $url | URL for message request |
string | $type | LTI message type |
string | $ltiVersionString | LTI version |
array | $params | Message parameters |
string | null | $loginHint | ID of user (optional) |
string | null | $ltiMessageHint | LTI message hint (optional, use null for none) |
array string ceLTIc\LTI\System::signParameters | ( | string | $url, |
string | $type, | ||
string | $ltiVersionString, | ||
array | $params ) |
Add the signature to an LTI message.
string | $url | URL for message request |
string | $type | LTI message type |
string | $ltiVersionString | LTI version |
array | $params | Message parameters |
array string ceLTIc\LTI\System::signServiceRequest | ( | string | $url, |
string | $method, | ||
string | $type, | ||
array|string|null | $data = null ) |
Generates the headers for an LTI service request.
string | $url | URL for message request |
string | $method | HTTP method |
string | $type | Media type |
array | string | null | $data | Data being passed in request body (optional) |
References useOAuth1().
bool ceLTIc\LTI\System::useOAuth1 | ( | ) |
Determine whether this consumer is using the OAuth 1 security model.
References checkMessage(), and setReason().
Referenced by doServiceRequest(), and signServiceRequest().
bool ceLTIc\LTI\System::verifySignature | ( | ) |
Verify the signature of a message.
References ceLTIc\LTI\OAuth\OAuthRequest\from_request().
int ceLTIc\LTI\System::$created = null |
Timestamp for when the object was created.
DataConnector ceLTIc\LTI\System::$dataConnector = null |
Data connector object.
Referenced by ceLTIc\LTI\Tool\fromConsumerKey(), ceLTIc\LTI\Platform\getId(), and ceLTIc\LTI\Platform\handleRequest().
bool ceLTIc\LTI\System::$debugMode = false |
Whether debug level messages are to be reported.
array ceLTIc\LTI\System::$details = [] |
Details for error message relating to last request processed.
bool ceLTIc\LTI\System::$enabled = false |
Whether the system instance is enabled to accept connection requests.
Referenced by ceLTIc\LTI\Tool\getPlatformToRegister().
int ceLTIc\LTI\System::$enableFrom = null |
Timestamp from which the the system instance is enabled to accept connection requests.
int ceLTIc\LTI\System::$enableUntil = null |
Timestamp until which the system instance is enabled to accept connection requests.
string ceLTIc\LTI\System::$encryptionMethod = '' |
Algorithm used for encrypting messages.
IdScope ceLTIc\LTI\System::$idScope = IdScope::IdOnly |
Default scope to use when generating an Id value for a user.
string ceLTIc\LTI\System::$jku = null |
Endpoint for public key.
|
protected |
JWT ClientInterface object.
string ceLTIc\LTI\System::$kid = null |
Key ID.
int ceLTIc\LTI\System::$lastAccess = null |
Timestamp for date of last connection to this system.
LtiVersion ceLTIc\LTI\System::$ltiVersion = null |
LTI version.
Referenced by parseRoles().
|
protected |
LTI message parameters.
Referenced by getJwt(), getRawParameters(), and hasJwt().
string ceLTIc\LTI\System::$name = null |
Local name of platform/tool.
Referenced by getKey(), and getRecordId().
bool ceLTIc\LTI\System::$ok = true |
True if the last request was successful.
Referenced by ceLTIc\LTI\Tool\findService(), ceLTIc\LTI\Platform\getDataConnector(), ceLTIc\LTI\Platform\getIsAvailable(), ceLTIc\LTI\Platform\getToolSettings(), ceLTIc\LTI\Platform\handleRequest(), ceLTIc\LTI\Platform\hasToolSettingsService(), and setSetting().
|
protected |
Raw message parameters.
string ceLTIc\LTI\System::$reason = null |
Error message for last request processed.
array ceLTIc\LTI\System::$requiredScopes = [] |
Scopes to request when obtaining an access token.
string ceLTIc\LTI\System::$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.
string ceLTIc\LTI\System::$secret = null |
Shared secret.
Referenced by checkMessage(), and ceLTIc\LTI\Tool\findService().
string ceLTIc\LTI\System::$signatureMethod = 'HMAC-SHA1' |
Method used for signing messages.
int ceLTIc\LTI\System::$updated = null |
Timestamp for when the object was last updated.
array ceLTIc\LTI\System::$warnings = [] |
Warnings relating to last request processed.