Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources.properties,v diff -u -r1.1.2.1 -r1.1.2.2 --- lams_central/conf/language/lams/ApplicationResources.properties 12 Mar 2007 01:17:23 -0000 1.1.2.1 +++ lams_central/conf/language/lams/ApplicationResources.properties 20 Apr 2007 06:04:20 -0000 1.1.2.2 @@ -180,6 +180,6 @@ flash.min.error =The Flash Player plugin version 7 or higher is required. flash.download.player =Download Flash Player audit.user.password.change =Password changed for: {0} +shibboleth.username.taken = Shibboleth username taken - #======= End labels: Exported 174 labels for en AU ===== Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources_en_AU.properties,v diff -u -r1.1.2.1 -r1.1.2.2 --- lams_central/conf/language/lams/ApplicationResources_en_AU.properties 12 Mar 2007 01:17:22 -0000 1.1.2.1 +++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties 20 Apr 2007 06:04:21 -0000 1.1.2.2 @@ -180,6 +180,7 @@ flash.min.error =The Flash Player plugin version 7 or higher is required. flash.download.player =Download Flash Player audit.user.password.change =Password changed for: {0} +shibboleth.username.taken = Shibboleth username taken #======= End labels: Exported 174 labels for en AU ===== Index: lams_central/src/java/org/lamsfoundation/lams/web/ShibLoginServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/Attic/ShibLoginServlet.java,v diff -u -r1.1.2.3 -r1.1.2.4 --- lams_central/src/java/org/lamsfoundation/lams/web/ShibLoginServlet.java 19 Apr 2007 06:51:38 -0000 1.1.2.3 +++ lams_central/src/java/org/lamsfoundation/lams/web/ShibLoginServlet.java 20 Apr 2007 06:04:21 -0000 1.1.2.4 @@ -35,7 +35,6 @@ import org.lamsfoundation.lams.usermanagement.service.UserManagementService; 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; /** @@ -71,12 +70,16 @@ String header = (String)headers.nextElement(); log.debug("Request header: "+header+" has value: "+request.getHeader(header)); } - log.debug("request.getPathInfo: "+request.getPathInfo()); log.debug("request.getContextPath: "+request.getContextPath()); - // get header name based on sysadmin's configuration + // get shib attributes based on sysadmin's configuration of shib header names String username = request.getHeader(Configuration.get(ConfigurationKeys.SHIB_ATTR_LOGIN)); + String firstname = request.getHeader(Configuration.get(ConfigurationKeys.SHIB_ATTR_FNAME)); + String lastname = request.getHeader(Configuration.get(ConfigurationKeys.SHIB_ATTR_LNAME)); + String roles = request.getHeader(Configuration.get(ConfigurationKeys.SHIB_ATTR_ROLES)); + + if (username != null && username.trim().length()>0) { User user = service.getUserByLogin(username); if (user != null) { @@ -85,7 +88,7 @@ if (user.getAuthenticationMethod().equals(service.findById(AuthenticationMethod.class, AuthenticationMethod.SHIBBOLETH))) { response.sendRedirect("j_security_check?j_username="+username+"&j_password=dummy"); } else { - //log.error("Shib username appears to already exist on LAMS system!"); + log.info("Shib username already exists and isn't set to authenticate via Shibboleth - redirecting user to login page."); // flag so that login.jsp knows not to redirect user to this servlet again request.getSession().setAttribute("shibLoginExists", "true"); response.sendRedirect("/lams/"); @@ -96,8 +99,16 @@ user = new User(); user.setLogin(username); user.setPassword("dummy"); - user.setFirstName(username); - user.setLastName(username); + if (firstname != null && firstname.trim().length()>0) { + user.setFirstName(firstname); + } else { + user.setFirstName(username); + } + if (lastname != null && lastname.trim().length()>0) { + user.setLastName(lastname); + } else { + user.setLastName(username); + } user.setEmail(username); user.setAuthenticationMethod((AuthenticationMethod) service.findById(AuthenticationMethod.class, AuthenticationMethod.SHIBBOLETH)); @@ -114,10 +125,12 @@ response.sendRedirect("j_security_check?j_username="+username+"&j_password=dummy"); } } else { - // shib login header not found - // TODO ensure user gets unauthorised result - log.error("No shib username found!"); - response.sendRedirect("j_security_check?j_username="+username+"&j_password=dummy"); + // we shouldn't reach here since login.jsp only redirects here when the shib request header + // containing username is not null; set a session attribute flag anyway so that user doesn't get + // continuously redirected + log.error("Couldn't get a username from shibboleth header: "+Configuration.get(ConfigurationKeys.SHIB_ATTR_LOGIN)); + request.getSession().setAttribute("shibLoginExists", "true"); + response.sendRedirect("/lams/"); } } } Index: lams_central/web/login.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/login.jsp,v diff -u -r1.26.2.4 -r1.26.2.5 --- lams_central/web/login.jsp 19 Apr 2007 06:51:38 -0000 1.26.2.4 +++ lams_central/web/login.jsp 20 Apr 2007 06:04:20 -0000 1.26.2.5 @@ -13,7 +13,7 @@ String shibUsername = (String) request.getHeader("LAMS-Login"); String shibLoginExists = (String) session.getAttribute("shibLoginExists"); - if (shibUsername != null && shibLoginExists != "true") { + if (shibUsername != null && shibUsername.trim().length()>0 && shibLoginExists != "true") { response.sendRedirect("ShibLogin"); } @@ -129,7 +129,7 @@ <% if (shibLoginExists == "true") { %>