public class BasicLTIUtil extends Object
Sample Descriptor
<?xml version="1.0" encoding="UTF-8"?>
<basic_lti_link xmlns="http://www.imsglobal.org/xsd/imsbasiclti_v1p0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<title>generated by tp+user</title>
<description>generated by tp+user</description>
<custom>
<parameter key="keyname">value</parameter>
</custom>
<extensions platform="www.lms.com">
<parameter key="keyname">value</parameter>
</extensions>
<launch_url>url to the lti launch URL</launch_url>
<secure_launch_url>url to the lti launch URL</secure_launch_url>
<icon>url to an icon for this tool (optional)</icon>
<secure_icon>url to an icon for this tool (optional)</secure_icon>
<cartridge_icon identifierref="BLTI001_Icon"/>
<vendor>
<code>vendor.com</code>
<name>Vendor Name</name>
<description>
This is a Grade Book that supports many column types.
</description>
<contact>
<email>support@vendor.com</email>
</contact>
<url>http://www.vendor.com/product</url>
</vendor>
</basic_lti_link>
| Modifier and Type | Field and Description |
|---|---|
static String |
BASICLTI_SUBMIT |
| Constructor and Description |
|---|
BasicLTIUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
adaptToCustomPropertyName(String propertyName)
A simple utility method which implements the specified semantics of
custom properties.
|
static boolean |
checkProperties(Map<String,String> postProp,
String url,
String method,
String oauth_consumer_key,
String oauth_consumer_secret)
Check if the fields are properly signed
|
static boolean |
checkProperties(Properties postProp,
String url,
String method,
String oauth_consumer_key,
String oauth_consumer_secret)
Deprecated.
|
static Map<String,String> |
cleanupProperties(Map<String,String> rawProperties)
Any properties which are not well known (i.e.
|
static Map<String,String> |
cleanupProperties(Map<String,String> rawProperties,
String[] blackList)
Any properties which are not well known (i.e.
|
static Properties |
cleanupProperties(Properties rawProperties)
Deprecated.
|
static Map<String,String> |
convertToMap(Properties properties)
Simple utility method to help with the migration from
Properties to Map<String, String>. |
static Properties |
convertToProperties(Map<String,String> map)
Deprecated.
Should migrate to
Map<String, String> signatures. |
static void |
dPrint(String str) |
static String |
getRealPath(javax.servlet.http.HttpServletRequest request,
String extUrl) |
static String |
getRealPath(String servletUrl,
String extUrl)
Simple utility method deal with a request that has the wrong URL when
behind a proxy.
|
static String |
htmlspecialchars(String input) |
static boolean |
isSpecifiedPropertyName(String propertyName)
Checks to see if the passed propertyName is equal to one of the Strings
contained in
BasicLTIConstants.validPropertyNames. |
static String |
mapKeyName(String keyname)
The parameter name is mapped to lower case and any character that is
neither a number or letter is replaced with an "underscore".
|
static boolean |
parseDescriptor(Map<String,String> launch_info,
Map<String,String> postProp,
String descriptor) |
static boolean |
parseDescriptor(Properties launch_info,
Properties postProp,
String descriptor)
Deprecated.
|
static String |
postLaunchHTML(Map<String,String> cleanProperties,
String endpoint,
boolean debug)
Create the HTML to render a POST form and then automatically submit it.
|
static String |
postLaunchHTML(Properties cleanProperties,
String endpoint,
boolean debug)
Deprecated.
Moved to
postLaunchHTML(Map, String, boolean) |
static String |
prepareForExport(String descriptor) |
static void |
setProperty(Map<String,String> map,
String key,
String value)
Mutates the passed
Map<String, String> map variable. |
static void |
setProperty(Properties props,
String key,
String value)
Deprecated.
|
static Map<String,String> |
signProperties(Map<String,String> postProp,
String url,
String method,
String oauth_consumer_key,
String oauth_consumer_secret,
String tool_consumer_instance_guid,
String tool_consumer_instance_description,
String tool_consumer_instance_url,
String tool_consumer_instance_name,
String tool_consumer_instance_contact_email)
Add the necessary fields and sign.
|
static Properties |
signProperties(Properties postProp,
String url,
String method,
String oauth_consumer_key,
String oauth_consumer_secret,
String org_id,
String org_desc,
String org_url)
|
static String |
validateDescriptor(String descriptor) |
static LtiVerificationResult |
validateMessage(javax.servlet.http.HttpServletRequest request,
String URL,
String oauth_secret) |
public static final String BASICLTI_SUBMIT
public static void dPrint(String str)
public static LtiVerificationResult validateMessage(javax.servlet.http.HttpServletRequest request, String URL, String oauth_secret)
public static Map<String,String> cleanupProperties(Map<String,String> rawProperties)
BasicLTIConstants.validPropertyNames) will be mapped to custom
properties per the specified semantics. NOTE: no blacklisting of keys is
performed.rawProperties - A set of properties that will be cleaned.public static Map<String,String> cleanupProperties(Map<String,String> rawProperties, String[] blackList)
BasicLTIConstants.validPropertyNames) will be mapped to custom
properties per the specified semantics.rawProperties - A set of properties that will be cleaned.blackList - An array of Strings which are considered unsafe
to be included in launch data. Any matches will be removed from the
return.public static Properties cleanupProperties(Properties rawProperties)
cleanupProperties(Map)BasicLTIConstants.validPropertyNames) will be mapped to custom
properties per the specified semantics.rawProperties - A set of Properties that will be cleaned.
Keys must be of type String.Properties.public static boolean isSpecifiedPropertyName(String propertyName)
BasicLTIConstants.validPropertyNames. String
matching is case sensitive.propertyName - BasicLTIConstants.validPropertyNames or is a custom parameter oe
extension parameter ; else return false.public static String adaptToCustomPropertyName(String propertyName)
i.e. The parameter names are mapped to lower case and any character that is neither a number nor letter in a parameter name is replaced with an "underscore".
e.g. Review:Chapter=1.2.56 would map to custom_review_chapter=1.2.56.
propertyName - public static Properties signProperties(Properties postProp, String url, String method, String oauth_consumer_key, String oauth_consumer_secret, String org_id, String org_desc, String org_url)
signProperties(Map, String, String, String, String, String, String, String, String, String)postProp - url - method - oauth_consumer_key - oauth_consumer_secret - org_id - See: BasicLTIConstants.TOOL_CONSUMER_INSTANCE_GUIDorg_desc - See:
BasicLTIConstants.TOOL_CONSUMER_INSTANCE_DESCRIPTIONorg_url - See: BasicLTIConstants.TOOL_CONSUMER_INSTANCE_URLpublic static Map<String,String> signProperties(Map<String,String> postProp, String url, String method, String oauth_consumer_key, String oauth_consumer_secret, String tool_consumer_instance_guid, String tool_consumer_instance_description, String tool_consumer_instance_url, String tool_consumer_instance_name, String tool_consumer_instance_contact_email)
postProp - url - method - oauth_consumer_key - oauth_consumer_secret - tool_consumer_instance_guid - See:
BasicLTIConstants.TOOL_CONSUMER_INSTANCE_GUIDtool_consumer_instance_description - See:
BasicLTIConstants.TOOL_CONSUMER_INSTANCE_DESCRIPTIONtool_consumer_instance_url - See:
BasicLTIConstants.TOOL_CONSUMER_INSTANCE_URLtool_consumer_instance_name - See:
BasicLTIConstants.TOOL_CONSUMER_INSTANCE_NAMEtool_consumer_instance_contact_email - See:
BasicLTIConstants.TOOL_CONSUMER_INSTANCE_CONTACT_EMAILpublic static boolean checkProperties(Properties postProp, String url, String method, String oauth_consumer_key, String oauth_consumer_secret)
checkProperties(Map, String, String, String, String)postProp - url - method - oauth_consumer_key - oauth_consumer_secret - public static boolean checkProperties(Map<String,String> postProp, String url, String method, String oauth_consumer_key, String oauth_consumer_secret)
postProp - url - method - oauth_consumer_key - oauth_consumer_secret - public static String postLaunchHTML(Properties cleanProperties, String endpoint, boolean debug)
postLaunchHTML(Map, String, boolean)cleanupProperties(Properties) before signing.cleanProperties - Assumes you have called
cleanupProperties(Properties) beforehand.endpoint - The LTI launch url.debug - Useful for viewing the HTML before posting to end point.public static String postLaunchHTML(Map<String,String> cleanProperties, String endpoint, boolean debug)
cleanupProperties(Properties) before signing.cleanProperties - Assumes you have called
cleanupProperties(Properties) beforehand.endpoint - The LTI launch url.debug - Useful for viewing the HTML before posting to end point.public static boolean parseDescriptor(Properties launch_info, Properties postProp, String descriptor)
parseDescriptor(Map, Map, String)launch_info - Variable is mutated by this method.postProp - Variable is mutated by this method.descriptor - public static boolean parseDescriptor(Map<String,String> launch_info, Map<String,String> postProp, String descriptor)
launch_info - Variable is mutated by this method.postProp - Variable is mutated by this method.descriptor - public static String mapKeyName(String keyname)
<parameter name="Vendor:Chapter">1.2.56</parameter>
Would map to: custom_vendor_chapter=1.2.56public static void setProperty(Map<String,String> map, String key, String value)
Map<String, String> map variable. Puts the key,value
into the Map if the value is not null and is not empty.map - Variable is mutated by this method.key - value - public static void setProperty(Properties props, String key, String value)
setProperty(Map, String, String)props - Variable is mutated by this method.key - value - public static String getRealPath(String servletUrl, String extUrl)
extUrl - The url that the external world sees us as responding to.
This needs to be up to but not including the last slash like and not
include any path information http://www.sakaiproject.org - although we do
compensate for extra stuff at the end.public static String getRealPath(javax.servlet.http.HttpServletRequest request, String extUrl)
public static Map<String,String> convertToMap(Properties properties)
Properties to Map<String, String>.properties - public static Properties convertToProperties(Map<String,String> map)
Map<String, String> signatures.Map<String, String>
to Properties.map - Copyright © 2009–2016 IMS Global Learning Consortium. All rights reserved.