Hi,
I think the key is to investigate your mysql tables.
Look my example:
*Table USER*
USERNAME varchar(40) NO PRI (null)
LASTSEEN datetime YES (null)
CREATED datetime YES (null)
EMAIL varchar(100) NO (null)
PASSWORD longblob NO (null)
*T**able USER_ROLE*
ID bigint(20) NO PRI (null) auto_increment
NAME varchar(255) NO (null)
USERNAME varchar(40) YES MUL (null)
Now follow my auth-realm description:
<auth-realm
classname="com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm"
name="redirect-realm">
<property name="jaas-context" value="jdbcRealm" />
<property name="datasource-jndi" value="jdbc/nprd" />
<property name="user-table" value="user" />
<property name="user-name-column" value="username" />
<property name="digest-algorithm" value="MD5"/>
<property name="password-column" value="password" />
<property name="group-table" value="user_role" />
<property name="group-name-column" value="name" />
</auth-realm>
Follow the snippet of my web.xml
<security-role>
<description />
<role-name>admin</role-name>
</security-role>
<security-role>
<description />
<role-name>user</role-name>
</security-role>
<security-role>
<description />
<role-name>sip</role-name>
</security-role>
and my sun-web.xml:
<security-role-mapping>
<role-name>admin</role-name>
<principal-name>AdminPrincipal</principal-name>
<group-name>admin</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>user</role-name>
<principal-name>UserPrincipal</principal-name>
<group-name>user</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>sip</role-name>
<principal-name>SipPrincipal</principal-name>
<group-name>sip</group-name>
</security-role-mapping>
This setup works correctly, so you should verify your tables design and the
auth description.
Best Regards.
-------------------------------
Paulo Reis
On Wed, Sep 1, 2010 at 1:36 PM, <glassfish_at_javadesktop.org> wrote:
> Hi,
>
> I having been trying for two days to get my webapp on glassfish v3 to
> authenticate to a mysql database.
>
> My web.xml:
>
> <web-app version="2.5" 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_2_5.xsd">
> <servlet>
> <servlet-name>Genki</servlet-name>
> <servlet-class>*****.Genki</servlet-class>
> </servlet>
> <servlet>
> <servlet-name>OnlySupers</servlet-name>
> <servlet-class>com.aclandinternet.clients.OnlySupers</servlet-class>
> </servlet>
> <servlet>
> <servlet-name>OnlyRegulars</servlet-name>
> <servlet-class>*****.OnlyRegulars</servlet-class>
> </servlet>
> <servlet-mapping>
> <servlet-name>Genki</servlet-name>
> <url-pattern>/app/Genki</url-pattern>
> </servlet-mapping>
> <servlet-mapping>
> <servlet-name>OnlySupers</servlet-name>
> <url-pattern>/app/supers/OnlySupers</url-pattern>
> </servlet-mapping>
> <servlet-mapping>
> <servlet-name>OnlyRegulars</servlet-name>
> <url-pattern>/app/regulars/OnlyRegulars</url-pattern>
> </servlet-mapping>
> <session-config>
> <session-timeout>
> 30
> </session-timeout>
> </session-config>
> <welcome-file-list>
> <welcome-file>index.jsp</welcome-file>
> </welcome-file-list>
> <security-constraint>
> <display-name>SuperUserConstraint</display-name>
> <web-resource-collection>
> <web-resource-name>superuser</web-resource-name>
> <description/>
> <url-pattern>/app/supers/*</url-pattern>
> </web-resource-collection>
> <auth-constraint>
> <description/>
> <role-name>superuser</role-name>
> </auth-constraint>
> </security-constraint>
> <security-constraint>
> <display-name>RegularUserConstraint</display-name>
> <web-resource-collection>
> <web-resource-name>regularuser</web-resource-name>
> <description/>
> <url-pattern>/app/regulars/*</url-pattern>
> </web-resource-collection>
> <auth-constraint>
> <description/>
> <role-name>regularuser</role-name>
> <role-name>superuser</role-name>
> </auth-constraint>
> </security-constraint>
> <login-config>
> <auth-method>BASIC</auth-method>
> <realm-name>client_access</realm-name>
> </login-config>
> <security-role>
> <description/>
> <role-name>regularuser</role-name>
> </security-role>
> <security-role>
> <description/>
> <role-name>superuser</role-name>
> </security-role>
> </web-app>
>
> sun-web.xml:
>
> <sun-web-app error-url="">
> <context-root>/ClientsDemo</context-root>
> <security-role-mapping>
> <role-name>regularuser</role-name>
> <group-name>regularuser</group-name>
> </security-role-mapping>
> <security-role-mapping>
> <role-name>superuser</role-name>
> <group-name>superuser</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 on glassfish the realm is set to:
>
> com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm
>
> and I have mysql-connector-java-5.1.13-bin.jar in
> /glassfish/domains/domain1/lib/ext
>
> I have experimented with disabling mysql so that the ping doesn't work from
> glassfish admin and the same problem persists which I take to mean that the
> error is not with the database or the mappings from the realm.
>
> Nothing shows in the logs and this is getting really frustrating so I would
> really appreciate some help,
>
> thanks in advance
> [Message sent by forum member 'hacland']
>
> http://forums.java.net/jive/thread.jspa?messageID=481597
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>