If you want to do the login thing from scratch you need to first create a security realm or use and existing one in the file called login-config.xml which is present in the jboss_install_dir/server/default/conf/login-config.xml
like so.
<application-policy name = "test_authentication">
<authentication>
<login-module code="login.handler.class"
flag = "required">
</login-module>
</authentication>
</application-policy>
once this is done you need to create a file called jboss-web.xml if you havnt already in your <web-application-folder>/WEB-INF/
In that you need to create the following entry. Which looks up the security realm that you had setup earlier.
<jboss-web>
<security-domain>
java:/jaas/test_authentication</security-domain>
</jboss-web>
And finally in your web.xml you need to add the following entry. which will link to the entry you have made in your jboss-web.xml.
<security-constraint>
<web-resource-collection>
<web-resource-name>webfiles</web-resource-name>
<url-pattern>*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>everyone</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>TestRealm</realm-name>
</login-config>
<security-role>
<role-name>everyone</role-name>
</security-role>
This setup will prompt you with a basic dialog box every time a user opens up any page on your webapplication. you can further change the authentication method to authenticate usinig a separate page by specifiying the auth-method in your web.xml as FORM.
hope this helped.