Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-07-2009, 03:04 AM
Member
 
Join Date: Dec 2008
Posts: 27
Rep Power: 0
simo_mon is on a distinguished road
Default servlet secure login
Hi i am confused about setting up a loginpage using servlets...

original design...

simple html form which redirects to servlet, which tests user name and password
against a database and redirects accordingly... works fine

however, upon further reading i discovered role based authentication, and
the inbuilt servlet security features.. here is the web.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>servletSecurity</display-name><description>login forms</description>
	
	
	
	
	<security-constraint>
		<web-resource-collection>
			<web-resource-name>Test</web-resource-name>
			<url-pattern>/LoginForm.html</url-pattern>
			<http-method>GET</http-method>
			<http-method>POST</http-method>
		</web-resource-collection>

		<auth-constraint>
			<role-name>manager</role-name></auth-constraint>
		<user-data-constraint>

			<transport-guarantee>NONE</transport-guarantee>
		</user-data-constraint>


		</security-constraint><login-config>
		<auth-method>FORM</auth-method>
			<form-login-config>
				<form-login-page>/LoginForm.html</form-login-page>
				<form-error-page>/LoginErr.html</form-error-page>
		</form-login-config></login-config>


		<servlet>
				<description></description>
				<display-name>logInCheck</display-name>
				<servlet-name>logInCheck</servlet-name>
				<servlet-class>logInCheck</servlet-class>
		</servlet>

		<servlet-mapping>
			<servlet-name>ApageMaker</servlet-name>
			<url-pattern>/ApageMaker</url-pattern>
		</servlet-mapping>



	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
		<welcome-file>LoginForm.html</welcome-file>
	</welcome-file-list>
	
</web-app>

now in the first version i had

Code:
<FORM ACTION="http://www.working_url.com/servlet/logIn" method="POST"..
which redirected the results ( usrname and password) to a servlet which queries the database and then redirects...

BUT, when i use this method i use

Code:
<form action="j_security_check">
which i assume calls some inherited class to get processed ? as it redirects
already to the loginErr.html page...

but how do i process my own username/password list ?
and how do redirect to the login processing servlet loginCheck.java

here's the html of the new login page that corresponds the web.xml...

Code:

<form action="j_security_check">
			
			
		<h1 align="center"></br> Login </h1>
			
			<center>
				<table border ="0">
					<tr>
						<td ><h3>user name</br></h3></td>
						<td>
							<input type="text" name =                                                                         "j_username">
						</td>
					</tr>
					
					<tr>
						<td><h3>password</h3></td>
						<td>
							<input type="password" name = "j_password">
						
						</td>
					
					</tr>
				
				
				
				</table>
			
			<input type ="submit" value = "Login!">
			
			</center>
any help would be appreciated ..

thanks

simo_mon
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How Java is so secure than other? makpandian New To Java 4 06-26-2009 05:22 AM
cannot open database requested in login. Login fails banduskank Database 0 06-25-2008 01:41 PM
Secure FTP Wrapper 3.0.2 Java Tip Java Announcements 0 04-29-2008 07:05 PM
Secure FTP Applet 4.4 vglass Java Announcements 0 11-13-2007 07:30 PM
Secure FTP Factory 7.0 vglass Java Announcements 0 07-20-2007 02:44 PM


All times are GMT +2. The time now is 11:57 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org