Skip to content

Commit

Permalink
#1424 Convert the bb lti flow to a generic lti flow
Browse files Browse the repository at this point in the history
oEQ now supports a generic LTI that be used for Blackboard integration.
  • Loading branch information
ddelblanco authored and cbeach47 committed Feb 18, 2020
1 parent 68e6f6f commit c885ba5
Show file tree
Hide file tree
Showing 18 changed files with 466 additions and 233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
@Entity
@AccessType("field")
public class LtiConsumer extends BaseEntity {
public static final String ATT_CUSTOM_USER_ID = "ATT_CUSTOM_USER_ID";
public static final String ATT_CUSTOM_USERNAME = "ATT_CUSTOM_USERNAME";
public static final String ATT_CUSTOM_ENABLE_ID_PREFIX = "ATT_CUSTOM_ENABLE_ID_PREFIX";

@Index(name = "consumerKey")
@Column(length = 255, nullable = false)
private String consumerKey;
Expand Down
28 changes: 14 additions & 14 deletions Source/Plugins/Core/com.equella.core/plugin-jpf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<parameter id="class" value="com.tle.core.xslt.guice.XsltModule" />
<parameter id="class" value="com.tle.integration.lti.brightspace.guice.BrightspaceIntegrationModule" />
<parameter id="class" value="com.tle.integration.lti.canvasextension.guice.CanvasIntegrationModule" />
<parameter id="class" value="com.tle.integration.lti.blackboard.guice.BlackboardLtiIntegrationModule" />
<parameter id="class" value="com.tle.integration.lti.generic.guice.GenericLtiIntegrationModule" />
<parameter id="class" value="com.tle.integration.standard.guice.StandardIntegrationModule" />
<parameter id="class" value="com.tle.mycontent.guice.MyContentModule" />
<parameter id="class" value="com.tle.mypages.guice.MyPagesModule" />
Expand Down Expand Up @@ -2173,9 +2173,9 @@
<parameter id="id" value="canvas" />
<parameter id="class" value="bean:com.tle.integration.lti.canvasextension.CanvasIntegration" />
</extension>
<extension plugin-id="com.tle.web.integration" point-id="integration" id="blackboardltiintegration">
<parameter id="id" value="blackboardlti" />
<parameter id="class" value="bean:com.tle.integration.lti.blackboard.BlackboardLtiIntegration" />
<extension plugin-id="com.tle.web.integration" point-id="integration" id="genericltiintegration">
<parameter id="id" value="lti" />
<parameter id="class" value="bean:com.tle.integration.lti.generic.GenericLtiIntegration" />
</extension>
<extension plugin-id="com.tle.web.sections" point-id="sectionTree" id="signon_2">
<parameter id="path" value="/canvassignon.do" />
Expand All @@ -2185,23 +2185,23 @@
<parameter id="path" value="/canvascipreturn.do" />
<parameter id="root" value="bean:/canvascipreturn" />
</extension>
<extension plugin-id="com.tle.web.sections" point-id="sectionTree" id="signon_blackboardLti">
<parameter id="path" value="/blackboardltisignon.do" />
<parameter id="root" value="bean:/blackboardltisignon" />
<extension plugin-id="com.tle.web.sections" point-id="sectionTree" id="signon_lti">
<parameter id="path" value="/ltisignon.do" />
<parameter id="root" value="bean:/ltisignon" />
</extension>
<extension plugin-id="com.tle.web.sections" point-id="sectionTree" id="contentItemPlacementsReturnBlackboardLti">
<parameter id="path" value="/blackboardlticipreturn.do" />
<parameter id="root" value="bean:/blackboardlticipreturn" />
<extension plugin-id="com.tle.web.sections" point-id="sectionTree" id="contentItemPlacementsReturnLti">
<parameter id="path" value="/lticipreturn.do" />
<parameter id="root" value="bean:/lticipreturn" />
</extension>
<extension plugin-id="com.tle.web.lti" point-id="ltiWrapperExtension" id="canvasLtiExt">
<parameter id="id" value="canvas" />
<parameter id="bean" value="bean:com.tle.integration.lti.canvasextension.CanvasLtiWrapperExtension" />
<parameter id="order" value="1000" />
</extension>
<extension plugin-id="com.tle.web.lti" point-id="ltiWrapperExtension" id="blackboardLtiExt">
<parameter id="id" value="bblti" />
<parameter id="bean" value="bean:com.tle.integration.lti.blackboard.BlackboardLtiWrapperExtension" />
<parameter id="order" value="1000" />
<extension plugin-id="com.tle.web.lti" point-id="ltiWrapperExtension" id="genericLtiExt">
<parameter id="id" value="genlti" />
<parameter id="bean" value="bean:com.tle.integration.lti.generic.GenericLtiWrapperExtension" />
<parameter id="order" value="9000" />
</extension>
<extension plugin-id="com.tle.web.connectors" point-id="connectorEditor" id="moodleEditor">
<parameter id="id" value="moodle" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,10 @@ editor.container.option.default=Default
editor.container.option.embed=Embed
editor.container.option.newwindow=New window
editor.customparams=Custom parameters
editor.custom.lti.params.help=The following custom LTI parameters are only in effect for the /ltisignon.do endpoint
editor.custom.lti.params.user.id=Custom user ID
editor.custom.lti.params.username=Custom username attribute
editor.custom.lti.params.prefix.id=Prefix the user ID with a value unique to this consumer
editor.dropdown.option.choosetype=Choose a connector type...
editor.email=Share launcher's email with tool
editor.error.accessdenied=You do not have the required permission to access this page\: {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<#include "/com.tle.web.sections.standard@/dropdown.ftl" />
<#include "/com.tle.web.sections.standard@/textfield.ftl"/>
<#include "/com.tle.web.sections.standard@/autocomplete.ftl"/>

<@css "editconsumer.css" />

<@setting label=b.key("editor.key") mandatory=true error=m.errors["key"]>
Expand All @@ -21,6 +20,18 @@
<@setting label=b.key("editor.postfix") help=b.key("editor.username.help")>
<@textfield section=s.postfixField maxlength=50 />
</@setting>
<hr/>
<@setting label='' help=b.key('editor.custom.lti.params.help') />
<@setting label=b.key("editor.custom.lti.params.user.id")>
<@textfield section=s.customUserIdParameterField maxlength=128 />
</@setting>
<@setting label=b.key("editor.custom.lti.params.username")>
<@textfield section=s.customUsernameParameterField maxlength=128 />
</@setting>
<@setting label=''>
<div class="input checkbox"><@render s.customEnableIdPrefixField /></div>
</@setting>
<hr/>
<@a.div id="allowed">
<@setting label=b.key("editor.allowed.label") help=b.key("editor.allowed.help")>
${m.prettyExpression}
Expand All @@ -40,8 +51,8 @@
</@a.div>
<@a.div id="customrole">
<@setting label=b.key("editor.role.custom.label") error=m.errors["nocustomrole"] help=b.key("editor.role.custom.help")>
<@render section=s.customRolesTable />
<@autocomplete section=s.customRoleField class="custom-role" placeholder=b.key("editor.role.custom.placeholder") />
<@render section=s.customRolesTable />
<@autocomplete section=s.customRoleField class="custom-role" placeholder=b.key("editor.role.custom.placeholder") />
<@render section=s.customRoleDialog.opener class="add">${b.key("editor.table.roles.add")}</@render>
</@setting>
</@a.div>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.base.Strings;
import com.google.inject.Inject;
import com.tle.common.Utils;
import com.tle.common.lti.consumers.entity.LtiConsumer;
import com.tle.core.guice.Bind;
import com.tle.web.lti.usermanagement.LtiWrapperExtension;
import javax.inject.Named;
Expand All @@ -46,21 +47,21 @@ public class BrightspaceLtiWrapperExtension implements LtiWrapperExtension {
private String userIdParameter;

@Override
public String getUserId(HttpServletRequest request) {
public String getUserId(HttpServletRequest request, LtiConsumer consumer) {
final String rawId = request.getParameter(userIdParameter);
if (!Strings.isNullOrEmpty(rawId)) {
return truncatedUniqueName(rawId);
}
// Fall back to username param (which may mean username and user ID are the same, which is fine)
final String rawUsername = getUsername(request);
final String rawUsername = getUsername(request, consumer);
if (!Strings.isNullOrEmpty(rawUsername)) {
return truncatedUniqueName(rawUsername);
}
return null;
}

/**
* EQUELLA only allows 40 chars for user IDs. We hope that this is vaguely unique.
* openEQUELLA only allows 40 chars for user IDs. We hope that this is vaguely unique.
*
* @param rawName
* @return
Expand All @@ -84,7 +85,7 @@ private String truncatedUniqueName(String rawName) {
}

@Override
public String getUsername(HttpServletRequest request) {
public String getUsername(HttpServletRequest request, LtiConsumer consumer) {
return request.getParameter(usernameParameter);
}

Expand All @@ -107,7 +108,7 @@ public String getEmail(HttpServletRequest request) {
}

@Override
public boolean isPrefixUserId() {
public boolean isPrefixUserId(LtiConsumer consumer) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.tle.integration.lti.canvasextension;

import com.tle.common.lti.consumers.entity.LtiConsumer;
import com.tle.core.guice.Bind;
import com.tle.web.lti.usermanagement.LtiWrapperExtension;
import javax.inject.Singleton;
Expand All @@ -33,12 +34,12 @@
@Singleton
public class CanvasLtiWrapperExtension implements LtiWrapperExtension {
@Override
public String getUserId(HttpServletRequest request) {
public String getUserId(HttpServletRequest request, LtiConsumer consumer) {
return request.getParameter("custom_canvas_user_id");
}

@Override
public String getUsername(HttpServletRequest request) {
public String getUsername(HttpServletRequest request, LtiConsumer consumer) {
return request.getParameter("custom_canvas_user_login_id");
}

Expand All @@ -58,7 +59,7 @@ public String getEmail(HttpServletRequest request) {
}

@Override
public boolean isPrefixUserId() {
public boolean isPrefixUserId(LtiConsumer consumer) {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package com.tle.integration.lti.blackboard;
package com.tle.integration.lti.generic;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -48,6 +48,7 @@
import com.tle.web.sections.js.generic.SimpleElementId;
import com.tle.web.sections.render.HiddenInput;
import com.tle.web.sections.render.HtmlRenderer;
import com.tle.web.sections.render.TextUtils;
import com.tle.web.selection.SelectedResource;
import com.tle.web.selection.SelectionService;
import com.tle.web.selection.SelectionSession;
Expand All @@ -60,15 +61,14 @@
import javax.inject.Inject;
import org.apache.log4j.Logger;

// TODO: defer - we should be able to make this a generic LTI return
@Bind
public class BlackboardContentItemPlacementReturn extends AbstractPrototypeSection<Object>
public class GenericLtiContentItemPlacementReturn extends AbstractPrototypeSection<Object>
implements HtmlRenderer {
private static final Logger LOGGER = Logger.getLogger(BlackboardContentItemPlacementReturn.class);
private static final Logger LOGGER = Logger.getLogger(GenericLtiContentItemPlacementReturn.class);

@Inject private SelectionService selectionService;
@Inject private IntegrationService integrationService;
@Inject private BlackboardLtiIntegration blackboardLtiIntegration;
@Inject private GenericLtiIntegration genericLtiIntegration;
@Inject private ItemResolver itemResolver;
@Inject private OAuthWebService oauthWebService;
@Inject private LtiConsumerService consumerService;
Expand All @@ -86,10 +86,10 @@ public SectionResult renderHtml(RenderEventContext context) throws Exception {
final IItem<?> item = getItemForResource(resource);

final LmsLink link =
blackboardLtiIntegration
genericLtiIntegration
.getLinkForResource(
context,
blackboardLtiIntegration.createViewableItem(item, resource),
genericLtiIntegration.createViewableItem(item, resource),
resource,
false,
session.isAttachmentUuidUrls())
Expand Down Expand Up @@ -145,10 +145,7 @@ private String buildSelectionJson(List<LmsLink> links) {
graph.id = link.getUrl();
graph.url = link.getUrl();
graph.title = link.getName();
graph.text = link.getName();
// FIXME: Is there a custom BB property for the description? Base LTI spec doesn't specify
// one
// graph.description = TextUtils.INSTANCE.ensureWrap(link.getDescription(),250, 250, true);
graph.text = TextUtils.INSTANCE.ensureWrap(link.getDescription(), 250, 250, true);
graph.mediaType = "application/vnd.ims.lti.v1.ltilink";
graph.windowTarget = "_blank";
final ContentItemSelection.ContentItemGraph.ContentItemPlacementAdvice placementAdvice =
Expand Down
Loading

0 comments on commit c885ba5

Please sign in to comment.