Versions Compared

Key

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

...

Active sessions will usually be available in element, panel and media item components since the controllers of these components are triggered by an editor who is logged in to XperienCentral. In other use cases, like testbundles or scheduled jobs, no active session will be available. Creating a session is not as straightforward as it may seem, because that requires login credentials.

To create a session with login credentials, the best way is to define the login credentials in configuration entries managed by the Configuration Management service. To create the session, those login credentials are used. The administrator can tune the authorization that is actually needed by that particular user.

To create the session, the SessionManager.createSession(HttpServletRequeststring, HttpServletResponsestring) method can be used. 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;
}

...