Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r61753b963f79323ff21d671c6b6d2b563957d289 -r4a1534e41ae03e0d1bcba97c6796f7cb666b65a4 Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestServlet.java =================================================================== diff -u -raa6023fdecba00eb9a7df76e834e681f7d58462d -r4a1534e41ae03e0d1bcba97c6796f7cb666b65a4 --- lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestServlet.java (.../LoginRequestServlet.java) (revision aa6023fdecba00eb9a7df76e834e681f7d58462d) +++ lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestServlet.java (.../LoginRequestServlet.java) (revision 4a1534e41ae03e0d1bcba97c6796f7cb666b65a4) @@ -39,6 +39,7 @@ import org.apache.catalina.authenticator.Constants; import org.apache.log4j.Logger; +import org.lamsfoundation.lams.integration.ExtCourseClassMap; import org.lamsfoundation.lams.integration.ExtServerOrgMap; import org.lamsfoundation.lams.integration.ExtUserUseridMap; import org.lamsfoundation.lams.integration.UserInfoFetchException; @@ -122,33 +123,40 @@ } } - ExtServerOrgMap serverMap = getService().getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = getIntegrationService().getExtServerOrgMap(serverId); boolean prefix = (usePrefix == null) ? true : Boolean.parseBoolean(usePrefix); try { ExtUserUseridMap userMap = null; if ((firstName == null) && (lastName == null)) { - userMap = getService().getExtUserUseridMap(serverMap, extUsername, prefix); + userMap = getIntegrationService().getExtUserUseridMap(serverMap, extUsername, prefix); } else { - userMap = getService().getImplicitExtUserUseridMap(serverMap, extUsername, firstName, lastName, - langIsoCode, countryIsoCode, email, prefix, isUpdateUserDetails); + userMap = getIntegrationService().getImplicitExtUserUseridMap(serverMap, extUsername, firstName, + lastName, langIsoCode, countryIsoCode, email, prefix, isUpdateUserDetails); } // in case of request for learner with strict authentication check cache should also contain lsid - String lsId = null; - if (LoginRequestDispatcher.METHOD_LEARNER_STRICT_AUTHENTICATION.equals(method)) { + String lsId = request.getParameter(LoginRequestDispatcher.PARAM_LESSON_ID); + if (LoginRequestDispatcher.METHOD_LEARNER_STRICT_AUTHENTICATION.equals(method) && lsId == null) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Login Failed - lsId parameter missing"); + return; + } + Authenticator.authenticateLoginRequest(serverMap, timestamp, extUsername, method, lsId, hash); - lsId = request.getParameter(LoginRequestDispatcher.PARAM_LESSON_ID); - if (lsId == null) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Login Failed - lsId parameter missing"); - return; + if (extCourseId == null && lsId != null) { + // derive course ID from lesson ID + ExtCourseClassMap classMap = integrationService.getExtCourseClassMap(serverMap.getSid(), + Long.parseLong(lsId)); + if (classMap == null) { + log.warn("Lesson " + lsId + " is not mapped to any course for server " + serverMap.getServername()); + } else { + extCourseId = classMap.getCourseid(); } } - Authenticator.authenticateLoginRequest(serverMap, timestamp, extUsername, method, lsId, hash); if (extCourseId != null) { // check if organisation, ExtCourseClassMap and user roles exist and up-to-date, and if not update them - getService().getExtCourseClassMap(serverMap, userMap, extCourseId, countryIsoCode, langIsoCode, - courseName, method, prefix); + getIntegrationService().getExtCourseClassMap(serverMap, userMap, extCourseId, countryIsoCode, + langIsoCode, courseName, method, prefix); } User user = userMap.getUser(); @@ -274,11 +282,11 @@ return hses; } - private IntegrationService getService() { + private IntegrationService getIntegrationService() { if (LoginRequestServlet.integrationService == null) { LoginRequestServlet.integrationService = (IntegrationService) WebApplicationContextUtils .getRequiredWebApplicationContext(getServletContext()).getBean("integrationService"); } return LoginRequestServlet.integrationService; } -} +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/integration/service/IIntegrationService.java =================================================================== diff -u -raa6023fdecba00eb9a7df76e834e681f7d58462d -r4a1534e41ae03e0d1bcba97c6796f7cb666b65a4 --- lams_common/src/java/org/lamsfoundation/lams/integration/service/IIntegrationService.java (.../IIntegrationService.java) (revision aa6023fdecba00eb9a7df76e834e681f7d58462d) +++ lams_common/src/java/org/lamsfoundation/lams/integration/service/IIntegrationService.java (.../IIntegrationService.java) (revision 4a1534e41ae03e0d1bcba97c6796f7cb666b65a4) @@ -27,6 +27,7 @@ import java.util.List; import org.lamsfoundation.lams.integration.ExtCourseClassMap; +import org.lamsfoundation.lams.integration.ExtServerLessonMap; import org.lamsfoundation.lams.integration.ExtServerOrgMap; import org.lamsfoundation.lams.integration.ExtServerToolAdapterMap; import org.lamsfoundation.lams.integration.ExtUserUseridMap; @@ -164,4 +165,6 @@ boolean isIntegratedServerGroupFetchingAvailable(Long lessonId); List getExtGroups(Long lessonId, String[] extGroupIds) throws Exception; + + ExtCourseClassMap getExtCourseClassMap(Integer sid, Long lessonId); } Index: lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java =================================================================== diff -u -ra2b9f050d31b1c0ed3da47f69d84e50d4e0b7b54 -r4a1534e41ae03e0d1bcba97c6796f7cb666b65a4 --- lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java (.../IntegrationService.java) (revision a2b9f050d31b1c0ed3da47f69d84e50d4e0b7b54) +++ lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java (.../IntegrationService.java) (revision 4a1534e41ae03e0d1bcba97c6796f7cb666b65a4) @@ -342,7 +342,7 @@ org.setOrganisationState( (OrganisationState) service.findById(OrganisationState.class, OrganisationState.ACTIVE)); org.setLocale(LanguageUtil.getSupportedLocale(langIsoCode, countryIsoCode)); - + org.setEnableCourseNotifications(true); // determine whether org will be a group or subgroup @@ -738,6 +738,17 @@ return extGroups; } + @Override + @SuppressWarnings("unchecked") + public ExtCourseClassMap getExtCourseClassMap(Integer sid, Long lessonId) { + Lesson lesson = lessonService.getLesson(lessonId); + Map properties = new HashMap(); + properties.put("extServerOrgMap.sid", sid); + properties.put("organisation.organisationId", lesson.getOrganisation().getOrganisationId()); + List list = service.findByProperties(ExtCourseClassMap.class, properties); + return list == null || list.isEmpty() ? null : list.get(0); + } + private ExtServerLessonMap getExtServerLessonMap(Long lessonId) { List list = service.findByProperty(ExtServerLessonMap.class, "lessonId", lessonId); if (list == null || list.size() == 0) {