Skip to content

Commit

Permalink
Merging the origin/master
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/pushyamig/sakai into SAK-29372
  • Loading branch information
pushyamig committed Jul 10, 2015
2 parents 3e7d7de + 1b654c5 commit c4b8b80
Show file tree
Hide file tree
Showing 53 changed files with 748 additions and 326 deletions.
2 changes: 1 addition & 1 deletion assignment/assignment-impl/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11</version>
<version>${sakai.poi.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,8 @@ public static String[] postRegisterHTML(Long deployKey, Map<String,Object> tool,

setProperty(ltiProps, BasicLTIConstants.LTI_VERSION, LTI2Constants.LTI2_VERSION_STRING);
setProperty(ltiProps, LTI2Constants.REG_KEY,key);
// Also duplicate reg_key as the proposed Tool Proxy GUID
setProperty(ltiProps, LTI2Constants.TOOL_PROXY_GUID,key);
// TODO: Lets show off and encrypt this secret too...
setProperty(ltiProps, LTI2Constants.REG_PASSWORD,password);
setProperty(ltiProps, BasicLTIUtil.BASICLTI_SUBMIT, getRB(rb, "launch.button", "Press to Launch External Tool"));
Expand Down
16 changes: 15 additions & 1 deletion basiclti/basiclti-docs/resources/docs/sakai-api-test/tp.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ function dataToggle(divName) {

$secret = isset($_SESSION['split_secret']) ? $_SESSION['split_secret'] : 'secret';
$re_register = false;
$tool_proxy_guid = false;
if ( $lti_message_type == "ToolProxyReregistrationRequest" ) {
$reg_key = $_POST['oauth_consumer_key'];
$tool_proxy_guid = isset($_POST['tool_proxy_guid']) ? $_POST['tool_proxy_guid'] : false;
$reg_password = "secret";
$re_register = false;
$context = new BLTI($secret, false, false);
Expand Down Expand Up @@ -294,8 +296,20 @@ function dataToggle(divName) {

$tc_half_shared_secret = false;
if ( $last_http_response == 201 || $last_http_response == 200 ) {

$responseObject = json_decode($response);

$tc_tool_proxy_guid = $responseObject->tool_proxy_guid;
if ( $tc_tool_proxy_guid ) {
echo('<p>Tool consumer returned tool_proxy_guid='.$tc_tool_proxy_guid."</p>\n");
if ( $tool_proxy_guid && $tool_proxy_guid != $tc_tool_proxy_guid ) {
echo('<p style="color: red;">Error: Returned tool_proxy_guid did not match launch tool_proxy_guid='.$tool_proxy_guid."</p>\n");
}
} else {
echo('<p style="color: red;">Error: Tool Consumer did not include tool_proxy_guid in its response.</p>'."\n");
}

if ( $oauth_splitsecret && $tp_half_shared_secret ) {
$responseObject = json_decode($response);
if ( isset($responseObject->tc_half_shared_secret) ) {
$tc_half_shared_secret = $responseObject->tc_half_shared_secret;
echo("<p>tc_half_shared_secret: ".$tc_half_shared_secret."</p>\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,57 +75,60 @@ public User findOrCreateUser(Map payload, boolean trustedConsumer, boolean email
// If trusted consumer, login, if email trusted consumer then we look up the user info based on the email address otherwise check for existing user and create one if required
// Note that if trusted, then the user must have already logged into Sakai in order to have an account stub created for them
// otherwise this will fail since they don't exist. Perhaps this should be addressed?
if (trustedConsumer) {
try {
if (BasicLTIUtil.isNotBlank((String) payload.get(BasicLTIConstants.EXT_SAKAI_PROVIDER_EID))) {
user = userDirectoryService.getUserByEid(eid);
} else {
user = userDirectoryService.getUser(user_id);
}
} catch (UserNotDefinedException e) {
throw new LTIException("launch.user.invalid", "user_id=" + user_id, e);
}

}else
if (trustedConsumer) {
try {
if (BasicLTIUtil.isNotBlank((String) payload.get(BasicLTIConstants.EXT_SAKAI_PROVIDER_EID))) {
user = userDirectoryService.getUserByEid(eid);
} else {
user = userDirectoryService.getUser(user_id);
}
} catch (UserNotDefinedException e) {
throw new LTIException("launch.user.invalid", "user_id=" + user_id, e);
}
return user;
}
/* looking up user based on email address may return multiple results, this is not a valid
case hence this is an error condition with this work flow */
if(emailtrusted){
Collection<User> findUsersByEmail = userDirectoryService.findUsersByEmail((String) email);
if(!findUsersByEmail.isEmpty()){
if(findUsersByEmail.size()>1){
throw new LTIException("launch.user.multiple.emailaddress", "email=" + email);
}
user= (User) findUsersByEmail.toArray()[0];
}else throw new LTIException("launch.user.invalid", "email=" + email);
}
else {

try {
user = userDirectoryService.getUserByEid(eid);
} catch (Exception e) {
if (M_log.isDebugEnabled()) {
M_log.debug(e.getLocalizedMessage(), e);
}
user = null;
}
if (emailtrusted) {
Collection<User> findUsersByEmail = userDirectoryService.findUsersByEmail((String) email);
if (!findUsersByEmail.isEmpty()) {
if (findUsersByEmail.size() > 1) {
M_log.warn("multiple user id's exist for emailaddress= " + email);
throw new LTIException("launch.user.multiple.emailaddress", "email=" + email);
}
user = (User) findUsersByEmail.toArray()[0];
} else {
M_log.warn("Invalid user for emailaddress= " + email);
throw new LTIException("launch.user.invalid", "email=" + email);
}
return user;
}

if (user == null) {
try {
String hiddenPW = IdManager.createUuid();
userDirectoryService.addUser(null, eid, fname, lname, email, hiddenPW, "registered", null);
M_log.info("Created user=" + eid);
user = userDirectoryService.getUserByEid(eid);
} catch (Exception e) {
throw new LTIException("launch.create.user", "user_id=" + user_id, e);
}
}
try {
user = userDirectoryService.getUserByEid(eid);
} catch (Exception e) {
if (M_log.isDebugEnabled()) {
M_log.debug(e.getLocalizedMessage(), e);
}
user = null;
}

// post the login event
// eventTrackingService().post(eventTrackingService().newEvent(EVENT_LOGIN,
// null, true));
}
if (user == null) {
try {
String hiddenPW = IdManager.createUuid();
userDirectoryService.addUser(null, eid, fname, lname, email, hiddenPW, "registered", null);
M_log.info("Created user=" + eid);
user = userDirectoryService.getUserByEid(eid);
} catch (Exception e) {
throw new LTIException("launch.create.user", "user_id=" + user_id, e);
}
}

// post the login event
// eventTrackingService().post(eventTrackingService().newEvent(EVENT_LOGIN,
// null, true));

return user;
return user;
}

private String getEid(Map payload, boolean trustedConsumer, String user_id) throws LTIException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.imsglobal.basiclti.BasicLTIUtil;
import org.imsglobal.basiclti.BasicLTIProviderUtil;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.lti.api.LTIException;
import org.sakaiproject.lti.api.LTIService;
import org.sakaiproject.lti.api.SiteMembershipsSynchroniser;


import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.StatefulJob;
Expand All @@ -32,30 +30,19 @@ public void setSiteMembershipsSynchroniser(SiteMembershipsSynchroniser siteMembe
}

public void execute(JobExecutionContext context) throws JobExecutionException {

M_log.info("SiteMembershipsSyncJob.execute");
List<String> emailTrustedConsumersList =null;
final String emailTrustedConsumersConfig = ServerConfigurationService
.getString("basiclti.provider.email.trusted.consumers", null);
if(BasicLTIUtil.isNotBlank(emailTrustedConsumersConfig)) {
String[] emailTrustedConsumers = emailTrustedConsumersConfig.split(":");
emailTrustedConsumersList = Arrays.asList(emailTrustedConsumers);

}

// Get the current list of jobs
List<Map<String, Object>> jobs = ltiService.getMembershipsJobs();

for (Map<String, Object> job : jobs) {
boolean isEmailTrustedConsumer=false;
String siteId = (String) job.get("SITE_ID");
String membershipsId = (String) job.get("memberships_id");
String membershipsUrl = (String) job.get("memberships_url");
String consumerKey = (String) job.get("consumerkey");
String ltiVersion = (String) job.get("lti_version");
if (emailTrustedConsumersList!=null&&emailTrustedConsumersList.contains(consumerKey)) {
isEmailTrustedConsumer = true;
}
boolean isEmailTrustedConsumer= BasicLTIProviderUtil.isEmailTrustedConsumer(consumerKey);

siteMembershipsSynchroniser.synchroniseSiteMemberships(siteId, membershipsId, membershipsUrl, consumerKey, isEmailTrustedConsumer,ltiVersion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,8 @@ public String formInputInteger(Object value, String field, String label,
return formInputText(value.toString(), field, label, required, size, loader);
}

// Produce a form for createing a new object or editing an existing object
/**
*
* Produce a form for creating a new object or editing an existing object
*/
public String formInput(Object row, String fieldinfo, Object loader) {
Properties info = parseFormString(fieldinfo);
Expand All @@ -605,19 +604,20 @@ public String formInput(Object row, String fieldinfo, Object loader) {
Object value = getField(row, field);
String label = info.getProperty("label", field);

// look for tool id prefix
if (field.indexOf("_") != -1)
// look for fields with a tool id prefix like 694_fa_prefix
int pos = field.indexOf("_");
if (pos != -1 && field.length() > pos+1)
{
String[] array = field.split("_");

String first = field.substring(0,pos);
String second = field.substring(pos+1);
try
{
// the first array item should be an long value
Long.parseLong(array[0]);
Long.parseLong(first);
// reset the input value
value = getField(row, array[1]);
value = getField(row, second);
// reset the input label
label = info.getProperty("label", array[1]);
label = info.getProperty("label", second);
}
catch (NumberFormatException e)
{
Expand Down Expand Up @@ -1015,7 +1015,7 @@ public String formExtract(Object parms, String[] formDefinition, Object loader,
}
if ( "header".equals(type) ) continue;
String label = info.getProperty("label", field);
// System.out.println("field="+field+" type="+type);
logger.fine("field="+field+" type="+type);

// Check the automatically populate empty date fields
if ("autodate".equals(type) && dataMap != null && (!isFieldSet(parms, field)) ) {
Expand Down Expand Up @@ -1554,7 +1554,6 @@ public String[] formAdjustTable(String table, String[] formDefinition, String ve
boolean isNullable = false;
try {
for( int i = 1; i <= md.getColumnCount(); i++ ) {
// System.out.println("F="+field+" SF="+md.getColumnLabel(i));
if ( field.equalsIgnoreCase(md.getColumnLabel(i)) ) {
sqlLength = md.getColumnDisplaySize(i);
autoIncrement = md.isAutoIncrement(i);
Expand All @@ -1567,8 +1566,9 @@ public String[] formAdjustTable(String table, String[] formDefinition, String ve
// ignore
}

System.out.println( field + " (" + maxlength + ") type="+type);
System.out.println( field + " (" + sqlLength + ") auto=" + autoIncrement+" type="+sqlType+" null="+isNullable);
logger.fine( field + " (" + maxlength + ") type="+type);
logger.fine( field + " (" + sqlLength + ") auto=" + autoIncrement+" type="+sqlType+" null="+isNullable);

// If the field is not there...
if ( sqlType == null ) {
if ( "oracle".equals(vendor) ) {
Expand Down Expand Up @@ -1678,7 +1678,6 @@ public static String getSuperType(String className)
c = c.getSuperclass();
}
} catch(Exception e) {
// System.out.println("OOPS");
e.printStackTrace();
}
return className;
Expand Down
Loading

0 comments on commit c4b8b80

Please sign in to comment.