Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r6a414b5f0f7756f0376670914c59c84b9ae916ef -r179f97f9c5145ac4376566e6d6a37d7f11e71e8f --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 179f97f9c5145ac4376566e6d6a37d7f11e71e8f) @@ -277,5 +277,10 @@ error.edit.disabled = Profile editing is disabled. message.partial.edit.only = Only contact fields are editable due to server configuration. +openid.not.enabled =OpenID is not enabled for LAMS. +openid.blacklisted =Your identity provider is not among the trusted providers. +openid.no.id =Authentication failed, no user id was passed from identity provider. +openid.auth.error =Authentication failed, there was an error during authentication, please contact the system administrator. +openid.auth.fail =Authentication failed, A user in LAMS did not exist for openid URL: {0} #======= End labels: Exported 268 labels for en AU ===== Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r6a414b5f0f7756f0376670914c59c84b9ae916ef -r179f97f9c5145ac4376566e6d6a37d7f11e71e8f --- lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) +++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 179f97f9c5145ac4376566e6d6a37d7f11e71e8f) @@ -277,5 +277,11 @@ error.edit.disabled = Profile editing is disabled. message.profile.partially.edited = Profile has only been partially updated due to server configuration. +openid.not.enabled =OpenID is not enabled for LAMS. +openid.blacklisted =Your identity provider is not among the trusted providers. +openid.no.id =Authentication failed, no user id was passed from identity provider. +openid.auth.error =Authentication failed, there was an error during authentication, please contact the system administrator. +openid.auth.fail =Authentication failed, A user in LAMS did not exist for openid URL: {0} + #======= End labels: Exported 268 labels for en AU ===== Index: lams_central/src/java/org/lamsfoundation/lams/web/SIFOpenIDServlet.java =================================================================== diff -u -r0dcd18e28734063363b86a2683ec99c8fa1a041f -r179f97f9c5145ac4376566e6d6a37d7f11e71e8f --- lams_central/src/java/org/lamsfoundation/lams/web/SIFOpenIDServlet.java (.../SIFOpenIDServlet.java) (revision 0dcd18e28734063363b86a2683ec99c8fa1a041f) +++ lams_central/src/java/org/lamsfoundation/lams/web/SIFOpenIDServlet.java (.../SIFOpenIDServlet.java) (revision 179f97f9c5145ac4376566e6d6a37d7f11e71e8f) @@ -2,6 +2,7 @@ import java.io.IOException; import java.net.URL; + import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -15,6 +16,7 @@ import org.lamsfoundation.lams.util.CSVUtil; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; +import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.util.AttributeNames; import org.springframework.web.context.WebApplicationContext; @@ -31,7 +33,7 @@ * Accepts the openid_url param and used joid libraries to authenticate the user. * * If the identity provider server authenticates the user, log them in through SSO - * + * */ public class SIFOpenIDServlet extends HttpServlet { @@ -42,13 +44,14 @@ private static final String PARAM_OPENID_URL = "openid_url"; private static final String PARAM_ERROR_MSG = "errorMsg"; - private static final String ERROR_NOT_ENABLED = "OpenID is not enabled for LAMS."; - private static final String ERROR_BLACKLISTED = "Your provider is not among the trusted providers, please use the portal for logging in."; - private static final String ERROR_NO_ID_PASSED = "Authentication failed, no user id was passed."; - private static final String ERROR_AUTH = "Authentication failed, there was an error during authentication, please contact the system administrator."; - private static final String ERROR_AUTH_LAMS = "Authentication failed, A user in LAMS did not exist for openid URL: "; + private static final String ERROR_KEY_NOT_ENABLED = "openid.not.enabled"; + private static final String ERROR_KEY_BLACKLISTED = "openid.blacklisted"; + private static final String ERROR_KEY_NO_ID_PASSED = "openid.no.id"; + private static final String ERROR_KEY_AUTH = "openid.auth.error"; + private static final String ERROR_KEY_AUTH_LAMS = "openid.auth.fail"; private IUserManagementService userService = null; + private MessageService messageService = null; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { @@ -70,7 +73,7 @@ // No user openid url passed and no session, return to portal log.error("OpenID authentication failed, no value passed for the openid url"); - redirectToPortal(response, ERROR_NO_ID_PASSED); + redirectToPortal(response, messageService.getMessage(ERROR_KEY_NO_ID_PASSED)); } else { String returnURL = UrlUtils.getBaseUrl(request) + "/OpenIDServlet"; @@ -82,7 +85,7 @@ loginUser(loggedInAs, request, response); } } else { - redirectToPortal(response, ERROR_NOT_ENABLED); + redirectToPortal(response, messageService.getMessage(ERROR_KEY_NOT_ENABLED)); } } @@ -100,22 +103,22 @@ String trustRoot) throws IOException { try { String openidRedirectURL = OpenIdFilter.joid().getAuthUrl(userOpenIDURL, returnTo, trustRoot); - + // See if it is a trusted server, then redirect if (isTrustedIdentityProvider(openidRedirectURL)) { log.info("No session found for user with url: " + userOpenIDURL + ". Sending authentication request to identity provider."); response.sendRedirect(openidRedirectURL); } else { log.error("Identity provider not permitted: " + userOpenIDURL); - redirectToPortal(response, ERROR_BLACKLISTED); + redirectToPortal(response, messageService.getMessage(ERROR_KEY_BLACKLISTED)); } } catch (OpenIdException e) { log.error("Problem getting openid url.", e); - redirectToPortal(response, ERROR_AUTH); + redirectToPortal(response, messageService.getMessage(ERROR_KEY_AUTH)); } catch (Exception e) { log.error("Error sending redirect request.", e); - redirectToPortal(response, ERROR_AUTH); + redirectToPortal(response, messageService.getMessage(ERROR_KEY_AUTH)); } } @@ -183,7 +186,10 @@ String lamsURL = "j_security_check?j_username=" + user.getLogin() + "&j_password=" + user.getPassword(); response.sendRedirect(lamsURL); } else { - redirectToPortal(response, ERROR_AUTH_LAMS + userOpenIDURL); + // No user found in lams that corresponds to this openid URL + String[] msg = new String[1]; + msg[0] = userOpenIDURL; + redirectToPortal(response, messageService.getMessage(ERROR_KEY_AUTH_LAMS, msg)); } } @@ -221,5 +227,10 @@ userService = (IUserManagementService) WebApplicationContextUtils.getRequiredWebApplicationContext( getServletContext()).getBean("userManagementService"); } + + if (messageService == null) { + messageService = (MessageService) WebApplicationContextUtils.getRequiredWebApplicationContext( + getServletContext()).getBean("centralMessageService"); + } } }