How-to logout from ADF Security
- by frank.nimphius
Normal
0
false
false
false
EN-US
X-NONE
X-NONE
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
ADF Security configures an authentication servlet, AuthenticationServlet,
in the web.xml file that also provides a logout functionality. Developers can
invoke the logout by a redirect performed from an action method in a managed
bean as shown next
public String onLogout() {
FacesContext fctx = FacesContext.getCurrentInstance();
ExternalContext ectx =
fctx.getExternalContext();
String url = ectx.getRequestContextPath()
+
"/adfAuthentication?logout=true&end_url=/faces/Home.jspx";
try {
ectx.redirect(url);
} catch (IOException e) {
e.printStackTrace();
}
fctx.responseComplete();
return null;
}
To use this functionality in your application, change the Home.jspx reference to a public page of
yours that the user is redirected to after successful logout.
Note that for a
successful logout, authentication should be through form based authentication. Basic
authentication is known as browser sign-on and re-authenticates users after the
logout redirect. Basic authentication is confusing to many developers for this
reason.