Index: lams_openid/build.xml
===================================================================
diff -u -r29546ca4b5a3f8426cd68af3e9022cf57f36037e -r2219e0e8fc391aa59813047d473f789334fbe057
--- lams_openid/build.xml (.../build.xml) (revision 29546ca4b5a3f8426cd68af3e9022cf57f36037e)
+++ lams_openid/build.xml (.../build.xml) (revision 2219e0e8fc391aa59813047d473f789334fbe057)
@@ -82,9 +82,9 @@
+
-
Index: lams_openid/src/java/org/lamsfoundation/lams/openid/openIdApplicationContext.xml
===================================================================
diff -u
--- lams_openid/src/java/org/lamsfoundation/lams/openid/openIdApplicationContext.xml (revision 0)
+++ lams_openid/src/java/org/lamsfoundation/lams/openid/openIdApplicationContext.xml (revision 2219e0e8fc391aa59813047d473f789334fbe057)
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+
+
+
+
\ No newline at end of file
Index: lams_openid/src/java/org/lamsfoundation/lams/openid/service/ILamsOpenIdService.java
===================================================================
diff -u
--- lams_openid/src/java/org/lamsfoundation/lams/openid/service/ILamsOpenIdService.java (revision 0)
+++ lams_openid/src/java/org/lamsfoundation/lams/openid/service/ILamsOpenIdService.java (revision 2219e0e8fc391aa59813047d473f789334fbe057)
@@ -0,0 +1,70 @@
+/****************************************************************
+ * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id$ */
+package org.lamsfoundation.lams.openid.service;
+
+import java.sql.SQLException;
+
+import javax.naming.NamingException;
+import javax.security.auth.login.FailedLoginException;
+
+import org.lamsfoundation.lams.integration.ExtCourseClassMap;
+import org.lamsfoundation.lams.integration.ExtServerOrgMap;
+import org.lamsfoundation.lams.integration.ExtUserUseridMap;
+import org.lamsfoundation.lams.integration.UserInfoFetchException;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.User;
+
+public interface ILamsOpenIdService {
+
+ String getUserPassword(String username) throws FailedLoginException, NamingException, SQLException;
+
+ ExtCourseClassMap addUserToGroup(String username, String serverId, String datetime, String hash, String courseId,
+ String courseName, String countryIsoCode, String langIsoCode, Boolean isTeacher)
+ throws java.rmi.RemoteException;
+
+ boolean addUserToSubgroup(String username, String serverId, String datetime, String hash, String courseId,
+ String courseName, String countryIsoCode, String langIsoCode, String subgroupId, String subgroupName,
+ Boolean isTeacher) throws java.rmi.RemoteException;
+
+ boolean addUserToGroupLessons(String username, String serverId, String datetime, String hash, String courseId,
+ String courseName, String countryIsoCode, String langIsoCode, Boolean asStaff, ExtCourseClassMap orgMap)
+ throws java.rmi.RemoteException;
+
+ boolean addUserToSubgroupLessons(String username, String serverId, String datetime, String hash, String courseId,
+ String courseName, String countryIsoCode, String langIsoCode, String subgroupId, String subgroupName,
+ Boolean asStaff) throws java.rmi.RemoteException;
+
+ void addUserToLessons(User user, Organisation org, Boolean asStaff);
+
+ ExtServerOrgMap getExtServerOrgMap(String serverId);
+
+ ExtUserUseridMap getExtUserUseridMap(ExtServerOrgMap serverMap, String extUsername) throws UserInfoFetchException;
+
+ ExtUserUseridMap getImplicitExtUserUseridMap(ExtServerOrgMap serverMap, String extUsername, String firstName,
+ String lastName, String langIsoCode, String countryIsoCode, String email) throws UserInfoFetchException;
+
+ User getUserByLogin(String login);
+
+ ExtUserUseridMap getExistingExtUserUseridMap(ExtServerOrgMap map, String loggedInAs) throws UserInfoFetchException;
+}
Index: lams_openid/src/java/org/lamsfoundation/lams/openid/service/LamsOpenIdService.java
===================================================================
diff -u
--- lams_openid/src/java/org/lamsfoundation/lams/openid/service/LamsOpenIdService.java (revision 0)
+++ lams_openid/src/java/org/lamsfoundation/lams/openid/service/LamsOpenIdService.java (revision 2219e0e8fc391aa59813047d473f789334fbe057)
@@ -0,0 +1,263 @@
+/****************************************************************
+ * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id$ */
+package org.lamsfoundation.lams.openid.service;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Iterator;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.security.auth.login.FailedLoginException;
+import javax.sql.DataSource;
+
+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;
+import org.lamsfoundation.lams.integration.service.IIntegrationService;
+import org.lamsfoundation.lams.lesson.Lesson;
+import org.lamsfoundation.lams.lesson.service.ILessonService;
+import org.lamsfoundation.lams.usermanagement.Organisation;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+
+public class LamsOpenIdService implements ILamsOpenIdService {
+
+ private static Logger log = Logger.getLogger(LamsOpenIdService.class);
+
+ private IIntegrationService integrationService = null;
+
+ private IUserManagementService userManagementService = null;
+
+ private ILessonService lessonService = null;
+
+ private static final String JNDI_DATASOURCE = "java:/jdbc/lams-ds";
+
+ private static final String PASSWORD_QUERY = "select password from lams_user where login=?";
+
+ // using JDBC connection to prevent the caching of passwords by hibernate
+ public String getUserPassword(String username) throws FailedLoginException, NamingException, SQLException {
+ InitialContext ctx = new InitialContext();
+
+ DataSource ds = (DataSource) ctx.lookup(JNDI_DATASOURCE);
+ Connection conn = null;
+ String password = null;
+ try {
+ conn = ds.getConnection();
+ PreparedStatement ps = conn.prepareStatement(PASSWORD_QUERY);
+ ps.setString(1, username);
+ ResultSet rs = ps.executeQuery();
+
+ // check if there is any result
+ if (rs.next() == false)
+ throw new FailedLoginException("invalid username");
+
+ password = rs.getString(1);
+ rs.close();
+ } finally {
+ if (conn != null && !conn.isClosed())
+ conn.close();
+ }
+ return password;
+ }
+
+ public ExtCourseClassMap addUserToGroup(String username, String serverId, String datetime, String hash,
+ String courseId, String courseName, String countryIsoCode, String langIsoCode, Boolean isTeacher)
+ throws java.rmi.RemoteException {
+ try {
+ // authenticate external server
+ ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId);
+
+ // get user map, creating if necessary
+ ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username);
+
+ User user = userManagementService.getUserByLogin(serverMap.getPrefix() + "_" + username);
+
+ log.debug("This is a login: " + user.getLogin());
+
+ userMap.setUser(user);
+
+ // add user to org, creating org if necessary
+ ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(serverMap, userMap, courseId,
+ courseName, countryIsoCode, langIsoCode, userManagementService.getRootOrganisation()
+ .getOrganisationId().toString(), isTeacher, false);
+ return orgMap;
+ } catch (Exception e) {
+ log.debug(e.getMessage(), e);
+ throw new java.rmi.RemoteException(e.getMessage());
+ }
+ }
+
+ public boolean addUserToSubgroup(String username, String serverId, String datetime, String hash, String courseId,
+ String courseName, String countryIsoCode, String langIsoCode, String subgroupId, String subgroupName,
+ Boolean isTeacher) throws java.rmi.RemoteException {
+ try {
+ // authenticate external server
+ ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId);
+ //Authenticator.authenticate(serverMap, datetime, hash);
+
+ // get group to use for this request
+ ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username);
+ Organisation rootOrg = userManagementService.getRootOrganisation();
+ ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(serverMap, userMap, courseId,
+ courseName, countryIsoCode, langIsoCode, rootOrg.getOrganisationId().toString(), isTeacher, false);
+ Organisation group = orgMap.getOrganisation();
+
+ // add user to subgroup, creating subgroup if necessary
+ ExtCourseClassMap subOrgMap = integrationService.getExtCourseClassMap(serverMap, userMap, subgroupId,
+ subgroupName, countryIsoCode, langIsoCode, group.getOrganisationId().toString(), isTeacher, false);
+ return true;
+ } catch (Exception e) {
+ log.debug(e.getMessage(), e);
+ throw new java.rmi.RemoteException(e.getMessage());
+ }
+ }
+
+ public boolean addUserToGroupLessons(String username, String serverId, String datetime, String hash,
+ String courseId, String courseName, String countryIsoCode, String langIsoCode, Boolean asStaff,
+ ExtCourseClassMap orgMap) throws java.rmi.RemoteException {
+ try {
+ // authenticate external server
+ ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId);
+ //Authenticator.authenticate(serverMap, datetime, hash);
+
+ // get group to use for this request
+ ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username);
+ //ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(serverMap, userMap, courseId,
+ // courseName, countryIsoCode, langIsoCode, userManagementService.getRootOrganisation()
+ // .getOrganisationId().toString(), asStaff, false);
+ Organisation org = orgMap.getOrganisation();
+
+ // add user to lessons
+ User user = userManagementService.getUserByLogin(serverMap.getPrefix() + "_" + username);
+ addUserToLessons(user, org, asStaff);
+ return true;
+ } catch (Exception e) {
+ log.debug(e.getMessage(), e);
+ throw new java.rmi.RemoteException(e.getMessage());
+ }
+ }
+
+ public boolean addUserToSubgroupLessons(String username, String serverId, String datetime, String hash,
+ String courseId, String courseName, String countryIsoCode, String langIsoCode, String subgroupId,
+ String subgroupName, Boolean asStaff) throws java.rmi.RemoteException {
+ try {
+ // authenticate external server
+ ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId);
+ //Authenticator.authenticate(serverMap, datetime, hash);
+
+ // get group to use for this request
+ ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username);
+ ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(serverMap, userMap, courseId,
+ courseName, countryIsoCode, langIsoCode, userManagementService.getRootOrganisation()
+ .getOrganisationId().toString(), asStaff, false);
+ Organisation group = orgMap.getOrganisation();
+
+ // get subgroup to add user to
+ ExtCourseClassMap subOrgMap = integrationService.getExtCourseClassMap(serverMap, userMap, subgroupId,
+ subgroupName, countryIsoCode, langIsoCode, group.getOrganisationId().toString(), asStaff, false);
+ Organisation subgroup = subOrgMap.getOrganisation();
+
+ // add user to subgroup lessons
+ if (subgroup != null) {
+ User user = userManagementService.getUserByLogin(username);
+ addUserToLessons(user, subgroup, asStaff);
+ return true;
+ }
+ return false;
+ } catch (Exception e) {
+ log.debug(e.getMessage(), e);
+ throw new java.rmi.RemoteException(e.getMessage());
+ }
+ }
+
+ public void addUserToLessons(User user, Organisation org, Boolean asStaff) {
+ if (org.getLessons() != null) {
+ Iterator iter2 = org.getLessons().iterator();
+ while (iter2.hasNext()) {
+ Lesson lesson = (Lesson) iter2.next();
+ lessonService.addLearner(lesson.getLessonId(), user.getUserId());
+ if (asStaff)
+ lessonService.addStaffMember(lesson.getLessonId(), user.getUserId());
+ if (log.isDebugEnabled()) {
+ log.debug("Added " + user.getLogin() + " to " + lesson.getLessonName()
+ + (asStaff ? " as staff, and" : " as learner"));
+ }
+ }
+ }
+ }
+
+ public ExtServerOrgMap getExtServerOrgMap(String serverId) {
+ return integrationService.getExtServerOrgMap(serverId);
+ }
+
+ public ExtUserUseridMap getExtUserUseridMap(ExtServerOrgMap serverMap, String extUsername)
+ throws UserInfoFetchException {
+ return integrationService.getExtUserUseridMap(serverMap, extUsername);
+ }
+
+ public ExtUserUseridMap getImplicitExtUserUseridMap(ExtServerOrgMap serverMap, String extUsername,
+ String firstName, String lastName, String langIsoCode, String countryIsoCode, String email)
+ throws UserInfoFetchException {
+ return integrationService.getImplicitExtUserUseridMap(serverMap, extUsername, firstName, lastName, langIsoCode,
+ countryIsoCode, email);
+ }
+
+ public ExtUserUseridMap getExistingExtUserUseridMap(ExtServerOrgMap map, String loggedInAs)
+ throws UserInfoFetchException {
+ return integrationService.getExistingExtUserUseridMap(map, loggedInAs);
+ }
+
+ public User getUserByLogin(String login) {
+ return userManagementService.getUserByLogin(login);
+ }
+
+ public IIntegrationService getIntegrationService() {
+ return integrationService;
+ }
+
+ public void setIntegrationService(IIntegrationService integrationService) {
+ this.integrationService = integrationService;
+ }
+
+ public IUserManagementService getUserManagementService() {
+ return userManagementService;
+ }
+
+ public void setUserManagementService(IUserManagementService userManagementService) {
+ this.userManagementService = userManagementService;
+ }
+
+ public ILessonService getLessonService() {
+ return lessonService;
+ }
+
+ public void setLessonService(ILessonService lessonService) {
+ this.lessonService = lessonService;
+ }
+}
Index: lams_openid/src/java/org/lamsfoundation/lams/openid/service/LamsOpenIdServiceProxy.java
===================================================================
diff -u
--- lams_openid/src/java/org/lamsfoundation/lams/openid/service/LamsOpenIdServiceProxy.java (revision 0)
+++ lams_openid/src/java/org/lamsfoundation/lams/openid/service/LamsOpenIdServiceProxy.java (revision 2219e0e8fc391aa59813047d473f789334fbe057)
@@ -0,0 +1,75 @@
+/****************************************************************
+ * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+/* $$Id$$ */
+
+package org.lamsfoundation.lams.openid.service;
+
+import javax.servlet.ServletContext;
+
+import org.lamsfoundation.lams.tool.ToolContentManager;
+import org.lamsfoundation.lams.tool.ToolSessionManager;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ *
+ * This class act as the proxy between web layer and service layer. It is
+ * designed to decouple the presentation logic and business logic completely. In
+ * this way, the presentation tier will no longer be aware of the changes in
+ * service layer. Therefore we can feel free to switch the business logic
+ * implementation.
+ *
+ */
+
+public class LamsOpenIdServiceProxy {
+
+ public static final ILamsOpenIdService getLamsOpenIdService(ServletContext servletContext) {
+ return (ILamsOpenIdService) getLamsOpenIdDomainService(servletContext);
+ }
+
+ private static Object getLamsOpenIdDomainService(ServletContext servletContext) {
+ WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
+ return wac.getBean("lamsOpenIdService");
+ }
+
+ /*
+ * Return the LamsOpenId tool version of tool session manager implementation.
+ * It will delegate to the Spring helper method to retrieve the proper
+ * bean from Spring bean factory.
+ * @param servletContext the servletContext for current application
+ * @return openid service object.*/
+ public static final ToolSessionManager getLamsOpenIdSessionManager(ServletContext servletContext) {
+ return (ToolSessionManager) getLamsOpenIdDomainService(servletContext);
+ }
+
+ /*
+ * Return the LamsOpenId tool version of tool content manager implementation.
+ * It will delegate to the Spring helper method to retrieve the proper
+ * bean from Spring bean factory.
+ * @param servletContext the servletContext for current application
+ * @return openid service object. */
+ public static final ToolContentManager getLamsOpenIdContentManager(ServletContext servletContext) {
+ return (ToolContentManager) getLamsOpenIdDomainService(servletContext);
+ }
+
+}
Index: lams_openid/src/java/org/lamsfoundation/lams/openid/web/LamsOpenIdRegisterServlet.java
===================================================================
diff -u
--- lams_openid/src/java/org/lamsfoundation/lams/openid/web/LamsOpenIdRegisterServlet.java (revision 0)
+++ lams_openid/src/java/org/lamsfoundation/lams/openid/web/LamsOpenIdRegisterServlet.java (revision 2219e0e8fc391aa59813047d473f789334fbe057)
@@ -0,0 +1,180 @@
+/****************************************************************
+ * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id$ */
+package org.lamsfoundation.lams.openid.web;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+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.security.Authenticator;
+import org.lamsfoundation.lams.integration.util.LoginRequestDispatcher;
+import org.lamsfoundation.lams.openid.service.ILamsOpenIdService;
+import org.lamsfoundation.lams.openid.service.LamsOpenIdServiceProxy;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.util.CentralConstants;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.ConfigurationKeys;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * A special servlet for registering open id users
+ * User will be registered, put into an organisation and its lessons, then
+ * logged in
+ *
+ * @author lfoxton
+ *
+ */
+public class LamsOpenIdRegisterServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ private static Logger log = Logger.getLogger(LamsOpenIdRegisterServlet.class);
+
+ private ILamsOpenIdService openIdService = null;
+
+ /**
+ * The doGet method of the servlet.
+ *
+ * This method is called when a form has its tag value method equals to get.
+ *
+ * @param request
+ * the request send by the client to the server
+ * @param response
+ * the response send by the server to the client
+ * @throws ServletException
+ * if an error occurred
+ * @throws IOException
+ * if an error occurred
+ */
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ try {
+ openIdService = LamsOpenIdServiceProxy.getLamsOpenIdService(getServletContext());
+
+ HttpSession hses = request.getSession(true);
+
+ String extUsername = request.getParameter(LoginRequestDispatcher.PARAM_USER_ID);
+ String serverId = request.getParameter(LoginRequestDispatcher.PARAM_SERVER_ID);
+ String extCourseId = request.getParameter(LoginRequestDispatcher.PARAM_COURSE_ID);
+ String timestamp = request.getParameter(LoginRequestDispatcher.PARAM_TIMESTAMP);
+ String hash = request.getParameter(LoginRequestDispatcher.PARAM_HASH);
+ String method = request.getParameter(LoginRequestDispatcher.PARAM_METHOD);
+ String countryIsoCode = request.getParameter(LoginRequestDispatcher.PARAM_COUNTRY);
+ String langIsoCode = request.getParameter(LoginRequestDispatcher.PARAM_LANGUAGE);
+ String courseName = request.getParameter(CentralConstants.PARAM_COURSE_NAME);
+
+ // implicit login params
+ String firstName = request.getParameter(LoginRequestDispatcher.PARAM_FIRST_NAME);
+ String lastName = request.getParameter(LoginRequestDispatcher.PARAM_LAST_NAME);
+ String email = request.getParameter(LoginRequestDispatcher.PARAM_EMAIL);
+
+ if (extUsername == null || method == null || serverId == null || timestamp == null || hash == null
+ || extCourseId == null) {
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Login Failed - login parameters missing");
+ return;
+ }
+
+ // Get the server map using the server id
+ ExtServerOrgMap serverMap = openIdService.getExtServerOrgMap(serverId);
+ ExtUserUseridMap userMap = null;
+
+ // Authenticate the call using the hash
+ Authenticator.authenticate(serverMap, timestamp, extUsername, method, hash);
+
+ // get the user if it exists, otherwise greate it
+ if (firstName == null && lastName == null) {
+ userMap = openIdService.getExtUserUseridMap(serverMap, extUsername);
+ } else {
+ userMap = openIdService.getImplicitExtUserUseridMap(serverMap, extUsername, firstName, lastName,
+ langIsoCode, countryIsoCode, email);
+ }
+
+ // Get a handle on the user, userMap.getUser() was throwing hibernate errors
+ User user = openIdService.getUserByLogin(serverMap.getPrefix() + "_" + userMap.getExtUsername());
+ //User user = userMap.getUser();
+
+ // Invalidate the session if there is an existing session
+ String login = user.getLogin();
+ String loginRequestUsername = (String) hses.getAttribute("extUser");
+ if (loginRequestUsername != null && loginRequestUsername.equals(login)) {
+ hses.invalidate();
+ hses = request.getSession(true);
+ } else if (loginRequestUsername != null && !loginRequestUsername.equals(login)) {
+ hses.invalidate();
+ hses = request.getSession(true);
+ } else if (request.getRemoteUser() != null && loginRequestUsername == null) {
+ hses.invalidate();
+ hses = request.getSession(true);
+ }
+
+ // adding the user to the specified group
+ Boolean addToGroup = WebUtil.readBooleanParam(request, "addToGroup");
+ if (addToGroup != null && addToGroup == Boolean.TRUE) {
+ boolean addToGroupAsTeacher = WebUtil.readBooleanParam(request, "addToGroupAsTeacher", true);
+
+ ExtCourseClassMap orgMap = openIdService.addUserToGroup(extUsername, serverId, timestamp, hash, extCourseId, courseName,
+ countryIsoCode, langIsoCode, addToGroupAsTeacher);
+
+ if (orgMap != null) {
+
+ // Add the user to the specified group lessons
+ boolean addToGroupLessons = WebUtil.readBooleanParam(request, "addToGroupLessons", true);
+ if (addToGroupLessons) {
+ boolean addToGroupLessonsAsStaff = WebUtil.readBooleanParam(request,
+ "addToGroupLessonsAsStaff", true);
+ openIdService.addUserToGroupLessons(extUsername, serverId, timestamp, hash, extCourseId, courseName,
+ countryIsoCode, langIsoCode, addToGroupLessonsAsStaff, orgMap);
+ }
+ }
+ }
+
+ log.debug("Session Id - " + hses.getId());
+
+ // connect to DB and get password here
+ String pass = openIdService.getUserPassword(userMap.getUser().getLogin());
+
+ // Put the user info in the session
+ hses.setAttribute("extUser", login);
+ hses.setAttribute(AttributeNames.USER, user.getUserDTO());
+
+ // Send redirect to the login action
+ response.sendRedirect(Configuration.get(ConfigurationKeys.SERVER_URL) + "j_security_check?j_username=" + URLEncoder.encode(login, "UTF8") + "&j_password=" + pass);
+ } catch (Exception e) {
+ log.error("Error registering user in OpenID", e);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ }
+ }
+}
Index: lams_openid/src/java/org/lamsfoundation/lams/openid/web/LamsOpenIdServlet.java
===================================================================
diff -u -r29546ca4b5a3f8426cd68af3e9022cf57f36037e -r2219e0e8fc391aa59813047d473f789334fbe057
--- lams_openid/src/java/org/lamsfoundation/lams/openid/web/LamsOpenIdServlet.java (.../LamsOpenIdServlet.java) (revision 29546ca4b5a3f8426cd68af3e9022cf57f36037e)
+++ lams_openid/src/java/org/lamsfoundation/lams/openid/web/LamsOpenIdServlet.java (.../LamsOpenIdServlet.java) (revision 2219e0e8fc391aa59813047d473f789334fbe057)
@@ -24,6 +24,7 @@
package org.lamsfoundation.lams.openid.web;
import java.io.IOException;
+import java.net.URLEncoder;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -34,36 +35,39 @@
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.integration.ExtServerOrgMap;
import org.lamsfoundation.lams.integration.ExtUserUseridMap;
-import org.lamsfoundation.lams.integration.service.IIntegrationService;
-import org.lamsfoundation.lams.integration.service.IntegrationService;
+import org.lamsfoundation.lams.integration.security.Authenticator;
import org.lamsfoundation.lams.integration.util.LoginRequestDispatcher;
+import org.lamsfoundation.lams.openid.service.ILamsOpenIdService;
+import org.lamsfoundation.lams.openid.service.LamsOpenIdServiceProxy;
+import org.lamsfoundation.lams.usermanagement.User;
import org.lamsfoundation.lams.util.CentralConstants;
import org.lamsfoundation.lams.util.Configuration;
import org.lamsfoundation.lams.util.ConfigurationKeys;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.lamsfoundation.lams.web.util.AttributeNames;
import org.verisign.joid.consumer.OpenIdFilter;
/**
* A special servlet for the openid management. This servlet manages requests
* from openID servlets to login. If the user exists in lams, then it will log
- * them in, otherwise they will be sent to the register page with any
- * user information released by open id populating the page.
+ * them in, otherwise they will be sent to the register page with any user
+ * information released by open id populating the page.
*
* @author lfoxton
- *
+ *
*/
public class LamsOpenIdServlet extends HttpServlet {
private static final long serialVersionUID = -3815302208768159008L;
private static Logger log = Logger.getLogger(LamsOpenIdServlet.class);
- private static IntegrationService integrationService = null;
+ private ILamsOpenIdService openIdService = null;
- private static final String LOGIN_REQUEST_SERVLET_URL = Configuration.get(ConfigurationKeys.SERVER_URL) + "/LoginRequest?";
- private static final String REGISTER_URL = Configuration.get(ConfigurationKeys.SERVER_URL) + "/openid/register_openid.jsp?";
-
+ private static final String LOGIN_REQUEST_SERVLET_URL = Configuration.get(ConfigurationKeys.SERVER_URL)
+ + "/LoginRequest?";
+ private static final String REGISTER_URL = Configuration.get(ConfigurationKeys.SERVER_URL)
+ + "/openid/register_openid.jsp?";
+
/**
* The doGet method of the servlet.
*
@@ -77,89 +81,69 @@
* if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
+
+ openIdService = LamsOpenIdServiceProxy.getLamsOpenIdService(getServletContext());
+
HttpSession session = request.getSession(true);
-
+
String loggedInAs = OpenIdFilter.getCurrentUser(session);
// First check that openid login was successful
- if (loggedInAs == null)
- {
+ if (loggedInAs == null) {
log.error("Did not get a user from open id");
throw new ServletException("Did not get a user from open id");
}
//String extUsername = request.getParameter(LoginRequestDispatcher.PARAM_USER_ID);
String serverId = request.getParameter(LoginRequestDispatcher.PARAM_SERVER_ID);
- String extCourseId = request.getParameter(LoginRequestDispatcher.PARAM_COURSE_ID);
+ //String extCourseId = request.getParameter(LoginRequestDispatcher.PARAM_COURSE_ID);
String timestamp = request.getParameter(LoginRequestDispatcher.PARAM_TIMESTAMP);
String hash = request.getParameter(LoginRequestDispatcher.PARAM_HASH);
String method = request.getParameter(LoginRequestDispatcher.PARAM_METHOD);
- String countryIsoCode = request.getParameter(LoginRequestDispatcher.PARAM_COUNTRY);
- String langIsoCode = request.getParameter(LoginRequestDispatcher.PARAM_LANGUAGE);
- String courseName = request.getParameter(CentralConstants.PARAM_COURSE_NAME);
+ //String countryIsoCode = request.getParameter(LoginRequestDispatcher.PARAM_COUNTRY);
+ //String langIsoCode = request.getParameter(LoginRequestDispatcher.PARAM_LANGUAGE);
+ //String courseName = request.getParameter(CentralConstants.PARAM_COURSE_NAME);
try {
- ExtServerOrgMap serverMap = getIntegrationService().getExtServerOrgMap(serverId);
-
- ExtUserUseridMap userMap = getIntegrationService().getExistingExtUserUseridMap(serverMap, loggedInAs);
-
- if (userMap == null)
- {
+ ExtServerOrgMap serverMap = openIdService.getExtServerOrgMap(serverId);
+
+ ExtUserUseridMap userMap = openIdService.getExistingExtUserUseridMap(serverMap, loggedInAs);
+
+ Authenticator.authenticate(serverMap, timestamp, loggedInAs, method, hash);
+
+ if (userMap == null) {
String registerURL = REGISTER_URL;
registerURL += "&openid_url=" + loggedInAs;
response.sendRedirect(registerURL);
- }
- else
- {
+ } else {
// User exists, do login
- String loginRequestURL = LOGIN_REQUEST_SERVLET_URL;
- loginRequestURL += "&uid=" + loggedInAs;
- loginRequestURL += "&method=" + method;
- loginRequestURL += "&ts=" + timestamp;
- loginRequestURL += "&sid=" + serverId;
- loginRequestURL += "&hash=" + hash;
- loginRequestURL += "&courseid=" + extCourseId;
- loginRequestURL += "&country=" + countryIsoCode;
- loginRequestURL += "&lang=" + langIsoCode;
- loginRequestURL += "&courseName=" + courseName;
- loginRequestURL += "&requestSrc=¬ifyCloseURL=&lsid=";
- response.sendRedirect(loginRequestURL);
+ User user = openIdService.getUserByLogin(serverMap.getPrefix() + "_" + loggedInAs);
+
+ // Invalidate the session if there is one already existing
+ String loginRequestUsername = (String) session.getAttribute("extUser");
+ if (loginRequestUsername != null && loginRequestUsername.equals(loggedInAs)) {
+ session.invalidate();
+ session = request.getSession(true);
+ } else if (loginRequestUsername != null && !loginRequestUsername.equals(loggedInAs)) {
+ session.invalidate();
+ session = request.getSession(true);
+ } else if (request.getRemoteUser() != null && loginRequestUsername == null) {
+ session.invalidate();
+ session = request.getSession(true);
+ }
+
+ session.setAttribute("extUser", loggedInAs);
+ session.setAttribute(AttributeNames.USER, user.getUserDTO());
+
+ // Get the user password from the database
+ String pass = openIdService.getUserPassword(user.getLogin());
+ response.sendRedirect(Configuration.get(ConfigurationKeys.SERVER_URL) + "j_security_check?j_username="
+ + URLEncoder.encode(user.getLogin(), "UTF8") + "&j_password=" + pass);
}
-
+
} catch (Exception e) {
log.error("Open ID login error: ", e);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
}
}
-
- /**
- * TODO: Use spring injection instead of hacking a context
- *
- * @return
- */
- public IIntegrationService getIntegrationService() throws Exception{
-
- if (integrationService == null) {
- String contexts[] = { "/org/lamsfoundation/lams/applicationContext.xml",
- "/org/lamsfoundation/lams/lesson/lessonApplicationContext.xml",
- "/org/lamsfoundation/lams/toolApplicationContext.xml",
- "/org/lamsfoundation/lams/integrationContext.xml",
- "/org/lamsfoundation/lams/learning/learningApplicationContext.xml",
- "/org/lamsfoundation/lams/contentrepository/applicationContext.xml",
- "/org/lamsfoundation/lams/commonContext.xml" };
-
- ApplicationContext context = new ClassPathXmlApplicationContext(contexts);
-
- if (context == null)
- throw new Exception("Unable to access application context. Cannot create integration service object.");
-
- IIntegrationService service = (IIntegrationService) context.getBean("integrationService");
- return service;
- } else {
- return integrationService;
- }
- }
}
-
-
Index: lams_openid/web/WEB-INF/web.xml
===================================================================
diff -u -r29546ca4b5a3f8426cd68af3e9022cf57f36037e -r2219e0e8fc391aa59813047d473f789334fbe057
--- lams_openid/web/WEB-INF/web.xml (.../web.xml) (revision 29546ca4b5a3f8426cd68af3e9022cf57f36037e)
+++ lams_openid/web/WEB-INF/web.xml (.../web.xml) (revision 2219e0e8fc391aa59813047d473f789334fbe057)
@@ -1,23 +1,65 @@
-
-
+
+
+ contextConfigLocation
+
+ classpath:/org/lamsfoundation/lams/applicationContext.xml
+ classpath:/org/lamsfoundation/lams/toolApplicationContext.xml
+ classpath:/org/lamsfoundation/lams/contentrepository/applicationContext.xml
+ classpath:/org/lamsfoundation/lams/authoring/authoringApplicationContext.xml
+ classpath:/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml
+ classpath:/org/lamsfoundation/lams/workspace/workspaceApplicationContext.xml
+ classpath:/org/lamsfoundation/lams/web/webApplicationContext.xml
+ classpath:/org/lamsfoundation/lams/integrationContext.xml
+ classpath:/org/lamsfoundation/lams/usermanagement/ldapContext.xml
+ classpath:/org/lamsfoundation/lams/lesson/lessonApplicationContext.xml
+ classpath:/org/lamsfoundation/lams/learning/learningApplicationContext.xml
+ classpath:/org/lamsfoundation/lams/openid/openIdApplicationContext.xml
+
+
+
+ SystemSessionFilter
+
+ org.lamsfoundation.lams.web.session.SystemSessionFilter
+
+
+
+ HibernateFilter
+
+ org.lamsfoundation.lams.util.CustomizedOpenSessionInViewFilter
+
+
+ sessionFactoryBeanName
+ coreSessionFactory
+
+
+ singleSession
+ true
+
+
+
+
+ SystemSessionFilter
+ /*
+
+
+ HibernateFilter
+ /*
+
+
+ OpenIdFilter
-
- This filter (for Consumer side) automatically parses OpenID
- responses and sets the user's identity in the session.
-
org.verisign.joid.consumer.OpenIdFilter
saveInCookietrue
-
- Optional. Will store the identity url in a cookie under
- "openid.identity" if set to true.
-
+
+
+ org.springframework.web.context.ContextLoaderListener
+
+
+
+
+ org.lamsfoundation.lams.web.session.SetMaxTimeoutListener
+
+
+
+
LoginUsingOpenId
- LoginUsingOpenId Servlet For OpenID
org.lamsfoundation.lams.openid.web.LamsOpenIdServlet
@@ -138,13 +180,18 @@
LoginUsingOpenId/LoginUsingOpenId
-
-
- contextConfigLocation
-
- classpath:/org/lamsfoundation/lams/integrationContext.xml
-
-
+
+ RegisterOpenId
+
+ org.lamsfoundation.lams.openid.web.LamsOpenIdRegisterServlet
+
+
+
+
+ RegisterOpenId
+ /RegisterOpenId
+
+
Index: lams_openid/web/config.jsp
===================================================================
diff -u -r29546ca4b5a3f8426cd68af3e9022cf57f36037e -r2219e0e8fc391aa59813047d473f789334fbe057
--- lams_openid/web/config.jsp (.../config.jsp) (revision 29546ca4b5a3f8426cd68af3e9022cf57f36037e)
+++ lams_openid/web/config.jsp (.../config.jsp) (revision 2219e0e8fc391aa59813047d473f789334fbe057)
@@ -5,9 +5,16 @@
final String LAMS_SERVER_URL = "http://172.20.100.188:8080/lams";
final String LAMS_SERVER_ID ="demolamsserver";
final String LAMS_SERVER_KEY = "ixybitzy";
- final boolean ADD_TO_GROUP = true;
- final String GROUP_ID = "Playpen";
- final String GROUP_NAME = "Playpen";
+ final boolean ADD_TO_GROUP =true;
+ final boolean GROUP_ADD_AS_TEACHER = true;
+ final boolean ADD_TO_GROUP_LESSONS = true;
+ final boolean ADD_TO_GROUP_LESSONS_AS_STAFF = false;
+ //final boolean ADD_TO_SUBGROUP = true;
+ //final boolean SUBGROUP_ADD_AS_TEACHER = false;
+ //final boolean ADD_TO_SUBGROUP_LESSONS = true;
+ //final boolean ADD_TO_SUBGROUP_LESSONS_AS_STAFF = false;
+ final String GROUP_ID = "Demo Course A";
+ final String GROUP_NAME = "Demo Course A";
final String GROUP_COUNTRY_ISO_CODE = "AU";
final String GROUP_LANG_ISO_CODE = "en";
final String[] TRUSTED_OPENID_PROVIDERS = {
Index: lams_openid/web/register.jsp
===================================================================
diff -u
--- lams_openid/web/register.jsp (revision 0)
+++ lams_openid/web/register.jsp (revision 2219e0e8fc391aa59813047d473f789334fbe057)
@@ -0,0 +1,312 @@
+
+<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
+<%@ page import="org.apache.axis.client.Call" %>
+<%@ page import="org.apache.axis.client.Service" %>
+<%@ page import="java.util.ArrayList" %>
+<%@ page import="java.util.Date" %>
+<%@ page import="org.lamsfoundation.lams.util.HashUtil" %>
+<%@ page import="org.lamsfoundation.lams.util.Emailer" %>
+<%@ page import="org.lamsfoundation.lams.util.Configuration" %>
+<%@ page import="org.lamsfoundation.lams.util.ConfigurationKeys" %>
+
+
+
+
+<%
+ //final String LAMS_SERVER_URL = "http://demo.lamscommunity.org/lams";
+ final String LAMS_SERVER_NAME = "LAMS 2 Demo Server";
+ final String LAMS_SERVER_URL = "http://172.20.100.188:8080/lams";
+ final String LAMS_SERVICE = LAMS_SERVER_URL + "/services/RegisterService?wsdl";
+ final String LAMS_SERVER_ID ="demolamsserver";
+ final String LAMS_SERVER_KEY ="ixybitzy";
+ final boolean ADD_TO_GROUP =true;
+ final boolean GROUP_ADD_AS_TEACHER = true;
+ final boolean ADD_TO_GROUP_LESSONS = true;
+ final boolean ADD_TO_GROUP_LESSONS_AS_STAFF = false;
+ final boolean ADD_TO_SUBGROUP = true;
+ final boolean SUBGROUP_ADD_AS_TEACHER = false;
+ final boolean ADD_TO_SUBGROUP_LESSONS = true;
+ final boolean ADD_TO_SUBGROUP_LESSONS_AS_STAFF = false;
+ final boolean EMAIL_USER = true;
+ final String GROUP_ID = "Playpen";
+ final String GROUP_NAME = "Playpen";
+ final String GROUP_COUNTRY_ISO_CODE = "AU";
+ final String GROUP_LANG_ISO_CODE = "en";
+
+ String userName = request.getParameter("username");
+ Boolean registered = new Boolean(false);
+ Boolean registerAttempt = new Boolean(false);
+ Boolean addedToGroup = new Boolean(false);
+ Boolean addedToGroupLessons = new Boolean(false);
+ Boolean addedToSubGroup = new Boolean(false);
+ Boolean addedToSubGroupLessons = new Boolean(false);
+ ArrayList errors = new ArrayList();
+
+ if (userName != null && !userName.equals(""))
+ {
+ registerAttempt = Boolean.TRUE;
+ String passwordOrig = request.getParameter("password");
+ String password = HashUtil.sha1(passwordOrig);
+ String firstName = request.getParameter("firstname");
+ String lastName = request.getParameter("lastname");
+ String email = request.getParameter("email");
+ String timestamp = "" + new Date().getTime();
+ String plaintext = timestamp + LAMS_SERVER_ID + LAMS_SERVER_KEY;
+ String hash = HashUtil.sha1(plaintext.toLowerCase());
+
+ try
+ {
+ Service service = new Service();
+ Call call = (Call) service.createCall();
+ call.setTargetEndpointAddress( new java.net.URL(LAMS_SERVICE) );
+
+ // register the user
+ String[] registerParams = new String[] {userName, password, firstName, lastName, email, LAMS_SERVER_ID, timestamp, hash};
+ registered = (Boolean)call.invoke("createUser", registerParams);
+
+ // add user to a group
+ if(ADD_TO_GROUP)
+ {
+ Object[] groupParams = new Object[] {userName, LAMS_SERVER_ID, timestamp, hash, GROUP_ID, GROUP_NAME, GROUP_COUNTRY_ISO_CODE, GROUP_LANG_ISO_CODE, new Boolean(GROUP_ADD_AS_TEACHER)};
+ addedToGroup = (Boolean)call.invoke("addUserToGroup", groupParams);
+ System.out.println("GROUP ADDED: " + addedToGroup.toString());
+
+ if (addedToGroup == Boolean.TRUE)
+ {
+ // email registered user if enabled
+ if (EMAIL_USER && Configuration.get(ConfigurationKeys.SMTP_SERVER) != null
+ && !Configuration.get(ConfigurationKeys.SMTP_SERVER).equals(""))
+ {
+ //public static void sendFromSupportEmail(String subject, String to, String body)
+ String message = "Congratulations " + firstName + " " + lastName + "! You have been registered to " + LAMS_SERVER_NAME;
+ message += "\n\nYour details are:";
+ message += "\nUsername: " + userName;
+ message += "\nPassword: " + passwordOrig;
+ message += "\nFirst name: " + firstName;
+ message += "\nLast name: " + lastName;
+ message += "\nEmail: " + email;
+ message += "\n\nYou can now log at " + LAMS_SERVER_URL + " using this username.";
+ Emailer.sendFromSupportEmail("Registered at " + LAMS_SERVER_NAME, email, message);
+ }
+
+ // add user to lessons group
+ if(ADD_TO_GROUP_LESSONS)
+ {
+ Object[] groupLessonsParams = new Object[] {userName, LAMS_SERVER_ID, timestamp, hash, GROUP_ID, GROUP_NAME, GROUP_COUNTRY_ISO_CODE, GROUP_LANG_ISO_CODE, new Boolean(ADD_TO_GROUP_LESSONS_AS_STAFF)};
+ addedToGroupLessons = (Boolean)call.invoke("addUserToGroupLessons", groupLessonsParams);
+ System.out.println("GROUP LESSONS ADDED: " + addedToGroupLessons.toString());
+
+ if (addedToGroupLessons == Boolean.FALSE)
+ {
+ errors.add("Your account could not be added to the group's lessons.");
+ }
+ }
+
+ // add user to subgroup
+ if (ADD_TO_SUBGROUP)
+ {
+ // $parameters = array($username,LAMS_SERVER_ID,$datetime,$hash,$courseId,$courseName,$countryIsoCode,$langIsoCode,$subgroupId,$subgroupName,SUBGROUP_ADD_AS_TEACHER);
+ Object[] subGroupParams = new Object[] {userName, LAMS_SERVER_ID, timestamp, hash, GROUP_ID, GROUP_NAME, GROUP_COUNTRY_ISO_CODE, GROUP_LANG_ISO_CODE, GROUP_NAME + " subgroup", GROUP_NAME + " subgroup", new Boolean(SUBGROUP_ADD_AS_TEACHER)};
+ addedToSubGroup = (Boolean)call.invoke("addUserToSubgroup", subGroupParams);
+ System.out.println("SUBGROUP ADDED: " + addedToSubGroup.toString());
+
+ // add user to subgroup lessons
+ if (addedToSubGroup == Boolean.TRUE)
+ {
+ if (ADD_TO_SUBGROUP_LESSONS) {
+ // $parameters = array($username,LAMS_SERVER_ID,$datetime,$hash,$courseId,$courseName,$countryIsoCode,$langIsoCode,$subgroupId,$subgroupName,ADD_TO_SUBGROUP_LESSONS_AS_STAFF);
+ Object[] subGroupLessonsParams = new Object[] {userName, LAMS_SERVER_ID, timestamp, hash, GROUP_ID, GROUP_NAME, GROUP_COUNTRY_ISO_CODE, GROUP_LANG_ISO_CODE, GROUP_NAME + " subgroup", GROUP_NAME + " subgroup", new Boolean(ADD_TO_SUBGROUP_LESSONS_AS_STAFF)};
+ addedToSubGroupLessons = (Boolean)call.invoke("addUserToSubgroupLessons", subGroupLessonsParams);
+ System.out.println("SUBGROUP LESSONS ADDED: " + addedToSubGroupLessons.toString());
+
+ if (addedToSubGroupLessons == Boolean.FALSE)
+ {
+ errors.add("Your account could not be added to your tutorial's lessons.");
+ }
+ }
+ }
+ else
+ {
+ errors.add("Your account could not be added to your tutorial group.");
+ }
+ }
+ }
+ else{
+ errors.add("Your account could not be added to the group.");
+ }
+ }
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+%>
+
+
+
+
+
+ Register - LAMS :: Learning Activity Management System
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%
+ if(registered == Boolean.TRUE){
+ %>
+
+ Congratulations <%=userName %>, you have been successfully registered!
+
+ Click here to continue to the login page.
+
+
+
+ <%
+ if(errors.size() > 0){
+ %>
+
+ You have been registered, but there has been a few errors adding you to groups, please go to http://lamscommunity.org for support.
+
+
+ Errors:
+ <%
+ for(int i=0; i" + errors.get(i) + "");
+ }
+ %>
+ <%
+ }
+ %>
+ <%
+ }else{
+ if (registerAttempt == Boolean.TRUE){
+ %>
+
+ Registration failed, the user credentials may already exist. Please try again with a different username.
+
+ <%} %>
+
+
Sign up to the <%=LAMS_SERVER_NAME %>
+
+
+
+ Just by completing this form, you can register and test LAMS as Teacher, Monitor and Learner.
+ You'll be assigned to a Course where you can create sequences, assign them to your students, monitor their progress
+ and participate in them as well. New to LAMS? No worries, have a look at
+ these animations.
+
+
+ If you already have an account, please proceed to the login page.
+