Thursday 11 August 2011

ADF Security : Logout action

ADF Security provides an Authentication Servlet with a logout method in order to invalidate the JAAS Session that was initialised on login. For completeness sake I've listed the java code you can use in your backing bean's action method in order to call this servlet method:
public String onLogout() {
    FacesContext facesCtx = FacesContext.getCurrentInstance();
    ExternalContext eCtx = facesCtx.getExternalContext();
    String url = eCtx.getRequestContextPath() +
        "/adfAuthentication?logout=true&end_url=/faces/index.jspx";
    try {
        eCtx.redirect(url);
    } catch(IOException e) {
        e.printStackTrace();
    }
    facesCtx.responseComplete();   
    return null;
}

No comments:

Post a Comment