I am trying to implement the correct output for my Java EE / JSF2 application.
This requires two things:
- I need to exit JAAS and cancel the session
- Then I have to go to the external URL in order to start logging out of Siteminder
The Siteminder exit URL (configured on the policy server -> I cannot change it) is out of my application context. For instance. if my webapp url is https: // localhost: 8080 / sm / MyWebApp , then the exit URL is https: // localhost: 8080 / anotherwebapp / logout.html .
This is the current local exit code:
public void logout() { System.out.println("Logging out..."); HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); try { request.logout(); } catch (ServletException e) { e.printStackTrace(); } HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false); if (session != null) { session.invalidate(); } }
And here is the property that returns the exit URL:
public String getLogoutUrl() { HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); String requestServer = request.getServerName(); String requestScheme = request.getScheme(); int serverPort = request.getServerPort(); String logoutUrl = requestScheme + "://" + requestServer + ":" + Integer.toString(serverPort) + "/anotherwebapp/logout.html"; return logoutUrl; }
However, I cannot find the JSF2 / Primefaces component that can call logout () and then open the external URL. For example, if I have:
<h:outputLink value="#{authBean.logoutUrl}" onclick="#{authBean.logout()}">[Logout]</h:outputLink>
then onclick does not seem to be called.
Another way I tried is to put the external URL at the end of the exit function so that it returns as a navigation bar, but it is not recognized (also used with "? Faces-redirect = true ...)."
Any help would be appreciated.
source share