users@glassfish.java.net

Re: Form autheitcation

From: <glassfish_at_javadesktop.org>
Date: Wed, 01 Sep 2010 16:23:12 PDT

Sometime the page are protected, sometime they aren't. When I press the submit button for login nothing happens. Here is some of my code:

I have a jdbc called jdbc/userPool and a connection pool named userPool. Also there is a jdbcRealm called exerciseReal. I also have a servlet with urlpattern coded in it.


web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <!--info pour la mise en page -->
    <jsp-config>
        <jsp-property-group>
            <description>header and footer</description>
            <url-pattern>/WEB-INF/view/*</url-pattern>
            <include-prelude>/WEB-INF/jspf/header.jspf</include-prelude>
            <include-coda>/WEB-INF/jspf/footer.jspf</include-coda>
        </jsp-property-group>
    </jsp-config>
    <!-- info pour la base de donner -->
    <security-role>
        <description/>
        <role-name>ADMIN</role-name>
    </security-role>
    <security-role>
        <description/>
        <role-name>USER</role-name>
    </security-role>
    <resource-ref>
        <description>Connection a ma db exercise</description>
        <res-ref-name>jdbc/exercise</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    <security-constraint>
        <display-name>User Constraint</display-name>
        <web-resource-collection>
            <web-resource-name>Secured Pages</web-resource-name>
            <description/>
            <url-pattern>/WEB-INF/view/*</url-pattern>
            <url-pattern>/myAgenda</url-pattern>
            <url-pattern>/myFeed</url-pattern>
            <url-pattern>/myLog</url-pattern>
            <url-pattern>/viewAgenda</url-pattern>
            <url-pattern>/viewLog</url-pattern>
            <url-pattern>/viewProfile</url-pattern>
            <http-method>POST</http-method>
            <http-method>GET</http-method>
            </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>USER</role-name>
        </auth-constraint>
    </security-constraint>
    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>exerciseReal</realm-name>
        <form-login-config>
            <form-login-page>/myFeed</form-login-page>
            <form-error-page>/badlogin.jsp</form-error-page>
        </form-login-config>
    </login-config>
</web-app>

my sun-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
<sun-web-app error-url="">
  <context-root>/Exercise</context-root>
  <security-role-mapping>
    <role-name>USER</role-name>
    <group-name>USER</group-name>
  </security-role-mapping>
  <security-role-mapping>
    <role-name>ADMIN</role-name>
    <group-name>ADMIN</group-name>
  </security-role-mapping>
  <class-loader delegate="true"/>
  <jsp-config>
    <property name="keepgenerated" value="true">
      <description>Keep a copy of the generated servlet class' java code.</description>
    </property>
  </jsp-config>
</sun-web-app>

and
[Message sent by forum member 'guiomie']

http://forums.java.net/jive/thread.jspa?messageID=481632