diff --git a/pom.xml b/pom.xml index ded1a5a..ead4c13 100644 --- a/pom.xml +++ b/pom.xml @@ -84,17 +84,6 @@ json-simple 1.1 - - org.codehaus.jackson - jackson-mapper-asl - 1.9.3 - - - org.codehaus.jackson - jackson-core-asl - 1.9.3 - jar - net.oauth.core oauth-provider diff --git a/src/main/java/org/imsglobal/lti2/LTI2Config.java b/src/main/java/org/imsglobal/lti2/LTI2Config.java deleted file mode 100644 index 638dc55..0000000 --- a/src/main/java/org/imsglobal/lti2/LTI2Config.java +++ /dev/null @@ -1,37 +0,0 @@ - -package org.imsglobal.lti2; - -// Capture the information needed to build a tool profile -public interface LTI2Config { - // A globally unique identifier for the service. The domain name is typical. - // The scope for this is tenant/customer - public String getGuid(); - public String getSupport_email(); - - // In a multi-tenant environment this data describes the tenant / customer. - public String getService_owner_id(); - public String getService_owner_owner_name(); - public String getService_owner_description(); - public String getService_owner_support_email(); - - // This represents the service provider that hosts a product. - // If this is self hosted, it is reasonable that these values - // are the same as the "owner" values above. - public String getService_provider_id(); - public String getService_provider_provider_name(); - public String getService_provider_description(); - public String getService_provider_support_email(); - - // This section is general information about the software product - public String getProduct_family_product_code(); - public String getProduct_family_vendor_code(); - public String getProduct_family_vendor_name(); - public String getProduct_family_vendor_description(); - public String getProduct_family_vendor_website(); - public String getProduct_family_vendor_contact(); - - // This is about one particular version of a product - public String getProduct_info_product_name(); - public String getProduct_info_product_version(); - public String getProduct_info_product_description(); -} diff --git a/src/main/java/org/imsglobal/lti2/LTI2ConfigSample.java b/src/main/java/org/imsglobal/lti2/LTI2ConfigSample.java deleted file mode 100644 index 0abc89d..0000000 --- a/src/main/java/org/imsglobal/lti2/LTI2ConfigSample.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.imsglobal.lti2; - -public class LTI2ConfigSample implements LTI2Config { - - // A globally unique identifier for the service. The domain name is typical. - // The scope for this is tenant/customer - public String getGuid() { - return "edunext.school.edu"; - } - public String getSupport_email() { - return "support@edunext.school.edu"; - } - - // In a multi-tenant environment this data describes the tenant / customer. - public String getService_owner_id() { - return "https://edunext.school.edu"; - } - public String getService_owner_owner_name() { - return "ETS at SchoolEdu"; - } - public String getService_owner_description() { - return "The Ed. Tech Services Division of SchoolEdu"; - } - public String getService_owner_support_email() { - return "edunext@school.edu"; - } - - // This represents the service provider that hosts a product. - // If this is self hosted, it is reasonable that these values - // are the same as the "owner" values above. - public String getService_provider_id() { - return "https://hosting.example.com"; - } - public String getService_provider_provider_name() { - return "Example Hosting Services"; - } - public String getService_provider_description() { - return "We are the best example of a hosting services for EduNext."; - } - public String getService_provider_support_email() { - return "sales@hosting.example.com"; - } - - // This section is about the software product - public String getProduct_family_product_code() { - return "edunext"; - } - public String getProduct_family_vendor_code() { - return "edunext"; - } - public String getProduct_family_vendor_name() { - return "Edu Next Project"; - } - public String getProduct_family_vendor_description() { - return "EduNext is whats next in education."; - } - public String getProduct_family_vendor_website() { - return "http://www.edunext.example.com"; - } - public String getProduct_family_vendor_contact() { - return "sales@edunext.sample.com"; - } - - // This is about one particular version of a product. - public String getProduct_info_product_name() { - return "Classes"; - } - public String getProduct_info_product_version() { - return "2.0"; - } - public String getProduct_info_product_description() { - return "Classes 2.0"; - } -} diff --git a/src/main/java/org/imsglobal/lti2/LTI2Constants.java b/src/main/java/org/imsglobal/lti2/LTI2Constants.java deleted file mode 100644 index 97d8710..0000000 --- a/src/main/java/org/imsglobal/lti2/LTI2Constants.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2013 IMS GLobal Learning Consortium - * - * 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.imsglobal.lti2; - -public class LTI2Constants { - /** - * LTI2_VERSION_STRING=LTI-2p0 - *

