/** Console logout */
  protected void logout(final HttpServletRequest request, final HttpServletResponse response)
      throws ServletException, IOException {
    final HttpSession session = request.getSession();

    final PlatformSession platformSession =
        (PlatformSession) session.getAttribute(PlatformLoginServlet.PLATFORMSESSION);
    if (platformSession != null) {
      try {
        final PlatformLoginAPI platformLoginAPI = PlatformAPIAccessor.getPlatformLoginAPI();
        platformLoginAPI.logout(platformSession);
      } catch (final BonitaException e) {
        if (LOGGER.isLoggable(Level.SEVERE)) {
          LOGGER.log(Level.SEVERE, "Error while performing the logout", e);
        }
      }
    }
    session.removeAttribute(PlatformLoginServlet.PLATFORMSESSION);
    session.invalidate();

    final String redirectAfterLoginStr =
        request.getParameter(AuthenticationManager.REDIRECT_AFTER_LOGIN_PARAM_NAME);
    // Do not modify this condition: the redirection should happen unless there is redirect=false in
    // the URL
    if (!Boolean.FALSE.toString().equals(redirectAfterLoginStr)) {
      response.sendRedirect(PLATFORM_LOGIN_PAGE);
    }
  }
Example #2
0
 public PlatformAPI getPlatformAPI() {
   if (this.platformAPI == null) {
     PlatformLoginAPI platformLoginAPI;
     try {
       platformLoginAPI = PlatformAPIAccessor.getPlatformLoginAPI();
       final PlatformSession platformSession =
           platformLoginAPI.login(PLATFORM_ADMIN, PLATFORM_PASSWORD);
       this.platformAPI = PlatformAPIAccessor.getPlatformAPI(platformSession);
     } catch (final BonitaHomeNotSetException e) {
       throw new TestToolkitException("Bonita home isn't set", e);
     } catch (final ServerAPIException e) {
       throw new TestToolkitException("Failed to call server API", e);
     } catch (final UnknownAPITypeException e) {
       throw new TestToolkitException("Invalid session to create tenant", e);
     } catch (final PlatformLoginException e) {
       throw new TestToolkitException("Invalid session to create tenant", e);
     } catch (final InvalidSessionException e) {
       throw new TestToolkitException("Invalid session to create tenant", e);
     }
   }
   return this.platformAPI;
 }