149 lines
6.9 KiB
HTML
149 lines
6.9 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
|
||
|
|
||
|
<title>Example: Form login</title>
|
||
|
</head>
|
||
|
|
||
|
<BODY>
|
||
|
<!-- Java sync-link -->
|
||
|
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
|
||
|
|
||
|
<h4><a name="secdlogx"></a>Example: Form login</h4>
|
||
|
|
||
|
The following is an example of how the form should be coded into the HTML page:
|
||
|
|
||
|
<pre> <form method="POST" action="j_security_check">
|
||
|
<input type="text" name="j_username">
|
||
|
<input type="text" name="j_password">
|
||
|
<\form></pre>
|
||
|
|
||
|
<p>The action of the login form must always be <tt>j_security_check</tt>. The j_username input field should be used to get the user name, and the j_password input field should be used to get the user's password.</p>
|
||
|
|
||
|
<p>On receiving a request from a Web client, the Web server sends the configured Form page to the client and preserves the original request. When the Web server receives the completed Form page from the Web client, it extracts the username and password from the form and authenticates the user. On successful authentication, the Web server redirects the call to original request. If authentication fails, the web server redirects the call to the configured error page.</p>
|
||
|
|
||
|
<p>Here is an example of an HTML login page:</p>
|
||
|
|
||
|
<pre> <!-- login.html -->
|
||
|
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 4.0 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Pragma" content="no-cache">
|
||
|
<title>Security FVT Login Page </title>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
|
||
|
<h2>Form Login</h2>
|
||
|
|
||
|
<form method="post" action="j_security_check">
|
||
|
<p>
|
||
|
<strong>You may have entered an invalid user ID
|
||
|
or password. To correct the problem, please enter
|
||
|
your correct user ID and password. If you have
|
||
|
forgotten your user ID or password, please contact
|
||
|
the server administrator.</strong>
|
||
|
</p>
|
||
|
<p>
|
||
|
<strong>Please enter user ID and password:</strong>
|
||
|
<br>
|
||
|
<strong>User ID</strong>
|
||
|
<input type="text" size="20" name="j_username">
|
||
|
<strong>Password</strong>
|
||
|
<input type="password" size="20" name="j_password">
|
||
|
</p>
|
||
|
|
||
|
<p>
|
||
|
<strong>And then click this button:</strong>
|
||
|
<input type="submit" name="login" value="Login">
|
||
|
</p>
|
||
|
</form>
|
||
|
|
||
|
</body>
|
||
|
</html></pre>
|
||
|
|
||
|
<p>Here is an example error page in a JSP file:</p>
|
||
|
|
||
|
<pre> <!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 4.0 Transitional//EN">
|
||
|
<html>
|
||
|
<head><title>A Form login authentication failure occurred</head></title>
|
||
|
<body>
|
||
|
<H1><B>A Form login authentication failure occurred</H1></B>
|
||
|
<P>Authentication may fail one of many reasons. Some possibilities include:
|
||
|
<OL>
|
||
|
<LI>The user-id or password may be entered incorrectly; either misspelled or the
|
||
|
wrong case was used.
|
||
|
<LI>The user-id or password does not exist, has expired, or has been disabled.
|
||
|
</OL>
|
||
|
</P>
|
||
|
|
||
|
</body>
|
||
|
</html></pre>
|
||
|
|
||
|
<p>After you configure the Web application to use form-based authentication, the deployment descriptor contain the login configuration as shown below:</p>
|
||
|
|
||
|
<pre><login-config id="LoginConfig_1">
|
||
|
<auth-method>FORM</auth-method>
|
||
|
<realm-name>Example Form-Based Authentication Area</realm-name>
|
||
|
<form-login-config id="FormLoginConfig_1">
|
||
|
<form-login-page>/login.html</form-login-page>
|
||
|
<form-error-page>/error.jsp</form-error-page>
|
||
|
</form-login-config>
|
||
|
</login-config></pre>
|
||
|
|
||
|
<p>Here is the directory structure for a sample Web application archive (WAR) file that shows the login and error pages for these examples:</p>
|
||
|
|
||
|
<pre> META-INF
|
||
|
META-INF/MANIFEST.MF
|
||
|
login.html
|
||
|
error.jsp
|
||
|
WEB-INF/
|
||
|
WEB-INF/classes/
|
||
|
WEB-INF/classes/aServlet.class</pre>
|
||
|
|
||
|
<p><strong>Form logout</strong></p>
|
||
|
|
||
|
<p>Form logout is a mechanism that allows uses to logout from an application without having to close all Web browser sessions. After the user logs out, access to a protected Web resource requires reauthentication. This feature is not required by J2EE specifications but is provided as an additional feature in WebSphere security.</p>
|
||
|
|
||
|
<p>A form logout works in the following manner:</p>
|
||
|
|
||
|
<ol>
|
||
|
<li>The URI for the logout-form URI is specified in the Web browser.</li>
|
||
|
<li>The browser loads the form.</li>
|
||
|
<li>The user clicks the submit button of the form to logout.</li>
|
||
|
<li>The WebSphere security code logs out the user.</li>
|
||
|
<li>Upon logout, the user is redirected to a logout exit page.</li>
|
||
|
</ol>
|
||
|
|
||
|
<p>Form logout does not require any attributes in any deployment descriptor. It is simply an HTML or JSP file that is included with the Web application. The form logout page is like most HTML forms. However, the form logout page, like the form login page, it has a special POST action that is recognized by the Web container. The Web container then dispatches it to a special internal WebSphere form logout servlet. The POST action in the form logout page must have a value of <tt>ibm_security_logout</tt>.</p>
|
||
|
|
||
|
<p>A logout exit page can be specified in the logout form. The exit page can be a HTML or JSP file to which users a redirected after they log out. The logout exit page must reside within the same Web application as the logout form. The logout exit page is simply specified as a parameter in the form logout page. If no logout exit page is specified, a default logout HTML message is returned to the user.</p>
|
||
|
|
||
|
<p>Here is a sample HTML logout form. This form configures the logout exit page to redirect the user back to the login page after logout.</p>
|
||
|
|
||
|
<pre><!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 4.0 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Pragma" content="no-cache">
|
||
|
<title>Logout Page </title>
|
||
|
<head>
|
||
|
|
||
|
<body>
|
||
|
<h2>Sample Form Logout</h2>
|
||
|
<form method="post" action="ibm_security_logout" name="logout">
|
||
|
<p>
|
||
|
<strong> Click this button to logout:</strong>
|
||
|
<input type="submit" name="logout" value="Logout">
|
||
|
<input type="hidden" name="logoutExitPage" value="/login.html">
|
||
|
</p>
|
||
|
</form>
|
||
|
|
||
|
</body>
|
||
|
</html></pre>
|
||
|
|
||
|
</body>
|
||
|
</html>
|
||
|
|