Skip to content

Commit

Permalink
SAK-28149
Browse files Browse the repository at this point in the history
Undo the commit with the unintended extra bit to SakaiBLTIUtil



git-svn-id: https://source.sakaiproject.org/svn/basiclti/trunk@315817 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
csev committed Dec 1, 2014
1 parent 8497891 commit c64119e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Properties;
import java.util.Map;
import java.util.TreeMap;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
Expand Down Expand Up @@ -629,12 +628,12 @@ public static String[] postLaunchHTML(Map<String, Object> content, Map<String,Ob
Map<String, Object> deploy = null;

Long deployKey = getLongKey(tool.get(LTIService.LTI_DEPLOYMENT_ID));
if ( deployKey >= 0 ) {
deploy = ltiService.getDeployDao(deployKey);
}
if ( deployKey >= 0 ) {
deploy = ltiService.getDeployDao(deployKey);
}

Long toolKey = getLongKey(tool.get(LTIService.LTI_ID));
proxyBinding = ltiService.getProxyBindingDao(toolKey,context);
proxyBinding = ltiService.getProxyBindingDao(toolKey,context);

Long toolVersion = getLongNull(tool.get(LTIService.LTI_VERSION));
boolean isLTI1 = toolVersion == null || (!toolVersion.equals(LTIService.LTI_VERSION_2));
Expand Down Expand Up @@ -816,7 +815,7 @@ public static String[] postLaunchHTML(Map<String, Object> content, Map<String,Ob
return postLaunchHTML(toolProps, ltiProps, rb);
}

// An LTI 2.0 Registration launch
// An LTI 2.0 Registration launch
// This must return an HTML message as the [0] in the array
// If things are successful - the launch URL is in [1]
public static String[] postRegisterHTML(Long deployKey, Map<String,Object> tool, ResourceLoader rb, String placementId)
Expand Down Expand Up @@ -851,21 +850,21 @@ public static String[] postRegisterHTML(Long deployKey, Map<String,Object> tool,

String serverUrl = getOurServerUrl();
setProperty(ltiProps, LTI2Constants.TC_PROFILE_URL,serverUrl + LTI2_PATH + SVC_tc_profile + "/" + consumerkey);
setProperty(ltiProps, BasicLTIConstants.LAUNCH_PRESENTATION_RETURN_URL, serverUrl + "/portal/tool/"+placementId+"?panel=PostRegister&id="+deployKey);
setProperty(ltiProps, BasicLTIConstants.LAUNCH_PRESENTATION_RETURN_URL, serverUrl + "/portal/tool/"+placementId+"?panel=Activate&id="+deployKey);

int debug = getInt(tool.get(LTIService.LTI_DEBUG));
debug = 1;

M_log.debug("ltiProps="+ltiProps);

boolean dodebug = debug == 1;
String postData = BasicLTIUtil.postLaunchHTML(ltiProps, launch_url, dodebug, null);
String postData = BasicLTIUtil.postLaunchHTML(ltiProps, launch_url, dodebug);

String [] retval = { postData, launch_url };
return retval;
}

// An LTI 2.0 ReRegistration launch
// An LTI 2.0 ReRegistration launch
// This must return an HTML message as the [0] in the array
// If things are successful - the launch URL is in [1]
public static String[] postReRegisterHTML(Long deployKey, Map<String,Object> deploy, ResourceLoader rb, String placementId)
Expand Down Expand Up @@ -899,19 +898,18 @@ public static String[] postReRegisterHTML(Long deployKey, Map<String,Object> dep

String serverUrl = getOurServerUrl();
setProperty(ltiProps, LTI2Constants.TC_PROFILE_URL,serverUrl + LTI2_PATH + SVC_tc_profile + "/" + consumerkey);
setProperty(ltiProps, BasicLTIConstants.LAUNCH_PRESENTATION_RETURN_URL, serverUrl + "/portal/tool/"+placementId+"?panel=PostRegister&id="+deployKey);
setProperty(ltiProps, BasicLTIConstants.LAUNCH_PRESENTATION_RETURN_URL, serverUrl + "/portal/tool/"+placementId+"?panel=Activate&id="+deployKey);

int debug = getInt(deploy.get(LTIService.LTI_DEBUG));
debug = 1;

Map<String,String> extra = new HashMap<String,String> ();
ltiProps = BasicLTIUtil.signProperties(ltiProps, launch_url, "POST",
consumerkey, secret, null, null, null, extra);
consumerkey, secret, null, null, null);

M_log.debug("signed ltiProps="+ltiProps);

boolean dodebug = debug == 1;
String postData = BasicLTIUtil.postLaunchHTML(ltiProps, launch_url, dodebug, extra);
String postData = BasicLTIUtil.postLaunchHTML(ltiProps, launch_url, dodebug);

String [] retval = { postData, launch_url };
return retval;
Expand Down Expand Up @@ -996,16 +994,15 @@ public static String[] postLaunchHTML(Properties toolProps, Properties ltiProps,
return postError("<p>" + getRB(rb, "error.nokey", "Error - must have a secret and a key.")+"</p>");
}

Map<String,String> extra = new HashMap<String,String> ();
ltiProps = BasicLTIUtil.signProperties(ltiProps, launch_url, "POST",
key, secret, org_guid, org_desc, org_url, extra);
key, secret, org_guid, org_desc, org_url);

if ( ltiProps == null ) return postError("<p>" + getRB(rb, "error.sign", "Error signing message.")+"</p>");
dPrint("LAUNCH III="+ltiProps);

String debugProperty = toolProps.getProperty(LTIService.LTI_DEBUG);
boolean dodebug = "on".equals(debugProperty) || "1".equals(debugProperty);
String postData = BasicLTIUtil.postLaunchHTML(ltiProps, launch_url, dodebug, extra);
String postData = BasicLTIUtil.postLaunchHTML(ltiProps, launch_url, dodebug);

