lti2 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lti2/version.rb +1 -1
- data/lti2_tp/Gemfile +14 -0
- data/lti2_tp/Gemfile.lock +94 -0
- data/lti2_tp/MIT-LICENSE +20 -0
- data/lti2_tp/README.md +77 -0
- data/lti2_tp/README.rdoc +3 -0
- data/lti2_tp/Rakefile +31 -0
- data/lti2_tp/app/assets/javascripts/lti2_tp/application.js +13 -0
- data/lti2_tp/app/assets/stylesheets/lti2_tp/application.css +13 -0
- data/lti2_tp/app/controllers/lti2_tp/application_controller.rb +4 -0
- data/lti2_tp/app/controllers/lti2_tp/registrations_controller.rb +200 -0
- data/lti2_tp/app/models/lti2_tp/context.rb +55 -0
- data/lti2_tp/app/models/lti2_tp/registration.rb +180 -0
- data/lti2_tp/app/models/lti2_tp/registry.rb +5 -0
- data/lti2_tp/app/models/lti2_tp/tool.rb +27 -0
- data/lti2_tp/app/models/lti2_tp/tool_deployment.rb +5 -0
- data/lti2_tp/app/models/lti2_tp/tool_provider_registry.rb +21 -0
- data/lti2_tp/app/views/layouts/lti2_tp/application.html.erb +14 -0
- data/lti2_tp/bin/rails +8 -0
- data/lti2_tp/config/initializers/lti2_tp.rb +11 -0
- data/lti2_tp/config/routes.rb +9 -0
- data/lti2_tp/db/migrate/20140826151614_create_lti2_tp_resources.rb +67 -0
- data/lti2_tp/lib/lti2_tp.rb +4 -0
- data/lti2_tp/lib/lti2_tp/engine.rb +5 -0
- data/lti2_tp/lib/lti2_tp/version.rb +3 -0
- data/lti2_tp/lib/tasks/lti2_tp_tasks.rake +4 -0
- data/lti2_tp/lti2_tp.gemspec +27 -0
- data/lti2_tp/test/dummy/README.rdoc +28 -0
- data/lti2_tp/test/dummy/Rakefile +6 -0
- data/lti2_tp/test/dummy/app/assets/javascripts/application.js +13 -0
- data/lti2_tp/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/lti2_tp/test/dummy/app/controllers/application_controller.rb +5 -0
- data/lti2_tp/test/dummy/app/helpers/application_helper.rb +2 -0
- data/lti2_tp/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/lti2_tp/test/dummy/bin/bundle +3 -0
- data/lti2_tp/test/dummy/bin/rails +4 -0
- data/lti2_tp/test/dummy/bin/rake +4 -0
- data/lti2_tp/test/dummy/config.ru +4 -0
- data/lti2_tp/test/dummy/config/application.rb +23 -0
- data/lti2_tp/test/dummy/config/boot.rb +5 -0
- data/lti2_tp/test/dummy/config/database.yml +25 -0
- data/lti2_tp/test/dummy/config/environment.rb +5 -0
- data/lti2_tp/test/dummy/config/environments/development.rb +29 -0
- data/lti2_tp/test/dummy/config/environments/production.rb +80 -0
- data/lti2_tp/test/dummy/config/environments/test.rb +36 -0
- data/lti2_tp/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/lti2_tp/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/lti2_tp/test/dummy/config/initializers/inflections.rb +16 -0
- data/lti2_tp/test/dummy/config/initializers/mime_types.rb +5 -0
- data/lti2_tp/test/dummy/config/initializers/secret_token.rb +12 -0
- data/lti2_tp/test/dummy/config/initializers/session_store.rb +3 -0
- data/lti2_tp/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/lti2_tp/test/dummy/config/locales/en.yml +23 -0
- data/lti2_tp/test/dummy/config/routes.rb +4 -0
- data/lti2_tp/test/dummy/db/schema.rb +63 -0
- data/lti2_tp/test/dummy/public/404.html +58 -0
- data/lti2_tp/test/dummy/public/422.html +58 -0
- data/lti2_tp/test/dummy/public/500.html +57 -0
- data/lti2_tp/test/dummy/public/favicon.ico +0 -0
- data/lti2_tp/test/integration/navigation_test.rb +10 -0
- data/lti2_tp/test/lti2_tp_test.rb +7 -0
- data/lti2_tp/test/test_helper.rb +15 -0
- metadata +62 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb9b1cb9478fafe356ddd56f682e39e9ccb0fb40
|
4
|
+
data.tar.gz: 089955ed0fad9c04e5ca52c43091962568b679b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 070e5d2d36507e3461aaae053a4ef698d0ae01ed5c8ffe28f4b5c20e04194da3c3a396a739a118e9a8f86d67c58f1a65a9d1c31073dc4397602232aa101cba2c
|
7
|
+
data.tar.gz: 89e35ca4f8969b6014dad1ebd22901fc2bfdbd8fbda2e1a2592c7c3e2ba9a90db6ce38bbb2b61d56e55d910aa22872024f87cf786d91398ac2f29e16449b2516
|
data/lib/lti2/version.rb
CHANGED
data/lti2_tp/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in lti2_tp.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use debugger
|
14
|
+
# gem 'debugger'
|
@@ -0,0 +1,94 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lti2_tp (0.0.2)
|
5
|
+
mysql2 (~> 0.3.13)
|
6
|
+
rails (~> 4.1.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (4.1.5)
|
12
|
+
actionpack (= 4.1.5)
|
13
|
+
actionview (= 4.1.5)
|
14
|
+
mail (~> 2.5.4)
|
15
|
+
actionpack (4.1.5)
|
16
|
+
actionview (= 4.1.5)
|
17
|
+
activesupport (= 4.1.5)
|
18
|
+
rack (~> 1.5.2)
|
19
|
+
rack-test (~> 0.6.2)
|
20
|
+
actionview (4.1.5)
|
21
|
+
activesupport (= 4.1.5)
|
22
|
+
builder (~> 3.1)
|
23
|
+
erubis (~> 2.7.0)
|
24
|
+
activemodel (4.1.5)
|
25
|
+
activesupport (= 4.1.5)
|
26
|
+
builder (~> 3.1)
|
27
|
+
activerecord (4.1.5)
|
28
|
+
activemodel (= 4.1.5)
|
29
|
+
activesupport (= 4.1.5)
|
30
|
+
arel (~> 5.0.0)
|
31
|
+
activesupport (4.1.5)
|
32
|
+
i18n (~> 0.6, >= 0.6.9)
|
33
|
+
json (~> 1.7, >= 1.7.7)
|
34
|
+
minitest (~> 5.1)
|
35
|
+
thread_safe (~> 0.1)
|
36
|
+
tzinfo (~> 1.1)
|
37
|
+
arel (5.0.1.20140414130214)
|
38
|
+
builder (3.2.2)
|
39
|
+
erubis (2.7.0)
|
40
|
+
hike (1.2.3)
|
41
|
+
i18n (0.6.11)
|
42
|
+
json (1.8.1)
|
43
|
+
mail (2.5.4)
|
44
|
+
mime-types (~> 1.16)
|
45
|
+
treetop (~> 1.4.8)
|
46
|
+
mime-types (1.25.1)
|
47
|
+
minitest (5.4.1)
|
48
|
+
multi_json (1.10.1)
|
49
|
+
mysql2 (0.3.16)
|
50
|
+
polyglot (0.3.5)
|
51
|
+
rack (1.5.2)
|
52
|
+
rack-test (0.6.2)
|
53
|
+
rack (>= 1.0)
|
54
|
+
rails (4.1.5)
|
55
|
+
actionmailer (= 4.1.5)
|
56
|
+
actionpack (= 4.1.5)
|
57
|
+
actionview (= 4.1.5)
|
58
|
+
activemodel (= 4.1.5)
|
59
|
+
activerecord (= 4.1.5)
|
60
|
+
activesupport (= 4.1.5)
|
61
|
+
bundler (>= 1.3.0, < 2.0)
|
62
|
+
railties (= 4.1.5)
|
63
|
+
sprockets-rails (~> 2.0)
|
64
|
+
railties (4.1.5)
|
65
|
+
actionpack (= 4.1.5)
|
66
|
+
activesupport (= 4.1.5)
|
67
|
+
rake (>= 0.8.7)
|
68
|
+
thor (>= 0.18.1, < 2.0)
|
69
|
+
rake (10.3.2)
|
70
|
+
sprockets (2.12.2)
|
71
|
+
hike (~> 1.2)
|
72
|
+
multi_json (~> 1.0)
|
73
|
+
rack (~> 1.0)
|
74
|
+
tilt (~> 1.1, != 1.3.0)
|
75
|
+
sprockets-rails (2.1.4)
|
76
|
+
actionpack (>= 3.0)
|
77
|
+
activesupport (>= 3.0)
|
78
|
+
sprockets (~> 2.8)
|
79
|
+
sqlite3 (1.3.8)
|
80
|
+
thor (0.19.1)
|
81
|
+
thread_safe (0.3.4)
|
82
|
+
tilt (1.4.1)
|
83
|
+
treetop (1.4.15)
|
84
|
+
polyglot
|
85
|
+
polyglot (>= 0.3.1)
|
86
|
+
tzinfo (1.2.2)
|
87
|
+
thread_safe (~> 0.1)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
lti2_tp!
|
94
|
+
sqlite3
|
data/lti2_tp/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lti2_tp/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
Lti2_Tp -- Tool Provider
|
2
|
+
========================
|
3
|
+
|
4
|
+
Lti2_Tp is a Rails gem (implemented here as a mountable Rails engine) that implements the Tool Provider of Lti2. It
|
5
|
+
can be added to a Rails application by adding the following to the application.
|
6
|
+
|
7
|
+
1. Mount the Rails engine within the application's routes.rb file:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
MyToolApp::Application.routes.draw do
|
11
|
+
|
12
|
+
mount Lti2Tp::Engine, at: '/lti2_tp'
|
13
|
+
...
|
14
|
+
<rest of routes.rb>
|
15
|
+
```
|
16
|
+
|
17
|
+
2. Mixin Lti2_Tp migrations with the application's own migrations:
|
18
|
+
|
19
|
+
```
|
20
|
+
rake lti2_tc:install:migrations
|
21
|
+
```
|
22
|
+
|
23
|
+
3. Implement a application-specific LtiRegistrationsController class in the application (not in Lti2_Tp).
|
24
|
+
|
25
|
+
The LtiRegistrationsController is needed to implement the specific user interface, models or other behavior to register
|
26
|
+
a new LTI2 ToolConsumer. It must implement the following paths:
|
27
|
+
|
28
|
+
a. Register action
|
29
|
+
|
30
|
+
The register action gives this controller the ingredients needed to do tool-specific validation, customization and
|
31
|
+
creation of the ToolProxy.
|
32
|
+
|
33
|
+
POST /lti_register_wip?action=register
|
34
|
+
|
35
|
+
request content-type: application/json
|
36
|
+
```javascript
|
37
|
+
{
|
38
|
+
"service_owner_name": <string>,
|
39
|
+
"lti_version": <string>,
|
40
|
+
"tool_consumer_profile", <text>,
|
41
|
+
"tool_profile", <text>,
|
42
|
+
"registration_return_url", <url>
|
43
|
+
}
|
44
|
+
```
|
45
|
+
|
46
|
+
Use the tool_consumer_profile and tool_profile to generate a tool_proxy (or to reject it). When this action is
|
47
|
+
complete do one of the following:
|
48
|
+
|
49
|
+
On success: redirect_to <registration_return_url>, action: 'accept_tool_proxy', id: <a_lti_register_wip_id>
|
50
|
+
|
51
|
+
On failure: redirect_to <registration_return_url>, action: 'reject_registration', status: <integer>,
|
52
|
+
message: <string>
|
53
|
+
|
54
|
+
|
55
|
+
b. Get ToolProxy
|
56
|
+
|
57
|
+
Gets the currently computed tool_proxy (or empty if not computed).
|
58
|
+
|
59
|
+
GET /lti_register_wip/:id
|
60
|
+
|
61
|
+
response content-type: application/json
|
62
|
+
|
63
|
+
<tool_proxy>
|
64
|
+
|
65
|
+
|
66
|
+
c. Update secret
|
67
|
+
|
68
|
+
Do whatever is necessary to update the shared secret. This is typically used at the last phase of registration.
|
69
|
+
|
70
|
+
PUT /lti_register_wip/:id/secret
|
71
|
+
|
72
|
+
request content-type: application/json
|
73
|
+
|
74
|
+
```javascript
|
75
|
+
{"secret": <string}
|
76
|
+
```
|
77
|
+
|
data/lti2_tp/README.rdoc
ADDED
data/lti2_tp/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Lti2Tp'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path( '../test/dummy/Rakefile', __FILE__ )
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,200 @@
|
|
1
|
+
|
2
|
+
module Lti2Tp
|
3
|
+
class RegistrationsController < InheritedResources::Base
|
4
|
+
protect_from_forgery :except => :create
|
5
|
+
|
6
|
+
include Lti2Commons
|
7
|
+
include MessageSupport
|
8
|
+
include Signer
|
9
|
+
|
10
|
+
def create
|
11
|
+
# this signals initial POST from TC
|
12
|
+
tool = params[:tool]
|
13
|
+
if tool.present?
|
14
|
+
tools = Tool.where( :id => tool )
|
15
|
+
if tools.present?
|
16
|
+
@tool = tools.first
|
17
|
+
else
|
18
|
+
tools = Tool.where( :tool_name => tool )
|
19
|
+
if tools.present?
|
20
|
+
@tool = tools.first
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
if @tool.nil?
|
25
|
+
@tool = Tool.first
|
26
|
+
end
|
27
|
+
|
28
|
+
@registration = Lti2Tp::Registration.new
|
29
|
+
@registration.user_id = params['user_id']
|
30
|
+
@registration.tc_profile_url = params['tc_profile_url']
|
31
|
+
@registration.reg_key = params['reg_key']
|
32
|
+
@registration.reg_password = params['reg_password']
|
33
|
+
@registration.launch_presentation_return_url = params['launch_presentation_return_url']
|
34
|
+
@registration.message_type = 'registration'
|
35
|
+
@registration.status = 'received'
|
36
|
+
|
37
|
+
@tool_consumer_profile = @registration.get_tool_consumer_profile()
|
38
|
+
tcp_wrapper = JsonWrapper.new( @tool_consumer_profile )
|
39
|
+
|
40
|
+
@registration.tool_consumer_profile_json = @tool_consumer_profile.to_json
|
41
|
+
@registration.tenant_basename = tcp_wrapper.first_at('product_instance.service_owner.service_owner_name.default_value')
|
42
|
+
@registration.tenant_name = @registration.tenant_basename # initialize here until we can qualify it
|
43
|
+
@registration.tenant_id = nil
|
44
|
+
@registration.tool_id = @tool.id
|
45
|
+
@registration.tool_profile_json = @tool.get_tool_profile.to_json
|
46
|
+
@registration.lti_version = @tool_consumer_profile['lti_version']
|
47
|
+
|
48
|
+
@registration.save
|
49
|
+
|
50
|
+
redirect_to "/lti_registration_wips?registration_id=#{@registration.id}&return_url=/lti2_tp/registrations"
|
51
|
+
end
|
52
|
+
|
53
|
+
def end_registration
|
54
|
+
response = pre_process_tenant
|
55
|
+
if response.nil?
|
56
|
+
return
|
57
|
+
else
|
58
|
+
if response.kind_of?(Array)
|
59
|
+
return unless response[0] == 200
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
@registration = Lti2Tp::Registration.where(:tenant_name => @tenant.tenant_name).first
|
64
|
+
|
65
|
+
json_str = request.body.read
|
66
|
+
|
67
|
+
@registration = Registration.where(:tenant_id => @tenant.id).first
|
68
|
+
end_registration_id = request.headers[Registration::HTTP_CORRELATION_ID]
|
69
|
+
(abort_registration("Missing #{Registration::CORRELATION_ID} header") and return) if end_registration_id.nil?
|
70
|
+
(abort_registration("Out of sequence #{Registration::CORRELATION_ID} header") \
|
71
|
+
and return) if end_registration_id != @registration.end_registration_id
|
72
|
+
|
73
|
+
begin
|
74
|
+
tool_proxy_disposition_wrapper = JsonWrapper.new(json_str)
|
75
|
+
rescue
|
76
|
+
render :json => 'JSON validation failure', :status => '500'
|
77
|
+
end
|
78
|
+
|
79
|
+
tool_proxy_disposition = tool_proxy_disposition_wrapper.root
|
80
|
+
tool_proxy_guid = tool_proxy_disposition['tool_proxy_guid']
|
81
|
+
tool_proxy_id = tool_proxy_disposition['@id']
|
82
|
+
|
83
|
+
disposition = request.headers[Registration::HTTP_DISPOSITION]
|
84
|
+
|
85
|
+
if disposition != 'commit'
|
86
|
+
abort_registration("Tool Consumer requested abort") and return
|
87
|
+
end
|
88
|
+
|
89
|
+
@registration.tool_proxy_json = @registration.proposed_tool_proxy_json
|
90
|
+
@registration.status = 'reregistered'
|
91
|
+
@registration.proposed_tool_proxy_json = nil
|
92
|
+
@registration.end_registration_id = nil
|
93
|
+
|
94
|
+
# recover secret from new tool_proxy
|
95
|
+
tool_proxy_wrapper = JsonWrapper.new(@registration.tool_proxy_json)
|
96
|
+
@registration.reg_password = tool_proxy_wrapper.first_at('security_contract.shared_secret')
|
97
|
+
|
98
|
+
LtiRegistrationWip.change_tenant_secret(@registration.tenant_id, @registration.reg_password)
|
99
|
+
|
100
|
+
|
101
|
+
@registration.save
|
102
|
+
|
103
|
+
end_registration_response = {
|
104
|
+
"@context" => "http://purl.imsglobal.org/ctx/lti/v2/ToolProxyId",
|
105
|
+
"@type" => "ToolProxy",
|
106
|
+
"@id" => tool_proxy_id,
|
107
|
+
"tool_proxy_guid" => tool_proxy_guid,
|
108
|
+
"disposition" => 'commit'
|
109
|
+
}
|
110
|
+
|
111
|
+
content_type = 'application/vnd.ims.lti.v2.toolproxy.id+json'
|
112
|
+
logger.info("Exit from Tool/create(POST)--status 201 content-type: #{content_type}")
|
113
|
+
logger.info(JSON.dump(end_registration_response))
|
114
|
+
|
115
|
+
render :json => end_registration_response.to_json, :content_type => content_type, :status => '201'
|
116
|
+
end
|
117
|
+
|
118
|
+
def index
|
119
|
+
registration = Lti2Tp::Registration.find( params[:id] )
|
120
|
+
final_hash = params.select { |k,v| [ :status, :tool_guid, :lti_errormsg, :lti_errorlog ].include? k.to_sym }
|
121
|
+
final_qs = final_hash.to_query
|
122
|
+
final_url = "#{registration.launch_presentation_return_url}?#{final_qs}"
|
123
|
+
redirect_to final_url
|
124
|
+
end
|
125
|
+
|
126
|
+
def reregister
|
127
|
+
response = pre_process_tenant
|
128
|
+
if response.nil?
|
129
|
+
return
|
130
|
+
else
|
131
|
+
if response.kind_of?(Array)
|
132
|
+
return unless response[0] == 200
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
@registration = Lti2Tp::Registration.where(:tenant_name => @tenant.tenant_name).first
|
137
|
+
|
138
|
+
@registration.tc_profile_url = params['tc_profile_url']
|
139
|
+
@registration.launch_presentation_return_url = params['launch_presentation_return_url']
|
140
|
+
@registration.message_type = "reregistration"
|
141
|
+
@registration.status = 'received'
|
142
|
+
|
143
|
+
# Use OLD key/secret to send NEW ToolProxy
|
144
|
+
(old_key, old_secret) = LtiRegistrationWip.get_tenant_credentials(@registration.tenant_id)
|
145
|
+
@registration.reg_key = old_key
|
146
|
+
@registration.reg_password = old_secret
|
147
|
+
@tool_consumer_profile = @registration.get_tool_consumer_profile()
|
148
|
+
tcp_wrapper = JsonWrapper.new @tool_consumer_profile
|
149
|
+
|
150
|
+
@registration.tool_consumer_profile_json = @tool_consumer_profile.to_json
|
151
|
+
@registration.tenant_basename = tcp_wrapper.first_at('product_instance.service_owner.service_owner_name.default_value')
|
152
|
+
@registration.tenant_id = @tenant.id
|
153
|
+
|
154
|
+
@tool = Tool.find(@registration.tool_id)
|
155
|
+
@registration.tool_profile_json = @tool.get_tool_profile.to_json
|
156
|
+
@registration.lti_version = @tool_consumer_profile['lti_version']
|
157
|
+
|
158
|
+
@registration.save
|
159
|
+
|
160
|
+
redirect_to "/lti_registration_wips?registration_id=#{@registration.id}&return_url=/lti2_tp/registrations"
|
161
|
+
end
|
162
|
+
|
163
|
+
def update
|
164
|
+
get_tool_consumer_profile Lti2Tp::Context.get_holder( session )
|
165
|
+
form_params = request.params['deployment_proposal']
|
166
|
+
@registration = Lti2Tp::Registration.find( request.params[:id] )
|
167
|
+
@registration.tenant_basename = form_params['tenant_name']
|
168
|
+
|
169
|
+
is_tenant_exists = Tenant.where( :tenant_name => @registration.tenant_basename ).exists?
|
170
|
+
if @registration.message_type == 'registration' and is_tenant_exists
|
171
|
+
@registration.errors[:tenant_name] << 'Institution name is already in database'
|
172
|
+
return render_view
|
173
|
+
elsif @registration.message_type == 'reregistration' and not is_tenant_exists
|
174
|
+
raise 'Attempt to reregister but not tenant currently exists'
|
175
|
+
end
|
176
|
+
|
177
|
+
@tool_options = []
|
178
|
+
params.each { |p|
|
179
|
+
if p.first =~ /^tool_/
|
180
|
+
@tool_options << p.first[5..-1]
|
181
|
+
end
|
182
|
+
}
|
183
|
+
|
184
|
+
if @tool_options.length == 0
|
185
|
+
@registration.errors[:tenant_name] << 'You must check at least one tool below to download'
|
186
|
+
return render_view
|
187
|
+
end
|
188
|
+
|
189
|
+
@registration.save!
|
190
|
+
|
191
|
+
show
|
192
|
+
end
|
193
|
+
|
194
|
+
private
|
195
|
+
|
196
|
+
def abort_registration(abort_msg)
|
197
|
+
render :status => 500, :json => abort_msg
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|