Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
Update to use official IMSGlobal libs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispittman committed Sep 6, 2019
1 parent 8f3340c commit 797f653
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 915 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
vendor
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
"psr-4": {"Chrispittman\\Lti1\\": "src/"}
},
"require": {
"php": ">5.4.0",
"php": ">5.6.0",
"imsglobal/lti": "^3.0.2",
"ext-xml":"*",
"ext-curl":"*"
"ext-curl":"*",
"ext-dom": "*"
}
}
}
15 changes: 10 additions & 5 deletions src/LTIUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
use DOMException;
use Exception;

use IMSGlobal\LTI\OAuth\OAuthConsumer;
use IMSGlobal\LTI\OAuth\OAuthServer;
use IMSGlobal\LTI\OAuth\OAuthRequest;
use IMSGlobal\LTI\OAuth\OAuthSignatureMethod_HMAC_SHA1;

class LTIUtils {
//
// LAUNCH FUNCTIONS
Expand All @@ -22,7 +27,7 @@ public function validate_oauth_signature($oauth_consumer_key, $shared_secret, $r

$server = new OAuthServer($store);

$method = new OAuthSignatureMethodHMACSHA1();
$method = new OAuthSignatureMethod_HMAC_SHA1();
$server->add_signature_method($method);
$request = OAuthRequest::from_request("POST", $request_url);

Expand Down Expand Up @@ -75,22 +80,22 @@ public function update_outcome($oauth_consumer_key, $shared_secret, $lti_sourced
$hash = base64_encode(sha1($xmlRequest, TRUE));
$params = array('oauth_body_hash'=>$hash);

$hmac_method = new OAuthSignatureMethodHMACSHA1();
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
$consumer = new OAuthConsumer($oauth_consumer_key, $shared_secret, NULL);

$req = OAuthRequest::from_consumer_and_token($consumer, NULL, 'POST', $lis_outcome_service_url, $params);
$req->sign_request($hmac_method, $consumer, NULL);
$header = $req->to_header();
$header .= "\nContent-type: application/xml";

$ext_response = LTIUtils::do_post_request($lis_outcome_service_url, $xmlRequest, $header);
$ext_response = $this->do_post_request($lis_outcome_service_url, $xmlRequest, $header);

try {
$ext_doc = new DOMDocument();
set_error_handler(array($this,'HandleXmlError'));
$ext_doc->loadXML($ext_response);
restore_error_handler();
$ext_nodes = LTIUtils::domnode_to_array($ext_doc->documentElement);
$ext_nodes = $this->domnode_to_array($ext_doc->documentElement);
if (!isset($ext_nodes['imsx_POXHeader']['imsx_POXResponseHeaderInfo']['imsx_statusInfo']['imsx_codeMajor'])) {
throw new Exception("No imsx_codeMajor from outcome service for ".$lti_sourced_id);
}
Expand Down Expand Up @@ -137,7 +142,7 @@ public function delete_outcome($oauth_consumer_key, $shared_secret, $lti_sourced
$hash = base64_encode(sha1($xmlRequest, TRUE));
$params = array('oauth_body_hash'=>$hash);

$hmac_method = new OAuthSignatureMethodHMACSHA1();
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
$consumer = new OAuthConsumer($oauth_consumer_key, $shared_secret, NULL);

$req = OAuthRequest::from_consumer_and_token($consumer, NULL, 'POST', $lis_outcome_service_url, $params);
Expand Down
26 changes: 0 additions & 26 deletions src/OAuthConsumer.php

This file was deleted.

38 changes: 0 additions & 38 deletions src/OAuthDataStore.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/OAuthException.php

This file was deleted.

Loading

0 comments on commit 797f653

Please sign in to comment.