ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzamy_5.4.0.1/50/sec/secdlogx.htm

149 lines
6.9 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!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> &lt;form method=&quot;POST&quot; action=&quot;j_security_check&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;j_username&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;j_password&quot;&gt;
&lt;\form&gt;</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> &lt;!-- login.html --&gt;
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C/DTD HTML 4.0 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Pragma&quot; content=&quot;no-cache&quot;&gt;
&lt;title&gt;Security FVT Login Page &lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h2&gt;Form Login&lt;/h2&gt;
&lt;form method=&quot;post&quot; action=&quot;j_security_check&quot;&gt;
&lt;p&gt;
&lt;strong&gt;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.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Please enter user ID and password:&lt;/strong&gt;
&lt;br&gt;
&lt;strong&gt;User ID&lt;/strong&gt;
&lt;input type=&quot;text&quot; size=&quot;20&quot; name=&quot;j_username&quot;&gt;
&lt;strong&gt;Password&lt;/strong&gt;
&lt;input type=&quot;password&quot; size=&quot;20&quot; name=&quot;j_password&quot;&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;And then click this button:&lt;/strong&gt;
&lt;input type=&quot;submit&quot; name=&quot;login&quot; value=&quot;Login&quot;&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Here is an example error page in a JSP file:</p>
<pre> &lt;!DOCTYPE HTML PUBLIC &quot;-//W3C/DTD HTML 4.0 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;&lt;title&gt;A Form login authentication failure occurred&lt;/head&gt;&lt;/title&gt;
&lt;body&gt;
&lt;H1&gt;&lt;B&gt;A Form login authentication failure occurred&lt;/H1&gt;&lt;/B&gt;
&lt;P&gt;Authentication may fail one of many reasons. Some possibilities include:
&lt;OL&gt;
&lt;LI&gt;The user-id or password may be entered incorrectly; either misspelled or the
wrong case was used.
&lt;LI&gt;The user-id or password does not exist, has expired, or has been disabled.
&lt;/OL&gt;
&lt;/P&gt;
&lt;/body&gt;
&lt;/html&gt;</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>&lt;login-config id=&quot;LoginConfig_1&quot;&gt;
&lt;auth-method&gt;FORM&lt;/auth-method&gt;
&lt;realm-name&gt;Example Form-Based Authentication Area&lt;/realm-name&gt;
&lt;form-login-config id=&quot;FormLoginConfig_1&quot;&gt;
&lt;form-login-page&gt;/login.html&lt;/form-login-page&gt;
&lt;form-error-page&gt;/error.jsp&lt;/form-error-page&gt;
&lt;/form-login-config&gt;
&lt;/login-config&gt;</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>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C/DTD HTML 4.0 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Pragma&quot; content=&quot;no-cache&quot;&gt;
&lt;title&gt;Logout Page &lt;/title&gt;
&lt;head&gt;
&lt;body&gt;
&lt;h2&gt;Sample Form Logout&lt;/h2&gt;
&lt;form method=&quot;post&quot; action=&quot;ibm_security_logout&quot; name=&quot;logout&quot;&gt;
&lt;p&gt;
&lt;strong&gt; Click this button to logout:&lt;/strong&gt;
&lt;input type=&quot;submit&quot; name=&quot;logout&quot; value=&quot;Logout&quot;&gt;
&lt;input type=&quot;hidden&quot; name=&quot;logoutExitPage&quot; value=&quot;/login.html&quot;&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</body>
</html>