Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To create the session, the SessionManager.createSession(HttpServletRequest, HttpServletResponse) method can be used. The HTTP request and response usually are not available but you can use mock requests and responses instead via the Spring mock module (org.springframework.mock.web). After logging in you should still invoke AuthorizationService.login(username, password, request) in order to be granted the proper authorization. The code example below shows an example of creating a session for user USERNAMEKEY on webinitiative with ID WEBSITEKEY and password PASSWORDKEY:


Code Block
themeEclipse
	private Session login() {
        String website = myConfigService.getParameter(WEBSITEKEY);
        Session session = mySessionManager.createSession(website, "username");
        return session;
}
		// Login using the authorization service
		   if (!myAuthorizationService.login(username, password, request)) {
			      LOG.warning("Login failed.");
			  return null;
			  }
			  return session;
	      } catch(ConfigurationManagementException e) {
		         LOG.log(Level.SEVERE, "An exception occurred during login()", e);
		         return null;
	      }
}


Back to Top