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 ($generateWarnings=false) |
| 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/EC 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. | |
| string | $onExitExceptionClass = null |
| Class of exception to be thrown instead of calling exit. | |
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 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 signServiceRequest().
| bool checkMessage | ( | bool | $generateWarnings = false | ) |
Verify the required properties of an LTI message.
| bool | $generateWarnings | True if warning messages should be generated |
References $secret.
| HttpMessage 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 |
| string null getBaseString | ( | ) |
Get the last signature base string.
References $secret, and verifySignature().
| ClientInterface getJwt | ( | ) |
| string null getKey | ( | ) |
Get the consumer key.
References $name, and getSetting().
Referenced by Context\save().
| array getMessageClaims | ( | bool | $fullyQualified = false | ) |
Get the message claims.
| bool | $fullyQualified | True if claims should be fully qualified rather than grouped (default is false) |
Referenced by saveSettings().
| array getRawParameters | ( | ) |
| int string null getRecordId | ( | ) |
Get the system record ID.
References $name, and getSetting().
Referenced by DataConnector\deleteResourceLink(), DataConnector_mysqli\getSharesResourceLink(), DataConnector_oci8\getSharesResourceLink(), DataConnector_pdo\getSharesResourceLink(), DataConnector_pgsql\getSharesResourceLink(), DataConnector_sql\getSharesResourceLink(), DataConnector\getUserResultSourcedIDsResourceLink(), DataConnector_oci8\loadPlatformNonce(), DataConnector_pdo\loadPlatformNonce(), DataConnector_pgsql\loadPlatformNonce(), DataConnector_sql\loadPlatformNonce(), DataConnector\savePlatformNonce(), DataConnector_mysqli\savePlatformNonce(), DataConnector_pgsql\savePlatformNonce(), and DataConnector_sql\savePlatformNonce().
| string null 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) |
References setSettings().
Referenced by getKey(), getRecordId(), Platform\hasToolSettingsService(), and Platform\setAccessToken().
| array getSettings | ( | ) |
| bool hasJwt | ( | ) |
|
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 saveSettings | ( | ) |
Save setting values.
References $messageParameters, getMessageClaims(), and Util\MESSAGE_TYPE_MAPPING.
| 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.
| 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 Util\jsonDecode().
| void setKey | ( | ?string | $key | ) |
| bool setReason | ( | string | $reason | ) |
Set the error reason.
| string | $reason | Reason value |
Referenced by addSignature(), Tool\doToolProxyService(), Tool\hasCustomQueryParameters(), Tool\onConfigure(), Tool\onContentItemUpdate(), Tool\onLaunch(), Tool\onResetSessionId(), and useOAuth1().
| void setRecordId | ( | int|string|null | $id | ) |
Sets the system record ID.
| int | string | null | $id | System record ID value |
References $name, and setSetting().
Referenced by Platform\fromConsumerKey(), and Tool\fromConsumerKey().
| void 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) |
Referenced by setRecordId().
| void setSettings | ( | array | $settings | ) |
Set an array of all setting values.
| array | $settings | Associative array of setting values |
References OAuthRequest\$POST_INPUT, getRawParameters(), and OAuthUtil\parse_parameters().
Referenced by getSetting().
| array string 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) |
References signParameters().
| array string 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 |
Referenced by signMessage().
| array string 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 addSignature(), and useOAuth1().
| bool useOAuth1 | ( | ) |
Determine whether this consumer is using the OAuth 1 security model.
References setReason().
Referenced by signServiceRequest().
| bool verifySignature | ( | $generateWarnings = false | ) |
Verify the signature of a message.
| bool | $generateWarnings | True if warning messages should be generated |
References Tool\$defaultTool, Util\$disableFetchedPublicKeysSave, $jku, $kid, and $ok.
Referenced by getBaseString(), and Platform\sendAccessToken().
| string $rsaKey = null |
RSA/EC 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.
| array $warnings = [] |
Warnings relating to last request processed.