- * This indicates an LTI 2.0 launch. - */ - public static final String LTI2_VERSION_STRING = "LTI-2p0"; - - /** - * REG_KEY="9875" - *

- * This is the registration key for the callback. - */ - public static final String REG_KEY = "reg_key"; - - /** - * REG_PASSWORD="9875" - *

- * This is the registration password for the callback. - */ - public static final String REG_PASSWORD = "reg_password"; - - /** - * TC_PROFILE_URL - *

- * This is the profile URL. - */ - public static final String TC_PROFILE_URL = "tc_profile_url"; - - public static final String JSONLD_ID = "@id"; - public static final String CONTEXT = "@context"; - public static final String TYPE = "@type"; - public static final String VALUE = "@value"; - public static final String GRAPH = "@graph"; - - public static final String CUSTOM_URL = "custom_url"; - public static final String TOOL_PROXY_GUID = "tool_proxy_guid"; - public static final String SHARED_SECRET = "shared_secret"; - public static final String CUSTOM = "custom"; - public static final String SECURITY_CONTRACT = "security_contract"; - public static final String SERVICE = "service"; - public static final String TOOL_SERVICE = "tool_service"; - public static final String GRADE = "grade"; - public static final String GRADE_TYPE_DECIMAL = "decimal"; - public static final String COMMENT = "comment"; - public static final String RESULTSCORE = "resultScore"; - - /** - * Utility array useful for validating property names when building launch - * data. - */ - public static final String[] validPropertyNames = { - REG_KEY, REG_PASSWORD, TC_PROFILE_URL }; - -} diff --git a/src/main/java/org/imsglobal/lti2/LTI2SampleData.java b/src/main/java/org/imsglobal/lti2/LTI2SampleData.java deleted file mode 100644 index 1b4560d..0000000 --- a/src/main/java/org/imsglobal/lti2/LTI2SampleData.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.imsglobal.lti2; - -import java.util.Properties; -import org.imsglobal.lti.BasicLTIConstants; - -public class LTI2SampleData { - - public static Properties getSubstitution() { - Properties lti2subst = new Properties(); - lti2subst.setProperty("CourseOffering.id","context_id_999"); - lti2subst.setProperty("CourseOffering.label","SI364"); - lti2subst.setProperty("CourseOffering.title","Building Interactive Applications"); - lti2subst.setProperty("Membership.role","Instructor"); - lti2subst.setProperty("ResourceLink.id","res_link_999"); - lti2subst.setProperty("ResourceLink.title","My weekly blog"); - lti2subst.setProperty("User.id","user_id_007"); - lti2subst.setProperty("User.username","bond"); - lti2subst.setProperty("Person.name.given","James"); - lti2subst.setProperty("Person.name.family","Bond"); - lti2subst.setProperty("Person.name.full","James Bond"); - lti2subst.setProperty("Person.email.primary","bond@example.com"); - return lti2subst; - } - - public static Properties getLaunch() { - Properties launch = new Properties(); - launch.setProperty(BasicLTIConstants.CONTEXT_ID,"context_id_999"); - launch.setProperty(BasicLTIConstants.CONTEXT_LABEL,"SI364"); - launch.setProperty(BasicLTIConstants.CONTEXT_TITLE,"Building Interactive Applications"); - launch.setProperty(BasicLTIConstants.ROLES,"Instructor"); - launch.setProperty(BasicLTIConstants.RESOURCE_LINK_ID,"res_link_999"); - launch.setProperty(BasicLTIConstants.RESOURCE_LINK_TITLE,"My weekly blog"); - launch.setProperty(BasicLTIConstants.USER_ID,"user_id_007"); - launch.setProperty(BasicLTIConstants.LIS_PERSON_NAME_GIVEN,"James"); - launch.setProperty(BasicLTIConstants.LIS_PERSON_NAME_FAMILY,"Bond"); - launch.setProperty(BasicLTIConstants.LIS_PERSON_NAME_FULL,"James Bond"); - launch.setProperty(BasicLTIConstants.LIS_PERSON_CONTACT_EMAIL_PRIMARY,"bond@example.com"); - return launch; - } - -} diff --git a/src/main/java/org/imsglobal/lti2/LTI2Servlet.java b/src/main/java/org/imsglobal/lti2/LTI2Servlet.java deleted file mode 100644 index cbe0cac..0000000 --- a/src/main/java/org/imsglobal/lti2/LTI2Servlet.java +++ /dev/null @@ -1,640 +0,0 @@ -/** - * Copyright (c) 2013 IMS GLobal Learning Consortium - * - * 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. - * - * Author: Charles Severance - */ - -package org.imsglobal.lti2; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.TreeMap; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.http.HttpStatus; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.ObjectWriter; -import org.imsglobal.lti.BasicLTIConstants; -import org.imsglobal.lti.BasicLTIUtil; -import org.imsglobal.lti.launch.LtiVerificationResult; -import org.imsglobal.json.IMSJSONRequest; -import org.imsglobal.lti2.objects.consumer.ServiceOffered; -import org.imsglobal.lti2.objects.consumer.StandardServices; -import org.imsglobal.lti2.objects.consumer.ToolConsumer; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -/** - * Notes: - * - * This is a sample "Hello World" servlet for LTI2. It is a simple UI - mostly - * intended to exercise the APIs and show the way for servlet-based LTI2 code. - * - * Here are the web.xml entries: - *

- * {@code
- *  
- *    SampleServlet
- *    org.imsglobal.lti2.LTI2Servlet
- *  
- *  
- *    SampleServlet
- *    /sample/*
- *  
- * }
- * 
- * - * Then navigate to: - * http://localhost/testservlet/sample/register - * - * A PHP endpoint is available at: - * - * https://source.sakaiproject.org/svn/basiclti/trunk/basiclti-docs/resources/docs/sakai-api-test - * - * The tp.php script is the Tool Provider registration endpoint in the PHP code - * - */ - -@SuppressWarnings("deprecation") -public class LTI2Servlet extends HttpServlet { - - private static final long serialVersionUID = 1L; - private static Logger M_log = Logger.getLogger(LTI2Servlet.class.getName()); - - protected ServiceOffered LTI2ResultItem = null; - protected ServiceOffered LTI2LtiLinkSettings = null; - protected ServiceOffered LTI2ToolProxyBindingSettings = null; - protected ServiceOffered LTI2ToolProxySettings = null; - - private static final String SVC_tc_profile = "tc_profile"; - private static final String SVC_tc_registration = "tc_registration"; - private static final String SVC_Settings = "Settings"; - private static final String SVC_Result = "Result"; - - @SuppressWarnings("unused") - private static final String EMPTY_JSON_OBJECT = "{\n}\n"; - - private static final String APPLICATION_JSON = "application/json"; - - // Normally these would be in a database - private static String TEST_KEY = "42"; - private static String TEST_SECRET = "zaphod"; - - // Pretending to be a database row :) - private static Map PERSIST = new TreeMap (); - - @Override - public void init(ServletConfig config) throws ServletException { - super.init(config); - } - - protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - doPost(request,response); - } - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - doPost(request,response); - } - - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException - { - try { - doRequest(request, response); - } catch (Exception e) { - String ipAddress = request.getRemoteAddr(); - String uri = request.getRequestURI(); - M_log.log(Level.WARNING, "General LTI2 Failure URI="+uri+" IP=" + ipAddress); - e.printStackTrace(); - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - doErrorJSON(request, response, null, "General failure", e); - } - } - - @SuppressWarnings("unused") - protected void doRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException - { - System.out.println("getServiceURL="+getServiceURL(request)); - - String ipAddress = request.getRemoteAddr(); - System.out.println("LTI Service request from IP=" + ipAddress); - - String rpi = request.getPathInfo(); - String uri = request.getRequestURI(); - String [] parts = uri.split("/"); - if ( parts.length < 4 ) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request, response, null, "Incorrect url format", null); - return; - } - String controller = parts[3]; - if ( "register".equals(controller) ) { - doRegister(request,response); - return; - } else if ( "launch".equals(controller) ) { - doLaunch(request,response); - return; - } else if ( SVC_tc_profile.equals(controller) && parts.length == 5 ) { - String profile_id = parts[4]; - getToolConsumerProfile(request,response,profile_id); - return; - } else if ( SVC_tc_registration.equals(controller) && parts.length == 5 ) { - String profile_id = parts[4]; - registerToolProviderProfile(request, response, profile_id); - return; - } else if ( SVC_Result.equals(controller) && parts.length == 5 ) { - String sourcedid = parts[4]; - handleResultRequest(request, response, sourcedid); - return; - } else if ( SVC_Settings.equals(controller) && parts.length >= 6 ) { - handleSettingsRequest(request, response, parts); - return; - } - - IMSJSONRequest jsonRequest = new IMSJSONRequest(request); - if ( jsonRequest.valid ) { - System.out.println(jsonRequest.getPostBody()); - } - - response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); - M_log.log(Level.WARNING, "Unknown request="+uri); - doErrorJSON(request, response, null, "Unknown request="+uri, null); - } - - protected void doRegister(HttpServletRequest request, HttpServletResponse response) - { - // Reset our database - PERSIST.clear(); - String launch_url = request.getParameter("launch_url"); - response.setContentType("text/html"); - - String output = null; - if ( launch_url != null ) { - Properties ltiProps = new Properties(); - - ltiProps.setProperty(BasicLTIConstants.LTI_VERSION, LTI2Constants.LTI2_VERSION_STRING); - ltiProps.setProperty(LTI2Constants.REG_KEY,TEST_KEY); - ltiProps.setProperty(LTI2Constants.REG_PASSWORD,TEST_SECRET); - ltiProps.setProperty(BasicLTIUtil.BASICLTI_SUBMIT, "Press to Launch External Tool"); - ltiProps.setProperty(BasicLTIConstants.LTI_MESSAGE_TYPE, BasicLTIConstants.LTI_MESSAGE_TYPE_TOOLPROXYREGISTRATIONREQUEST); - - String serverUrl = getServiceURL(request); - ltiProps.setProperty(LTI2Constants.TC_PROFILE_URL,serverUrl + SVC_tc_profile + "/" + TEST_KEY); - ltiProps.setProperty(BasicLTIConstants.LAUNCH_PRESENTATION_RETURN_URL, serverUrl + "launch"); - System.out.println("ltiProps="+ltiProps); - - boolean dodebug = true; - output = BasicLTIUtil.postLaunchHTML(ltiProps, launch_url, dodebug); - } else { - output = "
Register URL:
\n"; - } - - try { - PrintWriter out = response.getWriter(); - out.println(output); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - // We are actually bypassing the activation step. Usually activation will parse - // the profile, and install a tool if the admin is happy. For us we just parse - // the profile and do a launch. - @SuppressWarnings("unused") - protected void doLaunch(HttpServletRequest request, HttpServletResponse response) - { - - String profile = PERSIST.get("profile"); - response.setContentType("text/html"); - - String output = null; - if ( profile == null ) { - output = "Missing profile"; - } else { - JSONObject providerProfile = (JSONObject) JSONValue.parse(profile); - - List profileTools = new ArrayList (); - Properties info = new Properties(); - String retval = LTI2Util.parseToolProfile(profileTools, info, providerProfile); - String launch = null; - String parameter = null; - for ( Properties profileTool : profileTools ) { - launch = (String) profileTool.get("launch"); - parameter = (String) profileTool.get("parameter"); - } - JSONObject security_contract = (JSONObject) providerProfile.get(LTI2Constants.SECURITY_CONTRACT); - - String shared_secret = (String) security_contract.get(LTI2Constants.SHARED_SECRET); - System.out.println("launch="+launch); - System.out.println("shared_secret="+shared_secret); - - Properties ltiProps = LTI2SampleData.getLaunch(); - ltiProps.setProperty(BasicLTIConstants.LTI_VERSION,BasicLTIConstants.LTI_VERSION_2); - - Properties lti2subst = LTI2SampleData.getSubstitution(); - String settings_url = getServiceURL(request) + SVC_Settings + "/"; - lti2subst.setProperty("LtiLink.custom.url", settings_url + LTI2Util.SCOPE_LtiLink + "/" - + ltiProps.getProperty(BasicLTIConstants.RESOURCE_LINK_ID)); - lti2subst.setProperty("ToolProxyBinding.custom.url", settings_url + LTI2Util.SCOPE_ToolProxyBinding + "/" - + ltiProps.getProperty(BasicLTIConstants.CONTEXT_ID)); - lti2subst.setProperty("ToolProxy.custom.url", settings_url + LTI2Util.SCOPE_ToolProxy + "/" - + TEST_KEY); - lti2subst.setProperty("Result.url", getServiceURL(request) + SVC_Result + "/" - + ltiProps.getProperty(BasicLTIConstants.RESOURCE_LINK_ID)); - - // Do the substitutions - Properties custom = new Properties(); - LTI2Util.mergeLTI2Parameters(custom, parameter); - LTI2Util.substituteCustom(custom, lti2subst); - - // Place the custom values into the launch - LTI2Util.addCustomToLaunch(ltiProps, custom); - - ltiProps = BasicLTIUtil.signProperties(ltiProps, launch, "POST", - TEST_KEY, shared_secret, null, null, null); - - boolean dodebug = true; - output = BasicLTIUtil.postLaunchHTML(ltiProps, launch, dodebug); - } - - try { - PrintWriter out = response.getWriter(); - out.println(output); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - protected void getToolConsumerProfile(HttpServletRequest request, - HttpServletResponse response,String profile_id) - { - // Map deploy = ltiService.getDeployForConsumerKeyDao(profile_id); - Map deploy = null; - - ToolConsumer consumer = buildToolConsumerProfile(request, deploy, profile_id); - - ObjectMapper mapper = new ObjectMapper(); - try { - // http://stackoverflow.com/questions/6176881/how-do-i-make-jackson-pretty-print-the-json-content-it-generates - ObjectWriter writer = mapper.defaultPrettyPrintingWriter(); - // ***IMPORTANT!!!*** for Jackson 2.x use the line below instead of the one above: - // ObjectWriter writer = mapper.writer().withDefaultPrettyPrinter(); - // System.out.println(mapper.writeValueAsString(consumer)); - response.setContentType(APPLICATION_JSON); - PrintWriter out = response.getWriter(); - out.println(writer.writeValueAsString(consumer)); - // System.out.println(writer.writeValueAsString(consumer)); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - // Normally deploy would have the data about the deployment - for this test - // it is always null and we allow everything - protected ToolConsumer buildToolConsumerProfile(HttpServletRequest request, Map deploy, String profile_id) - { - // Load the configuration data - LTI2Config cnf = new org.imsglobal.lti2.LTI2ConfigSample(); - - ToolConsumer consumer = new ToolConsumer(profile_id, "LTI-2p0", getServiceURL(request), cnf); - - // Normally we would check permissions before we offer capabilities - List capabilities = consumer.getCapability_offered(); - LTI2Util.allowEmail(capabilities); - LTI2Util.allowName(capabilities); - LTI2Util.allowSettings(capabilities); - LTI2Util.allowResult(capabilities); - - // Normally we would check permissions before we offer services - List services = consumer.getService_offered(); - services.add(StandardServices.LTI2Registration(getServiceURL(request) + - SVC_tc_registration + "/" + profile_id)); - services.add(StandardServices.LTI2ResultItem(getServiceURL(request) + - SVC_Result + "/{" + BasicLTIConstants.LIS_RESULT_SOURCEDID + "}")); - services.add(StandardServices.LTI2LtiLinkSettings(getServiceURL(request) + - SVC_Settings + "/" + LTI2Util.SCOPE_LtiLink + "/{" + BasicLTIConstants.RESOURCE_LINK_ID + "}")); - services.add(StandardServices.LTI2ToolProxySettings(getServiceURL(request) + - SVC_Settings + "/" + LTI2Util.SCOPE_ToolProxyBinding + "/{" + BasicLTIConstants.CONTEXT_ID + "}")); - services.add(StandardServices.LTI2ToolProxySettings(getServiceURL(request) + - SVC_Settings + "/" + LTI2Util.SCOPE_ToolProxy + "/{" + LTI2Constants.TOOL_PROXY_GUID + "}")); - return consumer; - } - - @SuppressWarnings({ "unchecked", "unused", "rawtypes" }) - public void registerToolProviderProfile(HttpServletRequest request,HttpServletResponse response, - String profile_id) throws java.io.IOException - { - // Normally we would look up the deployment descriptor - if ( ! TEST_KEY.equals(profile_id) ) { - response.setStatus(HttpServletResponse.SC_NOT_FOUND); - return; - } - - String key = TEST_KEY; - String secret = TEST_SECRET; - - IMSJSONRequest jsonRequest = new IMSJSONRequest(request); - - if ( ! jsonRequest.valid ) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request, response, jsonRequest, "Request is not in a valid format", null); - return; - } - - System.out.println(jsonRequest.getPostBody()); - - // Lets check the signature - if ( key == null || secret == null ) { - response.setStatus(HttpServletResponse.SC_FORBIDDEN); - doErrorJSON(request, response, jsonRequest, "Deployment is missing credentials", null); - return; - } - - jsonRequest.validateRequest(key, secret, request); - if ( !jsonRequest.valid ) { - response.setStatus(HttpServletResponse.SC_FORBIDDEN); - doErrorJSON(request, response, jsonRequest, "OAuth signature failure", null); - return; - } - - JSONObject providerProfile = (JSONObject) JSONValue.parse(jsonRequest.getPostBody()); - // System.out.println("OBJ:"+providerProfile); - if ( providerProfile == null ) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request, response, jsonRequest, "JSON parse failed", null); - return; - } - - JSONObject default_custom = (JSONObject) providerProfile.get(LTI2Constants.CUSTOM); - - JSONObject security_contract = (JSONObject) providerProfile.get(LTI2Constants.SECURITY_CONTRACT); - if ( security_contract == null ) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request, response, jsonRequest, "JSON missing security_contract", null); - return; - } - - String shared_secret = (String) security_contract.get(LTI2Constants.SHARED_SECRET); - System.out.println("shared_secret="+shared_secret); - if ( shared_secret == null ) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request, response, jsonRequest, "JSON missing shared_secret", null); - return; - } - - // Make sure that the requested services are a subset of the offered services - ToolConsumer consumer = buildToolConsumerProfile(request, null, profile_id); - - JSONArray tool_services = (JSONArray) security_contract.get(LTI2Constants.TOOL_SERVICE); - String retval = LTI2Util.validateServices(consumer, providerProfile); - if ( retval != null ) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request, response, jsonRequest, retval, null); - return; - } - - // Parse the tool profile bit and extract the tools with error checking - retval = LTI2Util.validateCapabilities(consumer, providerProfile); - if ( retval != null ) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request, response, jsonRequest, retval, null); - return; - } - - // Pass the profile to the launch process - PERSIST.put("profile", providerProfile.toString()); - - // Share our happiness with the Tool Provider - Map jsonResponse = new TreeMap(); - jsonResponse.put(LTI2Constants.CONTEXT,StandardServices.TOOLPROXY_ID_CONTEXT); - jsonResponse.put(LTI2Constants.TYPE, StandardServices.TOOLPROXY_ID_TYPE); - jsonResponse.put(LTI2Constants.JSONLD_ID, getServiceURL(request) + SVC_tc_registration + "/" +profile_id); - jsonResponse.put(LTI2Constants.TOOL_PROXY_GUID, profile_id); - jsonResponse.put(LTI2Constants.CUSTOM_URL, getServiceURL(request) + SVC_Settings + "/" + LTI2Util.SCOPE_ToolProxy + "/" +profile_id); - response.setContentType(StandardServices.TOOLPROXY_ID_FORMAT); - response.setStatus(HttpServletResponse.SC_CREATED); - String jsonText = JSONValue.toJSONString(jsonResponse); - M_log.log(Level.FINE, jsonText); - PrintWriter out = response.getWriter(); - out.println(jsonText); - } - - public String getServiceURL(HttpServletRequest request) { - String scheme = request.getScheme(); // http - String serverName = request.getServerName(); // localhost - int serverPort = request.getServerPort(); // 80 - String contextPath = request.getContextPath(); // /imsblis - String servletPath = request.getServletPath(); // /ltitest - String url = scheme+"://"+serverName+":"+serverPort+contextPath+servletPath+"/"; - return url; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void handleResultRequest(HttpServletRequest request,HttpServletResponse response, - String sourcedid) throws java.io.IOException - { - IMSJSONRequest jsonRequest = null; - String retval = null; - if ( "GET".equals(request.getMethod()) ) { - String grade = PERSIST.get("grade"); - String comment = PERSIST.get("comment"); - - Map jsonResponse = new TreeMap(); - Map resultScore = new TreeMap(); - - jsonResponse.put(LTI2Constants.CONTEXT,StandardServices.RESULT_CONTEXT); - jsonResponse.put(LTI2Constants.TYPE, StandardServices.RESULT_TYPE); - resultScore.put(LTI2Constants.TYPE, LTI2Constants.GRADE_TYPE_DECIMAL); - jsonResponse.put(LTI2Constants.COMMENT, grade); - resultScore.put(LTI2Constants.VALUE, comment); - jsonResponse.put(LTI2Constants.RESULTSCORE,resultScore); - response.setContentType(StandardServices.RESULT_FORMAT); - response.setStatus(HttpServletResponse.SC_OK); - String jsonText = JSONValue.toJSONString(jsonResponse); - M_log.log(Level.FINE, jsonText); - PrintWriter out = response.getWriter(); - out.println(jsonText); - return; - } else if ( "PUT".equals(request.getMethod()) ) { - retval = "Error parsing input data"; - try { - jsonRequest = new IMSJSONRequest(request); - // System.out.println(jsonRequest.getPostBody()); - JSONObject requestData = (JSONObject) JSONValue.parse(jsonRequest.getPostBody()); - String comment = (String) requestData.get(LTI2Constants.COMMENT); - JSONObject resultScore = (JSONObject) requestData.get(LTI2Constants.RESULTSCORE); - String sGrade = (String) resultScore.get(LTI2Constants.VALUE); - Double dGrade = new Double(sGrade); - - PERSIST.put("comment", comment); - PERSIST.put("grade", dGrade+""); - response.setStatus(HttpServletResponse.SC_OK); - return; - } catch (Exception e) { - retval = "Error: "+ e.getMessage(); - } - } else { - retval = "Unsupported operation:" + request.getMethod(); - } - - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request,response, jsonRequest, (String) retval, null); - } - - // If this code looks like a hack - it is because the spec is a hack. - // There are five possible scenarios for GET and two possible scenarios - // for PUT. I begged to simplify the business logic but was overrulled. - // So we write obtuse code. - @SuppressWarnings("unused") - public void handleSettingsRequest(HttpServletRequest request,HttpServletResponse response, - String[] parts) throws java.io.IOException - { - - String URL = request.getRequestURL().toString(); -System.out.println("URL="+URL); - String scope = parts[4]; -System.out.println("scope="+scope); - - String acceptHdr = request.getHeader("Accept"); - String contentHdr = request.getContentType(); - boolean acceptComplex = acceptHdr == null || acceptHdr.indexOf(StandardServices.TOOLSETTINGS_FORMAT) >= 0 ; - -System.out.println("accept="+acceptHdr+" ac="+acceptComplex); - - // Check the JSON on PUT and check the oauth_body_hash - IMSJSONRequest jsonRequest = null; - JSONObject requestData = null; - if ( "PUT".equals(request.getMethod()) ) { - try { - jsonRequest = new IMSJSONRequest(request); - requestData = (JSONObject) JSONValue.parse(jsonRequest.getPostBody()); - } catch (Exception e) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request,response, jsonRequest, "Could not parse JSON", e); - return; - } - } - - String consumer_key = TEST_KEY; - String profile = PERSIST.get("profile"); - JSONObject providerProfile = (JSONObject) JSONValue.parse(profile); - JSONObject security_contract = (JSONObject) providerProfile.get(LTI2Constants.SECURITY_CONTRACT); - String oauth_secret = (String) security_contract.get(LTI2Constants.SHARED_SECRET); - - // Validate the incoming message - LtiVerificationResult result = BasicLTIUtil.validateMessage(request, URL, oauth_secret); - if (!result.getSuccess()) { - response.setStatus(HttpStatus.SC_FORBIDDEN); - doErrorJSON(request,response, jsonRequest, result.getMessage(), null); - return; - } - - // The URLs for the various settings resources - String settingsUrl = getServiceURL(request) + SVC_Settings; - String proxy_url = settingsUrl + "/" + LTI2Util.SCOPE_ToolProxy + "/" + consumer_key; - String binding_url = settingsUrl + "/" + LTI2Util.SCOPE_ToolProxyBinding + "/" + "TBD"; - String link_url = settingsUrl + "/" + LTI2Util.SCOPE_LtiLink + "/" + "TBD"; - - // Load and parse the old settings... - JSONObject link_settings = LTI2Util.parseSettings(PERSIST.get(LTI2Util.SCOPE_LtiLink)); - JSONObject binding_settings = LTI2Util.parseSettings(PERSIST.get(LTI2Util.SCOPE_ToolProxyBinding)); - JSONObject proxy_settings = LTI2Util.parseSettings(PERSIST.get(LTI2Util.SCOPE_ToolProxy)); - - // For a GET request we depend on LTI2Util to do the GET logic - if ( "GET".equals(request.getMethod()) ) { - Object obj = LTI2Util.getSettings(request, scope, - link_settings, binding_settings, proxy_settings, - link_url, binding_url, proxy_url); - - if ( obj instanceof String ) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request,response, jsonRequest, (String) obj, null); - return; - } - - if ( acceptComplex ) { - response.setContentType(StandardServices.TOOLSETTINGS_FORMAT); - } else { - response.setContentType(StandardServices.TOOLSETTINGS_SIMPLE_FORMAT); - } - - JSONObject jsonResponse = (JSONObject) obj; - response.setStatus(HttpServletResponse.SC_OK); - PrintWriter out = response.getWriter(); -System.out.println("jsonResponse="+jsonResponse); - out.println(jsonResponse.toString()); - return; - } else if ( "PUT".equals(request.getMethod()) ) { - // This is assuming the rule that a PUT of the complex settings - // format that there is only one entry in the graph and it is - // the same as our current URL. We parse without much checking. - String settings = null; - try { - JSONArray graph = (JSONArray) requestData.get(LTI2Constants.GRAPH); - if ( graph.size() != 1 ) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request,response, jsonRequest, "Only one graph entry allowed", null); - return; - } - JSONObject firstChild = (JSONObject) graph.get(0); - JSONObject custom = (JSONObject) firstChild.get(LTI2Constants.CUSTOM); - settings = custom.toString(); - } catch (Exception e) { - settings = jsonRequest.getPostBody(); - } - PERSIST.put(scope,settings); -System.out.println("Stored settings scope="+scope); -System.out.println("settings="+settings); - response.setStatus(HttpServletResponse.SC_OK); - } else { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - doErrorJSON(request,response, jsonRequest, "Method not handled="+request.getMethod(), null); - } - } - - /* IMS JSON version of Errors */ - public void doErrorJSON(HttpServletRequest request,HttpServletResponse response, - IMSJSONRequest json, String message, Exception e) - throws java.io.IOException - { - if (e != null) { - M_log.log(Level.WARNING, e.getLocalizedMessage(), e); - } - M_log.info(message); - String output = IMSJSONRequest.doErrorJSON(request, response, json, message, e); -System.out.println(output); - } - - public void destroy() { - } - -} diff --git a/src/main/java/org/imsglobal/lti2/LTI2Util.java b/src/main/java/org/imsglobal/lti2/LTI2Util.java deleted file mode 100644 index e4c370c..0000000 --- a/src/main/java/org/imsglobal/lti2/LTI2Util.java +++ /dev/null @@ -1,596 +0,0 @@ -/* - * $URL: https://source.sakaiproject.org/svn/basiclti/trunk/basiclti-util/src/java/org/imsglobal/lti2/LTI2Util.java $ - * $Id: LTI2Util.java 134448 2014-02-12 18:32:12Z csev@umich.edu $ - * - * Copyright (c) 2013 IMS GLobal Learning Consortium - * - * 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.imsglobal.lti2; - -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.logging.Logger; - -import javax.servlet.http.HttpServletRequest; - -import org.imsglobal.lti.BasicLTIUtil; -import org.imsglobal.lti2.objects.consumer.ServiceOffered; -import org.imsglobal.lti2.objects.consumer.StandardServices; -import org.imsglobal.lti2.objects.consumer.ToolConsumer; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -public class LTI2Util { - - // We use the built-in Java logger because this code needs to be very generic - private static Logger M_log = Logger.getLogger(LTI2Util.class.toString()); - - public static final String SCOPE_LtiLink = "LtiLink"; - public static final String SCOPE_ToolProxyBinding = "ToolProxyBinding"; - public static final String SCOPE_ToolProxy = "ToolProxy"; - - private static final String EMPTY_JSON_OBJECT = "{\n}\n"; - - // Validate the incoming tool_services against a tool consumer - public static String validateServices(ToolConsumer consumer, JSONObject providerProfile) - { - // Mostly to catch casting errors from bad JSON - try { - JSONObject security_contract = (JSONObject) providerProfile.get(LTI2Constants.SECURITY_CONTRACT); - if ( security_contract == null ) { - return "JSON missing security_contract"; - } - JSONArray tool_services = (JSONArray) security_contract.get(LTI2Constants.TOOL_SERVICE); - - List services_offered = consumer.getService_offered(); - - if ( tool_services != null ) for (Object o : tool_services) { - JSONObject tool_service = (JSONObject) o; - String json_service = (String) tool_service.get(LTI2Constants.SERVICE); - - boolean found = false; - for (ServiceOffered service : services_offered ) { - String service_endpoint = service.getEndpoint(); - if ( service_endpoint.equals(json_service) ) { - found = true; - break; - } - } - if ( ! found ) return "Service not allowed: "+json_service; - } - return null; - } - catch (Exception e) { - return "Exception:"+ e.getLocalizedMessage(); - } - } - - // Validate incoming capabilities requested against out ToolConsumer - public static String validateCapabilities(ToolConsumer consumer, JSONObject providerProfile) - { - List theTools = new ArrayList (); - Properties info = new Properties(); - - // Mostly to catch casting errors from bad JSON - try { - String retval = parseToolProfile(theTools, info, providerProfile); - if ( retval != null ) return retval; - - if ( theTools.size() < 1 ) return "No tools found in profile"; - - // Check all the capabilities requested by all the tools comparing against consumer - List capabilities = consumer.getCapability_offered(); - for ( Properties theTool : theTools ) { - String ec = (String) theTool.get("enabled_capability"); - JSONArray enabled_capability = (JSONArray) JSONValue.parse(ec); - if ( enabled_capability != null ) for (Object o : enabled_capability) { - ec = (String) o; - if ( capabilities.contains(ec) ) continue; - return "Capability not permitted="+ec; - } - } - return null; - } - catch (Exception e ) { - return "Exception:"+ e.getLocalizedMessage(); - } - } - - public static void allowEmail(List capabilities) { - capabilities.add("Person.email.primary"); - } - - public static void allowName(List capabilities) { - capabilities.add("User.username"); - capabilities.add("Person.name.fullname"); - capabilities.add("Person.name.given"); - capabilities.add("Person.name.family"); - capabilities.add("Person.name.full"); - } - - public static void allowResult(List capabilities) { - capabilities.add("Result.sourcedId"); - capabilities.add("Result.autocreate"); - capabilities.add("Result.url"); - } - - public static void allowSettings(List capabilities) { - capabilities.add("LtiLink.custom.url"); - capabilities.add("ToolProxy.custom.url"); - capabilities.add("ToolProxyBinding.custom.url"); - } - - // If this code looks like a hack - it is because the spec is a hack. - // There are five possible scenarios for GET and two possible scenarios - // for PUT. I begged to simplify the business logic but was overrulled. - // So we write obtuse code. - @SuppressWarnings({ "unchecked", "unused" }) - public static Object getSettings(HttpServletRequest request, String scope, - JSONObject link_settings, JSONObject binding_settings, JSONObject proxy_settings, - String link_url, String binding_url, String proxy_url) - { - // Check to see if we are doing the bubble - String bubbleStr = request.getParameter("bubble"); - String acceptHdr = request.getHeader("Accept"); - String contentHdr = request.getContentType(); - - if ( bubbleStr != null && bubbleStr.equals("all") && - acceptHdr.indexOf(StandardServices.TOOLSETTINGS_FORMAT) < 0 ) { - return "Simple format does not allow bubble=all"; - } - - if ( SCOPE_LtiLink.equals(scope) || SCOPE_ToolProxyBinding.equals(scope) - || SCOPE_ToolProxy.equals(scope) ) { - // All good - } else { - return "Bad Setttings Scope="+scope; - } - - boolean bubble = bubbleStr != null && "GET".equals(request.getMethod()); - boolean distinct = bubbleStr != null && "distinct".equals(bubbleStr); - boolean bubbleAll = bubbleStr != null && "all".equals(bubbleStr); - - // Check our output format - boolean acceptComplex = acceptHdr == null || acceptHdr.indexOf(StandardServices.TOOLSETTINGS_FORMAT) >= 0; - - if ( distinct && link_settings != null && scope.equals(SCOPE_LtiLink) ) { - Iterator i = link_settings.keySet().iterator(); - while ( i.hasNext() ) { - String key = (String) i.next(); - if ( binding_settings != null ) binding_settings.remove(key); - if ( proxy_settings != null ) proxy_settings.remove(key); - } - } - - if ( distinct && binding_settings != null && scope.equals(SCOPE_ToolProxyBinding) ) { - Iterator i = binding_settings.keySet().iterator(); - while ( i.hasNext() ) { - String key = (String) i.next(); - if ( proxy_settings != null ) proxy_settings.remove(key); - } - } - - // Lets get this party started... - JSONObject jsonResponse = null; - if ( (distinct || bubbleAll) && acceptComplex ) { - jsonResponse = new JSONObject(); - jsonResponse.put(LTI2Constants.CONTEXT,StandardServices.TOOLSETTINGS_CONTEXT); - JSONArray graph = new JSONArray(); - boolean started = false; - if ( link_settings != null && SCOPE_LtiLink.equals(scope) ) { - JSONObject cjson = new JSONObject(); - cjson.put(LTI2Constants.JSONLD_ID,link_url); - cjson.put(LTI2Constants.TYPE,SCOPE_LtiLink); - cjson.put(LTI2Constants.CUSTOM,link_settings); - graph.add(cjson); - started = true; - } - if ( binding_settings != null && ( started || SCOPE_ToolProxyBinding.equals(scope) ) ) { - JSONObject cjson = new JSONObject(); - cjson.put(LTI2Constants.JSONLD_ID,binding_url); - cjson.put(LTI2Constants.TYPE,SCOPE_ToolProxyBinding); - cjson.put(LTI2Constants.CUSTOM,binding_settings); - graph.add(cjson); - started = true; - } - if ( proxy_settings != null && ( started || SCOPE_ToolProxy.equals(scope) ) ) { - JSONObject cjson = new JSONObject(); - cjson.put(LTI2Constants.JSONLD_ID,proxy_url); - cjson.put(LTI2Constants.TYPE,SCOPE_ToolProxy); - cjson.put(LTI2Constants.CUSTOM,proxy_settings); - graph.add(cjson); - } - jsonResponse.put(LTI2Constants.GRAPH,graph); - - } else if ( distinct ) { // Simple format output - jsonResponse = proxy_settings; - if ( SCOPE_LtiLink.equals(scope) ) { - jsonResponse.putAll(binding_settings); - jsonResponse.putAll(link_settings); - } else if ( SCOPE_ToolProxyBinding.equals(scope) ) { - jsonResponse.putAll(binding_settings); - } - } else { // bubble not specified - jsonResponse = new JSONObject(); - jsonResponse.put(LTI2Constants.CONTEXT,StandardServices.TOOLSETTINGS_CONTEXT); - JSONObject theSettings = null; - String endpoint = null; - if ( SCOPE_LtiLink.equals(scope) ) { - endpoint = link_url; - theSettings = link_settings; - } else if ( SCOPE_ToolProxyBinding.equals(scope) ) { - endpoint = binding_url; - theSettings = binding_settings; - } - if ( SCOPE_ToolProxy.equals(scope) ) { - endpoint = proxy_url; - theSettings = proxy_settings; - } - if ( acceptComplex ) { - JSONArray graph = new JSONArray(); - JSONObject cjson = new JSONObject(); - cjson.put(LTI2Constants.JSONLD_ID,endpoint); - cjson.put(LTI2Constants.TYPE,scope); - cjson.put(LTI2Constants.CUSTOM,theSettings); - graph.add(cjson); - jsonResponse.put(LTI2Constants.GRAPH,graph); - } else { - jsonResponse = theSettings; - } - } - return jsonResponse; - } - - // Parse a provider profile with lots of error checking... - public static String parseToolProfile(List theTools, Properties info, JSONObject jsonObject) - { - try { - return parseToolProfileInternal(theTools, info, jsonObject); - } catch (Exception e) { - M_log.warning("Internal error parsing tool proxy\n"+jsonObject.toString()); - e.printStackTrace(); - return "Internal error parsing tool proxy:"+e.getLocalizedMessage(); - } - } - - // Parse a provider profile with lots of error checking... - @SuppressWarnings("unused") - private static String parseToolProfileInternal(List theTools, Properties info, JSONObject jsonObject) - { - Object o = null; - JSONObject tool_profile = (JSONObject) jsonObject.get("tool_profile"); - if ( tool_profile == null ) { - return "JSON missing tool_profile"; - } - JSONObject product_instance = (JSONObject) tool_profile.get("product_instance"); - if ( product_instance == null ) { - return "JSON missing product_instance"; - } - - String instance_guid = (String) product_instance.get("guid"); - if ( instance_guid == null ) { - return "JSON missing product_info / guid"; - } - info.put("instance_guid",instance_guid); - - JSONObject product_info = (JSONObject) product_instance.get("product_info"); - if ( product_info == null ) { - return "JSON missing product_info"; - } - - // Look for required fields - JSONObject product_name = product_info == null ? null : (JSONObject) product_info.get("product_name"); - String productTitle = product_name == null ? null : (String) product_name.get("default_value"); - JSONObject description = product_info == null ? null : (JSONObject) product_info.get("description"); - String productDescription = description == null ? null : (String) description.get("default_value"); - - JSONObject product_family = product_info == null ? null : (JSONObject) product_info.get("product_family"); - String productCode = product_family == null ? null : (String) product_family.get("code"); - JSONObject product_vendor = product_family == null ? null : (JSONObject) product_family.get("vendor"); - description = product_vendor == null ? null : (JSONObject) product_vendor.get("description"); - String vendorDescription = description == null ? null : (String) description.get("default_value"); - String vendorCode = product_vendor == null ? null : (String) product_vendor.get("code"); - - if ( productTitle == null || productDescription == null ) { - return "JSON missing product_name or description "; - } - if ( productCode == null || vendorCode == null || vendorDescription == null ) { - return "JSON missing product code, vendor code or description"; - } - - info.put("product_name", productTitle); - info.put("description", productDescription); // Backwards compatibility - info.put("product_description", productDescription); - info.put("product_code", productCode); - info.put("vendor_code", vendorCode); - info.put("vendor_description", vendorDescription); - - o = tool_profile.get("base_url_choice"); - if ( ! (o instanceof JSONArray)|| o == null ) { - return "JSON missing base_url_choices"; - } - JSONArray base_url_choices = (JSONArray) o; - - String secure_base_url = null; - String default_base_url = null; - for ( Object i : base_url_choices ) { - JSONObject url_choice = (JSONObject) i; - secure_base_url = (String) url_choice.get("secure_base_url"); - default_base_url = (String) url_choice.get("default_base_url"); - } - - String launch_url = secure_base_url; - if ( launch_url == null ) launch_url = default_base_url; - if ( launch_url == null ) { - return "Unable to determine launch URL"; - } - - o = (JSONArray) tool_profile.get("resource_handler"); - if ( ! (o instanceof JSONArray)|| o == null ) { - return "JSON missing resource_handlers"; - } - JSONArray resource_handlers = (JSONArray) o; - - // Loop through resource handlers, read, and check for errors - for(Object i : resource_handlers ) { - JSONObject resource_handler = (JSONObject) i; - JSONObject resource_type_json = (JSONObject) resource_handler.get("resource_type"); - String resource_type_code = (String) resource_type_json.get("code"); - if ( resource_type_code == null ) { - return "JSON missing resource_type code"; - } - o = (JSONArray) resource_handler.get("message"); - if ( ! (o instanceof JSONArray)|| o == null ) { - return "JSON missing resource_handler / message"; - } - JSONArray messages = (JSONArray) o; - - JSONObject titleObject = (JSONObject) resource_handler.get("name"); - String title = titleObject == null ? null : (String) titleObject.get("default_value"); - if ( title == null || titleObject == null ) { - return "JSON missing resource_handler / name / default_value"; - } - - JSONObject buttonObject = (JSONObject) resource_handler.get("short_name"); - String button = buttonObject == null ? null : (String) buttonObject.get("default_value"); - - JSONObject descObject = (JSONObject) resource_handler.get("description"); - String resourceDescription = descObject == null ? null : (String) descObject.get("default_value"); - - String path = null; - JSONArray parameter = null; - JSONArray enabled_capability = null; - for ( Object m : messages ) { - JSONObject message = (JSONObject) m; - String message_type = (String) message.get("message_type"); - if ( ! "basic-lti-launch-request".equals(message_type) ) continue; - if ( path != null ) { - return "A resource_handler cannot have more than one basic-lti-launch-request message RT="+resource_type_code; - } - path = (String) message.get("path"); - if ( path == null ) { - return "A basic-lti-launch-request message must have a path RT="+resource_type_code; - } - o = (JSONArray) message.get("parameter"); - if ( ! (o instanceof JSONArray)) { - return "Must be an array: parameter RT="+resource_type_code; - } - parameter = (JSONArray) o; - - o = (JSONArray) message.get("enabled_capability"); - if ( ! (o instanceof JSONArray)) { - return "Must be an array: enabled_capability RT="+resource_type_code; - } - enabled_capability = (JSONArray) o; - } - - // Ignore everything except launch handlers - if ( path == null ) continue; - - // Check the URI - String thisLaunch = launch_url; - if ( ! thisLaunch.endsWith("/") && ! path.startsWith("/") ) thisLaunch = thisLaunch + "/"; - thisLaunch = thisLaunch + path; - try { - URL url = new URL(thisLaunch); - } catch ( Exception e ) { - return "Bad launch URL="+thisLaunch; - } - - // Passed all the tests... Lets keep it... - Properties theTool = new Properties(); - - theTool.put("resource_type", resource_type_code); // Backwards compatibility - theTool.put("resource_type_code", resource_type_code); - if ( title == null ) title = productTitle; - if ( title != null ) theTool.put("title", title); - if ( button != null ) theTool.put("button", button); - if ( resourceDescription == null ) resourceDescription = productDescription; - if ( resourceDescription != null ) theTool.put("description", resourceDescription); - if ( parameter != null ) theTool.put("parameter", parameter.toString()); - if ( enabled_capability != null ) theTool.put("enabled_capability", enabled_capability.toString()); - theTool.put("launch", thisLaunch); - theTools.add(theTool); - } - return null; // All good - } - - public static JSONObject parseSettings(String settings) - { - if ( settings == null || settings.length() < 1 ) { - settings = EMPTY_JSON_OBJECT; - } - return (JSONObject) JSONValue.parse(settings); - } - - /* Two possible formats: - - key=val;key2=val2; - - key=val - key2=val2 - */ - public static boolean mergeLTI1Custom(Properties custom, String customstr) - { - if ( customstr == null || customstr.length() < 1 ) return true; - - String [] params = customstr.split("[\n;]"); - for (int i = 0 ; i < params.length; i++ ) { - String param = params[i]; - if ( param == null ) continue; - if ( param.length() < 1 ) continue; - - int pos = param.indexOf("="); - if ( pos < 1 ) continue; - if ( pos+1 > param.length() ) continue; - String key = mapKeyName(param.substring(0,pos)); - if ( key == null ) continue; - - if ( custom.containsKey(key) ) continue; - - String value = param.substring(pos+1); - if ( value == null ) continue; - value = value.trim(); - if ( value.length() < 1 ) continue; - setProperty(custom, key, value); - } - return true; - } - - /* - "custom" : - { - "isbn" : "978-0321558145", - "style" : "jazzy" - } - */ - public static boolean mergeLTI2Custom(Properties custom, String customstr) - { - if ( customstr == null || customstr.length() < 1 ) return true; - JSONObject json = null; - try { - json = (JSONObject) JSONValue.parse(customstr.trim()); - } catch(Exception e) { - M_log.warning("mergeLTI2Custom could not parse\n"+customstr); - M_log.warning(e.getLocalizedMessage()); - return false; - } - - // This could happen if the old settings service was used - // on an LTI 2.x placement to put in settings that are not - // JSON - we just ignore it. - if ( json == null ) return false; - Iterator keys = json.keySet().iterator(); - while( keys.hasNext() ){ - String key = (String)keys.next(); - if ( custom.containsKey(key) ) continue; - Object value = json.get(key); - if ( value instanceof String ){ - setProperty(custom, key, (String) value); - } - } - return true; - } - - /* - "parameter" : - [ - { "name" : "result_url", - "variable" : "Result.url" - }, - { "name" : "discipline", - "fixed" : "chemistry" - } - ] - */ - public static boolean mergeLTI2Parameters(Properties custom, String customstr) { - if ( customstr == null || customstr.length() < 1 ) return true; - JSONArray json = null; - try { - json = (JSONArray) JSONValue.parse(customstr.trim()); - } catch(Exception e) { - M_log.warning("mergeLTI2Parameters could not parse\n"+customstr); - M_log.warning(e.getLocalizedMessage()); - return false; - } - Iterator parameters = json.iterator(); - while( parameters.hasNext() ){ - Object o = parameters.next(); - JSONObject parameter = null; - try { - parameter = (JSONObject) o; - } catch(Exception e) { - M_log.warning("mergeLTI2Parameters did not find list of objects\n"+customstr); - M_log.warning(e.getLocalizedMessage()); - return false; - } - - String name = (String) parameter.get("name"); - - if ( name == null ) continue; - if ( custom.containsKey(name) ) continue; - String fixed = (String) parameter.get("fixed"); - String variable = (String) parameter.get("variable"); - if ( variable != null ) { - setProperty(custom, name, variable); - continue; - } - if ( fixed != null ) { - setProperty(custom, name, fixed); - } - } - return true; - } - - public static void substituteCustom(Properties custom, Properties lti2subst) - { - if ( custom == null || lti2subst == null ) return; - Enumeration e = custom.propertyNames(); - while (e.hasMoreElements()) { - String key = (String) e.nextElement(); - String value = custom.getProperty(key); - if ( value == null || value.length() < 1 ) continue; - String newValue = lti2subst.getProperty(value); - if ( newValue == null || newValue.length() < 1 ) continue; - setProperty(custom, key, (String) newValue); - } - } - - // Place the custom values into the launch - public static void addCustomToLaunch(Properties ltiProps, Properties custom) - { - Enumeration e = custom.propertyNames(); - while (e.hasMoreElements()) { - String keyStr = (String) e.nextElement(); - String value = custom.getProperty(keyStr); - setProperty(ltiProps,"custom_"+keyStr,value); - } - } - - @SuppressWarnings("deprecation") - public static void setProperty(Properties props, String key, String value) { - BasicLTIUtil.setProperty(props, key, value); - } - - public static String mapKeyName(String keyname) { - return BasicLTIUtil.mapKeyName(keyname); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/BaseJson.java b/src/main/java/org/imsglobal/lti2/objects/BaseJson.java deleted file mode 100644 index 7773026..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/BaseJson.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2014 IMS Global Learning Consortium. - * - * 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.imsglobal.lti2.objects; - -import java.util.HashMap; -import java.util.Map; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; - -/** - * - * @author pgray - */ -public class BaseJson { - - private Map additionalProperties = new HashMap(); - - @com.fasterxml.jackson.annotation.JsonAnyGetter - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @com.fasterxml.jackson.annotation.JsonAnySetter - @JsonAnySetter - public void addAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/BaseJsonLd.java b/src/main/java/org/imsglobal/lti2/objects/BaseJsonLd.java deleted file mode 100644 index 53c36ed..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/BaseJsonLd.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2014 IMS Global Learning Consortium. - * - * 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.imsglobal.lti2.objects; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * - * @author paul - */ -public class BaseJsonLd extends BaseJson { - - @JsonProperty("@id") - @org.codehaus.jackson.annotate.JsonProperty("@id") - protected String id; - @JsonProperty("@context") - @org.codehaus.jackson.annotate.JsonProperty("@context") - protected String context; - @JsonProperty("@type") - @org.codehaus.jackson.annotate.JsonProperty("@type") - protected String type; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getContext() { - return context; - } - - public void setContext(String context) { - this.context = context; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/Contact.java b/src/main/java/org/imsglobal/lti2/objects/consumer/Contact.java deleted file mode 100644 index 3bf40a0..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/Contact.java +++ /dev/null @@ -1,51 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "email" -}) -public class Contact { - - @JsonProperty("email") - private String email; - private Map additionalProperties = new HashMap(); - - public Contact(String email) { - this.email = email; - } - - public Contact() { - } - - @JsonProperty("email") - public String getEmail() { - return email; - } - - @JsonProperty("email") - public void setEmail(String email) { - this.email = email; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/Description.java b/src/main/java/org/imsglobal/lti2/objects/consumer/Description.java deleted file mode 100644 index 2568cc5..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/Description.java +++ /dev/null @@ -1,65 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "default_value", - "key" -}) -public class Description { - - @JsonProperty("default_value") - private String default_value; - @JsonProperty("key") - private String key; - private Map additionalProperties = new HashMap(); - - public Description(String description) { - this.default_value = description; - this.key = "product.vendor.description"; - } - - public Description() { - } - - @JsonProperty("default_value") - public String getDefault_value() { - return default_value; - } - - @JsonProperty("default_value") - public void setDefault_value(String default_value) { - this.default_value = default_value; - } - - @JsonProperty("key") - public String getKey() { - return key; - } - - @JsonProperty("key") - public void setKey(String key) { - this.key = key; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/Name.java b/src/main/java/org/imsglobal/lti2/objects/consumer/Name.java deleted file mode 100644 index ed107ea..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/Name.java +++ /dev/null @@ -1,65 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "default_value", - "key" -}) -public class Name { - - @JsonProperty("default_value") - private String default_value; - @JsonProperty("key") - private String key; - private Map additionalProperties = new HashMap(); - - public Name(String name) { - this.default_value = name; - this.key = "product.vendor.name"; - } - - public Name() { - } - - @JsonProperty("default_value") - public String getDefault_value() { - return default_value; - } - - @JsonProperty("default_value") - public void setDefault_value(String default_value) { - this.default_value = default_value; - } - - @JsonProperty("key") - public String getKey() { - return key; - } - - @JsonProperty("key") - public void setKey(String key) { - this.key = key; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/NamedContext.java b/src/main/java/org/imsglobal/lti2/objects/consumer/NamedContext.java deleted file mode 100644 index 3bf50d9..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/NamedContext.java +++ /dev/null @@ -1,27 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") - -public class NamedContext { - - private Map additionalProperties = new HashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/ProductFamily.java b/src/main/java/org/imsglobal/lti2/objects/consumer/ProductFamily.java deleted file mode 100644 index d573c0a..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/ProductFamily.java +++ /dev/null @@ -1,67 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import org.imsglobal.lti2.LTI2Config; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "code", - "vendor" -}) -public class ProductFamily { - - @JsonProperty("code") - private String code; - @JsonProperty("vendor") - private Vendor vendor; - private Map additionalProperties = new HashMap(); - - public ProductFamily(LTI2Config cnf) { - this.code = cnf.getProduct_family_product_code(); - this.vendor = new Vendor(cnf); - } - - public ProductFamily() { - } - - @JsonProperty("code") - public String getCode() { - return code; - } - - @JsonProperty("code") - public void setCode(String code) { - this.code = code; - } - - @JsonProperty("vendor") - public Vendor getVendor() { - return vendor; - } - - @JsonProperty("vendor") - public void setVendor(Vendor vendor) { - this.vendor = vendor; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/ProductInfo.java b/src/main/java/org/imsglobal/lti2/objects/consumer/ProductInfo.java deleted file mode 100644 index e69a930..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/ProductInfo.java +++ /dev/null @@ -1,75 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import org.imsglobal.lti2.LTI2Config; - -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.imsglobal.lti2.objects.BaseJson; - -@JsonPropertyOrder({ - "product_name", - "product_version", - "description", - "technical_description", - "product_family" -}) -public class ProductInfo extends BaseJson { - - private ProductName product_name; - private String product_version; - private Description description; - private TechnicalDescription technical_description; - private ProductFamily product_family; - - public ProductInfo(LTI2Config cnf) { - this.product_name = new ProductName(cnf.getProduct_info_product_name()); - this.product_version = cnf.getProduct_info_product_version(); - this.description = new Description(cnf.getProduct_info_product_description()); - this.product_family = new ProductFamily(cnf); - } - - public ProductInfo(){ - - } - - public ProductName getProduct_name() { - return product_name; - } - - public void setProduct_name(ProductName product_name) { - this.product_name = product_name; - } - - public String getProduct_version() { - return product_version; - } - - public void setProduct_version(String product_version) { - this.product_version = product_version; - } - - public Description getDescription() { - return description; - } - - public void setDescription(Description description) { - this.description = description; - } - - public TechnicalDescription getTechnical_description() { - return technical_description; - } - - public void setTechnical_description(TechnicalDescription technical_description) { - this.technical_description = technical_description; - } - - public ProductFamily getProduct_family() { - return product_family; - } - - public void setProduct_family(ProductFamily product_family) { - this.product_family = product_family; - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/ProductInstance.java b/src/main/java/org/imsglobal/lti2/objects/consumer/ProductInstance.java deleted file mode 100644 index e71ef48..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/ProductInstance.java +++ /dev/null @@ -1,73 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import org.imsglobal.lti2.LTI2Config; - -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.imsglobal.lti2.objects.BaseJson; - -@JsonPropertyOrder({ - "guid", - "product_info", - "support" -}) -public class ProductInstance extends BaseJson { - - private String guid; - private ProductInfo product_info; - private ServiceOwner service_owner; - private ServiceProvider service_provider; - private Support support; - - public ProductInstance(LTI2Config cnf) { - this.guid = cnf.getGuid(); - this.product_info = new ProductInfo(cnf); - this.service_owner = new ServiceOwner(cnf); - this.service_provider = new ServiceProvider(cnf); - this.support = new Support(cnf.getSupport_email()); - } - - public ProductInstance() { - } - - public String getGuid() { - return guid; - } - - public void setGuid(String guid) { - this.guid = guid; - } - - public ProductInfo getProduct_info() { - return product_info; - } - - public void setProduct_info(ProductInfo product_info) { - this.product_info = product_info; - } - - public ServiceOwner getService_owner() { - return service_owner; - } - - public void setService_owner(ServiceOwner service_owner) { - this.service_owner = service_owner; - } - - public ServiceProvider getService_provider() { - return service_provider; - } - - public void setService_provider(ServiceProvider service_provider) { - this.service_provider = service_provider; - } - - public Support getSupport() { - return support; - } - - public void setSupport(Support support) { - this.support = support; - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/ProductName.java b/src/main/java/org/imsglobal/lti2/objects/consumer/ProductName.java deleted file mode 100644 index 0779f0a..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/ProductName.java +++ /dev/null @@ -1,66 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "default_value", - "key" -}) -public class ProductName { - - @JsonProperty("default_value") - private String default_value; - @JsonProperty("key") - private String key; - private Map additionalProperties = new HashMap(); - - public ProductName(String name) { - this.default_value = name; - this.key = "product.name"; - } - - public ProductName() { - } - - - @JsonProperty("default_value") - public String getDefault_value() { - return default_value; - } - - @JsonProperty("default_value") - public void setDefault_value(String default_value) { - this.default_value = default_value; - } - - @JsonProperty("key") - public String getKey() { - return key; - } - - @JsonProperty("key") - public void setKey(String key) { - this.key = key; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOffered.java b/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOffered.java deleted file mode 100644 index 33766b6..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOffered.java +++ /dev/null @@ -1,117 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.HashMap; -import java.util.Map; -import java.util.ArrayList; -import java.util.List; -import java.util.Collections; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "@type", - "@id", - "endpoint", - "format", - "action" -}) -public class ServiceOffered { - - @JsonProperty("@type") - private String _type; - @JsonProperty("@id") - private String _id; - @JsonProperty("endpoint") - private String endpoint; - @JsonProperty("format") - private List format = new ArrayList(); - @JsonProperty("action") - private List action = new ArrayList(); - private Map additionalProperties = new HashMap(); - - public ServiceOffered() { } - - public ServiceOffered(String endpoint, String id, String type, String format, String action) { - this.endpoint = endpoint; - this._id = id; - this._type = type; - this.format.add(format); - this.action.add(action); - } - - public ServiceOffered(String endpoint, String id, String type, String[] format, String[] action) { - this.endpoint = endpoint; - this._id = id; - this._type = type; - Collections.addAll(this.format, format); - Collections.addAll(this.action, action); - } - - @JsonProperty("@type") - public String get_type() { - return _type; - } - - @JsonProperty("@type") - public void set_type(String _type) { - this._type = _type; - } - - @JsonProperty("@id") - public String get_id() { - return _id; - } - - @JsonProperty("@id") - public void set_id(String _id) { - this._id = _id; - } - - @JsonProperty("endpoint") - public String getEndpoint() { - return endpoint; - } - - @JsonProperty("endpoint") - public void setEndpoint(String endpoint) { - this.endpoint = endpoint; - } - - @JsonProperty("format") - public List getFormat() { - return format; - } - - @JsonProperty("format") - public void setFormat(List format) { - this.format = format; - } - - @JsonProperty("action") - public List getAction() { - return action; - } - - @JsonProperty("action") - public void setAction(List action) { - this.action = action; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOwner.java b/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOwner.java deleted file mode 100644 index 5bd597f..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOwner.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.imsglobal.lti2.objects.consumer; - -import org.imsglobal.lti2.LTI2Config; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "@id", - "service_owner_name", - "description", - "timestamp", - "support" -}) -public class ServiceOwner { - - @JsonProperty("@id") - private String _id; - @JsonProperty("service_owner_name") - private ServiceOwnerName service_owner_name; - @JsonProperty("description") - private Description description; - @JsonProperty("timestamp") - private String timestamp; - @JsonProperty("support") - private Support support; - private Map additionalProperties = new HashMap(); - - public ServiceOwner(LTI2Config cnf) { - this._id = cnf.getService_owner_id(); - this.service_owner_name = new ServiceOwnerName(cnf.getService_owner_owner_name()); - this.description = new Description(cnf.getService_owner_description()); - this.support = new Support(cnf.getService_owner_support_email()); - } - - public ServiceOwner() { - } - - @JsonProperty("@id") - public String get_id() { - return _id; - } - - @JsonProperty("@id") - public void set_id(String _id) { - this._id = _id; - } - - @JsonProperty("service_owner_name") - public ServiceOwnerName getService_owner_name() { - return service_owner_name; - } - - @JsonProperty("service_owner_name") - public void setService_name(ServiceOwnerName service_owner_name) { - this.service_owner_name = service_owner_name; - } - - @JsonProperty("description") - public Description getDescription() { - return description; - } - - @JsonProperty("description") - public void setDescription(Description description) { - this.description = description; - } - - @JsonProperty("timestamp") - public String getTimestamp() { - return timestamp; - } - - @JsonProperty("timestamp") - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } - - @JsonProperty("support") - public Support getSupport() { - return support; - } - - @JsonProperty("support") - public void setSupport(Support support) { - this.support = support; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOwnerName.java b/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOwnerName.java deleted file mode 100644 index 640a2cd..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceOwnerName.java +++ /dev/null @@ -1,65 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "default_value", - "key" -}) -public class ServiceOwnerName { - - @JsonProperty("default_value") - private String default_value; - @JsonProperty("key") - private String key; - private Map additionalProperties = new HashMap(); - - public ServiceOwnerName(String name) { - this.default_value = name; - this.key = "product.name"; - } - - public ServiceOwnerName() { - } - - @JsonProperty("default_value") - public String getDefault_value() { - return default_value; - } - - @JsonProperty("default_value") - public void setDefault_value(String default_value) { - this.default_value = default_value; - } - - @JsonProperty("key") - public String getKey() { - return key; - } - - @JsonProperty("key") - public void setKey(String key) { - this.key = key; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceProvider.java b/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceProvider.java deleted file mode 100644 index baec6c9..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceProvider.java +++ /dev/null @@ -1,108 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import org.imsglobal.lti2.LTI2Config; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "@id", - "service_provider_name", - "description", - "timestamp", - "support" -}) -public class ServiceProvider { - - @JsonProperty("@id") - private String _id; - @JsonProperty("service_provider_name") - private ServiceProviderName service_provider_name; - @JsonProperty("description") - private Description description; - @JsonProperty("timestamp") - private String timestamp; - @JsonProperty("support") - private Support support; - private Map additionalProperties = new HashMap(); - - public ServiceProvider(LTI2Config cnf) { - this._id = cnf.getService_provider_id(); - this.service_provider_name = new ServiceProviderName(cnf.getService_provider_provider_name()); - this.description = new Description(cnf.getService_provider_description()); - this.support = new Support(cnf.getService_provider_support_email()); - } - - public ServiceProvider() { - } - - @JsonProperty("@id") - public String get_id() { - return _id; - } - - @JsonProperty("@id") - public void set_id(String _id) { - this._id = _id; - } - - @JsonProperty("service_provider_name") - public ServiceProviderName getService_provider_name() { - return service_provider_name; - } - - @JsonProperty("service_provider_name") - public void setService_name(ServiceProviderName service_provider_name) { - this.service_provider_name = service_provider_name; - } - - @JsonProperty("description") - public Description getDescription() { - return description; - } - - @JsonProperty("description") - public void setDescription(Description description) { - this.description = description; - } - - @JsonProperty("timestamp") - public String getTimestamp() { - return timestamp; - } - - @JsonProperty("timestamp") - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } - - @JsonProperty("support") - public Support getSupport() { - return support; - } - - @JsonProperty("support") - public void setSupport(Support support) { - this.support = support; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceProviderName.java b/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceProviderName.java deleted file mode 100644 index 7135aaa..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/ServiceProviderName.java +++ /dev/null @@ -1,65 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "default_value", - "key" -}) -public class ServiceProviderName { - - @JsonProperty("default_value") - private String default_value; - @JsonProperty("key") - private String key; - private Map additionalProperties = new HashMap(); - - public ServiceProviderName(String name) { - this.default_value = name; - this.key = "product.name"; - } - - public ServiceProviderName() { - } - - @JsonProperty("default_value") - public String getDefault_value() { - return default_value; - } - - @JsonProperty("default_value") - public void setDefault_value(String default_value) { - this.default_value = default_value; - } - - @JsonProperty("key") - public String getKey() { - return key; - } - - @JsonProperty("key") - public void setKey(String key) { - this.key = key; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/StandardServices.java b/src/main/java/org/imsglobal/lti2/objects/consumer/StandardServices.java deleted file mode 100644 index 25f0376..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/StandardServices.java +++ /dev/null @@ -1,86 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.Arrays; - -public class StandardServices { - - public static final String TOOLPROXY_FORMAT = "application/vnd.ims.lti.v2.toolproxy+json"; - public static final String TOOLSETTINGS_CONTEXT = "http://purl.imsglobal.org/ctx/lti/v2/ToolSettings"; - public static final String TOOLSETTINGS_FORMAT = "application/vnd.ims.lti.v2.toolsettings+json"; - public static final String TOOLSETTINGS_SIMPLE_FORMAT = "application/vnd.ims.lti.v2.toolsettings.simple+json"; - - public static final String TOOLPROXY_ID_CONTEXT = "http://purl.imsglobal.org/ctx/lti/v2/ToolProxyId"; - public static final String TOOLPROXY_ID_FORMAT = "application/vnd.ims.lti.v2.toolproxy.id+json"; - public static final String TOOLPROXY_ID_TYPE = "ToolProxy"; - - public static final String RESULT_FORMAT = "application/vnd.ims.lis.v2.result+json"; - public static final String RESULT_CONTEXT = "http://purl.imsglobal.org/ctx/lis/v2/Result"; - public static final String RESULT_TYPE = "Result"; - - public static ServiceOffered LTI2Registration(String endpoint) { - ServiceOffered ret = new ServiceOffered(); - ret.setEndpoint(endpoint); - ret.set_id("tcp:ToolProxy.collection"); // TODO: Is this right see 5.6 in the docs - ret.set_type("RestService"); - ret.setFormat(Arrays.asList(TOOLPROXY_FORMAT)); - ret.setAction(Arrays.asList("POST")); - return ret; - } - - // "endpoint" : "http://lms.example.com/resources/ToolProxy/{tool_proxy_guid}", - public static ServiceOffered LTI2ProxyItem(String endpoint) { - ServiceOffered ret = new ServiceOffered(); - ret.setEndpoint(endpoint); - ret.set_id("tcp:ToolProxy.item"); - ret.set_type("RestService"); - ret.setFormat(Arrays.asList(TOOLPROXY_FORMAT)); - ret.setAction(Arrays.asList("GET", "PUT")); - return ret; - } - - // "endpoint" : "http://lms.example.com/resources/Result/{sourcedId}", - public static ServiceOffered LTI2ResultItem(String endpoint) { - ServiceOffered ret = new ServiceOffered(); - ret.setEndpoint(endpoint); - ret.set_id("tcp:Result.item"); // TODO: Is this right see 5.6 in the docs - ret.set_type("RestService"); - ret.setFormat(Arrays.asList(RESULT_FORMAT)); - ret.setAction(Arrays.asList("GET", "PUT")); - return ret; - } - - // "endpoint" : "http://lms.example.com/resources/ToolProxy/{tool_proxy_guid}/custom", - public static ServiceOffered LTI2ToolProxySettings(String endpoint) { - ServiceOffered ret = new ServiceOffered(); - ret.setEndpoint(endpoint); - ret.set_id("tcp:ToolProxySettings"); - ret.set_type("RestService"); - ret.setFormat(Arrays.asList(TOOLSETTINGS_FORMAT, TOOLSETTINGS_SIMPLE_FORMAT)); - ret.setAction(Arrays.asList("GET", "PUT")); - return ret; - } - - // "endpoint" : "http://lms.example.com/resources/links/{link_id}/custom", - public static ServiceOffered LTI2LtiLinkSettings(String endpoint) { - ServiceOffered ret = new ServiceOffered(); - ret.setEndpoint(endpoint); - ret.set_id("tcp:LtiLinkSettings"); - ret.set_type("RestService"); - ret.setFormat(Arrays.asList(TOOLSETTINGS_FORMAT, TOOLSETTINGS_SIMPLE_FORMAT)); - ret.setAction(Arrays.asList("GET", "PUT")); - return ret; - } - - public static ServiceOffered LTI1Outcomes(String endpoint) { - ServiceOffered ret = new ServiceOffered(); - ret.setEndpoint(endpoint); - ret.set_id("tcp:LTI_1_1_ResultService"); - ret.set_type("RestService"); - ret.setFormat(Arrays.asList("application/vnd.ims.lti.v1.outcome+xml")); - ret.setAction(Arrays.asList("POST")); - return ret; - } - - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/Support.java b/src/main/java/org/imsglobal/lti2/objects/consumer/Support.java deleted file mode 100644 index 17e7dab..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/Support.java +++ /dev/null @@ -1,51 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "email" -}) -public class Support { - - @JsonProperty("email") - private String email; - private Map additionalProperties = new HashMap(); - - public Support(String email) { - this.email = email; - } - - public Support() { - } - - @JsonProperty("email") - public String getEmail() { - return email; - } - - @JsonProperty("email") - public void setEmail(String email) { - this.email = email; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/TechnicalDescription.java b/src/main/java/org/imsglobal/lti2/objects/consumer/TechnicalDescription.java deleted file mode 100644 index 4f706ba..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/TechnicalDescription.java +++ /dev/null @@ -1,60 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "default_value", - "key" -}) -public class TechnicalDescription { - - @JsonProperty("default_value") - private String default_value; - @JsonProperty("key") - private String key; - private Map additionalProperties = new HashMap(); - - public TechnicalDescription() { - } - - @JsonProperty("default_value") - public String getDefault_value() { - return default_value; - } - - @JsonProperty("default_value") - public void setDefault_value(String default_value) { - this.default_value = default_value; - } - - @JsonProperty("key") - public String getKey() { - return key; - } - - @JsonProperty("key") - public void setKey(String key) { - this.key = key; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/ToolConsumer.java b/src/main/java/org/imsglobal/lti2/objects/consumer/ToolConsumer.java deleted file mode 100644 index f53626a..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/ToolConsumer.java +++ /dev/null @@ -1,708 +0,0 @@ -package org.imsglobal.lti2.objects.consumer; - -import org.imsglobal.lti2.LTI2Config; - -import java.util.ArrayList; -import java.util.List; -import java.util.Collections; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.imsglobal.lti2.objects.BaseJson; - -@JsonPropertyOrder({ - "@context", - "@type", - "@id" -}) -@com.fasterxml.jackson.annotation.JsonPropertyOrder({ - "@context", - "@type", - "@id" -}) -public class ToolConsumer extends BaseJson { - - @JsonProperty("@context") - @com.fasterxml.jackson.annotation.JsonProperty("@context") - private Object _context; - @JsonProperty("@type") - @com.fasterxml.jackson.annotation.JsonProperty("@type") - private String _type; - @JsonProperty("@id") - @com.fasterxml.jackson.annotation.JsonProperty("@id") - private String _id; - private String lti_version; - private String guid; - private ProductInstance product_instance; - private List capability_offered = new ArrayList(); - private List service_offered = new ArrayList(); - - public static final class LtiCapability { - public static final String BASICLTI_LAUNCH = "basic-lti-launch-request"; - public static final String USER_ID = "User.id"; - public static final String USER_IMAGE = "User.image"; - public static final String COURSE_SECTION_ID = "CourseSection.sourcedId"; - public static final String PERSON_ID = "Person.sourcedId"; - public static final String MEMBERSHIP_ROLE = "Membership.role"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#Context.org - * A URI describing the organisational properties of the context from which a launch request originates (typically a CourseSection); for example, an ldap:// URI such as - * ldap://host.com:6666/cid=abc123,ou=dept,dc=plainjoe,dc=org - * If more than one format of organisational URI is specified, each should be separated with a space. - */ - public static final String LAUNCH_CONTEXT = "ltiv:Context.org"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseOffering.academicSession - * The text data that is used to describe the academic session for the course offering. - * In the LIS Database, this value corresponds to - * courseOfferingRecord/courseOffering/defaultCredits/textString - */ - public static final String CO_ACADEMIC_SESSION = "ltiv:CourseOffering.academicSession"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseOffering.credits - * The default credits set for this Course Offering - * In the LIS Database, this value corresponds to - * courseOfferingRecord/courseOffering/defaultCredits/textString - */ - public static String CO_CREDITS = "CourseOffering.credits"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseOffering.label - * A human readable label for the Course Offering - * In the LIS Database, this value corresponds to - * courseOfferingRecord/courseOffering/label - */ - public static String CO_LABEL = "CourseOffering.label"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseOffering.longDescription - * A long description of the Course Offering. - * In the LIS Database, this value corresponds to - * courseOfferingRecord/courseOffering/catalogDescription/longDescription - */ - public static String CO_LONG_DESCRIPTION = "ltiv:CourseOffering.longDescription"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseOffering.shortDescription - * A short description of the Course Offering. - * In the LIS Database, this value corresponds to - * courseOfferingRecord/courseOffering/catalogDescription/shortDescription - */ - public static String CO_SHORT_DESCRIPTION = "CourseOffering.shortDescription"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseOffering.sourcedId - * The LIS identifier for the Course Offering. - * In the LIS Database, this value corresponds to - * courseOfferingRecord/sourcedId - */ - public static String CO_SOURCED_ID = "CourseOffering.sourcedId"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseOffering.title - * The title of the Course Offering. - * In the LIS Database, this value corresponds to - * courseOfferingRecord/courseOffering/title - */ - public static String CO_TITLE = "CourseOffering.title"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.courseNumber - * The course number, such as "Biology 101". In general, this number is not just a numeric value. - * In the LIS Database, this value corresponds to - * courseSectionRecord/courseSection/courseNumber/textString - */ - public static String CS_COURSE_NUMBER = "ltiv:CourseSection.courseNumber"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.credits - The default credits set for the Course Section. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/defaultCredits/textString - */ - public static String CS_CREDITS = "CourseSection.credits"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.dataSource - An identifier for the original source system of the CourseSection object. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/dataSource - */ - public static String CS_DATA_SOURCE = "CourseSection.dataSource"; - - /** - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.dept - * The department within which the Course Section is offered. - * In the LIS Database, this value corresponds to - * courseSectionRecord/courseSection/org[type/textString="Dept"]/orgName/textString - */ - public static String CS_DEPARTMENT = "CourseSection.dept"; - - /** - * ltiv:CourseSection.enrollControl.allowed - * http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.enrollControl.allowed - * A boolean value that specifies whether the Tool Provider can enroll people in the Course Section. The value false indicates that only the source system can enroll people. - * In the LIS Database, this value corresponds to - * courseSectionRecord/courseSection/enrollControl/enrollAllowed - */ - public static String CS_ENROLL_ALLOWED = ""; - - - /** http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.enrollControll.accept */ - public static String CS_ENROLL_CONTROLL = "ltiv:CourseSection.enrollControll.accept"; - - /* - A boolean value that specifies whether the Course Section is accepting enrollments. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/enrollControl/enrollAccept - ltiv:CourseSection.label - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.label - A human readable label for the Course Section. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/label - ltiv:CourseSection.longDescription - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.longDescription - A long description of the Course Section. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/catalogDescription/longDescription - CourseSection.maxNumberofStudents - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.maxNumberofStudents - The maximum number of students that can be enrolled in the Course Section. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/maxNumberofStudents - CourseSection.numberofStudents - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.numberofStudents - The number of students who are enrolled in the Course Section. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/numberofStudents - CourseSection.shortDescription - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.shortDescription - A short description of the Course Section. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/catalogDescription/shortDescription - ltiv:CourseSection.sourceSectionId - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.sourceSectionId - The identifier for the source Course Section from which the target Course Section was cloned. - In the LIS Database, this value corresponds to - - createCourseSectionFromCourseSectionRequest/sourcedId - ltiv:CourseSection.sourcedId - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.sourcedId - The LIS identifier for the Course Section - In the LIS Database, this value corresponds to - - courseSection/sourcedId - CourseSection.timeFrame.begin - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.timeFrame.begin - The date and time when the Course Section becomes available. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/timeFrame/begin - CourseSection.timeFrame.end - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.timeFrame.end - The date and time after which the Course Section is no longer available. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/timeFrame/end - CourseSection.title - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseSection.title - The title of the Course Section. - In the LIS Database, this value corresponds to - - courseSectionRecord/courseSection/title - ltiv:CourseTemplate.courseNumber - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseTemplate.courseNumber - The course number, such as "Biology 101". In general, this number is not just a numeric value. - In the LIS Database, this value corresponds to - - courseTemplateRecord/courseTemplate/courseNumber/textString - ltiv:CourseTemplate.credits - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseTemplate.credits - The default credits set for this Course Template. - In the LIS Database, this value corresponds to - - courseTemplateRecord/courseTemplate/defaultCredits/textString - CourseTemplate.label - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseTemplate.label - A human readable label used to help identify the Course Template. - In the LIS Database, this value corresponds to - - courseTemplateRecord/courseTemplate/label/textString - ltiv:CourseTemplate.longDescription - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseTemplate.longDescription - A long description of the Course Template. - In the LIS Database, this value corresponds to - - courseTemplateRecord/courseTemplate/catalogDescription/longDescription - ltiv:CourseTemplate.shortDescription - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseTemplate.shortDescription - A short description of the Course Template. - In the LIS Database, this value corresponds to - - courseTemplateRecord/courseTemplate/catalogDescription/shortDescription - ltiv:CourseTemplate.sourcedId - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseTemplate.sourcedId - The LIS identifier for the Course Template. - In the LIS Database, this value corresponds to - - courseTemplateRecord/sourcedId - ltiv:CourseTemplate.title - http://purl.imsglobal.org/vocab/lti/v2/variable#CourseTemplate.title - The title of the Course Template. - In the LIS Database, this value corresponds to - - courseTemplateRecord/courseTemplate/title/textString - ltiv:Group.email - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.email - An email address used for posting messages to members of the group. - In the LIS Database, this value corresponds to - - groupRecord/group/email - Group.enrollControl.accept - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.enrollControl.accept - A boolean value that specifies whether the Group is accepting enrollments. - In the LIS Database, this value corresponds to - - groupRecord/group/enrollControl/enrollAccept - ltiv:Group.enrollControl.allowed - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.enrollControl.allowed - A boolean value that specifies whether the Tool Provider can enroll people in the Group. The value false indicates that only the source system can enroll people. - In the LIS Database, this value corresponds to - - groupRecord/group/enrollControl/enrollAllowed - ltiv:Group.grouptype - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.grouptype - A URI that uniquely identifies the type of group. This convention differs from the LIS convention of using a structured object to describe the type of a group. Ideally, the URI should resolve to JSON-LD document that describes the group type. However, any URI that uniquely identifies the group type in accordance with the rules of the grouptype scheme is acceptable. - ltiv:Group.longDescription - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.longDescription - A long description of the Group. - In the LIS Database, this value corresponds to - - groupRecord/group/description/longDescription - ltiv:Group.parentId - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.parentId - An identifier for the parent group within which the target group is nested. - In the LIS Database, this value corresponds to - - groupRecord/group/relationship[relation="Parent"]/sourcedId - ltiv:Group.shortDescription - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.shortDescription - A short description of the Group. - In the LIS Database, this value corresponds to - - groupRecord/group/description/shortDescription - Group.sourcedId - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.sourcedId - The LIS identifier for the Group. - In the LIS Database, this value corresponds to - - groupRecord/sourcedId - ltiv:Group.timeFrame.begin - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.timeFrame.begin - The date and time when access to Group resources begins. - In the LIS Database, this value corresponds to - - groupRecord/group/timeframe/begin - Group.timeFrame.end - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.timeFrame.end - The date and time when access to Group resources ends. - In the LIS Database, this value corresponds to - - groupRecord/group/timeframe/end - ltiv:Group.url - http://purl.imsglobal.org/vocab/lti/v2/variable#Group.url - The web address of the Group. - In the LIS Database, this value corresponds to - - groupRecord/group/url - LineItem.dataSource - http://purl.imsglobal.org/vocab/lti/v2/variable#LineItem.dataSource - An identifier for the original source system of the LineItem record. - In the LIS Database, this value corresponds to - - lineItemRecord/lineItem/dataSource - ltiv:LineItem.resultValue.max - http://purl.imsglobal.org/vocab/lti/v2/variable#LineItem.resultValue.max - The maximum numeric score that a learner may earn on the assignment associated with this LineItem. - In the LIS Database, this value corresponds to - - resultValueRecord/resultValue/valueRange/max - where - - resultValueRecord.sourcedId = lineItemRecord/lineItem/resultValueSourcedId - ltiv:LineItem.sourcedId - http://purl.imsglobal.org/vocab/lti/v2/variable#LineItem.sourcedId - The LIS identifier for the LineItem - In the LIS Database, this value corresponds to - - lineItemRecord/sourcedId - LineItem.type - http://purl.imsglobal.org/vocab/lti/v2/variable#LineItem.type - A URI that uniquely identifies the LineItem type. This convention differs from the LIS convention of using a structured object to describe LineItem types. The URI should resolve to a JSON-LD resource that describes the LineItem type. As a best practice the URI should start with a base URL that identifies the LineItemType vocabulary and end with a relative URL for a type within that vocabulary. - In the LIS Database, the LineItem type is given by - - lineItemRecord/lineItem/lineItemType - ltiv:LineItem.type.displayName - http://purl.imsglobal.org/vocab/lti/v2/variable#LineItem.type.displayName - The display name for the LineItemType. - In the LIS Database, this value corresponds to - - lineItemTypeRecord/lineItemType/displayName - LtiLink.custom.url - http://purl.imsglobal.org/vocab/lti/v2/variable#LtiLink.custom.url - The endpoint URL for accessing link-level tool settings. - Membership.collectionSourcedId - http://purl.imsglobal.org/vocab/lti/v2/variable#Membership.collectionSourcedId - The LIS identifier for the organizational unit (Course Section, Group, etc.) to which the Membership pertains. - In the LIS Database, this value corresponds to - - membershipRecord/membership/collectionSourcedId - ltiv:Membership.createdTimestamp - http://purl.imsglobal.org/vocab/lti/v2/variable#Membership.createdTimestamp - The date and time when the membership role was created. If the Person has more than one role within the organizational unit, then this value is a comma separated list corresponding to the roles listed by the Membership.role variable. - In the LIS Database, this value corresponds to - - membershipRecord/membership/member/role/dateTime - ltiv:Membership.dataSource - http://purl.imsglobal.org/vocab/lti/v2/variable#Membership.dataSource - An identifier for the original source system of the Membership record. - In the LIS Database, this value corresponds to - - membershipRecord/membership/member/role/dataSource - ltiv:Membership.personSourcedId - http://purl.imsglobal.org/vocab/lti/v2/variable#Membership.personSourcedId - The LIS identifier for the Person associated with the Membership. - In the LIS Database, this value corresponds to - - membershipRecord/membership/member/personSourcedId - ltiv:Membership.role - http://purl.imsglobal.org/vocab/lti/v2/variable#Membership.role - A comma separated list of roles that the Person has within the organizational unit. - In the LIS Database, this value corresponds to - - membershipRecord/membership/member/role/roleType - ltiv:Membership.sourcedId - http://purl.imsglobal.org/vocab/lti/v2/variable#Membership.sourcedId - The LIS identifier for the Membership. - In the LIS Database, this value corresponds to - - membershipRecord/sourcedId - Membership.status - http://purl.imsglobal.org/vocab/lti/v2/variable#Membership.status - Indicates if the membership is active or inactive. In accordance with the LIS specification, the value should be either Active or Inactive. If the Person has more than one role within the organizational unit, then this value is a comma separated list, where the values are ordered in correspondence with the roles named by the Membership.role variable. - In the LIS Database, this value corresponds to - - membershipRecord/membership/member/role/status - Person.address.country - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.address.country - The country within the user's address. - In the LIS Database, this value corresponds to - - personRecord/person/address/[addressType/instanceValue/text="Preferred"]addressPart /nameValuePair /[instanceName/text="Country"]/instanceValue/text - ltiv:Person.address.locality - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.address.locality - The city, town, or other locality within the user's address. - In the LIS Database, this value corresponds to - - personRecord/person/address/[addressType/instanceValue/text="Preferred"]addressPart /nameValuePair /[instanceName/text="Locality"]/instanceValue/text - Person.address.postcode - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.address.postcode - The postal code within the user's address. - In the LIS Database, this value corresponds to - - personRecord/person/address/[addressType/instanceValue/text="Preferred"]addressPart /nameValuePair /[instanceName/text="Postcode"]/instanceValue/text - ltiv:Person.address.statepr - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.address.statepr - The state or province within the user's address. - In the LIS Database, this value corresponds to - - personRecord/person/address/[addressType/instanceValue/text="Preferred"]addressPart /nameValuePair/[instanceName/text="Statepr"]/instanceValue/text - ltiv:Person.address.street1 - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.address.street1 - The first line of the user's street address. - In the LIS Database, this value corresponds to - - personRecord/person/address/[addressType/instanceValue/text="Preferred"]addressPart /nameValuePair /[instanceName/text="NonFieldedStreetAddress1"]/instanceValue /text - ltiv:Person.address.street2 - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.address.street2 - The second line of the user's street address. - In the LIS Database, this value corresponds to - - personRecord/person/address/[addressType/instanceValue/text="Preferred"] addressPart /nameValuePair[instanceName/text="NonFieldedStreetAddress2"] /instanceValue/text - ltiv:Person.address.street3 - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.address.street3 - The third line of the user's street address. - In the LIS Database, this value corresponds to - - personRecord/person/address/[addressType/instanceValue/text="Preferred"]addressPart /nameValuePair /[instanceName/text="NonFieldedStreetAddress3"] /instanceValue/text - ltiv:Person.address.street4 - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.address.street4 - The fourth line of the user's street address. - In the LIS Database, this value corresponds to - - personRecord/person/address/[addressType/instanceValue/text="Preferred"]addressPart /nameValuePair /[instanceName/text="NonFieldedStreetAddress4"] /instanceValue/text - Person.address.timezone - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.address.timezone - The user's time zone. - In the LIS Database, this value corresponds to - - personRecord/person/address/[addressType/instanceValue/text="Preferred"]addressPart /nameValuePair /[instanceName/text="Timezone"]/instanceValue/text - ltiv:Person.email.personal - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.email.personal - The user's personal email address - In the LIS Database, this value corresponds to - - person/contactinfo[contactinfoType/instanceValue/text="Email_Personal"]/contactinfoValue /text - ltiv:Person.email.primary - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.email.primary - The user's primary email address. - In the LIS Database, this value corresponds to - - personRecord/person/contactinfo[contactinfoType/instanceValue/text="Email_Primary"] /contactinfoValue/text - ltiv:Person.name.family - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.name.family - The family name of the user. - In the LIS Database, this value corresponds to - - personRecord/person/name/partName[instanceName/text="Family”]/instanceValue/text - Person.name.full - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.name.full - The full name of the user. - In the LIS Database, this value corresponds to - - personRecord/person/formname/[formnameType/instanceValue/text="Full"] /formattedName/text - Person.name.given - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.name.given - The given name of the user. - In the LIS Database, this value corresponds to - - personRecord/person/name/partName[instanceName/text="Given”]/instanceValue/text - ltiv:Person.name.middle - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.name.middle - The middle name of the user. - In the LIS Database, this value corresponds to - - personRecord/person/name/partName[instanceName/text="Middle”]/instanceValue/text - Person.name.prefix - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.name.prefix - The prefix for the user's name, such as Dr., Mr., Ms. etc. - In the LIS Database, this value corresponds to - - personRecord/person/name/partName[instanceName/text="Prefix”]/instanceValue/text - ltiv:Person.name.suffix - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.name.suffix - The suffix for the user's name, such as Jr., II, etc. - In the LIS Database, this value corresponds to - - personRecord/person/name/partName[instanceName/text="Suffix”]/instanceValue/text - ltiv:Person.phone.home - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.phone.home - The user's home phone number - In the LIS Database, this value corresponds to - - personRecord/person/contactinfo [contactinfoType/instanceValue/text="Telephone_Home"]/contactinfoValue /text - ltiv:Person.phone.mobile - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.phone.mobile - The user's mobile phone number - In the LIS Database, this value corresponds to - - personRecord/person/contactinfo[contactinfoType/instanceValue/text="Mobile"] /contactInfoValue/text - Person.phone.primary - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.phone.primary - The user's primary phone number - In the LIS Database, this value corresponds to - - personRecord/person/contactinfo [contactinfoType/instanceValue/text="Telephone_Primary"]/contactinfoValue /text - ltiv:Person.phone.work - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.phone.work - The user's work phone number. - In the LIS Database, this value corresponds to - - personRecord/person/contactinfo [contactinfoType/instanceValue/text="Telephone_Work"]/contactinfoValue /text - Person.sms - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.sms - The number at which the user prefers to receive SMS text messages. - In the LIS Database, this value corresponds to - - personRecord/person/contactinfo[contactinfoType/instanceValue/text="SMS"] /contactinfoValue/text - ltiv:Person.sourcedId - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.sourcedId - The LIS identifier for the user. - In the LIS Database, this value corresponds to personRecord/sourcedId - - Person.webaddress - http://purl.imsglobal.org/vocab/lti/v2/variable#Person.webaddress - The user's web address. This could be a facebook address, a blog, or any other web address linked to the user. The value should be a URL. - In the LIS Database, this value corresponds to - - personRecord/person/contactinfo[contactinfoType/instanceValue/text="Web-Address"] /contactinfoValue/text - ltiv:ResourceLink.description - http://purl.imsglobal.org/vocab/lti/v2/variable#ResourceLink.description - A plain text description of the link’s destination, suitable for display alongside the link. - ltiv:ResourceLink.title - http://purl.imsglobal.org/vocab/lti/v2/variable#ResourceLink.title - A plain text title for the resource. - Result.autocreate - http://purl.imsglobal.org/vocab/lti/v2/capability#Result.autocreate - Result.comment - http://purl.imsglobal.org/vocab/lti/v2/variable#Result.comment - A comment associated with the outcome which may be made visible to the student. - ltiv:Result.createdTimestamp - http://purl.imsglobal.org/vocab/lti/v2/variable#Result.createdTimestamp - The date and time when the Result was created. - In the LIS Database, this value corresponds to - - ltiv:Result.dataSource - http://purl.imsglobal.org/vocab/lti/v2/variable#Result.dataSource - An identifier for the original source system of the Result record. - In the LIS Database, this value corresponds to - - resultRecord/result/dataSource - Result.resultScore - http://purl.imsglobal.org/vocab/lti/v2/variable#Result.resultScore - The score that the learner earned on the assignment or activity to which this Result pertains. - In the LIS Database, this value corresponds to - - resultRecord/result/resultScore/textString - ltiv:Result.sourcedId - http://purl.imsglobal.org/vocab/lti/v2/variable#Result.sourcedId - The LIS identifier for the Result resource. - In the LIS Database, this value corresponds to - - ltiv:Result.status - http://purl.imsglobal.org/vocab/lti/v2/variable#Result.status - A URI for the status of the Result. As a best practice, the URI should resolve to a JSON-LD description of the status value or a term in a VDEX file. The vocabulary for Result status values is extensible. The set of standard values includes: - http://www.imsglobal.org/lis/omsv1p0/statusofresultvocabularyv1p0#Unmoderated - http://www.imsglobal.org/lis/omsv1p0/statusofresultvocabularyv1p0#Tobemoderated - http://www.imsglobal.org/lis/omsv1p0/statusofresultvocabularyv1p0#Pending - http://www.imsglobal.org/lis/omsv1p0/statusofresultvocabularyv1p0#Completed - Result.url - http://purl.imsglobal.org/vocab/lti/v2/variable#Result.url - The URL of the Result resource. Client applications may issue an HTTP request to read, update or delete the resource at this URL. - ltiv:ToolProxy.custom.url - http://purl.imsglobal.org/vocab/lti/v2/variable#ToolProxy.custom.url - The endpoint URL for accessing system-wide tool settings. - ToolProxyBinding.custom.url - http://purl.imsglobal.org/vocab/lti/v2/variable#ToolProxyBinding.custom.url - The endpoint URL for accessing context-level tool settings. - User.id - http://purl.imsglobal.org/vocab/lti/v2/variable#User.id - Corresponds to the user_id launch parameterfrom the LaunchMixin class. This is the local identifier for the user within the Tool Consumer system. - User.image - http://purl.imsglobal.org/vocab/lti/v2/variable#User.image - The URL for an image of the user suitable for use as a profile picture or avatar. - User.org - http://purl.imsglobal.org/vocab/lti/v2/variable#User.org - A URI describing the user's organisational properties; for example, an ldap:// URI such as - ldap://host.com:6666/uid=user,ou=people,dc=example,dc=com - . If more than one format of organisational URI is specified, each should be separated with a space. - User.username - */ - - - - } - - public static String TYPE = "ToolConsumerProfile"; - public static String TC_PROFILE_CONTEXT = "http://purl.imsglobal.org/ctx/lti/v2/ToolConsumerProfile"; - - public ToolConsumer(){} - - // Constructor - public ToolConsumer(String guid, String ltiVersion, String tcp, LTI2Config cnf) { - this._context = TC_PROFILE_CONTEXT; - this._type = TYPE; - this.lti_version = ltiVersion; // "LTI-2p0"; - this.guid = guid; - this.product_instance = new ProductInstance(cnf); - } - - public Object get_context() { - return _context; - } - - public void set_context(List _context) { - this._context = _context; - } - - public String get_type() { - return _type; - } - - public void set_type(String _type) { - this._type = _type; - } - - public String get_id() { - return _id; - } - - public void set_id(String _id) { - this._id = _id; - } - - public String getLti_version() { - return lti_version; - } - - public void setLti_version(String lti_version) { - this.lti_version = lti_version; - } - - public String getGuid() { - return guid; - } - - public void setGuid(String guid) { - this.guid = guid; - } - - public ProductInstance getProduct_instance() { - return product_instance; - } - - public void setProduct_instance(ProductInstance product_instance) { - this.product_instance = product_instance; - } - - public List getCapability_offered() { - return capability_offered; - } - - public void setCapability_offered(List capability_offered) { - this.capability_offered = capability_offered; - } - - public List getService_offered() { - return service_offered; - } - - public void setService_offered(List service_offered) { - this.service_offered = service_offered; - } - - // Convienence method - public void addCapabilites(List capabilities) { - this.capability_offered.addAll(capabilities); - } - - public void addServiceOffered(ServiceOffered service) { - this.service_offered.add(service); - } - - public void addAllServiceOffered(List service) { - this.service_offered.addAll(service); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/consumer/Vendor.java b/src/main/java/org/imsglobal/lti2/objects/consumer/Vendor.java deleted file mode 100644 index f43a250..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/consumer/Vendor.java +++ /dev/null @@ -1,122 +0,0 @@ - -package org.imsglobal.lti2.objects.consumer; - -import org.imsglobal.lti2.LTI2Config; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import org.codehaus.jackson.annotate.JsonAnyGetter; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonPropertyOrder; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@Generated("com.googlecode.jsonschema2pojo") -@JsonPropertyOrder({ - "code", - "vendor_name", - "description", - "website", - "timestamp", - "contact" -}) -public class Vendor { - - @JsonProperty("code") - private String code; - @JsonProperty("vendor_name") - private Name vendor_name; - @JsonProperty("description") - private Description description; - @JsonProperty("website") - private String website; - @JsonProperty("timestamp") - private String timestamp; - @JsonProperty("contact") - private Contact contact; - private Map additionalProperties = new HashMap(); - - public Vendor(LTI2Config cnf) { - this.code = cnf.getProduct_family_vendor_code(); - this.vendor_name = new Name(cnf.getProduct_family_vendor_name()); - this.description = new Description(cnf.getProduct_family_vendor_description()); - this.website = cnf.getProduct_family_vendor_website(); - this.contact = new Contact(cnf.getProduct_family_vendor_contact()); - } - - public Vendor() { - } - - @JsonProperty("code") - public String getCode() { - return code; - } - - @JsonProperty("code") - public void setCode(String code) { - this.code = code; - } - - @JsonProperty("vendor_name") - public Name getVendor_name() { - return vendor_name; - } - - @JsonProperty("name") - public void setVendor_name(Name vendor_name) { - this.vendor_name = vendor_name; - } - - @JsonProperty("description") - public Description getDescription() { - return description; - } - - @JsonProperty("description") - public void setDescription(Description description) { - this.description = description; - } - - @JsonProperty("website") - public String getWebsite() { - return website; - } - - @JsonProperty("website") - public void setWebsite(String website) { - this.website = website; - } - - @JsonProperty("timestamp") - public String getTimestamp() { - return timestamp; - } - - @JsonProperty("timestamp") - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } - - @JsonProperty("contact") - public Contact getContact() { - return contact; - } - - @JsonProperty("contact") - public void setContact(Contact contact) { - this.contact = contact; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperties(String name, Object value) { - this.additionalProperties.put(name, value); - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/provider/BaseUrlChoice.java b/src/main/java/org/imsglobal/lti2/objects/provider/BaseUrlChoice.java deleted file mode 100644 index a79f763..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/provider/BaseUrlChoice.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2014 IMS Global Learning Consortium. - * - * 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.imsglobal.lti2.objects.provider; - -/** - * - * @author paul - */ -public class BaseUrlChoice { - - private String default_base_url; - private String secure_base_url; - private Object selector; - - public BaseUrlChoice() { - } - - public BaseUrlChoice(String default_base_url, String secure_base_url, Object selector) { - this.default_base_url = default_base_url; - this.secure_base_url = secure_base_url; - this.selector = selector; - } - - public String getDefault_base_url() { - return default_base_url; - } - - public void setDefault_base_url(String default_base_url) { - this.default_base_url = default_base_url; - } - - public String getSecure_base_url() { - return secure_base_url; - } - - public void setSecure_base_url(String secure_base_url) { - this.secure_base_url = secure_base_url; - } - - public Object getSelector() { - return selector; - } - - public void setSelector(Object selector) { - this.selector = selector; - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/provider/SecurityContract.java b/src/main/java/org/imsglobal/lti2/objects/provider/SecurityContract.java deleted file mode 100644 index af40058..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/provider/SecurityContract.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2014 IMS Global Learning Consortium. - * - * 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.imsglobal.lti2.objects.provider; - -import java.util.List; - -/** - * - * @author paul - */ -public class SecurityContract { - - private String shared_secret; - private List tool_service; - private List end_user_service; - - public SecurityContract() { - } - - public SecurityContract(String shared_secret, List tool_service, List end_user_service) { - this.shared_secret = shared_secret; - this.tool_service = tool_service; - this.end_user_service = end_user_service; - } - - public String getShared_secret() { - return shared_secret; - } - - public void setShared_secret(String shared_secret) { - this.shared_secret = shared_secret; - } - - public List getTool_service() { - return tool_service; - } - - public void setTool_service(List tool_service) { - this.tool_service = tool_service; - } - - public List getEnd_user_service() { - return end_user_service; - } - - public void setEnd_user_service(List end_user_service) { - this.end_user_service = end_user_service; - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/provider/ToolProfile.java b/src/main/java/org/imsglobal/lti2/objects/provider/ToolProfile.java deleted file mode 100644 index b09b62c..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/provider/ToolProfile.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2014 IMS Global Learning Consortium. - * - * 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.imsglobal.lti2.objects.provider; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.databind.JsonNode; -import org.imsglobal.lti2.objects.consumer.ProductInstance; - -/** - * - * @author paul - */ -public class ToolProfile { - - @JsonProperty("@id") - @org.codehaus.jackson.annotate.JsonProperty("@id") - private String id; - private String lti_version; - private JsonNode base_url_choice; - private ProductInstance product_instance; - private JsonNode resource_handler; - private JsonNode message; - - public ToolProfile() { - } - - public ToolProfile(String id, String lti_version, JsonNode base_url_choice, ProductInstance product_instance, JsonNode resource_handler, JsonNode message) { - this.id = id; - this.lti_version = lti_version; - this.base_url_choice = base_url_choice; - this.product_instance = product_instance; - this.resource_handler = resource_handler; - this.message = message; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getLti_version() { - return lti_version; - } - - public void setLti_version(String lti_version) { - this.lti_version = lti_version; - } - - public ProductInstance getProduct_instance() { - return product_instance; - } - - public void setProduct_instance(ProductInstance product_instance) { - this.product_instance = product_instance; - } - - public JsonNode getBase_url_choice() { - return base_url_choice; - } - - public void setBase_url_choice(JsonNode base_url_choice) { - this.base_url_choice = base_url_choice; - } - - public JsonNode getResource_handler() { - return resource_handler; - } - - public void setResource_handler(JsonNode resource_handler) { - this.resource_handler = resource_handler; - } - - public JsonNode getMessage() { - return message; - } - - public void setMessage(JsonNode message) { - this.message = message; - } - -} diff --git a/src/main/java/org/imsglobal/lti2/objects/provider/ToolProxy.java b/src/main/java/org/imsglobal/lti2/objects/provider/ToolProxy.java deleted file mode 100644 index e811e01..0000000 --- a/src/main/java/org/imsglobal/lti2/objects/provider/ToolProxy.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2014 IMS Global Learning Consortium. - * - * 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.imsglobal.lti2.objects.provider; - -import org.codehaus.jackson.JsonNode; -import org.imsglobal.lti2.objects.BaseJsonLd; - -/** - * - * @author pgray - */ -public class ToolProxy extends BaseJsonLd { - - private String tool_proxy_guid; - private String custom_url; - private String lti_version; - private String tool_consumer_profile; - private ToolProfile tool_profile; - private Object custom; - private SecurityContract security_contract; - - public static final String CONTENT_TYPE = "application/vnd.ims.lti.v2.toolproxy+json"; - public static final String CONTEXT_URL = "http://purl.imsglobal.org/ctx/lti/v2/ToolProxyId"; - public static final String TYPE = "http://purl.imsglobal.org/ctx/lti/v2/ToolProxyId"; - - public ToolProxy(){ - } - - public ToolProxy(String id, String type, String tool_proxy_guid, String custom_url) { - this.id = id; - this.type = type; - this.tool_proxy_guid = tool_proxy_guid; - this.custom_url = custom_url; - this.context = CONTEXT_URL; - } - - public String getTool_proxy_guid() { - return tool_proxy_guid; - } - - public void setTool_proxy_guid(String tool_proxy_guid) { - this.tool_proxy_guid = tool_proxy_guid; - } - - public String getCustom_url() { - return custom_url; - } - - public void setCustom_url(String custom_url) { - this.custom_url = custom_url; - } - - public String getLti_version() { - return lti_version; - } - - public void setLti_version(String lti_version) { - this.lti_version = lti_version; - } - - public String getTool_consumer_profile() { - return tool_consumer_profile; - } - - public void setTool_consumer_profile(String tool_consumer_profile) { - this.tool_consumer_profile = tool_consumer_profile; - } - - public ToolProfile getTool_profile() { - return tool_profile; - } - - public void setTool_profile(ToolProfile tool_profile) { - this.tool_profile = tool_profile; - } - - public Object getCustom() { - return custom; - } - - public void setCustom(Object custom) { - this.custom = custom; - } - - public SecurityContract getSecurity_contract() { - return security_contract; - } - - public void setSecurity_contract(SecurityContract security_contract) { - this.security_contract = security_contract; - } - -} diff --git a/src/test/java/org/imsglobal/lti/lti2/ProductInstanceTest.java b/src/test/java/org/imsglobal/lti/lti2/ProductInstanceTest.java deleted file mode 100644 index 29e13bf..0000000 --- a/src/test/java/org/imsglobal/lti/lti2/ProductInstanceTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2014 IMS Global Learning Consortium. - * - * 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.imsglobal.lti.lti2; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import java.io.IOException; -import junit.framework.Assert; -import org.imsglobal.lti2.objects.consumer.ProductInstance; -import org.junit.Test; - -/** - * - * @author pgray - */ -public class ProductInstanceTest { - - public String getJson(Object o, Boolean prettyPrint) throws JsonProcessingException { - ObjectMapper mapper = new ObjectMapper(); - if(prettyPrint){ - mapper.enable(SerializationFeature.INDENT_OUTPUT); - } - return mapper.writeValueAsString(o); - } - - public T toObject(String json, Class claz) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(json, claz); - } - - @Test - public void serializeProfile() throws JsonProcessingException{ - ProductInstance ppi = new ProductInstance(new TestLtiConsumerProfile()); - ppi.addAdditionalProperty("test", "yolo"); - ppi.addAdditionalProperty("another_test", "swag"); - System.out.println(getJson(ppi, true)); - } - - @Test - public void deserializeProfile() throws JsonProcessingException, IOException{ - ProductInstance ppi = new ProductInstance(new TestLtiConsumerProfile()); - ppi.addAdditionalProperty("test", "yolo"); - ppi.addAdditionalProperty("another_test", "swag"); - - String json = getJson(ppi, false); - - ProductInstance pi = toObject(json, ProductInstance.class); - - Assert.assertEquals("1", pi.getGuid()); - Assert.assertEquals("yolo", pi.getAdditionalProperties().get("test")); - Assert.assertEquals("swag", pi.getAdditionalProperties().get("another_test")); - } - -} diff --git a/src/test/java/org/imsglobal/lti/lti2/TestLtiConsumerProfile.java b/src/test/java/org/imsglobal/lti/lti2/TestLtiConsumerProfile.java deleted file mode 100644 index d844fa3..0000000 --- a/src/test/java/org/imsglobal/lti/lti2/TestLtiConsumerProfile.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2014 IMS Global Learning Consortium. - * - * 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.imsglobal.lti.lti2; - -import org.imsglobal.lti2.LTI2Config; -import org.imsglobal.lti2.objects.consumer.ToolConsumer; - -/** - * - * @author pgray - */ -public class TestLtiConsumerProfile implements LTI2Config { - - public static String GUID = "1"; - public static String SUPPORT_EMAIL = "test@example.com"; - - @Override - public String getGuid() { - return GUID; - } - - @Override - public String getSupport_email() { - return SUPPORT_EMAIL; - } - - @Override - public String getService_owner_id() { - return null; - } - - @Override - public String getService_owner_owner_name() { - return null; - } - - @Override - public String getService_owner_description() { - return null; - } - - @Override - public String getService_owner_support_email() { - return null; - } - - @Override - public String getService_provider_id() { - return null; - } - - @Override - public String getService_provider_provider_name() { - return null; - } - - @Override - public String getService_provider_description() { - return null; - } - - @Override - public String getService_provider_support_email() { - return null; - } - - @Override - public String getProduct_family_product_code() { - return null; - } - - @Override - public String getProduct_family_vendor_code() { - return null; - } - - @Override - public String getProduct_family_vendor_name() { - return null; - } - - @Override - public String getProduct_family_vendor_description() { - return null; - } - - @Override - public String getProduct_family_vendor_website() { - return null; - } - - @Override - public String getProduct_family_vendor_contact() { - return null; - } - - @Override - public String getProduct_info_product_name() { - return null; - } - - @Override - public String getProduct_info_product_version() { - return "1.0.0"; - } - - @Override - public String getProduct_info_product_description() { - return null; - } - - public String[] getCapabilities() { - String[] caps = { - ToolConsumer.LtiCapability.BASICLTI_LAUNCH, - ToolConsumer.LtiCapability.USER_ID - }; - return caps; - } -} diff --git a/src/test/java/org/imsglobal/lti/lti2/ToolConsumerTest.java b/src/test/java/org/imsglobal/lti/lti2/ToolConsumerTest.java deleted file mode 100644 index 646457e..0000000 --- a/src/test/java/org/imsglobal/lti/lti2/ToolConsumerTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2014 IMS Global Learning Consortium. - * - * 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.imsglobal.lti.lti2; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.imsglobal.lti2.objects.consumer.ToolConsumer; -import org.junit.Test; - -import java.io.IOException; - -/** - * - * @author pgray - */ -public class ToolConsumerTest { - - - @Test - public void TestProfile() throws IOException { - TestLtiConsumerProfile config = new TestLtiConsumerProfile(); - ToolConsumer consumer = new ToolConsumer("guid", "LTI-2p0", "tcp?", config); - //consumer.addCapabilites(config.getCapabilities()); - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.INDENT_OUTPUT); - mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); - String json = mapper.writeValueAsString(consumer); - System.out.println(json); - - ToolConsumer parsed = mapper.readValue(json, ToolConsumer.class); - } - -}