forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-30372 - Initial version of the objects - more cleanup to do
- Loading branch information
Showing
14 changed files
with
898 additions
and
0 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
basiclti/basiclti-common/src/java/org/sakaiproject/basiclti/util/SakaiCASAUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* $URL$ | ||
* $Id$ | ||
* | ||
* Copyright (c) 2006-2009 The Sakai Foundation | ||
* | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.opensource.org/licenses/ECL-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.sakaiproject.basiclti.util; | ||
|
||
import org.json.simple.JSONObject; | ||
import org.json.simple.JSONArray; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import org.tsugi.basiclti.BasicLTIUtil; | ||
import org.tsugi.casa.CASAUtil; | ||
import org.tsugi.lti2.LTI2Config; | ||
|
||
import org.sakaiproject.lti2.SakaiLTI2Config; | ||
import org.sakaiproject.lti2.SakaiLTI2Base; | ||
|
||
import org.sakaiproject.tool.api.Tool; | ||
import org.sakaiproject.tool.cover.ToolManager; | ||
import org.sakaiproject.component.cover.ServerConfigurationService; | ||
|
||
/** | ||
* Some Sakai Utility code for IMS CASA | ||
* This is mostly code to support the Sakai conventions for | ||
* dealing with CASA. | ||
*/ | ||
@SuppressWarnings("deprecation") | ||
public class SakaiCASAUtil { | ||
|
||
private static Log M_log = LogFactory.getLog(SakaiCASAUtil.class); | ||
|
||
public static JSONObject getCASAEntry(String toolRegistration) | ||
{ | ||
Tool theTool = ToolManager.getTool(toolRegistration); | ||
if ( theTool == null ) return null; | ||
LTI2Config cnf = new SakaiLTI2Config(); | ||
boolean sample = false; | ||
if ( cnf.getGuid() == null ) { | ||
cnf = new SakaiLTI2Base(); | ||
sample = true; | ||
} | ||
|
||
JSONObject jsonResponse = new JSONObject(); | ||
JSONObject identity = new JSONObject(); | ||
identity.put("product_instance_guid", cnf.getService_owner_id()); | ||
identity.put("originator_id", cnf.getService_owner_id()); | ||
identity.put("id", toolRegistration); | ||
jsonResponse.put("identity", identity); | ||
JSONObject use = new JSONObject(); | ||
use.put(CASAUtil.TITLE_SCHEMA,theTool.getTitle()); | ||
use.put(CASAUtil.TEXT_SCHEMA,theTool.getDescription()); | ||
JSONArray contact = new JSONArray(); | ||
JSONObject name = new JSONObject(); | ||
name.put("name", cnf.getService_owner_owner_name()); | ||
name.put("email", cnf.getService_owner_support_email()); | ||
contact.add(name); | ||
use.put(CASAUtil.CONTACT_SCHEMA, contact); | ||
use.put(CASAUtil.ICON_SCHEMA, "https://www.apereo.org/sites/all/themes/apereo/images/apereo-logo-white-bg.png"); | ||
|
||
JSONObject launch = new JSONObject(); | ||
launch.put("launch_url", ServerConfigurationService.getServerUrl() + "/imsblis/provider/"+toolRegistration); | ||
use.put(CASAUtil.LAUNCH_SCHEMA, launch); | ||
|
||
JSONObject original = new JSONObject(); | ||
original.put("use", use); | ||
original.put("timestamp", "2015-01-02T22:17:00.371Z"); | ||
original.put("uri", ServerConfigurationService.getServerUrl()); | ||
original.put("share", Boolean.TRUE); | ||
original.put("propagate", Boolean.TRUE); | ||
jsonResponse.put("original", original); | ||
|
||
return jsonResponse; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* $URL$ | ||
* $Id$ | ||
* | ||
* Copyright (c) 2016- Charles R. Severance | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package org.tsugi.casa; | ||
|
||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.Enumeration; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Properties; | ||
import java.util.HashMap; | ||
import java.util.logging.Logger; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.tsugi.basiclti.BasicLTIUtil; | ||
import org.tsugi.basiclti.BasicLTIConstants; | ||
import org.tsugi.lti2.objects.StandardServices; | ||
import org.json.simple.JSONArray; | ||
import org.json.simple.JSONObject; | ||
import org.json.simple.JSONValue; | ||
|
||
public class CASAUtil { | ||
|
||
// We use the built-in Java logger because this code needs to be very generic | ||
private static Logger M_log = Logger.getLogger(CASAUtil.class.toString()); | ||
|
||
/* | ||
$entry = new stdClass(); | ||
$entry->identity = new stdClass(); | ||
$entry->identity->product_instance_guid = $CFG->product_instance_guid; | ||
$entry->identity->originator_id = $CFG->casa_originator_id; | ||
// id an string unique to the app among all apps published by the publisher. | ||
$entry->identity->id = $id; | ||
$orig = new stdClass(); | ||
$orig->timestamp = "2015-01-02T22:17:00.371Z"; | ||
$orig->uri = $CFG->wwwroot; | ||
$orig->share = true; | ||
$orig->propagate = true; | ||
$use = new stdClass(); | ||
$use->{"1f2625c2-615f-11e3-bf13-d231feb1dc81"} = $title; | ||
$use->{"b7856963-4078-4698-8e95-8feceafe78da"} = $text; | ||
// $use->{"d59e3a1f-c034-4309-a282-60228089194e"} = [{"name":"Paul Gray","email":"[email protected]"}], | ||
if ( $icon !== false ) $use->{"d25b3012-1832-4843-9ecf-3002d3434155"} = $icon; | ||
$launch = new stdClass(); | ||
$script = isset($REGISTER_LTI2['script']) ? $REGISTER_LTI2['script'] : "index.php"; | ||
$script = $CFG->wwwroot . '/' . str_replace("register.php", $script, $path); | ||
$launch->launch_url = $script; | ||
$launch->registration_url = $CFG->wwwroot . '/lti/register.php'; | ||
$use->{"f6820326-5ea3-4a02-840d-7f91e75eb01b"} = $launch; | ||
$orig->use = $use; | ||
$entry->original = $orig; | ||
$output[] = $entry; | ||
*/ | ||
|
||
public static final String TITLE_SCHEMA = "1f2625c2-615f-11e3-bf13-d231feb1dc81"; | ||
public static final String TITLE = "title"; | ||
public static final String TEXT_SCHEMA = "b7856963-4078-4698-8e95-8feceafe78da"; | ||
public static final String TEXT = "text"; | ||
public static final String CONTACT_SCHEMA = "d59e3a1f-c034-4309-a282-60228089194e"; | ||
public static final String CONTACT = "contact"; | ||
public static final String CONTACT_NAME = "name"; | ||
public static final String CONTACT_EMAIL = "email"; | ||
public static final String LAUNCH_SCHEMA = "f6820326-5ea3-4a02-840d-7f91e75eb01b"; | ||
public static final String LAUNCH = "launch"; | ||
public static final String ICON_SCHEMA = "d25b3012-1832-4843-9ecf-3002d3434155"; | ||
public static final String ICON = "icon_path"; | ||
|
||
private static final String EMPTY_JSON_OBJECT = "{\n}\n"; | ||
|
||
} |
89 changes: 89 additions & 0 deletions
89
basiclti/tsugi-util/src/java/org/tsugi/casa/objects/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
|
||
package org.tsugi.casa.objects; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.annotation.Generated; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
|
||
import org.tsugi.jackson.objects.JacksonBase; | ||
import org.tsugi.casa.CASAUtil; | ||
|
||
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) | ||
@Generated("com.googlecode.jsonschema2pojo") | ||
@JsonPropertyOrder({ | ||
"identity", | ||
"original" | ||
// TODO: "requires" | ||
}) | ||
|
||
public class Application extends JacksonBase { | ||
|
||
@JsonProperty("identity") | ||
private Identity identity; | ||
@JsonProperty("original") | ||
private Original original; | ||
|
||
// Constructor | ||
public Application(Identity identity, Original original) { | ||
this.identity = identity; | ||
this.original = original; | ||
} | ||
|
||
@JsonProperty("identity") | ||
public Identity getIdentity() { | ||
return identity; | ||
} | ||
|
||
@JsonProperty("identity") | ||
public void setIdentity(Identity identity) { | ||
this.identity = identity; | ||
} | ||
|
||
@JsonProperty("original") | ||
public Original getOriginal() { | ||
return original; | ||
} | ||
|
||
@JsonProperty("original") | ||
public void setOriginal(Original original) { | ||
this.original = original; | ||
} | ||
|
||
|
||
/* | ||
From: https://gist.github.com/pfgray/acca0e7966e452cb7c58 | ||
[{ | ||
"identity":{ | ||
"originator_id":"a9a860ae-7c0f-4c12-a1cf-9fe490ee1f49", | ||
"id":"local-lti-provider" | ||
}, | ||
"original":{ | ||
"timestamp":"2015-01-02T22:17:00.371Z", | ||
"uri":"http://lti-provider.paulgray.net", | ||
"share":true, | ||
"propagate":true, | ||
"use":{ | ||
"f6820326-5ea3-4a02-840d-7f91e75eb01b":{ | ||
"registration_url":"http://lti-provider.paulgray.net/register", | ||
"launch_url":"http://www.google.com" | ||
}, | ||
"1f2625c2-615f-11e3-bf13-d231feb1dc81":"Local Mock Lti2 Provider", | ||
"d59e3a1f-c034-4309-a282-60228089194e":[{"name":"Paul Gray","email":"[email protected]"}], | ||
"c80df319-d5da-4f59-8ca3-c89b234c5055":["dev","lti"], | ||
"c6e33506-b170-475b-83e9-4ecd6b6dd42a":["lti"], | ||
"d25b3012-1832-4843-9ecf-3002d3434155":"http://www.iconsdb.com/icons/preview/green/literature-xxl.png", | ||
}, | ||
"require":{} | ||
} | ||
}] | ||
*/ | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
basiclti/tsugi-util/src/java/org/tsugi/casa/objects/Contact.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
package org.tsugi.casa.objects; | ||
|
||
public class Contact extends org.tsugi.shared.objects.Contact { | ||
|
||
public Contact(String name, String email) { | ||
super(name,email); | ||
} | ||
|
||
/* | ||
"use":{ | ||
"f6820326-5ea3-4a02-840d-7f91e75eb01b":{ | ||
"registration_url":"http://lti-provider.paulgray.net/register", | ||
"launch_url":"http://www.google.com" | ||
}, | ||
"1f2625c2-615f-11e3-bf13-d231feb1dc81":"Local Mock Lti2 Provider", | ||
"d59e3a1f-c034-4309-a282-60228089194e":[{"name":"Paul Gray","email":"[email protected]"}], | ||
"c80df319-d5da-4f59-8ca3-c89b234c5055":["dev","lti"], | ||
"c6e33506-b170-475b-83e9-4ecd6b6dd42a":["lti"], | ||
"d25b3012-1832-4843-9ecf-3002d3434155":"http://www.iconsdb.com/icons/preview/green/literature-xxl.png", | ||
}, | ||
*/ | ||
} | ||
|
Oops, something went wrong.