String [] retval = { postData, launch_url };
return retval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public static String adaptToCustomPropertyName(final String propertyName) {
* Add the necessary fields and sign.
*
* @deprecated See:
* {@link BasicLTIUtil#signProperties(Map, String, String, String, String, String, String, String, String, String)}
* {@link BasicLTIUtil#signProperties(Map, String, String, String, String, String, String, String, String, String)}
*
* @param postProp
* @param url
Expand All @@ -332,15 +332,14 @@ public static String adaptToCustomPropertyName(final String propertyName) {
* See: {@link BasicLTIConstants#TOOL_CONSUMER_INSTANCE_DESCRIPTION}
* @param org_url
* See: {@link BasicLTIConstants#TOOL_CONSUMER_INSTANCE_URL}
* @param extra
* @return
*/
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, Map<String,String> extra) {
String org_id, String org_desc, String org_url) {
final Map<String, String> signedMap = signProperties(
convertToMap(postProp), url, method, oauth_consumer_key,
oauth_consumer_secret, org_id, org_desc, org_url, null, null, extra);
oauth_consumer_secret, org_id, org_desc, org_url, null, null);
return convertToProperties(signedMap);
}

Expand All @@ -363,7 +362,6 @@ public static Properties signProperties(Properties postProp, String url,
* @param tool_consumer_instance_contact_email
* See:
* {@link BasicLTIConstants#TOOL_CONSUMER_INSTANCE_CONTACT_EMAIL}
* @param extra
* @return
*/
public static Map<String, String> signProperties(
Expand All @@ -372,9 +370,7 @@ public static Map<String, String> signProperties(
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,
Map<String, String> extra) {

String tool_consumer_instance_contact_email) {
postProp = BasicLTIUtil.cleanupProperties(postProp);

if ( postProp.get(LTI_VERSION) == null ) postProp.put(LTI_VERSION, "LTI-1p0");
Expand Down Expand Up @@ -411,11 +407,7 @@ public static Map<String, String> signProperties(
OAuthAccessor acc = new OAuthAccessor(cons);
try {
oam.addRequiredParameters(acc);
String base_string = OAuthSignatureMethod.getBaseString(oam);
M_log.fine("Base Message String\n"+base_string+"\n");
if ( extra != null ) {
extra.put("BaseString", base_string);
}
// System.out.println("Base Message String\n"+OAuthSignatureMethod.getBaseString(oam)+"\n");

List<Map.Entry<String, String>> params = oam.getParameters();

Expand Down Expand Up @@ -519,13 +511,12 @@ public static boolean checkProperties(
* The LTI launch url.
* @param debug
* Useful for viewing the HTML before posting to end point.
* @param extra
* @return the HTML ready for IFRAME src = inclusion.
*/
public static String postLaunchHTML(final Properties cleanProperties,
String endpoint, boolean debug, Map<String,String> extra) {
String endpoint, boolean debug) {
Map<String, String> map = convertToMap(cleanProperties);
return postLaunchHTML(map, endpoint, debug, extra);
return postLaunchHTML(map, endpoint, debug);
}

/**
Expand All @@ -539,14 +530,10 @@ public static String postLaunchHTML(final Properties cleanProperties,
* The LTI launch url.
* @param debug
* Useful for viewing the HTML before posting to end point.
* @param extra
* Useful for viewing the HTML before posting to end point.
* @return the HTML ready for IFRAME src = inclusion.
*/
public static String postLaunchHTML(
final Map<String, String> cleanProperties, String endpoint,
boolean debug, Map<String,String> extra) {

final Map<String, String> cleanProperties, String endpoint, boolean debug) {
if (cleanProperties == null || cleanProperties.isEmpty()) {
throw new IllegalArgumentException(
"cleanProperties == null || cleanProperties.isEmpty()");
Expand Down Expand Up @@ -624,14 +611,6 @@ public static String postLaunchHTML(
text.append("\n");
}
text.append("</pre>\n");
if ( extra != null ) {
String base_string = extra.get("BaseString");
if ( base_string != null ) {
text.append("<!-- Base String\n");
text.append(base_string.replaceAll("-->","__>"));
text.append("\n-->\n");
}
}
} else {
// paint auto submit script
text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Properties;
import java.util.TreeMap;

Expand Down Expand Up @@ -205,7 +204,7 @@ protected void doRegister(HttpServletRequest request, HttpServletResponse respon
System.out.println("ltiProps="+ltiProps);

boolean dodebug = true;
output = BasicLTIUtil.postLaunchHTML(ltiProps, launch_url, dodebug, null);
output = BasicLTIUtil.postLaunchHTML(ltiProps, launch_url, dodebug);
} else {
output = "<form>Register URL:<br/><input type=\"text\" name=\"launch_url\" size=\"80\"\n" +
"value=\"http://localhost:8888/sakai-api-test/tp.php\"><input type=\"submit\">\n";
Expand Down Expand Up @@ -273,12 +272,11 @@ protected void doLaunch(HttpServletRequest request, HttpServletResponse response
// Place the custom values into the launch
LTI2Util.addCustomToLaunch(ltiProps, custom);

Map<String,String> extra = new HashMap<String,String> ();
ltiProps = BasicLTIUtil.signProperties(ltiProps, launch, "POST",
TEST_KEY, shared_secret, null, null, null, extra);
TEST_KEY, shared_secret, null, null, null);

boolean dodebug = true;
output = BasicLTIUtil.postLaunchHTML(ltiProps, launch, dodebug, extra);
output = BasicLTIUtil.postLaunchHTML(ltiProps, launch, dodebug);
}

try {
Expand Down

0 comments on commit c64119e

Please sign in to comment.