Index: lams_central/conf/xdoclet/servlet-mappings.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/xdoclet/servlet-mappings.xml,v diff -u -r1.12.2.3 -r1.12.2.4 --- lams_central/conf/xdoclet/servlet-mappings.xml 7 Jun 2007 02:12:31 -0000 1.12.2.3 +++ lams_central/conf/xdoclet/servlet-mappings.xml 26 Jul 2007 03:46:13 -0000 1.12.2.4 @@ -34,6 +34,21 @@ + ShibLearnerServlet + /shiblearner + + + + ShibMonitorServlet + /shibmonitor + + + + ShibExportPortfolioServlet + /shibexportportfolio + + + FederationGroups /federation/groups Index: lams_central/conf/xdoclet/servlets.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/xdoclet/servlets.xml,v diff -u -r1.14.2.4 -r1.14.2.5 --- lams_central/conf/xdoclet/servlets.xml 7 Jun 2007 02:12:31 -0000 1.14.2.4 +++ lams_central/conf/xdoclet/servlets.xml 26 Jul 2007 03:46:13 -0000 1.14.2.5 @@ -70,6 +70,30 @@ + ShibLearnerServlet + ShibLearner Servlet For Shibboleth Users + + org.lamsfoundation.lams.web.ShibLearnerServlet + + + + + ShibMonitorServlet + ShibMonitorServlet Servlet For Shibboleth Users + + org.lamsfoundation.lams.web.ShibMonitorServlet + + + + + ShibExportPortfolioServlet + ShibExportPortfolioServlet Servlet For Shibboleth Users + + org.lamsfoundation.lams.web.ShibExportPortfolioServlet + + + + FederationGroups org.gomba.XMLServlet Index: lams_central/conf/xdoclet/web-security.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/xdoclet/web-security.xml,v diff -u -r1.10.2.1 -r1.10.2.2 --- lams_central/conf/xdoclet/web-security.xml 7 Jun 2007 02:12:31 -0000 1.10.2.1 +++ lams_central/conf/xdoclet/web-security.xml 26 Jul 2007 03:46:13 -0000 1.10.2.2 @@ -7,6 +7,8 @@ *.do /servlet/* /fckeditor/* + /shiblearner + /shibexportportfolio LEARNER @@ -34,6 +36,7 @@ Staff Content /monitoring.do + /shibmonitor MONITOR Index: lams_central/src/java/org/lamsfoundation/lams/web/ShibExportPortfolioServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/Attic/ShibExportPortfolioServlet.java,v diff -u -r1.1.2.3 -r1.1.2.4 --- lams_central/src/java/org/lamsfoundation/lams/web/ShibExportPortfolioServlet.java 26 Jul 2007 01:39:48 -0000 1.1.2.3 +++ lams_central/src/java/org/lamsfoundation/lams/web/ShibExportPortfolioServlet.java 26 Jul 2007 03:46:13 -0000 1.1.2.4 @@ -23,80 +23,24 @@ import java.io.IOException; import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; -import org.lamsfoundation.lams.federation.service.IFederationService; -import org.lamsfoundation.lams.lesson.Lesson; -import org.lamsfoundation.lams.lesson.LessonClass; -import org.lamsfoundation.lams.lesson.service.ILessonService; -import org.lamsfoundation.lams.usermanagement.Role; -import org.lamsfoundation.lams.usermanagement.User; -import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; -import org.lamsfoundation.lams.util.Configuration; -import org.lamsfoundation.lams.util.ConfigurationKeys; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.WebApplicationContextUtils; /** * @author jliew * - * @web:servlet name="ShibExportPortfolioServlet" load-on-startup="1" - * @web:servlet-mapping url-pattern="/shibexportportfolio" */ -public class ShibExportPortfolioServlet extends HttpServlet { +public class ShibExportPortfolioServlet extends ShibLearnerServlet { private static Logger log = Logger.getLogger(ShibExportPortfolioServlet.class); - private static IUserManagementService service; - private static ILessonService lessonService; - private static IFederationService fedService; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); - if(lessonService==null){ - lessonService = (ILessonService) ctx.getBean("lessonService"); - } - if(service==null){ - service = (IUserManagementService) ctx.getBean("userManagementServiceTarget"); - } - if(fedService==null){ - fedService = (IFederationService) ctx.getBean("federationService"); - } + String lessonIdStr = addLearnerToLesson(request, response); - String lessonIdStr = request.getParameter("lessonID"); - Long lessonId = Long.parseLong(lessonIdStr); - - String roles = request.getHeader(Configuration.get(ConfigurationKeys.SHIB_ATTR_ROLES)); - String username = request.getHeader(Configuration.get(ConfigurationKeys.SHIB_ATTR_LOGIN)); - String originServerURL = request.getHeader(Configuration.get(ConfigurationKeys.SHIB_ATTR_SERVER_URL)); - - // add this shib user to lesson as learner if they have learner role and are not already a member - // TODO check this shib user's fed server id and org id against this server's shared lessons in lams_fed_lesson - User user = null; - if (roles != null && roles.indexOf(Role.LEARNER)>0) { - try { - String localUsername = fedService.getLocalUsername(username, originServerURL); - user = service.getUserByLogin(localUsername); - } catch (Exception e) { - log.error("Couldn't get local user from shib username "+username); - } - Lesson lesson = lessonId != null ? lessonService.getLesson(lessonId) : null; - if (lesson != null) { - LessonClass lessonClass = lesson.getLessonClass(); - if (user != null && lessonClass != null && !lessonClass.getLearners().contains(user)) { - if (lessonService.addLearner(lessonId, user.getUserId())) { - log.info("Added shib user "+user.getLogin()+" as learner to lesson with id "+lessonIdStr); - } - } - } - } else { - log.warn("Shib user "+username+" tried to access export portfolio without "+Role.LEARNER+" role."); - } - response.sendRedirect("/lams/learning/exportWaitingPage.jsp?mode=learner&lessonID="+lessonIdStr); } Index: lams_central/src/java/org/lamsfoundation/lams/web/ShibLearnerServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/Attic/ShibLearnerServlet.java,v diff -u -r1.1.2.6 -r1.1.2.7 --- lams_central/src/java/org/lamsfoundation/lams/web/ShibLearnerServlet.java 24 Jul 2007 04:08:50 -0000 1.1.2.6 +++ lams_central/src/java/org/lamsfoundation/lams/web/ShibLearnerServlet.java 26 Jul 2007 03:46:13 -0000 1.1.2.7 @@ -43,8 +43,6 @@ /** * @author jliew * - * @web:servlet name="ShibLearnerServlet" load-on-startup="1" - * @web:servlet-mapping url-pattern="/shiblearner" */ public class ShibLearnerServlet extends HttpServlet { @@ -53,9 +51,7 @@ private static ILessonService lessonService; private static IFederationService fedService; - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - + protected String addLearnerToLesson(HttpServletRequest request, HttpServletResponse response) { WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); if(lessonService==null){ lessonService = (ILessonService) ctx.getBean("lessonService"); @@ -87,17 +83,36 @@ Lesson lesson = lessonId != null ? lessonService.getLesson(lessonId) : null; if (lesson != null) { LessonClass lessonClass = lesson.getLessonClass(); - if (user != null && lessonClass != null && !lessonClass.getLearners().contains(user)) { - boolean result = lessonService.addLearner(lessonId, user.getUserId()); - if (result) { - log.info("Added shib user "+user.getLogin()+" as learner to lesson with id "+lessonIdStr); + if (user != null) { + if (lessonClass != null) { + if (!lessonClass.getLearners().contains(user)) { + if (lessonService.addLearner(lessonId, user.getUserId())) { + log.info("Added shib user "+user.getLogin()+" as learner to lesson with id "+lessonIdStr); + } + } else { + log.info("User "+user.getLogin()+" is already a learner in the lesson."); + } + } else { + log.warn("Didn't get LessonClass from Lesson with id="+lessonIdStr+", user may not be added as learner."); } + } else { + log.warn("Didn't get User for shib user "+username+", user may not be added as learner."); } + } else { + log.warn("Didn't get Lesson with lessonID="+lessonIdStr+", user may not be added as learner."); } } else { log.warn("Shib user "+username+" tried to access learner without "+Role.LEARNER+" role."); } + return lessonIdStr; + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + String lessonIdStr = addLearnerToLesson(request, response); + response.sendRedirect("/lams/home.do?method=learner&lessonID="+lessonIdStr); } Index: lams_central/src/java/org/lamsfoundation/lams/web/ShibMonitorServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/Attic/ShibMonitorServlet.java,v diff -u -r1.1.2.3 -r1.1.2.4 --- lams_central/src/java/org/lamsfoundation/lams/web/ShibMonitorServlet.java 26 Jul 2007 01:39:48 -0000 1.1.2.3 +++ lams_central/src/java/org/lamsfoundation/lams/web/ShibMonitorServlet.java 26 Jul 2007 03:46:13 -0000 1.1.2.4 @@ -42,9 +42,7 @@ /** * @author jliew - * - * @web:servlet name="ShibMonitorServlet" load-on-startup="1" - * @web:servlet-mapping url-pattern="/shibmonitor" + * */ public class ShibMonitorServlet extends HttpServlet { @@ -87,11 +85,23 @@ Lesson lesson = lessonId != null ? lessonService.getLesson(lessonId) : null; if (lesson != null) { LessonClass lessonClass = lesson.getLessonClass(); - if (user != null && lessonClass != null && !lessonClass.isStaffMember(user)) { - if (lessonService.addStaffMember(lessonId, user.getUserId())) { - log.info("Added shib user "+user.getLogin()+" as staff to lesson with id "+lessonIdStr); + if (user != null) { + if (lessonClass != null) { + if (!lessonClass.isStaffMember(user)) { + if (lessonService.addStaffMember(lessonId, user.getUserId())) { + log.info("Added shib user "+user.getLogin()+" as staff to lesson with id "+lessonIdStr); + } + } else { + log.info("User "+user.getLogin()+" is already a staff member in the lesson."); + } + } else { + log.warn("Didn't get LessonClass from Lesson with id="+lessonIdStr+", user may not be added as staff."); } + } else { + log.warn("Didn't get User for shib user "+username+", user may not be added as staff."); } + } else { + log.warn("Didn't get Lesson with lessonID="+lessonIdStr+", user may not be added as staff."); } } else { log.warn("Shib user "+username+" tried to access monitor without "+Role.MONITOR+" role.");