/** * Get user details from SSO connection and set them in the user session. * * @return boolean: Flag whether a user was actually logged in or not. */ @Override public boolean ssoCheckUserDetails(JsonSessionState session) { // After the SSO roun-trip, restore any old query parameters we lost List<String> currentParams = request.getParameterNames(); // Cast a copy of keySet() to array to avoid errors as we modify String[] oldParams = session.keySet().toArray(new String[0]); // Loop through session data... for (String key : oldParams) { // ... looking for SSO stored params if (key.startsWith(SSO_STORAGE_PREFIX)) { // Remove our prefix... String oldParam = key.replace(SSO_STORAGE_PREFIX, ""); // ... and check if it survived the trip if (!currentParams.contains(oldParam)) { // No it didn't, add it to form data... the parameters are // already accessible from there in Jython String data = (String) session.get(key); formData.set(oldParam, data); // Don't forget to clear it from the session session.remove(key); } } } // Check our SSO providers for valid logins for (String ssoId : sso.keySet()) { sso.get(ssoId).ssoCheckUserDetails(session); GenericUser user = (GenericUser) sso.get(ssoId).getUserObject(session); if (user != null) { session.set("username", user.getUsername()); session.set("source", ssoId); return true; } } return false; }