();
322 | mm.put("/personSourcedId","789user123");
323 | mm.put("/role/roleType","Instructor");
324 | lm.add(mm);
325 | theMap.put("/readMembershipResponse/membershipRecord/membership/member", lm);
326 |
327 | String theXml = XMLMap.getXMLFragment(theMap, true);
328 | // System.out.println("th="+theXml);
329 | output = pox.getResponseSuccess(desc,theXml);
330 | System.out.println("---- Success String ----");
331 | System.out.println(output);
332 | */
333 | }
334 |
335 | /*
336 |
337 | roleType:
338 | Learner
339 | Instructor
340 | ContentDeveloper
341 | Member
342 | Manager
343 | Mentor
344 | Administrator
345 | TeachingAssistant
346 |
347 | fieldType:
348 | Boolean
349 | Integer
350 | Real
351 | String
352 |
353 |
355 |
356 | GUID.TYPE
357 |
358 | GUID.TYPE
359 | MEMBERSHIPIDTYPE.TYPE
360 |
361 | GUID.TYPE
362 |
363 | STRING
364 | STRING
365 |
366 | DATETIME
367 | DATETIME
368 | BOOLEAN
369 |
370 | LANGUAGESET.TYPE
371 | STRING
372 |
373 |
374 | STATUS.TYPE
375 | DATETIME
376 | GUID.TYPE
377 |
378 |
379 | STRING
380 | FIELDTYPE.TYPE
381 | STRING
382 |
383 |
384 |
385 |
386 | STRING
387 | FIELDTYPE.TYPE
388 | STRING
389 |
390 |
391 |
392 |
393 | INTEGER
394 | GUID.TYPE
395 |
396 |
397 |
398 | */
399 | }
400 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/BasicLTIConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2008 IMS GLobal Learning Consortium
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 | * implied. See the License for the specific language governing
14 | * permissions and limitations under the License.
15 | */
16 | package org.imsglobal.lti;
17 |
18 | public class BasicLTIConstants {
19 | /**
20 | * context_id=8213060-006f-27b2066ac545
21 | *
22 | * This is an opaque identifier that uniquely identifies the context that
23 | * contains the link being launched.
24 | */
25 | public static final String CONTEXT_ID = "context_id";
26 | /**
27 | * context_label=SI182
28 | *
29 | * A label for the context - intended to fit in a column.
30 | */
31 | public static final String CONTEXT_LABEL = "context_label";
32 | /**
33 | * context_title=Design of Personal Environments
34 | *
35 | * A title of the context - it should be about the length of a line.
36 | */
37 | public static final String CONTEXT_TITLE = "context_title";
38 |
39 | /**
40 | * context_type=CourseSection
41 | *
42 | * This string is a comma-separated list of URN values that identify the type
43 | * of context. At a minimum, the list MUST include a URN value drawn from the
44 | * LIS vocabulary (see Appendix A). The assumed namespace of these URNs is the
45 | * LIS vocabulary so TCs can use the handles when the intent is to refer to an
46 | * LIS context type. If the TC wants to include a context type from another
47 | * namespace, a fully-qualified URN should be used.
48 | */
49 | public static final String CONTEXT_TYPE = "context_type";
50 | public static final String CONTEXT_TYPE_COURSE_OFFERING = "CourseOffering";
51 | public static final String CONTEXT_TYPE_COURSE_SECTION = "CourseSection";
52 | public static final String CONTEXT_TYPE_COURSE_TEMPLATE = "CourseTemplate";
53 | public static final String CONTEXT_TYPE_GROUP = "Group";
54 |
55 | /**
56 | * ext_param=value
57 | *
58 | * Systems can add their own values to the launch but should prefix
59 | * any extensions with "ext_".
60 | */
61 | public static final String EXTENSION_PREFIX = "ext_";
62 | /**
63 | * custom_keyname=value
64 | *
65 | * The creator of a Basic LTI link can add custom key/value parameters to a
66 | * launch which are to be included with the launch of the Basic LTI link. The
67 | * Common Cartridge section below describes how these parameters are
68 | * represented when storing custom parameters in a Common Cartridge.
69 | *
70 | * When there are custom name / value parameters in the launch, a POST
71 | * parameter is included for each custom parameter. The parameter names are
72 | * mapped to lower case and any character that is neither a number nor letter
73 | * in a parameter name is replaced with an "underscore". So if a custom entry
74 | * was as follows:
75 | *
76 | * Review:Chapter=1.2.56
77 | *
78 | * Would map to: custom_review_chapter=1.2.56
79 | *
80 | * Creators of Basic LTI links would be well served to limit their parameter
81 | * names to lower case and to use no punctuation other than underscores. If
82 | * these custom parameters are included in the Basic LTI link, the TC must
83 | * include them in the launch data or the TP may fail to function.
84 | */
85 | public static final String CUSTOM_PREFIX = "custom_";
86 | /**
87 | * Parameters with the OAuth prefix are also acceptible.
88 | */
89 | public static final String OAUTH_PREFIX = "oauth_";
90 | /**
91 | * launch_presentation_document_target=iframe
92 | *
93 | * The value should be either 'frame', 'iframe' or 'window'. This field
94 | * communicates the kind of browser window/frame where the TC has launched the
95 | * tool.
96 | */
97 | public static final String LAUNCH_PRESENTATION_DOCUMENT_TARGET = "launch_presentation_document_target";
98 | /**
99 | * launch_presentation_height=240
100 | *
101 | * The height of the window or frame where the content from the tool will be
102 | * displayed.
103 | */
104 | public static final String LAUNCH_PRESENTATION_HEIGHT = "launch_presentation_height";
105 | /**
106 | * launch_presentation_locale=en_US_variant
107 | *
108 | * Language, country and variant separated by underscores. Language is the
109 | * lower-case, two-letter code as defined by ISO-639 (list of codes available
110 | * at http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt). Country is the
111 | * upper-case, two-letter code as defined by ISO-3166 (list of codes available
112 | * at http://www.chemie.fu- berlin.de/diverse/doc/ISO_3166.html). Country and
113 | * variant codes are optional.
114 | */
115 | public static final String LAUNCH_PRESENTATION_LOCALE = "launch_presentation_locale";
116 | /**
117 | * launch_presentation_return_url=http://lmsng.school.edu/portal/123/page/988/
118 | *
119 | * Fully qualified URL where the TP can redirect the user back to the TC interface. This
120 | * URL can be used once the TP is finished or if the TP cannot start or has some
121 | * technical difficulty. In the case of an error, the TP may add a parameter called
122 | * lti_errormsg that includes some detail as to the nature of the error. The
123 | * lti_errormsg value should make sense if displayed to the user. If the tool has
124 | * displayed a message to the end user and only wants to give the TC a message to log,
125 | * use the parameter lti_errorlog instead of lti_errormsg. If the tool is terminating
126 | * normally, and wants a message displayed to the user it can include a text message as
127 | * the lti_msg parameter to the return URL. If the tool is terminating normally and
128 | * wants to give the TC a message to log, use the parameter lti_log. This data should be
129 | * sent on the URL as a GET - so the TP should take care to keep the overall length of
130 | * the parameters small enough to fit within the limitations of a GET request.
131 | */
132 | public static final String LAUNCH_PRESENTATION_RETURN_URL = "launch_presentation_return_url";
133 | /**
134 | * launch_presentation_width=320
135 | *
136 | * The width of the window or frame where the content from the tool will be
137 | * displayed.
138 | */
139 | public static final String LAUNCH_PRESENTATION_WIDTH = "launch_presentation_width";
140 | /**
141 | * launch_presentation_css_url=http://www.toolconsumer.url/path/to/lti.css
142 | *
143 | * This points to a fully qualified URL for a CSS which can be used to style the tool.
144 | * There are no officially defined CSS classes for this file, but the Consumer can
145 | * apply styles to paragraphs, body, and the various HTML elements. It is up to the
146 | * tool as to whether this CSS is used or not, and in what order this is included relative
147 | * to the tool-specific CSS.
148 | */
149 | public static final String LAUNCH_PRESENTATION_CSS_URL = "launch_presentation_css_url";
150 | /**
151 | * lis_person_contact_email_primary=user@school.edu
152 | *
153 | * These fields contain information about the user account that is performing
154 | * this launch. The names of these data items are taken from LIS. The precise
155 | * meaning of the content in these fields is defined by LIS.
156 | */
157 | public static final String LIS_PERSON_CONTACT_EMAIL_PRIMARY = "lis_person_contact_email_primary";
158 | /**
159 | * lis_person_name_family=Public
160 | *
161 | * These fields contain information about the user account that is performing
162 | * this launch. The names of these data items are taken from LIS. The precise
163 | * meaning of the content in these fields is defined by LIS.
164 | */
165 | public static final String LIS_PERSON_NAME_FAMILY = "lis_person_name_family";
166 | /**
167 | * lis_person_name_full=Jane Q. Public
168 | *
169 | * These fields contain information about the user account that is performing
170 | * this launch. The names of these data items are taken from LIS. The precise
171 | * meaning of the content in these fields is defined by LIS.
172 | */
173 | public static final String LIS_PERSON_NAME_FULL = "lis_person_name_full";
174 | /**
175 | * lis_person_name_given=Jane
176 | *
177 | * These fields contain information about the user account that is performing
178 | * this launch. The names of these data items are taken from LIS. The precise
179 | * meaning of the content in these fields is defined by LIS.
180 | */
181 | public static final String LIS_PERSON_NAME_GIVEN = "lis_person_name_given";
182 |
183 | /**
184 | * lis_person_sourcedid=school.edu:user
185 | *
186 | * This field contains the LIS identifier for the user account that is
187 | * performing this launch. The example syntax of "school:user"
188 | * is not the required format – lis_person_sourcedid is simply a
189 | * unique identifier (i.e., a normalized string). This field
190 | * is optional and its content and meaning are defined by LIS.
191 | */
192 | public static final String LIS_PERSON_SOURCEDID = "lis_person_sourcedid";
193 |
194 | /**
195 | * lis_course_offering_sourcedid=school.edu:SI182-F08
196 | * lis_course_section_sourcedid=school.edu:SI182-001-F08
197 | *
198 | * These fields contain LIS course identifiers associated with the
199 | * context of this launch. These fields are optional and their
200 | * content and meaning are defined by LIS.
201 | */
202 | public static final String LIS_COURSE_OFFERING_SOURCEDID = "lis_course_offering_sourcedid";
203 | public static final String LIS_COURSE_SECTION_SOURCEDID = "lis_course_section_sourcedid";
204 |
205 | /**
206 | * lis_outcome_service_url=http://lmsng.school.edu/service/ltiout/
207 | *
208 | * This field should be no more than 1023 characters long and the TP
209 | * should assume that the URL might change from launch to launch and
210 | * allow for the fact that a TC might change their service URL from
211 | * launch to launch and only use the most recent value for this
212 | * parameter. The service URL may support various operations / services.
213 | * The TC will respond with a response of 'unimplemented' for services
214 | * it does not support.
215 | */
216 | public static final String LIS_OUTCOME_SERVICE_URL = "lis_outcome_service_url";
217 |
218 | /**
219 | * lis_result_sourcedid=83873872987329873264783687634
220 | *
221 | * This field contains an identifier that indicates the LIS Result
222 | * Identifier (if any) associated with this launch. This field is
223 | * optional and its content and meaning is defined by LIS.
224 | */
225 | public static final String LIS_RESULT_SOURCEDID = "lis_result_sourcedid";
226 |
227 | /**
228 | * lti_message_type=basic-lti-launch-request
229 | *
230 | * This indicates that this is a Basic LTI Launch Message. This allows a TP to
231 | * accept a number of different LTI message types at the same launch URL. This
232 | * parameter is required.
233 | */
234 | public static final String LTI_MESSAGE_TYPE = "lti_message_type";
235 | public static final String LTI_MESSAGE_TYPE_TOOLPROXYREGISTRATIONREQUEST = "ToolProxyRegistrationRequest";
236 | public static final String LTI_MESSAGE_TYPE_TOOLPROXY_RE_REGISTRATIONREQUEST = "ToolProxyReregistrationRequest";
237 | public static final String LTI_MESSAGE_TYPE_BASICLTILAUNCHREQUEST = "basic-lti-launch-request";
238 | /**
239 | * lti_version=LTI-1p0
240 | *
241 | * This indicates which version of the specification is being used for this
242 | * particular message. This parameter is required.
243 | */
244 | public static final String LTI_VERSION = "lti_version";
245 | public static final String LTI_VERSION_1 = "LTI-1p0";
246 | public static final String LTI_VERSION_2 = "LTI-2p0";
247 |
248 | /**
249 | * tool_consumer_info_product_family_code=desire2learn
250 | *
251 | * In order to better assist tools in using extensions and also making their user
252 | * interface fit into the TC's user interface that they are being called from,
253 | * each TC is encouraged to include the this parameter. Possible example values
254 | * for this field might be:
255 | *
256 | * learn
257 | * desire2learn
258 | * sakai
259 | * eracer
260 | * olat
261 | * webct
262 | * This parameter is optional but recommended.
263 | */
264 | public static final String TOOL_CONSUMER_INFO_PRODUCT_FAMILY_CODE = "tool_consumer_info_product_family_code";
265 |
266 | /**
267 | * tool_consumer_info_version=9.2.4
268 | *
269 | * This field should have a major release number followed by a period. The format of the minor release is flexible. Possible vaues for this field might be:
270 | *
271 | * 9.1.7081
272 | * 2.8-01
273 | * 7.1
274 | * 8
275 | * The Tool Provider should be flexible when parsing this field. This parameter is optional but recommended.
276 |
277 | */
278 | public static final String TOOL_CONSUMER_INFO_VERSION = "tool_consumer_info_version";
279 |
280 | /**
281 | * resource_link_id=88391-e1919-bb3456
282 | *
283 | * This is an opaque unique identifier that the TC guarantees will be unique
284 | * within the TC for every placement of the link. If the tool / activity is
285 | * placed multiple times in the same context, each of those placements will be
286 | * distinct. This value will also change if the item is exported from one
287 | * system or context and imported into another system or context. This
288 | * parameter is required.
289 | */
290 | public static final String RESOURCE_LINK_ID = "resource_link_id";
291 |
292 | /**
293 | * resource_link_title=My Weekly Wiki
294 | *
295 | * A title for the resource. This is the clickable text that appears
296 | * in the link. This parameter is recommended.
297 | */
298 | public static final String RESOURCE_LINK_TITLE = "resource_link_title";
299 |
300 | /**
301 | * resource_link_description=…
302 | *
303 | * A plain text description of the link’s destination, suitable for
304 | * display alongside the link. Typically no more than several lines
305 | * long. This parameter is optional.
306 | */
307 | public static final String RESOURCE_LINK_DESCRIPTION = "resource_link_description";
308 |
309 | /**
310 | * roles=Instructor,Student
311 | *
312 | * A comma-separated list of URN values for roles. If this list is non-empty,
313 | * it should contain at least one role from the LIS System Role, LIS
314 | * Institution Role, or LIS Context Role vocabularies (See Appendix A). The
315 | * assumed namespace of these URNs is the LIS vocabulary of LIS Context Roles
316 | * so TCs can use the handles when the intent is to refer to an LIS context
317 | * role. If the TC wants to include a role from another namespace, a
318 | * fully-qualified URN should be used. Usage of roles from non-LIS
319 | * vocabularies is discouraged as it may limit interoperability. This
320 | * parameter is recommended.
321 | */
322 | public static final String ROLES = "roles";
323 |
324 | /**
325 | * tc_profile_url=http://...
326 | *
327 | * This URL specifies the address where the Tool Provider can retrieve
328 | * the Tool Consumer Profile. This URL must be retrievable by a GET
329 | * request by the Tool Provider. If the URL is protected from retrieval
330 | * in general, the Tool Consumer must append the necessary parameters to
331 | * allow the Tool Provider to retrieve the URL with nothing more than
332 | * a GET request. It is legal for this URL to contain a security token
333 | * that is changed for each ToolProxyRegistrationRequest so the Tool
334 | * Provider must retrieve the tc_profile_url on each request.
335 | */
336 | public static final String TC_PROFILE_URL = "tc_profile_url";
337 |
338 | /**
339 | * tool_consumer_instance_contact_email=System.Admin@school.edu
340 | *
341 | * An email contact for the TC instance.
342 | */
343 | public static final String TOOL_CONSUMER_INSTANCE_CONTACT_EMAIL = "tool_consumer_instance_contact_email";
344 | /**
345 | * tool_consumer_instance_description=University of School (LMSng)
346 | *
347 | * This is a user visible field - it should be about the length of a line.
348 | */
349 | public static final String TOOL_CONSUMER_INSTANCE_DESCRIPTION = "tool_consumer_instance_description";
350 | // global settings
351 | /**
352 | * tool_consumer_instance_guid=lmsng.school.edu
353 | *
354 | * This is a key to be used when setting a TC-wide password. The TP uses this
355 | * as a key to look up the TC-wide secret when validating a message. A common
356 | * practice is to use the DNS of the organization or the DNS of the TC
357 | * instance. If the organization has multiple TC instances, then the best
358 | * practice is to prefix the domain name with a locally unique identifier for
359 | * the TC instance. This parameter is recommended.
360 | */
361 | public static final String TOOL_CONSUMER_INSTANCE_GUID = "tool_consumer_instance_guid";
362 | /**
363 | * tool_consumer_instance_name=SchoolU
364 | *
365 | * This is a user visible field - it should be about the length of a column.
366 | */
367 | public static final String TOOL_CONSUMER_INSTANCE_NAME = "tool_consumer_instance_name";
368 | /**
369 | * Missing from implementation guide. Needs documentation. Not required, but
370 | * "tasty".
371 | */
372 | public static final String TOOL_CONSUMER_INSTANCE_URL = "tool_consumer_instance_url";
373 |
374 | /**
375 | * user_id=0ae836b9-7fc9-4060-006f-27b2066ac545
376 | *
377 | * Uniquely identifies the user. This should not contain any identifying
378 | * information for the user. Best practice is that this field should be a
379 | * TC-generated long-term "primary key" to the user record - not the logical
380 | * key. This parameter is recommended.
381 | */
382 | public static final String USER_ID = "user_id";
383 |
384 | /**
385 | * user_image=http://my.sakai.org/direct/profile/0ae836b9-7fc9-4060-006f-27b2066ac545/image
386 | *
387 | * This attribute specifies the URI for an image of the user who launched this request.
388 | * This image is suitable for use as a "profile picture" or an avatar representing the user.
389 | * It is expected to be a relatively small graphic image file using a widely supported image
390 | * format (i.e. PNG, JPG, or GIF) with a square aspect ratio. This parameter is optional.
391 | */
392 | public static final String USER_IMAGE = "user_image";
393 |
394 | /**
395 | * ext_sakai_provider_eid=jsmith26
396 | *
397 | * If set, this will signal that the external application has provided an eid which
398 | * should be used preferentially. Many external applications will not have access to a user's uuid
399 | * in Sakai, so this allows integrations with those systems.
400 | * This parameter is optional and is unique to the Sakai Basic LTI provider.
401 | */
402 | public static final String EXT_SAKAI_PROVIDER_EID = "ext_sakai_provider_eid";
403 |
404 | /**
405 | * ext_sakai_provider_displayid=john.smith
406 | *
407 | * If set, this will indicate to an external application that the user is normally
408 | * known by this ID and when displaying the ID to the user this ID should be used instead of the
409 | * user_id and ext_sakai_provider_eid.
410 | * This parameter is optional and is unique to the Sakai Basic LTI provider.
411 | */
412 | public static final String EXT_SAKAI_PROVIDER_DISPLAYID = "ext_sakai_provider_displayid";
413 |
414 | /**
415 | * Utility array useful for validating property names when building launch
416 | * data.
417 | */
418 | public static final String[] validPropertyNames = { CONTEXT_ID,
419 | CONTEXT_LABEL, CONTEXT_TITLE, CONTEXT_TYPE,
420 | LAUNCH_PRESENTATION_DOCUMENT_TARGET, LAUNCH_PRESENTATION_HEIGHT,
421 | LAUNCH_PRESENTATION_LOCALE, LAUNCH_PRESENTATION_RETURN_URL,
422 | LAUNCH_PRESENTATION_WIDTH, LIS_PERSON_CONTACT_EMAIL_PRIMARY,
423 | LAUNCH_PRESENTATION_CSS_URL,
424 | TOOL_CONSUMER_INFO_PRODUCT_FAMILY_CODE,
425 | TOOL_CONSUMER_INFO_VERSION,
426 | LIS_PERSON_NAME_FAMILY, LIS_PERSON_NAME_FULL, LIS_PERSON_NAME_GIVEN,
427 | LIS_PERSON_SOURCEDID, LIS_COURSE_OFFERING_SOURCEDID,
428 | LIS_COURSE_SECTION_SOURCEDID,
429 | LIS_OUTCOME_SERVICE_URL, LIS_RESULT_SOURCEDID,
430 | LTI_MESSAGE_TYPE, LTI_VERSION, RESOURCE_LINK_ID,
431 | RESOURCE_LINK_TITLE, RESOURCE_LINK_DESCRIPTION, ROLES,
432 | TC_PROFILE_URL,
433 | TOOL_CONSUMER_INSTANCE_CONTACT_EMAIL, TOOL_CONSUMER_INSTANCE_DESCRIPTION,
434 | TOOL_CONSUMER_INSTANCE_GUID, TOOL_CONSUMER_INSTANCE_NAME,
435 | TOOL_CONSUMER_INSTANCE_URL, USER_ID, USER_IMAGE };
436 |
437 | /**
438 | * The default site type to use if a site needs to be created. Can be overriden in sakai.properties or as part of the launch.
439 | * This contains a number of preconfigured roles, so that the IMS role vocabulary can be used.
440 | * See BLTI-151
441 | */
442 | public static final String NEW_SITE_TYPE = "lti";
443 |
444 | }
445 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/launch/LtiError.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti.launch;
2 |
3 | /**
4 | * Created by paul on 5/28/14.
5 | */
6 | public class LtiError {
7 |
8 | private final String label;
9 |
10 | public static final LtiError INVALID_HASH = new LtiError("invalid_hash");
11 | public static final LtiError TIMESTAMP_MISMATCH = new LtiError("timestamp_mismatch");
12 | public static final LtiError BAD_REQUEST = new LtiError("bad_request");
13 |
14 | private LtiError(String label){
15 | this.label = label;
16 | }
17 |
18 | public String toString(){
19 | return label;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/launch/LtiLaunch.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti.launch;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 | import java.util.Map;
5 |
6 | /**
7 | * Created by paul on 5/28/14.
8 | */
9 | public class LtiLaunch {
10 |
11 | private LtiUser user;
12 |
13 | private String version;
14 | private String messageType;
15 | private String resourceLinkId;
16 |
17 | private String contextId;
18 | private String launchPresentationReturnUrl;
19 | private String toolConsumerInstanceGuid;
20 |
21 | public LtiLaunch(HttpServletRequest request) {
22 | this.user = new LtiUser(request);
23 | this.version = request.getParameter("lti_version");
24 | this.messageType = request.getParameter("lti_message_type");
25 | this.resourceLinkId = request.getParameter("resource_link_id");
26 | this.contextId = request.getParameter("context_id");
27 | this.launchPresentationReturnUrl = request.getParameter("launch_presentation_return_url");
28 | this.toolConsumerInstanceGuid = request.getParameter("tool_consumer_instance_guid");
29 | }
30 |
31 | public LtiLaunch(Map parameters) {
32 | this.user = new LtiUser(parameters);
33 | this.version = parameters.get("lti_version");
34 | this.messageType = parameters.get("lti_message_type");
35 | this.resourceLinkId = parameters.get("resource_link_id");
36 | this.contextId = parameters.get("context_id");
37 | this.launchPresentationReturnUrl = parameters.get("launch_presentation_return_url");
38 | this.toolConsumerInstanceGuid = parameters.get("tool_consumer_instance_guid");
39 | }
40 |
41 | public LtiUser getUser() {
42 | return user;
43 | }
44 |
45 | public void setUser(LtiUser user) {
46 | this.user = user;
47 | }
48 |
49 | public String getVersion() {
50 | return version;
51 | }
52 |
53 | public void setVersion(String version) {
54 | this.version = version;
55 | }
56 |
57 | public String getMessageType() {
58 | return messageType;
59 | }
60 |
61 | public void setMessageType(String messageType) {
62 | this.messageType = messageType;
63 | }
64 |
65 | public String getResourceLinkId() {
66 | return resourceLinkId;
67 | }
68 |
69 | public void setResourceLinkId(String resourceLinkId) {
70 | this.resourceLinkId = resourceLinkId;
71 | }
72 |
73 | public String getContextId() {
74 | return contextId;
75 | }
76 |
77 | public void setContextId(String contextId) {
78 | this.contextId = contextId;
79 | }
80 |
81 | public String getLaunchPresentationReturnUrl() {
82 | return launchPresentationReturnUrl;
83 | }
84 |
85 | public void setLaunchPresentationReturnUrl(String launchPresentationReturnUrl) {
86 | this.launchPresentationReturnUrl = launchPresentationReturnUrl;
87 | }
88 |
89 | public String getToolConsumerInstanceGuid() {
90 | return toolConsumerInstanceGuid;
91 | }
92 |
93 | public void setToolConsumerInstanceGuid(String toolConsumerInstanceGuid) {
94 | this.toolConsumerInstanceGuid = toolConsumerInstanceGuid;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/launch/LtiOauthSigner.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti.launch;
2 |
3 | import net.oauth.OAuthAccessor;
4 | import net.oauth.OAuthConsumer;
5 | import net.oauth.OAuthException;
6 | import net.oauth.OAuthMessage;
7 | import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
8 | import oauth.signpost.exception.OAuthCommunicationException;
9 | import oauth.signpost.exception.OAuthExpectationFailedException;
10 | import oauth.signpost.exception.OAuthMessageSignerException;
11 | import oauth.signpost.http.HttpParameters;
12 | import org.apache.commons.codec.binary.Base64;
13 | import org.apache.http.HttpEntity;
14 | import org.apache.http.HttpEntityEnclosingRequest;
15 | import org.apache.http.HttpRequest;
16 | import org.apache.commons.io.IOUtils;
17 |
18 | import java.io.IOException;
19 | import java.net.URISyntaxException;
20 | import java.net.URLEncoder;
21 | import java.security.MessageDigest;
22 | import java.security.NoSuchAlgorithmException;
23 | import java.util.HashMap;
24 | import java.util.Map;
25 |
26 | /**
27 | * This class signs LTI requests according to the Oauth 1.0 spec
28 | * @author Paul Gray
29 | * @since 1.1
30 | */
31 | public class LtiOauthSigner implements LtiSigner {
32 |
33 | private MessageDigest md;
34 |
35 | public LtiOauthSigner() {
36 | try{
37 | md = MessageDigest.getInstance("SHA1");
38 | } catch(NoSuchAlgorithmException e) {
39 | throw new RuntimeException("Could not construct new instance of LtiOauthSigner", e);
40 | }
41 | }
42 |
43 | public LtiOauthSigner(MessageDigest md) {
44 | this.md = md;
45 | }
46 |
47 | @Override
48 | public HttpRequest sign(HttpRequest request, String key, String secret) throws LtiSigningException {
49 | CommonsHttpOAuthConsumer signer = new CommonsHttpOAuthConsumer(key, secret);
50 | try {
51 | String body = getRequestBody(request);
52 | String bodyHash = new String(Base64.encodeBase64(md.digest(body.getBytes())));
53 |
54 | HttpParameters params = new HttpParameters();
55 | params.put("oauth_body_hash", URLEncoder.encode(bodyHash, "UTF-8"));
56 | signer.setAdditionalParameters(params);
57 |
58 | signer.sign(request);
59 | } catch (OAuthMessageSignerException|OAuthExpectationFailedException|OAuthCommunicationException|IOException e) {
60 | throw new LtiSigningException("Exception encountered while singing Lti request...", e);
61 | }
62 | return request;
63 | }
64 |
65 | @Override
66 | public Map signParameters(Map parameters, String key, String secret, String url, String method) throws LtiSigningException {
67 | OAuthMessage oam = new OAuthMessage(method, url, parameters.entrySet());
68 | OAuthConsumer cons = new OAuthConsumer(null, key, secret, null);
69 | OAuthAccessor acc = new OAuthAccessor(cons);
70 | try {
71 | oam.addRequiredParameters(acc);
72 |
73 | Map signedParameters = new HashMap<>();
74 | for(Map.Entry param : oam.getParameters()){
75 | signedParameters.put(param.getKey(), param.getValue());
76 | }
77 | return signedParameters;
78 | } catch (OAuthException |IOException |URISyntaxException e) {
79 | throw new LtiSigningException("Error signing LTI request.", e);
80 | }
81 | }
82 |
83 | private String getRequestBody(HttpRequest req) throws IOException {
84 | if(req instanceof HttpEntityEnclosingRequest){
85 | HttpEntity body = ((HttpEntityEnclosingRequest) req).getEntity();
86 | if(body == null) {
87 | return "";
88 | } else {
89 | return IOUtils.toString(body.getContent());
90 | }
91 | } else {
92 | // requests with no entity have an empty string as the body
93 | return "";
94 | }
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/launch/LtiOauthVerifier.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti.launch;
2 |
3 | import net.oauth.*;
4 | import net.oauth.server.OAuthServlet;
5 |
6 | import javax.servlet.http.HttpServletRequest;
7 | import java.util.Arrays;
8 | import java.util.Map;
9 | import java.util.logging.Logger;
10 |
11 | /**
12 | * This class verifies LTI launches according to the Oauth 1.0 spec
13 | * @author Paul Gray
14 | * @since 1.1
15 | */
16 | public class LtiOauthVerifier implements LtiVerifier {
17 |
18 | public static final String OAUTH_KEY_PARAMETER= "oauth_consumer_key";
19 |
20 | private final static Logger logger = Logger.getLogger(LtiOauthVerifier.class.getName());
21 |
22 | /**
23 | * This method verifies the signed HttpServletRequest
24 | * @param request the HttpServletRequest that will be verified
25 | * @param secret the secret to verify the properties with
26 | * @return the result of the verification, along with contextual
27 | * information
28 | * @throws LtiVerificationException
29 | */
30 | @Override
31 | public LtiVerificationResult verify(HttpServletRequest request, String secret) throws LtiVerificationException {
32 | OAuthMessage oam = OAuthServlet.getMessage(request, OAuthServlet.getRequestURL(request));
33 | String oauth_consumer_key = null;
34 | try {
35 | oauth_consumer_key = oam.getConsumerKey();
36 | } catch (Exception e) {
37 | return new LtiVerificationResult(false, LtiError.BAD_REQUEST, "Unable to find consumer key in message");
38 | }
39 |
40 | OAuthValidator oav = new SimpleOAuthValidator();
41 | OAuthConsumer cons = new OAuthConsumer(null, oauth_consumer_key, secret, null);
42 | OAuthAccessor acc = new OAuthAccessor(cons);
43 |
44 | try {
45 | oav.validateMessage(oam, acc);
46 | } catch (Exception e) {
47 | return new LtiVerificationResult(false, LtiError.BAD_REQUEST, "Failed to validate: " + e.getLocalizedMessage());
48 | }
49 | return new LtiVerificationResult(true, new LtiLaunch(request));
50 | }
51 |
52 | /**
53 | * This method will verify a collection of parameters
54 | * @param parameters the parameters that will be verified. mapped by key & value
55 | * @param url the url this request was made at
56 | * @param method the method this url was requested with
57 | * @param secret the secret to verify the propertihes with
58 | * @return
59 | * @throws LtiVerificationException
60 | */
61 | @Override
62 | public LtiVerificationResult verifyParameters(Map parameters, String url, String method, String secret) throws LtiVerificationException {
63 | OAuthMessage oam = new OAuthMessage(method, url, parameters.entrySet());
64 | OAuthConsumer cons = new OAuthConsumer(null, parameters.get(OAUTH_KEY_PARAMETER), secret, null);
65 | OAuthValidator oav = new SimpleOAuthValidator();
66 | OAuthAccessor acc = new OAuthAccessor(cons);
67 |
68 | try {
69 | oav.validateMessage(oam, acc);
70 | } catch (Exception e) {
71 | return new LtiVerificationResult(false, LtiError.BAD_REQUEST, "Failed to validate: " + e.getLocalizedMessage() + ", Parameters: " + Arrays.toString(parameters.entrySet().toArray()));
72 | }
73 | return new LtiVerificationResult(true, new LtiLaunch(parameters));
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/launch/LtiSigner.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti.launch;
2 |
3 | import org.apache.http.HttpRequest;
4 |
5 | import java.util.Map;
6 |
7 | /**
8 | * This interface contains methods that sign HttpRequests
9 | * and generic request parameters according to the LTI
10 | * specification.
11 | * @author Paul Gray
12 | * @since 1.1
13 | */
14 | public interface LtiSigner {
15 |
16 | /**
17 | * This method will return a signed HttpRequest object.
18 | * Once returned, adding new parameters or changing the
19 | * body will invalidate the signature. This method should
20 | * be used for server to server connection requests.
21 | * For example, posting an LTI Outcome back to the LTI
22 | * Consumer.
23 | * @param request the HttpRequest that will be signed
24 | * @param key the key that will be added to the request.
25 | * @param secret the secret to be used
26 | * @return a signed HttpRequest object
27 | * @throws LtiSigningException
28 | */
29 | public HttpRequest sign(HttpRequest request, String key, String secret) throws LtiSigningException;
30 |
31 | /**
32 | * This method will return a list of signed parameters.
33 | * Once returned, adding new parameters or changing the
34 | * body will invalidate the signature. This method will
35 | * overwrite reserved parameters from the underlying
36 | * specification. For example, if you are using the Oauth
37 | * implementation, oauth_signature will be removed
38 | * & replaced with the generated signature from the properties.
39 | * @param parameters the parameters that will be signed. mapped by key & value
40 | * @param key the key that will be added to the request.
41 | * @param secret the secret to be sign the parameters with
42 | * @return a map of signed parameters (including the signature)
43 | * @throws LtiSigningException
44 | */
45 | public Map signParameters(Map parameters, String key, String secret, String url, String method) throws LtiSigningException;
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/launch/LtiSigningException.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti.launch;
2 |
3 | /**
4 | * This exception is thrown to indicate that there was an error when signing an LTI request.
5 | *
6 | * Created by pgray on 8/23/14.
7 | */
8 | public class LtiSigningException extends Exception {
9 | public LtiSigningException(String message, Exception exception) {
10 | super(message, exception);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/launch/LtiUser.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti.launch;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 | import java.util.LinkedList;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | /**
9 | * Created by paul on 5/28/14.
10 | */
11 | public class LtiUser {
12 |
13 | private String id;
14 | private List roles;
15 |
16 | public LtiUser(HttpServletRequest request) {
17 | this.id = request.getParameter("user_id");
18 | this.roles = new LinkedList<>();
19 | if(request.getParameter("roles") != null) {
20 | for (String role : request.getParameter("roles").split(",")) {
21 | this.roles.add(role.trim());
22 | }
23 | }
24 | }
25 |
26 | public LtiUser(Map parameters) {
27 | this.id = parameters.get("user_id");
28 | this.roles = new LinkedList<>();
29 | if(parameters.get("roles") != null) {
30 | for (String role : parameters.get("roles").split(",")) {
31 | this.roles.add(role.trim());
32 | }
33 | }
34 | }
35 |
36 | public String getId() {
37 | return id;
38 | }
39 |
40 | public void setId(String id) {
41 | this.id = id;
42 | }
43 |
44 | public List getRoles() {
45 | return roles;
46 | }
47 |
48 | public void setRoles(List roles) {
49 | this.roles = roles;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/launch/LtiVerificationException.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti.launch;
2 |
3 | /**
4 | * Created by pgray on 8/28/14.
5 | */
6 | public class LtiVerificationException extends Exception {
7 | public LtiVerificationException(String message, Exception exception) {
8 | super(message, exception);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/launch/LtiVerificationResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package org.imsglobal.lti.launch;
7 |
8 | import org.imsglobal.lti.launch.LtiError;
9 | import org.imsglobal.lti.launch.LtiLaunch;
10 |
11 | /**
12 | *
13 | * @author pgray
14 | */
15 | public class LtiVerificationResult {
16 |
17 | private Boolean success;
18 | private LtiError error;
19 | private String message;
20 | private LtiLaunch ltiLaunchResult;
21 |
22 | public LtiVerificationResult() {
23 | }
24 |
25 | public LtiVerificationResult(Boolean success, LtiError error, String message) {
26 | this.success = success;
27 | this.error = error;
28 | this.message = message;
29 | }
30 |
31 | public LtiVerificationResult(Boolean success, LtiLaunch ltiLaunchResult) {
32 | this.ltiLaunchResult = ltiLaunchResult;
33 | this.success = success;
34 | }
35 |
36 | public LtiVerificationResult(Boolean success, LtiError error, String message, LtiLaunch ltiLaunchResult) {
37 | this.success = success;
38 | this.error = error;
39 | this.message = message;
40 | this.ltiLaunchResult = ltiLaunchResult;
41 | }
42 |
43 | public Boolean getSuccess() {
44 | return success;
45 | }
46 |
47 | public void setSuccess(Boolean success) {
48 | this.success = success;
49 | }
50 |
51 | public LtiError getError() {
52 | return error;
53 | }
54 |
55 | public void setError(LtiError error) {
56 | this.error = error;
57 | }
58 |
59 | public LtiLaunch getLtiLaunchResult() {
60 | return ltiLaunchResult;
61 | }
62 |
63 | public void setLtiLaunchResult(LtiLaunch ltiLaunchResult) {
64 | this.ltiLaunchResult = ltiLaunchResult;
65 | }
66 |
67 | public String getMessage() {
68 | return message;
69 | }
70 |
71 | public void setMessage(String message) {
72 | this.message = message;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti/launch/LtiVerifier.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti.launch;
2 |
3 |
4 | import javax.servlet.http.HttpServletRequest;
5 | import java.util.Map;
6 |
7 | /**
8 | * This interface contains methods that verify HttpRequests
9 | * and generic request parameters according to the LTI
10 | * specification.
11 | * @author Paul Gray
12 | * @since 1.1
13 | */
14 | public interface LtiVerifier {
15 |
16 | /**
17 | * This method will verify the HttpServletRequest.
18 | *
19 | * @param request the HttpServletRequest that will be verified
20 | * @param secret the secret to verify the properties with
21 | * @return an LtiVerificationResult which will
22 | * contain information about the request (whether or
23 | * not it is valid, and if it is valid, contextual
24 | * information about the request).
25 | * @throws LtiVerificationException
26 | */
27 | public LtiVerificationResult verify(HttpServletRequest request, String secret) throws LtiVerificationException;
28 |
29 | /**
30 | * This method will verify a list of properties (mapped
31 | * by key & value).
32 | * @param parameters the parameters that will be verified. mapped by key & value
33 | * @param url the url this request was made at
34 | * @param method the method this url was requested with
35 | * @param secret the secret to verify the propertihes with
36 | * @return an LtiVerificationResult which will
37 | * contain information about the request (whether or
38 | * not it is valid, and if it is valid, contextual
39 | * information about the request).
40 | * @throws LtiVerificationException
41 | */
42 | public LtiVerificationResult verifyParameters(Map parameters, String url, String method, String secret) throws LtiVerificationException;
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/LTI2Config.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2;
3 |
4 | // Capture the information needed to build a tool profile
5 | public interface LTI2Config {
6 | // A globally unique identifier for the service. The domain name is typical.
7 | // The scope for this is tenant/customer
8 | public String getGuid();
9 | public String getSupport_email();
10 |
11 | // In a multi-tenant environment this data describes the tenant / customer.
12 | public String getService_owner_id();
13 | public String getService_owner_owner_name();
14 | public String getService_owner_description();
15 | public String getService_owner_support_email();
16 |
17 | // This represents the service provider that hosts a product.
18 | // If this is self hosted, it is reasonable that these values
19 | // are the same as the "owner" values above.
20 | public String getService_provider_id();
21 | public String getService_provider_provider_name();
22 | public String getService_provider_description();
23 | public String getService_provider_support_email();
24 |
25 | // This section is general information about the software product
26 | public String getProduct_family_product_code();
27 | public String getProduct_family_vendor_code();
28 | public String getProduct_family_vendor_name();
29 | public String getProduct_family_vendor_description();
30 | public String getProduct_family_vendor_website();
31 | public String getProduct_family_vendor_contact();
32 |
33 | // This is about one particular version of a product
34 | public String getProduct_info_product_name();
35 | public String getProduct_info_product_version();
36 | public String getProduct_info_product_description();
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/LTI2ConfigSample.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti2;
2 |
3 | public class LTI2ConfigSample implements LTI2Config {
4 |
5 | // A globally unique identifier for the service. The domain name is typical.
6 | // The scope for this is tenant/customer
7 | public String getGuid() {
8 | return "edunext.school.edu";
9 | }
10 | public String getSupport_email() {
11 | return "support@edunext.school.edu";
12 | }
13 |
14 | // In a multi-tenant environment this data describes the tenant / customer.
15 | public String getService_owner_id() {
16 | return "https://edunext.school.edu";
17 | }
18 | public String getService_owner_owner_name() {
19 | return "ETS at SchoolEdu";
20 | }
21 | public String getService_owner_description() {
22 | return "The Ed. Tech Services Division of SchoolEdu";
23 | }
24 | public String getService_owner_support_email() {
25 | return "edunext@school.edu";
26 | }
27 |
28 | // This represents the service provider that hosts a product.
29 | // If this is self hosted, it is reasonable that these values
30 | // are the same as the "owner" values above.
31 | public String getService_provider_id() {
32 | return "https://hosting.example.com";
33 | }
34 | public String getService_provider_provider_name() {
35 | return "Example Hosting Services";
36 | }
37 | public String getService_provider_description() {
38 | return "We are the best example of a hosting services for EduNext.";
39 | }
40 | public String getService_provider_support_email() {
41 | return "sales@hosting.example.com";
42 | }
43 |
44 | // This section is about the software product
45 | public String getProduct_family_product_code() {
46 | return "edunext";
47 | }
48 | public String getProduct_family_vendor_code() {
49 | return "edunext";
50 | }
51 | public String getProduct_family_vendor_name() {
52 | return "Edu Next Project";
53 | }
54 | public String getProduct_family_vendor_description() {
55 | return "EduNext is whats next in education.";
56 | }
57 | public String getProduct_family_vendor_website() {
58 | return "http://www.edunext.example.com";
59 | }
60 | public String getProduct_family_vendor_contact() {
61 | return "sales@edunext.sample.com";
62 | }
63 |
64 | // This is about one particular version of a product.
65 | public String getProduct_info_product_name() {
66 | return "Classes";
67 | }
68 | public String getProduct_info_product_version() {
69 | return "2.0";
70 | }
71 | public String getProduct_info_product_description() {
72 | return "Classes 2.0";
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/LTI2Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 IMS GLobal Learning Consortium
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 | * implied. See the License for the specific language governing
14 | * permissions and limitations under the License.
15 | *
16 | */
17 | package org.imsglobal.lti2;
18 |
19 | public class LTI2Constants {
20 | /**
21 | * LTI2_VERSION_STRING=LTI-2p0
22 | *
23 | * This indicates an LTI 2.0 launch.
24 | */
25 | public static final String LTI2_VERSION_STRING = "LTI-2p0";
26 |
27 | /**
28 | * REG_KEY="9875"
29 | *
30 | * This is the registration key for the callback.
31 | */
32 | public static final String REG_KEY = "reg_key";
33 |
34 | /**
35 | * REG_PASSWORD="9875"
36 | *
37 | * This is the registration password for the callback.
38 | */
39 | public static final String REG_PASSWORD = "reg_password";
40 |
41 | /**
42 | * TC_PROFILE_URL
43 | *
44 | * This is the profile URL.
45 | */
46 | public static final String TC_PROFILE_URL = "tc_profile_url";
47 |
48 | public static final String JSONLD_ID = "@id";
49 | public static final String CONTEXT = "@context";
50 | public static final String TYPE = "@type";
51 | public static final String VALUE = "@value";
52 | public static final String GRAPH = "@graph";
53 |
54 | public static final String CUSTOM_URL = "custom_url";
55 | public static final String TOOL_PROXY_GUID = "tool_proxy_guid";
56 | public static final String SHARED_SECRET = "shared_secret";
57 | public static final String CUSTOM = "custom";
58 | public static final String SECURITY_CONTRACT = "security_contract";
59 | public static final String SERVICE = "service";
60 | public static final String TOOL_SERVICE = "tool_service";
61 | public static final String GRADE = "grade";
62 | public static final String GRADE_TYPE_DECIMAL = "decimal";
63 | public static final String COMMENT = "comment";
64 | public static final String RESULTSCORE = "resultScore";
65 |
66 | /**
67 | * Utility array useful for validating property names when building launch
68 | * data.
69 | */
70 | public static final String[] validPropertyNames = {
71 | REG_KEY, REG_PASSWORD, TC_PROFILE_URL };
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/LTI2SampleData.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti2;
2 |
3 | import java.util.Properties;
4 | import org.imsglobal.lti.BasicLTIConstants;
5 |
6 | public class LTI2SampleData {
7 |
8 | public static Properties getSubstitution() {
9 | Properties lti2subst = new Properties();
10 | lti2subst.setProperty("CourseOffering.id","context_id_999");
11 | lti2subst.setProperty("CourseOffering.label","SI364");
12 | lti2subst.setProperty("CourseOffering.title","Building Interactive Applications");
13 | lti2subst.setProperty("Membership.role","Instructor");
14 | lti2subst.setProperty("ResourceLink.id","res_link_999");
15 | lti2subst.setProperty("ResourceLink.title","My weekly blog");
16 | lti2subst.setProperty("User.id","user_id_007");
17 | lti2subst.setProperty("User.username","bond");
18 | lti2subst.setProperty("Person.name.given","James");
19 | lti2subst.setProperty("Person.name.family","Bond");
20 | lti2subst.setProperty("Person.name.full","James Bond");
21 | lti2subst.setProperty("Person.email.primary","bond@example.com");
22 | return lti2subst;
23 | }
24 |
25 | public static Properties getLaunch() {
26 | Properties launch = new Properties();
27 | launch.setProperty(BasicLTIConstants.CONTEXT_ID,"context_id_999");
28 | launch.setProperty(BasicLTIConstants.CONTEXT_LABEL,"SI364");
29 | launch.setProperty(BasicLTIConstants.CONTEXT_TITLE,"Building Interactive Applications");
30 | launch.setProperty(BasicLTIConstants.ROLES,"Instructor");
31 | launch.setProperty(BasicLTIConstants.RESOURCE_LINK_ID,"res_link_999");
32 | launch.setProperty(BasicLTIConstants.RESOURCE_LINK_TITLE,"My weekly blog");
33 | launch.setProperty(BasicLTIConstants.USER_ID,"user_id_007");
34 | launch.setProperty(BasicLTIConstants.LIS_PERSON_NAME_GIVEN,"James");
35 | launch.setProperty(BasicLTIConstants.LIS_PERSON_NAME_FAMILY,"Bond");
36 | launch.setProperty(BasicLTIConstants.LIS_PERSON_NAME_FULL,"James Bond");
37 | launch.setProperty(BasicLTIConstants.LIS_PERSON_CONTACT_EMAIL_PRIMARY,"bond@example.com");
38 | return launch;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/LTI2Util.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $URL: https://source.sakaiproject.org/svn/basiclti/trunk/basiclti-util/src/java/org/imsglobal/lti2/LTI2Util.java $
3 | * $Id: LTI2Util.java 134448 2014-02-12 18:32:12Z csev@umich.edu $
4 | *
5 | * Copyright (c) 2013 IMS GLobal Learning Consortium
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16 | * implied. See the License for the specific language governing
17 | * permissions and limitations under the License.
18 | */
19 |
20 | package org.imsglobal.lti2;
21 |
22 | import java.net.URL;
23 | import java.util.ArrayList;
24 | import java.util.Enumeration;
25 | import java.util.Iterator;
26 | import java.util.List;
27 | import java.util.Properties;
28 | import java.util.logging.Logger;
29 |
30 | import javax.servlet.http.HttpServletRequest;
31 |
32 | import org.imsglobal.lti.BasicLTIUtil;
33 | import org.imsglobal.lti2.objects.consumer.ServiceOffered;
34 | import org.imsglobal.lti2.objects.consumer.StandardServices;
35 | import org.imsglobal.lti2.objects.consumer.ToolConsumer;
36 | import org.json.simple.JSONArray;
37 | import org.json.simple.JSONObject;
38 | import org.json.simple.JSONValue;
39 |
40 | public class LTI2Util {
41 |
42 | // We use the built-in Java logger because this code needs to be very generic
43 | private static Logger M_log = Logger.getLogger(LTI2Util.class.toString());
44 |
45 | public static final String SCOPE_LtiLink = "LtiLink";
46 | public static final String SCOPE_ToolProxyBinding = "ToolProxyBinding";
47 | public static final String SCOPE_ToolProxy = "ToolProxy";
48 |
49 | private static final String EMPTY_JSON_OBJECT = "{\n}\n";
50 |
51 | // Validate the incoming tool_services against a tool consumer
52 | public static String validateServices(ToolConsumer consumer, JSONObject providerProfile)
53 | {
54 | // Mostly to catch casting errors from bad JSON
55 | try {
56 | JSONObject security_contract = (JSONObject) providerProfile.get(LTI2Constants.SECURITY_CONTRACT);
57 | if ( security_contract == null ) {
58 | return "JSON missing security_contract";
59 | }
60 | JSONArray tool_services = (JSONArray) security_contract.get(LTI2Constants.TOOL_SERVICE);
61 |
62 | List services_offered = consumer.getService_offered();
63 |
64 | if ( tool_services != null ) for (Object o : tool_services) {
65 | JSONObject tool_service = (JSONObject) o;
66 | String json_service = (String) tool_service.get(LTI2Constants.SERVICE);
67 |
68 | boolean found = false;
69 | for (ServiceOffered service : services_offered ) {
70 | String service_endpoint = service.getEndpoint();
71 | if ( service_endpoint.equals(json_service) ) {
72 | found = true;
73 | break;
74 | }
75 | }
76 | if ( ! found ) return "Service not allowed: "+json_service;
77 | }
78 | return null;
79 | }
80 | catch (Exception e) {
81 | return "Exception:"+ e.getLocalizedMessage();
82 | }
83 | }
84 |
85 | // Validate incoming capabilities requested against out ToolConsumer
86 | public static String validateCapabilities(ToolConsumer consumer, JSONObject providerProfile)
87 | {
88 | List theTools = new ArrayList ();
89 | Properties info = new Properties();
90 |
91 | // Mostly to catch casting errors from bad JSON
92 | try {
93 | String retval = parseToolProfile(theTools, info, providerProfile);
94 | if ( retval != null ) return retval;
95 |
96 | if ( theTools.size() < 1 ) return "No tools found in profile";
97 |
98 | // Check all the capabilities requested by all the tools comparing against consumer
99 | List capabilities = consumer.getCapability_offered();
100 | for ( Properties theTool : theTools ) {
101 | String ec = (String) theTool.get("enabled_capability");
102 | JSONArray enabled_capability = (JSONArray) JSONValue.parse(ec);
103 | if ( enabled_capability != null ) for (Object o : enabled_capability) {
104 | ec = (String) o;
105 | if ( capabilities.contains(ec) ) continue;
106 | return "Capability not permitted="+ec;
107 | }
108 | }
109 | return null;
110 | }
111 | catch (Exception e ) {
112 | return "Exception:"+ e.getLocalizedMessage();
113 | }
114 | }
115 |
116 | public static void allowEmail(List capabilities) {
117 | capabilities.add("Person.email.primary");
118 | }
119 |
120 | public static void allowName(List capabilities) {
121 | capabilities.add("User.username");
122 | capabilities.add("Person.name.fullname");
123 | capabilities.add("Person.name.given");
124 | capabilities.add("Person.name.family");
125 | capabilities.add("Person.name.full");
126 | }
127 |
128 | public static void allowResult(List capabilities) {
129 | capabilities.add("Result.sourcedId");
130 | capabilities.add("Result.autocreate");
131 | capabilities.add("Result.url");
132 | }
133 |
134 | public static void allowSettings(List capabilities) {
135 | capabilities.add("LtiLink.custom.url");
136 | capabilities.add("ToolProxy.custom.url");
137 | capabilities.add("ToolProxyBinding.custom.url");
138 | }
139 |
140 | // If this code looks like a hack - it is because the spec is a hack.
141 | // There are five possible scenarios for GET and two possible scenarios
142 | // for PUT. I begged to simplify the business logic but was overrulled.
143 | // So we write obtuse code.
144 | @SuppressWarnings({ "unchecked", "unused" })
145 | public static Object getSettings(HttpServletRequest request, String scope,
146 | JSONObject link_settings, JSONObject binding_settings, JSONObject proxy_settings,
147 | String link_url, String binding_url, String proxy_url)
148 | {
149 | // Check to see if we are doing the bubble
150 | String bubbleStr = request.getParameter("bubble");
151 | String acceptHdr = request.getHeader("Accept");
152 | String contentHdr = request.getContentType();
153 |
154 | if ( bubbleStr != null && bubbleStr.equals("all") &&
155 | acceptHdr.indexOf(StandardServices.TOOLSETTINGS_FORMAT) < 0 ) {
156 | return "Simple format does not allow bubble=all";
157 | }
158 |
159 | if ( SCOPE_LtiLink.equals(scope) || SCOPE_ToolProxyBinding.equals(scope)
160 | || SCOPE_ToolProxy.equals(scope) ) {
161 | // All good
162 | } else {
163 | return "Bad Setttings Scope="+scope;
164 | }
165 |
166 | boolean bubble = bubbleStr != null && "GET".equals(request.getMethod());
167 | boolean distinct = bubbleStr != null && "distinct".equals(bubbleStr);
168 | boolean bubbleAll = bubbleStr != null && "all".equals(bubbleStr);
169 |
170 | // Check our output format
171 | boolean acceptComplex = acceptHdr == null || acceptHdr.indexOf(StandardServices.TOOLSETTINGS_FORMAT) >= 0;
172 |
173 | if ( distinct && link_settings != null && scope.equals(SCOPE_LtiLink) ) {
174 | Iterator i = link_settings.keySet().iterator();
175 | while ( i.hasNext() ) {
176 | String key = (String) i.next();
177 | if ( binding_settings != null ) binding_settings.remove(key);
178 | if ( proxy_settings != null ) proxy_settings.remove(key);
179 | }
180 | }
181 |
182 | if ( distinct && binding_settings != null && scope.equals(SCOPE_ToolProxyBinding) ) {
183 | Iterator i = binding_settings.keySet().iterator();
184 | while ( i.hasNext() ) {
185 | String key = (String) i.next();
186 | if ( proxy_settings != null ) proxy_settings.remove(key);
187 | }
188 | }
189 |
190 | // Lets get this party started...
191 | JSONObject jsonResponse = null;
192 | if ( (distinct || bubbleAll) && acceptComplex ) {
193 | jsonResponse = new JSONObject();
194 | jsonResponse.put(LTI2Constants.CONTEXT,StandardServices.TOOLSETTINGS_CONTEXT);
195 | JSONArray graph = new JSONArray();
196 | boolean started = false;
197 | if ( link_settings != null && SCOPE_LtiLink.equals(scope) ) {
198 | JSONObject cjson = new JSONObject();
199 | cjson.put(LTI2Constants.JSONLD_ID,link_url);
200 | cjson.put(LTI2Constants.TYPE,SCOPE_LtiLink);
201 | cjson.put(LTI2Constants.CUSTOM,link_settings);
202 | graph.add(cjson);
203 | started = true;
204 | }
205 | if ( binding_settings != null && ( started || SCOPE_ToolProxyBinding.equals(scope) ) ) {
206 | JSONObject cjson = new JSONObject();
207 | cjson.put(LTI2Constants.JSONLD_ID,binding_url);
208 | cjson.put(LTI2Constants.TYPE,SCOPE_ToolProxyBinding);
209 | cjson.put(LTI2Constants.CUSTOM,binding_settings);
210 | graph.add(cjson);
211 | started = true;
212 | }
213 | if ( proxy_settings != null && ( started || SCOPE_ToolProxy.equals(scope) ) ) {
214 | JSONObject cjson = new JSONObject();
215 | cjson.put(LTI2Constants.JSONLD_ID,proxy_url);
216 | cjson.put(LTI2Constants.TYPE,SCOPE_ToolProxy);
217 | cjson.put(LTI2Constants.CUSTOM,proxy_settings);
218 | graph.add(cjson);
219 | }
220 | jsonResponse.put(LTI2Constants.GRAPH,graph);
221 |
222 | } else if ( distinct ) { // Simple format output
223 | jsonResponse = proxy_settings;
224 | if ( SCOPE_LtiLink.equals(scope) ) {
225 | jsonResponse.putAll(binding_settings);
226 | jsonResponse.putAll(link_settings);
227 | } else if ( SCOPE_ToolProxyBinding.equals(scope) ) {
228 | jsonResponse.putAll(binding_settings);
229 | }
230 | } else { // bubble not specified
231 | jsonResponse = new JSONObject();
232 | jsonResponse.put(LTI2Constants.CONTEXT,StandardServices.TOOLSETTINGS_CONTEXT);
233 | JSONObject theSettings = null;
234 | String endpoint = null;
235 | if ( SCOPE_LtiLink.equals(scope) ) {
236 | endpoint = link_url;
237 | theSettings = link_settings;
238 | } else if ( SCOPE_ToolProxyBinding.equals(scope) ) {
239 | endpoint = binding_url;
240 | theSettings = binding_settings;
241 | }
242 | if ( SCOPE_ToolProxy.equals(scope) ) {
243 | endpoint = proxy_url;
244 | theSettings = proxy_settings;
245 | }
246 | if ( acceptComplex ) {
247 | JSONArray graph = new JSONArray();
248 | JSONObject cjson = new JSONObject();
249 | cjson.put(LTI2Constants.JSONLD_ID,endpoint);
250 | cjson.put(LTI2Constants.TYPE,scope);
251 | cjson.put(LTI2Constants.CUSTOM,theSettings);
252 | graph.add(cjson);
253 | jsonResponse.put(LTI2Constants.GRAPH,graph);
254 | } else {
255 | jsonResponse = theSettings;
256 | }
257 | }
258 | return jsonResponse;
259 | }
260 |
261 | // Parse a provider profile with lots of error checking...
262 | public static String parseToolProfile(List theTools, Properties info, JSONObject jsonObject)
263 | {
264 | try {
265 | return parseToolProfileInternal(theTools, info, jsonObject);
266 | } catch (Exception e) {
267 | M_log.warning("Internal error parsing tool proxy\n"+jsonObject.toString());
268 | e.printStackTrace();
269 | return "Internal error parsing tool proxy:"+e.getLocalizedMessage();
270 | }
271 | }
272 |
273 | // Parse a provider profile with lots of error checking...
274 | @SuppressWarnings("unused")
275 | private static String parseToolProfileInternal(List theTools, Properties info, JSONObject jsonObject)
276 | {
277 | Object o = null;
278 | JSONObject tool_profile = (JSONObject) jsonObject.get("tool_profile");
279 | if ( tool_profile == null ) {
280 | return "JSON missing tool_profile";
281 | }
282 | JSONObject product_instance = (JSONObject) tool_profile.get("product_instance");
283 | if ( product_instance == null ) {
284 | return "JSON missing product_instance";
285 | }
286 |
287 | String instance_guid = (String) product_instance.get("guid");
288 | if ( instance_guid == null ) {
289 | return "JSON missing product_info / guid";
290 | }
291 | info.put("instance_guid",instance_guid);
292 |
293 | JSONObject product_info = (JSONObject) product_instance.get("product_info");
294 | if ( product_info == null ) {
295 | return "JSON missing product_info";
296 | }
297 |
298 | // Look for required fields
299 | JSONObject product_name = product_info == null ? null : (JSONObject) product_info.get("product_name");
300 | String productTitle = product_name == null ? null : (String) product_name.get("default_value");
301 | JSONObject description = product_info == null ? null : (JSONObject) product_info.get("description");
302 | String productDescription = description == null ? null : (String) description.get("default_value");
303 |
304 | JSONObject product_family = product_info == null ? null : (JSONObject) product_info.get("product_family");
305 | String productCode = product_family == null ? null : (String) product_family.get("code");
306 | JSONObject product_vendor = product_family == null ? null : (JSONObject) product_family.get("vendor");
307 | description = product_vendor == null ? null : (JSONObject) product_vendor.get("description");
308 | String vendorDescription = description == null ? null : (String) description.get("default_value");
309 | String vendorCode = product_vendor == null ? null : (String) product_vendor.get("code");
310 |
311 | if ( productTitle == null || productDescription == null ) {
312 | return "JSON missing product_name or description ";
313 | }
314 | if ( productCode == null || vendorCode == null || vendorDescription == null ) {
315 | return "JSON missing product code, vendor code or description";
316 | }
317 |
318 | info.put("product_name", productTitle);
319 | info.put("description", productDescription); // Backwards compatibility
320 | info.put("product_description", productDescription);
321 | info.put("product_code", productCode);
322 | info.put("vendor_code", vendorCode);
323 | info.put("vendor_description", vendorDescription);
324 |
325 | o = tool_profile.get("base_url_choice");
326 | if ( ! (o instanceof JSONArray)|| o == null ) {
327 | return "JSON missing base_url_choices";
328 | }
329 | JSONArray base_url_choices = (JSONArray) o;
330 |
331 | String secure_base_url = null;
332 | String default_base_url = null;
333 | for ( Object i : base_url_choices ) {
334 | JSONObject url_choice = (JSONObject) i;
335 | secure_base_url = (String) url_choice.get("secure_base_url");
336 | default_base_url = (String) url_choice.get("default_base_url");
337 | }
338 |
339 | String launch_url = secure_base_url;
340 | if ( launch_url == null ) launch_url = default_base_url;
341 | if ( launch_url == null ) {
342 | return "Unable to determine launch URL";
343 | }
344 |
345 | o = (JSONArray) tool_profile.get("resource_handler");
346 | if ( ! (o instanceof JSONArray)|| o == null ) {
347 | return "JSON missing resource_handlers";
348 | }
349 | JSONArray resource_handlers = (JSONArray) o;
350 |
351 | // Loop through resource handlers, read, and check for errors
352 | for(Object i : resource_handlers ) {
353 | JSONObject resource_handler = (JSONObject) i;
354 | JSONObject resource_type_json = (JSONObject) resource_handler.get("resource_type");
355 | String resource_type_code = (String) resource_type_json.get("code");
356 | if ( resource_type_code == null ) {
357 | return "JSON missing resource_type code";
358 | }
359 | o = (JSONArray) resource_handler.get("message");
360 | if ( ! (o instanceof JSONArray)|| o == null ) {
361 | return "JSON missing resource_handler / message";
362 | }
363 | JSONArray messages = (JSONArray) o;
364 |
365 | JSONObject titleObject = (JSONObject) resource_handler.get("name");
366 | String title = titleObject == null ? null : (String) titleObject.get("default_value");
367 | if ( title == null || titleObject == null ) {
368 | return "JSON missing resource_handler / name / default_value";
369 | }
370 |
371 | JSONObject buttonObject = (JSONObject) resource_handler.get("short_name");
372 | String button = buttonObject == null ? null : (String) buttonObject.get("default_value");
373 |
374 | JSONObject descObject = (JSONObject) resource_handler.get("description");
375 | String resourceDescription = descObject == null ? null : (String) descObject.get("default_value");
376 |
377 | String path = null;
378 | JSONArray parameter = null;
379 | JSONArray enabled_capability = null;
380 | for ( Object m : messages ) {
381 | JSONObject message = (JSONObject) m;
382 | String message_type = (String) message.get("message_type");
383 | if ( ! "basic-lti-launch-request".equals(message_type) ) continue;
384 | if ( path != null ) {
385 | return "A resource_handler cannot have more than one basic-lti-launch-request message RT="+resource_type_code;
386 | }
387 | path = (String) message.get("path");
388 | if ( path == null ) {
389 | return "A basic-lti-launch-request message must have a path RT="+resource_type_code;
390 | }
391 | o = (JSONArray) message.get("parameter");
392 | if ( ! (o instanceof JSONArray)) {
393 | return "Must be an array: parameter RT="+resource_type_code;
394 | }
395 | parameter = (JSONArray) o;
396 |
397 | o = (JSONArray) message.get("enabled_capability");
398 | if ( ! (o instanceof JSONArray)) {
399 | return "Must be an array: enabled_capability RT="+resource_type_code;
400 | }
401 | enabled_capability = (JSONArray) o;
402 | }
403 |
404 | // Ignore everything except launch handlers
405 | if ( path == null ) continue;
406 |
407 | // Check the URI
408 | String thisLaunch = launch_url;
409 | if ( ! thisLaunch.endsWith("/") && ! path.startsWith("/") ) thisLaunch = thisLaunch + "/";
410 | thisLaunch = thisLaunch + path;
411 | try {
412 | URL url = new URL(thisLaunch);
413 | } catch ( Exception e ) {
414 | return "Bad launch URL="+thisLaunch;
415 | }
416 |
417 | // Passed all the tests... Lets keep it...
418 | Properties theTool = new Properties();
419 |
420 | theTool.put("resource_type", resource_type_code); // Backwards compatibility
421 | theTool.put("resource_type_code", resource_type_code);
422 | if ( title == null ) title = productTitle;
423 | if ( title != null ) theTool.put("title", title);
424 | if ( button != null ) theTool.put("button", button);
425 | if ( resourceDescription == null ) resourceDescription = productDescription;
426 | if ( resourceDescription != null ) theTool.put("description", resourceDescription);
427 | if ( parameter != null ) theTool.put("parameter", parameter.toString());
428 | if ( enabled_capability != null ) theTool.put("enabled_capability", enabled_capability.toString());
429 | theTool.put("launch", thisLaunch);
430 | theTools.add(theTool);
431 | }
432 | return null; // All good
433 | }
434 |
435 | public static JSONObject parseSettings(String settings)
436 | {
437 | if ( settings == null || settings.length() < 1 ) {
438 | settings = EMPTY_JSON_OBJECT;
439 | }
440 | return (JSONObject) JSONValue.parse(settings);
441 | }
442 |
443 | /* Two possible formats:
444 |
445 | key=val;key2=val2;
446 |
447 | key=val
448 | key2=val2
449 | */
450 | public static boolean mergeLTI1Custom(Properties custom, String customstr)
451 | {
452 | if ( customstr == null || customstr.length() < 1 ) return true;
453 |
454 | String [] params = customstr.split("[\n;]");
455 | for (int i = 0 ; i < params.length; i++ ) {
456 | String param = params[i];
457 | if ( param == null ) continue;
458 | if ( param.length() < 1 ) continue;
459 |
460 | int pos = param.indexOf("=");
461 | if ( pos < 1 ) continue;
462 | if ( pos+1 > param.length() ) continue;
463 | String key = mapKeyName(param.substring(0,pos));
464 | if ( key == null ) continue;
465 |
466 | if ( custom.containsKey(key) ) continue;
467 |
468 | String value = param.substring(pos+1);
469 | if ( value == null ) continue;
470 | value = value.trim();
471 | if ( value.length() < 1 ) continue;
472 | setProperty(custom, key, value);
473 | }
474 | return true;
475 | }
476 |
477 | /*
478 | "custom" :
479 | {
480 | "isbn" : "978-0321558145",
481 | "style" : "jazzy"
482 | }
483 | */
484 | public static boolean mergeLTI2Custom(Properties custom, String customstr)
485 | {
486 | if ( customstr == null || customstr.length() < 1 ) return true;
487 | JSONObject json = null;
488 | try {
489 | json = (JSONObject) JSONValue.parse(customstr.trim());
490 | } catch(Exception e) {
491 | M_log.warning("mergeLTI2Custom could not parse\n"+customstr);
492 | M_log.warning(e.getLocalizedMessage());
493 | return false;
494 | }
495 |
496 | // This could happen if the old settings service was used
497 | // on an LTI 2.x placement to put in settings that are not
498 | // JSON - we just ignore it.
499 | if ( json == null ) return false;
500 | Iterator> keys = json.keySet().iterator();
501 | while( keys.hasNext() ){
502 | String key = (String)keys.next();
503 | if ( custom.containsKey(key) ) continue;
504 | Object value = json.get(key);
505 | if ( value instanceof String ){
506 | setProperty(custom, key, (String) value);
507 | }
508 | }
509 | return true;
510 | }
511 |
512 | /*
513 | "parameter" :
514 | [
515 | { "name" : "result_url",
516 | "variable" : "Result.url"
517 | },
518 | { "name" : "discipline",
519 | "fixed" : "chemistry"
520 | }
521 | ]
522 | */
523 | public static boolean mergeLTI2Parameters(Properties custom, String customstr) {
524 | if ( customstr == null || customstr.length() < 1 ) return true;
525 | JSONArray json = null;
526 | try {
527 | json = (JSONArray) JSONValue.parse(customstr.trim());
528 | } catch(Exception e) {
529 | M_log.warning("mergeLTI2Parameters could not parse\n"+customstr);
530 | M_log.warning(e.getLocalizedMessage());
531 | return false;
532 | }
533 | Iterator> parameters = json.iterator();
534 | while( parameters.hasNext() ){
535 | Object o = parameters.next();
536 | JSONObject parameter = null;
537 | try {
538 | parameter = (JSONObject) o;
539 | } catch(Exception e) {
540 | M_log.warning("mergeLTI2Parameters did not find list of objects\n"+customstr);
541 | M_log.warning(e.getLocalizedMessage());
542 | return false;
543 | }
544 |
545 | String name = (String) parameter.get("name");
546 |
547 | if ( name == null ) continue;
548 | if ( custom.containsKey(name) ) continue;
549 | String fixed = (String) parameter.get("fixed");
550 | String variable = (String) parameter.get("variable");
551 | if ( variable != null ) {
552 | setProperty(custom, name, variable);
553 | continue;
554 | }
555 | if ( fixed != null ) {
556 | setProperty(custom, name, fixed);
557 | }
558 | }
559 | return true;
560 | }
561 |
562 | public static void substituteCustom(Properties custom, Properties lti2subst)
563 | {
564 | if ( custom == null || lti2subst == null ) return;
565 | Enumeration> e = custom.propertyNames();
566 | while (e.hasMoreElements()) {
567 | String key = (String) e.nextElement();
568 | String value = custom.getProperty(key);
569 | if ( value == null || value.length() < 1 ) continue;
570 | String newValue = lti2subst.getProperty(value);
571 | if ( newValue == null || newValue.length() < 1 ) continue;
572 | setProperty(custom, key, (String) newValue);
573 | }
574 | }
575 |
576 | // Place the custom values into the launch
577 | public static void addCustomToLaunch(Properties ltiProps, Properties custom)
578 | {
579 | Enumeration> e = custom.propertyNames();
580 | while (e.hasMoreElements()) {
581 | String keyStr = (String) e.nextElement();
582 | String value = custom.getProperty(keyStr);
583 | setProperty(ltiProps,"custom_"+keyStr,value);
584 | }
585 | }
586 |
587 | @SuppressWarnings("deprecation")
588 | public static void setProperty(Properties props, String key, String value) {
589 | BasicLTIUtil.setProperty(props, key, value);
590 | }
591 |
592 | public static String mapKeyName(String keyname) {
593 | return BasicLTIUtil.mapKeyName(keyname);
594 | }
595 |
596 | }
597 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/BaseJson.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 IMS Global Learning Consortium.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.imsglobal.lti2.objects;
18 |
19 | import java.util.HashMap;
20 | import java.util.Map;
21 | import org.codehaus.jackson.annotate.JsonAnyGetter;
22 | import org.codehaus.jackson.annotate.JsonAnySetter;
23 |
24 | /**
25 | *
26 | * @author pgray
27 | */
28 | public class BaseJson {
29 |
30 | private Map additionalProperties = new HashMap();
31 |
32 | @com.fasterxml.jackson.annotation.JsonAnyGetter
33 | @JsonAnyGetter
34 | public Map getAdditionalProperties() {
35 | return this.additionalProperties;
36 | }
37 |
38 | @com.fasterxml.jackson.annotation.JsonAnySetter
39 | @JsonAnySetter
40 | public void addAdditionalProperty(String name, Object value) {
41 | this.additionalProperties.put(name, value);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/BaseJsonLd.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 IMS Global Learning Consortium.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.imsglobal.lti2.objects;
17 |
18 | import com.fasterxml.jackson.annotation.JsonProperty;
19 |
20 | /**
21 | *
22 | * @author paul
23 | */
24 | public class BaseJsonLd extends BaseJson {
25 |
26 | @JsonProperty("@id")
27 | @org.codehaus.jackson.annotate.JsonProperty("@id")
28 | protected String id;
29 | @JsonProperty("@context")
30 | @org.codehaus.jackson.annotate.JsonProperty("@context")
31 | protected String context;
32 | @JsonProperty("@type")
33 | @org.codehaus.jackson.annotate.JsonProperty("@type")
34 | protected String type;
35 |
36 | public String getId() {
37 | return id;
38 | }
39 |
40 | public void setId(String id) {
41 | this.id = id;
42 | }
43 |
44 | public String getContext() {
45 | return context;
46 | }
47 |
48 | public void setContext(String context) {
49 | this.context = context;
50 | }
51 |
52 | public String getType() {
53 | return type;
54 | }
55 |
56 | public void setType(String type) {
57 | this.type = type;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/Contact.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import javax.annotation.Generated;
7 | import org.codehaus.jackson.annotate.JsonAnyGetter;
8 | import org.codehaus.jackson.annotate.JsonAnySetter;
9 | import org.codehaus.jackson.annotate.JsonProperty;
10 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
11 | import org.codehaus.jackson.map.annotate.JsonSerialize;
12 |
13 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
14 | @Generated("com.googlecode.jsonschema2pojo")
15 | @JsonPropertyOrder({
16 | "email"
17 | })
18 | public class Contact {
19 |
20 | @JsonProperty("email")
21 | private String email;
22 | private Map additionalProperties = new HashMap();
23 |
24 | public Contact(String email) {
25 | this.email = email;
26 | }
27 |
28 | public Contact() {
29 | }
30 |
31 | @JsonProperty("email")
32 | public String getEmail() {
33 | return email;
34 | }
35 |
36 | @JsonProperty("email")
37 | public void setEmail(String email) {
38 | this.email = email;
39 | }
40 |
41 | @JsonAnyGetter
42 | public Map getAdditionalProperties() {
43 | return this.additionalProperties;
44 | }
45 |
46 | @JsonAnySetter
47 | public void setAdditionalProperties(String name, Object value) {
48 | this.additionalProperties.put(name, value);
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/Description.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import javax.annotation.Generated;
7 | import org.codehaus.jackson.annotate.JsonAnyGetter;
8 | import org.codehaus.jackson.annotate.JsonAnySetter;
9 | import org.codehaus.jackson.annotate.JsonProperty;
10 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
11 | import org.codehaus.jackson.map.annotate.JsonSerialize;
12 |
13 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
14 | @Generated("com.googlecode.jsonschema2pojo")
15 | @JsonPropertyOrder({
16 | "default_value",
17 | "key"
18 | })
19 | public class Description {
20 |
21 | @JsonProperty("default_value")
22 | private String default_value;
23 | @JsonProperty("key")
24 | private String key;
25 | private Map additionalProperties = new HashMap();
26 |
27 | public Description(String description) {
28 | this.default_value = description;
29 | this.key = "product.vendor.description";
30 | }
31 |
32 | public Description() {
33 | }
34 |
35 | @JsonProperty("default_value")
36 | public String getDefault_value() {
37 | return default_value;
38 | }
39 |
40 | @JsonProperty("default_value")
41 | public void setDefault_value(String default_value) {
42 | this.default_value = default_value;
43 | }
44 |
45 | @JsonProperty("key")
46 | public String getKey() {
47 | return key;
48 | }
49 |
50 | @JsonProperty("key")
51 | public void setKey(String key) {
52 | this.key = key;
53 | }
54 |
55 | @JsonAnyGetter
56 | public Map getAdditionalProperties() {
57 | return this.additionalProperties;
58 | }
59 |
60 | @JsonAnySetter
61 | public void setAdditionalProperties(String name, Object value) {
62 | this.additionalProperties.put(name, value);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/Name.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import javax.annotation.Generated;
7 | import org.codehaus.jackson.annotate.JsonAnyGetter;
8 | import org.codehaus.jackson.annotate.JsonAnySetter;
9 | import org.codehaus.jackson.annotate.JsonProperty;
10 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
11 | import org.codehaus.jackson.map.annotate.JsonSerialize;
12 |
13 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
14 | @Generated("com.googlecode.jsonschema2pojo")
15 | @JsonPropertyOrder({
16 | "default_value",
17 | "key"
18 | })
19 | public class Name {
20 |
21 | @JsonProperty("default_value")
22 | private String default_value;
23 | @JsonProperty("key")
24 | private String key;
25 | private Map additionalProperties = new HashMap();
26 |
27 | public Name(String name) {
28 | this.default_value = name;
29 | this.key = "product.vendor.name";
30 | }
31 |
32 | public Name() {
33 | }
34 |
35 | @JsonProperty("default_value")
36 | public String getDefault_value() {
37 | return default_value;
38 | }
39 |
40 | @JsonProperty("default_value")
41 | public void setDefault_value(String default_value) {
42 | this.default_value = default_value;
43 | }
44 |
45 | @JsonProperty("key")
46 | public String getKey() {
47 | return key;
48 | }
49 |
50 | @JsonProperty("key")
51 | public void setKey(String key) {
52 | this.key = key;
53 | }
54 |
55 | @JsonAnyGetter
56 | public Map getAdditionalProperties() {
57 | return this.additionalProperties;
58 | }
59 |
60 | @JsonAnySetter
61 | public void setAdditionalProperties(String name, Object value) {
62 | this.additionalProperties.put(name, value);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/NamedContext.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import javax.annotation.Generated;
7 | import org.codehaus.jackson.annotate.JsonAnyGetter;
8 | import org.codehaus.jackson.annotate.JsonAnySetter;
9 | import org.codehaus.jackson.map.annotate.JsonSerialize;
10 |
11 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
12 | @Generated("com.googlecode.jsonschema2pojo")
13 |
14 | public class NamedContext {
15 |
16 | private Map additionalProperties = new HashMap();
17 |
18 | @JsonAnyGetter
19 | public Map getAdditionalProperties() {
20 | return this.additionalProperties;
21 | }
22 |
23 | @JsonAnySetter
24 | public void setAdditionalProperties(String name, Object value) {
25 | this.additionalProperties.put(name, value);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/ProductFamily.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import org.imsglobal.lti2.LTI2Config;
5 |
6 | import java.util.HashMap;
7 | import java.util.Map;
8 | import javax.annotation.Generated;
9 | import org.codehaus.jackson.annotate.JsonAnyGetter;
10 | import org.codehaus.jackson.annotate.JsonAnySetter;
11 | import org.codehaus.jackson.annotate.JsonProperty;
12 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
13 | import org.codehaus.jackson.map.annotate.JsonSerialize;
14 |
15 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
16 | @Generated("com.googlecode.jsonschema2pojo")
17 | @JsonPropertyOrder({
18 | "code",
19 | "vendor"
20 | })
21 | public class ProductFamily {
22 |
23 | @JsonProperty("code")
24 | private String code;
25 | @JsonProperty("vendor")
26 | private Vendor vendor;
27 | private Map additionalProperties = new HashMap();
28 |
29 | public ProductFamily(LTI2Config cnf) {
30 | this.code = cnf.getProduct_family_product_code();
31 | this.vendor = new Vendor(cnf);
32 | }
33 |
34 | public ProductFamily() {
35 | }
36 |
37 | @JsonProperty("code")
38 | public String getCode() {
39 | return code;
40 | }
41 |
42 | @JsonProperty("code")
43 | public void setCode(String code) {
44 | this.code = code;
45 | }
46 |
47 | @JsonProperty("vendor")
48 | public Vendor getVendor() {
49 | return vendor;
50 | }
51 |
52 | @JsonProperty("vendor")
53 | public void setVendor(Vendor vendor) {
54 | this.vendor = vendor;
55 | }
56 |
57 | @JsonAnyGetter
58 | public Map getAdditionalProperties() {
59 | return this.additionalProperties;
60 | }
61 |
62 | @JsonAnySetter
63 | public void setAdditionalProperties(String name, Object value) {
64 | this.additionalProperties.put(name, value);
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/ProductInfo.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import org.imsglobal.lti2.LTI2Config;
5 |
6 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
7 | import org.imsglobal.lti2.objects.BaseJson;
8 |
9 | @JsonPropertyOrder({
10 | "product_name",
11 | "product_version",
12 | "description",
13 | "technical_description",
14 | "product_family"
15 | })
16 | public class ProductInfo extends BaseJson {
17 |
18 | private ProductName product_name;
19 | private String product_version;
20 | private Description description;
21 | private TechnicalDescription technical_description;
22 | private ProductFamily product_family;
23 |
24 | public ProductInfo(LTI2Config cnf) {
25 | this.product_name = new ProductName(cnf.getProduct_info_product_name());
26 | this.product_version = cnf.getProduct_info_product_version();
27 | this.description = new Description(cnf.getProduct_info_product_description());
28 | this.product_family = new ProductFamily(cnf);
29 | }
30 |
31 | public ProductInfo(){
32 |
33 | }
34 |
35 | public ProductName getProduct_name() {
36 | return product_name;
37 | }
38 |
39 | public void setProduct_name(ProductName product_name) {
40 | this.product_name = product_name;
41 | }
42 |
43 | public String getProduct_version() {
44 | return product_version;
45 | }
46 |
47 | public void setProduct_version(String product_version) {
48 | this.product_version = product_version;
49 | }
50 |
51 | public Description getDescription() {
52 | return description;
53 | }
54 |
55 | public void setDescription(Description description) {
56 | this.description = description;
57 | }
58 |
59 | public TechnicalDescription getTechnical_description() {
60 | return technical_description;
61 | }
62 |
63 | public void setTechnical_description(TechnicalDescription technical_description) {
64 | this.technical_description = technical_description;
65 | }
66 |
67 | public ProductFamily getProduct_family() {
68 | return product_family;
69 | }
70 |
71 | public void setProduct_family(ProductFamily product_family) {
72 | this.product_family = product_family;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/ProductInstance.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import org.imsglobal.lti2.LTI2Config;
5 |
6 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
7 | import org.imsglobal.lti2.objects.BaseJson;
8 |
9 | @JsonPropertyOrder({
10 | "guid",
11 | "product_info",
12 | "support"
13 | })
14 | public class ProductInstance extends BaseJson {
15 |
16 | private String guid;
17 | private ProductInfo product_info;
18 | private ServiceOwner service_owner;
19 | private ServiceProvider service_provider;
20 | private Support support;
21 |
22 | public ProductInstance(LTI2Config cnf) {
23 | this.guid = cnf.getGuid();
24 | this.product_info = new ProductInfo(cnf);
25 | this.service_owner = new ServiceOwner(cnf);
26 | this.service_provider = new ServiceProvider(cnf);
27 | this.support = new Support(cnf.getSupport_email());
28 | }
29 |
30 | public ProductInstance() {
31 | }
32 |
33 | public String getGuid() {
34 | return guid;
35 | }
36 |
37 | public void setGuid(String guid) {
38 | this.guid = guid;
39 | }
40 |
41 | public ProductInfo getProduct_info() {
42 | return product_info;
43 | }
44 |
45 | public void setProduct_info(ProductInfo product_info) {
46 | this.product_info = product_info;
47 | }
48 |
49 | public ServiceOwner getService_owner() {
50 | return service_owner;
51 | }
52 |
53 | public void setService_owner(ServiceOwner service_owner) {
54 | this.service_owner = service_owner;
55 | }
56 |
57 | public ServiceProvider getService_provider() {
58 | return service_provider;
59 | }
60 |
61 | public void setService_provider(ServiceProvider service_provider) {
62 | this.service_provider = service_provider;
63 | }
64 |
65 | public Support getSupport() {
66 | return support;
67 | }
68 |
69 | public void setSupport(Support support) {
70 | this.support = support;
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/ProductName.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import javax.annotation.Generated;
7 | import org.codehaus.jackson.annotate.JsonAnyGetter;
8 | import org.codehaus.jackson.annotate.JsonAnySetter;
9 | import org.codehaus.jackson.annotate.JsonProperty;
10 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
11 | import org.codehaus.jackson.map.annotate.JsonSerialize;
12 |
13 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
14 | @Generated("com.googlecode.jsonschema2pojo")
15 | @JsonPropertyOrder({
16 | "default_value",
17 | "key"
18 | })
19 | public class ProductName {
20 |
21 | @JsonProperty("default_value")
22 | private String default_value;
23 | @JsonProperty("key")
24 | private String key;
25 | private Map additionalProperties = new HashMap();
26 |
27 | public ProductName(String name) {
28 | this.default_value = name;
29 | this.key = "product.name";
30 | }
31 |
32 | public ProductName() {
33 | }
34 |
35 |
36 | @JsonProperty("default_value")
37 | public String getDefault_value() {
38 | return default_value;
39 | }
40 |
41 | @JsonProperty("default_value")
42 | public void setDefault_value(String default_value) {
43 | this.default_value = default_value;
44 | }
45 |
46 | @JsonProperty("key")
47 | public String getKey() {
48 | return key;
49 | }
50 |
51 | @JsonProperty("key")
52 | public void setKey(String key) {
53 | this.key = key;
54 | }
55 |
56 | @JsonAnyGetter
57 | public Map getAdditionalProperties() {
58 | return this.additionalProperties;
59 | }
60 |
61 | @JsonAnySetter
62 | public void setAdditionalProperties(String name, Object value) {
63 | this.additionalProperties.put(name, value);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOffered.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import java.util.ArrayList;
7 | import java.util.List;
8 | import java.util.Collections;
9 | import javax.annotation.Generated;
10 | import org.codehaus.jackson.annotate.JsonAnyGetter;
11 | import org.codehaus.jackson.annotate.JsonAnySetter;
12 | import org.codehaus.jackson.annotate.JsonProperty;
13 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
14 | import org.codehaus.jackson.map.annotate.JsonSerialize;
15 |
16 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
17 | @Generated("com.googlecode.jsonschema2pojo")
18 | @JsonPropertyOrder({
19 | "@type",
20 | "@id",
21 | "endpoint",
22 | "format",
23 | "action"
24 | })
25 | public class ServiceOffered {
26 |
27 | @JsonProperty("@type")
28 | private String _type;
29 | @JsonProperty("@id")
30 | private String _id;
31 | @JsonProperty("endpoint")
32 | private String endpoint;
33 | @JsonProperty("format")
34 | private List format = new ArrayList();
35 | @JsonProperty("action")
36 | private List action = new ArrayList();
37 | private Map additionalProperties = new HashMap();
38 |
39 | public ServiceOffered() { }
40 |
41 | public ServiceOffered(String endpoint, String id, String type, String format, String action) {
42 | this.endpoint = endpoint;
43 | this._id = id;
44 | this._type = type;
45 | this.format.add(format);
46 | this.action.add(action);
47 | }
48 |
49 | public ServiceOffered(String endpoint, String id, String type, String[] format, String[] action) {
50 | this.endpoint = endpoint;
51 | this._id = id;
52 | this._type = type;
53 | Collections.addAll(this.format, format);
54 | Collections.addAll(this.action, action);
55 | }
56 |
57 | @JsonProperty("@type")
58 | public String get_type() {
59 | return _type;
60 | }
61 |
62 | @JsonProperty("@type")
63 | public void set_type(String _type) {
64 | this._type = _type;
65 | }
66 |
67 | @JsonProperty("@id")
68 | public String get_id() {
69 | return _id;
70 | }
71 |
72 | @JsonProperty("@id")
73 | public void set_id(String _id) {
74 | this._id = _id;
75 | }
76 |
77 | @JsonProperty("endpoint")
78 | public String getEndpoint() {
79 | return endpoint;
80 | }
81 |
82 | @JsonProperty("endpoint")
83 | public void setEndpoint(String endpoint) {
84 | this.endpoint = endpoint;
85 | }
86 |
87 | @JsonProperty("format")
88 | public List getFormat() {
89 | return format;
90 | }
91 |
92 | @JsonProperty("format")
93 | public void setFormat(List format) {
94 | this.format = format;
95 | }
96 |
97 | @JsonProperty("action")
98 | public List getAction() {
99 | return action;
100 | }
101 |
102 | @JsonProperty("action")
103 | public void setAction(List action) {
104 | this.action = action;
105 | }
106 |
107 | @JsonAnyGetter
108 | public Map getAdditionalProperties() {
109 | return this.additionalProperties;
110 | }
111 |
112 | @JsonAnySetter
113 | public void setAdditionalProperties(String name, Object value) {
114 | this.additionalProperties.put(name, value);
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOwner.java:
--------------------------------------------------------------------------------
1 | package org.imsglobal.lti2.objects.consumer;
2 |
3 | import org.imsglobal.lti2.LTI2Config;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 | import javax.annotation.Generated;
8 | import org.codehaus.jackson.annotate.JsonAnyGetter;
9 | import org.codehaus.jackson.annotate.JsonAnySetter;
10 | import org.codehaus.jackson.annotate.JsonProperty;
11 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
12 | import org.codehaus.jackson.map.annotate.JsonSerialize;
13 |
14 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
15 | @Generated("com.googlecode.jsonschema2pojo")
16 | @JsonPropertyOrder({
17 | "@id",
18 | "service_owner_name",
19 | "description",
20 | "timestamp",
21 | "support"
22 | })
23 | public class ServiceOwner {
24 |
25 | @JsonProperty("@id")
26 | private String _id;
27 | @JsonProperty("service_owner_name")
28 | private ServiceOwnerName service_owner_name;
29 | @JsonProperty("description")
30 | private Description description;
31 | @JsonProperty("timestamp")
32 | private String timestamp;
33 | @JsonProperty("support")
34 | private Support support;
35 | private Map additionalProperties = new HashMap();
36 |
37 | public ServiceOwner(LTI2Config cnf) {
38 | this._id = cnf.getService_owner_id();
39 | this.service_owner_name = new ServiceOwnerName(cnf.getService_owner_owner_name());
40 | this.description = new Description(cnf.getService_owner_description());
41 | this.support = new Support(cnf.getService_owner_support_email());
42 | }
43 |
44 | public ServiceOwner() {
45 | }
46 |
47 | @JsonProperty("@id")
48 | public String get_id() {
49 | return _id;
50 | }
51 |
52 | @JsonProperty("@id")
53 | public void set_id(String _id) {
54 | this._id = _id;
55 | }
56 |
57 | @JsonProperty("service_owner_name")
58 | public ServiceOwnerName getService_owner_name() {
59 | return service_owner_name;
60 | }
61 |
62 | @JsonProperty("service_owner_name")
63 | public void setService_name(ServiceOwnerName service_owner_name) {
64 | this.service_owner_name = service_owner_name;
65 | }
66 |
67 | @JsonProperty("description")
68 | public Description getDescription() {
69 | return description;
70 | }
71 |
72 | @JsonProperty("description")
73 | public void setDescription(Description description) {
74 | this.description = description;
75 | }
76 |
77 | @JsonProperty("timestamp")
78 | public String getTimestamp() {
79 | return timestamp;
80 | }
81 |
82 | @JsonProperty("timestamp")
83 | public void setTimestamp(String timestamp) {
84 | this.timestamp = timestamp;
85 | }
86 |
87 | @JsonProperty("support")
88 | public Support getSupport() {
89 | return support;
90 | }
91 |
92 | @JsonProperty("support")
93 | public void setSupport(Support support) {
94 | this.support = support;
95 | }
96 |
97 | @JsonAnyGetter
98 | public Map getAdditionalProperties() {
99 | return this.additionalProperties;
100 | }
101 |
102 | @JsonAnySetter
103 | public void setAdditionalProperties(String name, Object value) {
104 | this.additionalProperties.put(name, value);
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOwnerName.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import javax.annotation.Generated;
7 | import org.codehaus.jackson.annotate.JsonAnyGetter;
8 | import org.codehaus.jackson.annotate.JsonAnySetter;
9 | import org.codehaus.jackson.annotate.JsonProperty;
10 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
11 | import org.codehaus.jackson.map.annotate.JsonSerialize;
12 |
13 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
14 | @Generated("com.googlecode.jsonschema2pojo")
15 | @JsonPropertyOrder({
16 | "default_value",
17 | "key"
18 | })
19 | public class ServiceOwnerName {
20 |
21 | @JsonProperty("default_value")
22 | private String default_value;
23 | @JsonProperty("key")
24 | private String key;
25 | private Map additionalProperties = new HashMap();
26 |
27 | public ServiceOwnerName(String name) {
28 | this.default_value = name;
29 | this.key = "product.name";
30 | }
31 |
32 | public ServiceOwnerName() {
33 | }
34 |
35 | @JsonProperty("default_value")
36 | public String getDefault_value() {
37 | return default_value;
38 | }
39 |
40 | @JsonProperty("default_value")
41 | public void setDefault_value(String default_value) {
42 | this.default_value = default_value;
43 | }
44 |
45 | @JsonProperty("key")
46 | public String getKey() {
47 | return key;
48 | }
49 |
50 | @JsonProperty("key")
51 | public void setKey(String key) {
52 | this.key = key;
53 | }
54 |
55 | @JsonAnyGetter
56 | public Map getAdditionalProperties() {
57 | return this.additionalProperties;
58 | }
59 |
60 | @JsonAnySetter
61 | public void setAdditionalProperties(String name, Object value) {
62 | this.additionalProperties.put(name, value);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceProvider.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import org.imsglobal.lti2.LTI2Config;
5 |
6 | import java.util.HashMap;
7 | import java.util.Map;
8 | import javax.annotation.Generated;
9 | import org.codehaus.jackson.annotate.JsonAnyGetter;
10 | import org.codehaus.jackson.annotate.JsonAnySetter;
11 | import org.codehaus.jackson.annotate.JsonProperty;
12 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
13 | import org.codehaus.jackson.map.annotate.JsonSerialize;
14 |
15 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
16 | @Generated("com.googlecode.jsonschema2pojo")
17 | @JsonPropertyOrder({
18 | "@id",
19 | "service_provider_name",
20 | "description",
21 | "timestamp",
22 | "support"
23 | })
24 | public class ServiceProvider {
25 |
26 | @JsonProperty("@id")
27 | private String _id;
28 | @JsonProperty("service_provider_name")
29 | private ServiceProviderName service_provider_name;
30 | @JsonProperty("description")
31 | private Description description;
32 | @JsonProperty("timestamp")
33 | private String timestamp;
34 | @JsonProperty("support")
35 | private Support support;
36 | private Map additionalProperties = new HashMap();
37 |
38 | public ServiceProvider(LTI2Config cnf) {
39 | this._id = cnf.getService_provider_id();
40 | this.service_provider_name = new ServiceProviderName(cnf.getService_provider_provider_name());
41 | this.description = new Description(cnf.getService_provider_description());
42 | this.support = new Support(cnf.getService_provider_support_email());
43 | }
44 |
45 | public ServiceProvider() {
46 | }
47 |
48 | @JsonProperty("@id")
49 | public String get_id() {
50 | return _id;
51 | }
52 |
53 | @JsonProperty("@id")
54 | public void set_id(String _id) {
55 | this._id = _id;
56 | }
57 |
58 | @JsonProperty("service_provider_name")
59 | public ServiceProviderName getService_provider_name() {
60 | return service_provider_name;
61 | }
62 |
63 | @JsonProperty("service_provider_name")
64 | public void setService_name(ServiceProviderName service_provider_name) {
65 | this.service_provider_name = service_provider_name;
66 | }
67 |
68 | @JsonProperty("description")
69 | public Description getDescription() {
70 | return description;
71 | }
72 |
73 | @JsonProperty("description")
74 | public void setDescription(Description description) {
75 | this.description = description;
76 | }
77 |
78 | @JsonProperty("timestamp")
79 | public String getTimestamp() {
80 | return timestamp;
81 | }
82 |
83 | @JsonProperty("timestamp")
84 | public void setTimestamp(String timestamp) {
85 | this.timestamp = timestamp;
86 | }
87 |
88 | @JsonProperty("support")
89 | public Support getSupport() {
90 | return support;
91 | }
92 |
93 | @JsonProperty("support")
94 | public void setSupport(Support support) {
95 | this.support = support;
96 | }
97 |
98 | @JsonAnyGetter
99 | public Map getAdditionalProperties() {
100 | return this.additionalProperties;
101 | }
102 |
103 | @JsonAnySetter
104 | public void setAdditionalProperties(String name, Object value) {
105 | this.additionalProperties.put(name, value);
106 | }
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceProviderName.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import javax.annotation.Generated;
7 | import org.codehaus.jackson.annotate.JsonAnyGetter;
8 | import org.codehaus.jackson.annotate.JsonAnySetter;
9 | import org.codehaus.jackson.annotate.JsonProperty;
10 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
11 | import org.codehaus.jackson.map.annotate.JsonSerialize;
12 |
13 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
14 | @Generated("com.googlecode.jsonschema2pojo")
15 | @JsonPropertyOrder({
16 | "default_value",
17 | "key"
18 | })
19 | public class ServiceProviderName {
20 |
21 | @JsonProperty("default_value")
22 | private String default_value;
23 | @JsonProperty("key")
24 | private String key;
25 | private Map additionalProperties = new HashMap();
26 |
27 | public ServiceProviderName(String name) {
28 | this.default_value = name;
29 | this.key = "product.name";
30 | }
31 |
32 | public ServiceProviderName() {
33 | }
34 |
35 | @JsonProperty("default_value")
36 | public String getDefault_value() {
37 | return default_value;
38 | }
39 |
40 | @JsonProperty("default_value")
41 | public void setDefault_value(String default_value) {
42 | this.default_value = default_value;
43 | }
44 |
45 | @JsonProperty("key")
46 | public String getKey() {
47 | return key;
48 | }
49 |
50 | @JsonProperty("key")
51 | public void setKey(String key) {
52 | this.key = key;
53 | }
54 |
55 | @JsonAnyGetter
56 | public Map getAdditionalProperties() {
57 | return this.additionalProperties;
58 | }
59 |
60 | @JsonAnySetter
61 | public void setAdditionalProperties(String name, Object value) {
62 | this.additionalProperties.put(name, value);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/StandardServices.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.Arrays;
5 |
6 | public class StandardServices {
7 |
8 | public static final String TOOLPROXY_FORMAT = "application/vnd.ims.lti.v2.toolproxy+json";
9 | public static final String TOOLSETTINGS_CONTEXT = "http://purl.imsglobal.org/ctx/lti/v2/ToolSettings";
10 | public static final String TOOLSETTINGS_FORMAT = "application/vnd.ims.lti.v2.toolsettings+json";
11 | public static final String TOOLSETTINGS_SIMPLE_FORMAT = "application/vnd.ims.lti.v2.toolsettings.simple+json";
12 |
13 | public static final String TOOLPROXY_ID_CONTEXT = "http://purl.imsglobal.org/ctx/lti/v2/ToolProxyId";
14 | public static final String TOOLPROXY_ID_FORMAT = "application/vnd.ims.lti.v2.toolproxy.id+json";
15 | public static final String TOOLPROXY_ID_TYPE = "ToolProxy";
16 |
17 | public static final String RESULT_FORMAT = "application/vnd.ims.lis.v2.result+json";
18 | public static final String RESULT_CONTEXT = "http://purl.imsglobal.org/ctx/lis/v2/Result";
19 | public static final String RESULT_TYPE = "Result";
20 |
21 | public static ServiceOffered LTI2Registration(String endpoint) {
22 | ServiceOffered ret = new ServiceOffered();
23 | ret.setEndpoint(endpoint);
24 | ret.set_id("tcp:ToolProxy.collection"); // TODO: Is this right see 5.6 in the docs
25 | ret.set_type("RestService");
26 | ret.setFormat(Arrays.asList(TOOLPROXY_FORMAT));
27 | ret.setAction(Arrays.asList("POST"));
28 | return ret;
29 | }
30 |
31 | // "endpoint" : "http://lms.example.com/resources/ToolProxy/{tool_proxy_guid}",
32 | public static ServiceOffered LTI2ProxyItem(String endpoint) {
33 | ServiceOffered ret = new ServiceOffered();
34 | ret.setEndpoint(endpoint);
35 | ret.set_id("tcp:ToolProxy.item");
36 | ret.set_type("RestService");
37 | ret.setFormat(Arrays.asList(TOOLPROXY_FORMAT));
38 | ret.setAction(Arrays.asList("GET", "PUT"));
39 | return ret;
40 | }
41 |
42 | // "endpoint" : "http://lms.example.com/resources/Result/{sourcedId}",
43 | public static ServiceOffered LTI2ResultItem(String endpoint) {
44 | ServiceOffered ret = new ServiceOffered();
45 | ret.setEndpoint(endpoint);
46 | ret.set_id("tcp:Result.item"); // TODO: Is this right see 5.6 in the docs
47 | ret.set_type("RestService");
48 | ret.setFormat(Arrays.asList(RESULT_FORMAT));
49 | ret.setAction(Arrays.asList("GET", "PUT"));
50 | return ret;
51 | }
52 |
53 | // "endpoint" : "http://lms.example.com/resources/ToolProxy/{tool_proxy_guid}/custom",
54 | public static ServiceOffered LTI2ToolProxySettings(String endpoint) {
55 | ServiceOffered ret = new ServiceOffered();
56 | ret.setEndpoint(endpoint);
57 | ret.set_id("tcp:ToolProxySettings");
58 | ret.set_type("RestService");
59 | ret.setFormat(Arrays.asList(TOOLSETTINGS_FORMAT, TOOLSETTINGS_SIMPLE_FORMAT));
60 | ret.setAction(Arrays.asList("GET", "PUT"));
61 | return ret;
62 | }
63 |
64 | // "endpoint" : "http://lms.example.com/resources/links/{link_id}/custom",
65 | public static ServiceOffered LTI2LtiLinkSettings(String endpoint) {
66 | ServiceOffered ret = new ServiceOffered();
67 | ret.setEndpoint(endpoint);
68 | ret.set_id("tcp:LtiLinkSettings");
69 | ret.set_type("RestService");
70 | ret.setFormat(Arrays.asList(TOOLSETTINGS_FORMAT, TOOLSETTINGS_SIMPLE_FORMAT));
71 | ret.setAction(Arrays.asList("GET", "PUT"));
72 | return ret;
73 | }
74 |
75 | public static ServiceOffered LTI1Outcomes(String endpoint) {
76 | ServiceOffered ret = new ServiceOffered();
77 | ret.setEndpoint(endpoint);
78 | ret.set_id("tcp:LTI_1_1_ResultService");
79 | ret.set_type("RestService");
80 | ret.setFormat(Arrays.asList("application/vnd.ims.lti.v1.outcome+xml"));
81 | ret.setAction(Arrays.asList("POST"));
82 | return ret;
83 | }
84 |
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/Support.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import javax.annotation.Generated;
7 | import org.codehaus.jackson.annotate.JsonAnyGetter;
8 | import org.codehaus.jackson.annotate.JsonAnySetter;
9 | import org.codehaus.jackson.annotate.JsonProperty;
10 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
11 | import org.codehaus.jackson.map.annotate.JsonSerialize;
12 |
13 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
14 | @Generated("com.googlecode.jsonschema2pojo")
15 | @JsonPropertyOrder({
16 | "email"
17 | })
18 | public class Support {
19 |
20 | @JsonProperty("email")
21 | private String email;
22 | private Map additionalProperties = new HashMap();
23 |
24 | public Support(String email) {
25 | this.email = email;
26 | }
27 |
28 | public Support() {
29 | }
30 |
31 | @JsonProperty("email")
32 | public String getEmail() {
33 | return email;
34 | }
35 |
36 | @JsonProperty("email")
37 | public void setEmail(String email) {
38 | this.email = email;
39 | }
40 |
41 | @JsonAnyGetter
42 | public Map getAdditionalProperties() {
43 | return this.additionalProperties;
44 | }
45 |
46 | @JsonAnySetter
47 | public void setAdditionalProperties(String name, Object value) {
48 | this.additionalProperties.put(name, value);
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/TechnicalDescription.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import javax.annotation.Generated;
7 | import org.codehaus.jackson.annotate.JsonAnyGetter;
8 | import org.codehaus.jackson.annotate.JsonAnySetter;
9 | import org.codehaus.jackson.annotate.JsonProperty;
10 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
11 | import org.codehaus.jackson.map.annotate.JsonSerialize;
12 |
13 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
14 | @Generated("com.googlecode.jsonschema2pojo")
15 | @JsonPropertyOrder({
16 | "default_value",
17 | "key"
18 | })
19 | public class TechnicalDescription {
20 |
21 | @JsonProperty("default_value")
22 | private String default_value;
23 | @JsonProperty("key")
24 | private String key;
25 | private Map additionalProperties = new HashMap();
26 |
27 | public TechnicalDescription() {
28 | }
29 |
30 | @JsonProperty("default_value")
31 | public String getDefault_value() {
32 | return default_value;
33 | }
34 |
35 | @JsonProperty("default_value")
36 | public void setDefault_value(String default_value) {
37 | this.default_value = default_value;
38 | }
39 |
40 | @JsonProperty("key")
41 | public String getKey() {
42 | return key;
43 | }
44 |
45 | @JsonProperty("key")
46 | public void setKey(String key) {
47 | this.key = key;
48 | }
49 |
50 | @JsonAnyGetter
51 | public Map getAdditionalProperties() {
52 | return this.additionalProperties;
53 | }
54 |
55 | @JsonAnySetter
56 | public void setAdditionalProperties(String name, Object value) {
57 | this.additionalProperties.put(name, value);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/consumer/Vendor.java:
--------------------------------------------------------------------------------
1 |
2 | package org.imsglobal.lti2.objects.consumer;
3 |
4 | import org.imsglobal.lti2.LTI2Config;
5 |
6 | import java.util.HashMap;
7 | import java.util.Map;
8 | import javax.annotation.Generated;
9 | import org.codehaus.jackson.annotate.JsonAnyGetter;
10 | import org.codehaus.jackson.annotate.JsonAnySetter;
11 | import org.codehaus.jackson.annotate.JsonProperty;
12 | import org.codehaus.jackson.annotate.JsonPropertyOrder;
13 | import org.codehaus.jackson.map.annotate.JsonSerialize;
14 |
15 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
16 | @Generated("com.googlecode.jsonschema2pojo")
17 | @JsonPropertyOrder({
18 | "code",
19 | "vendor_name",
20 | "description",
21 | "website",
22 | "timestamp",
23 | "contact"
24 | })
25 | public class Vendor {
26 |
27 | @JsonProperty("code")
28 | private String code;
29 | @JsonProperty("vendor_name")
30 | private Name vendor_name;
31 | @JsonProperty("description")
32 | private Description description;
33 | @JsonProperty("website")
34 | private String website;
35 | @JsonProperty("timestamp")
36 | private String timestamp;
37 | @JsonProperty("contact")
38 | private Contact contact;
39 | private Map additionalProperties = new HashMap();
40 |
41 | public Vendor(LTI2Config cnf) {
42 | this.code = cnf.getProduct_family_vendor_code();
43 | this.vendor_name = new Name(cnf.getProduct_family_vendor_name());
44 | this.description = new Description(cnf.getProduct_family_vendor_description());
45 | this.website = cnf.getProduct_family_vendor_website();
46 | this.contact = new Contact(cnf.getProduct_family_vendor_contact());
47 | }
48 |
49 | public Vendor() {
50 | }
51 |
52 | @JsonProperty("code")
53 | public String getCode() {
54 | return code;
55 | }
56 |
57 | @JsonProperty("code")
58 | public void setCode(String code) {
59 | this.code = code;
60 | }
61 |
62 | @JsonProperty("vendor_name")
63 | public Name getVendor_name() {
64 | return vendor_name;
65 | }
66 |
67 | @JsonProperty("name")
68 | public void setVendor_name(Name vendor_name) {
69 | this.vendor_name = vendor_name;
70 | }
71 |
72 | @JsonProperty("description")
73 | public Description getDescription() {
74 | return description;
75 | }
76 |
77 | @JsonProperty("description")
78 | public void setDescription(Description description) {
79 | this.description = description;
80 | }
81 |
82 | @JsonProperty("website")
83 | public String getWebsite() {
84 | return website;
85 | }
86 |
87 | @JsonProperty("website")
88 | public void setWebsite(String website) {
89 | this.website = website;
90 | }
91 |
92 | @JsonProperty("timestamp")
93 | public String getTimestamp() {
94 | return timestamp;
95 | }
96 |
97 | @JsonProperty("timestamp")
98 | public void setTimestamp(String timestamp) {
99 | this.timestamp = timestamp;
100 | }
101 |
102 | @JsonProperty("contact")
103 | public Contact getContact() {
104 | return contact;
105 | }
106 |
107 | @JsonProperty("contact")
108 | public void setContact(Contact contact) {
109 | this.contact = contact;
110 | }
111 |
112 | @JsonAnyGetter
113 | public Map getAdditionalProperties() {
114 | return this.additionalProperties;
115 | }
116 |
117 | @JsonAnySetter
118 | public void setAdditionalProperties(String name, Object value) {
119 | this.additionalProperties.put(name, value);
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/provider/BaseUrlChoice.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 IMS Global Learning Consortium.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.imsglobal.lti2.objects.provider;
17 |
18 | /**
19 | *
20 | * @author paul
21 | */
22 | public class BaseUrlChoice {
23 |
24 | private String default_base_url;
25 | private String secure_base_url;
26 | private Object selector;
27 |
28 | public BaseUrlChoice() {
29 | }
30 |
31 | public BaseUrlChoice(String default_base_url, String secure_base_url, Object selector) {
32 | this.default_base_url = default_base_url;
33 | this.secure_base_url = secure_base_url;
34 | this.selector = selector;
35 | }
36 |
37 | public String getDefault_base_url() {
38 | return default_base_url;
39 | }
40 |
41 | public void setDefault_base_url(String default_base_url) {
42 | this.default_base_url = default_base_url;
43 | }
44 |
45 | public String getSecure_base_url() {
46 | return secure_base_url;
47 | }
48 |
49 | public void setSecure_base_url(String secure_base_url) {
50 | this.secure_base_url = secure_base_url;
51 | }
52 |
53 | public Object getSelector() {
54 | return selector;
55 | }
56 |
57 | public void setSelector(Object selector) {
58 | this.selector = selector;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/imsglobal/lti2/objects/provider/SecurityContract.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 IMS Global Learning Consortium.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.imsglobal.lti2.objects.provider;
17 |
18 | import java.util.List;
19 |
20 | /**
21 | *
22 | * @author paul
23 | */
24 | public class SecurityContract {
25 |
26 | private String shared_secret;
27 | private List