Setting up login from DB.
infectedrhythms Nov 21, 2004 9:36 PMHey am still having problems this time I decided to use dault values...
login-config.xml...
<application-policy name = "Mamoth"> <authentication> <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required"> <module-option name = "unauthenticatedIdentity">guest</module-option> <module-option name = "dsJndiName">java:/jdbc/MamothDB</module-option> </login-module> </authentication> </application-policy>
jboss-web.xml...
<jboss-web> <context-root>/mamoth</context-root> <security-domain>java:/jaas/Mamoth</security-domain> <resource-ref> <res-ref-name>jdbc/MamothDB</res-ref-name> <jndi-name>java:/jdbc/MamothDB</jndi-name> </resource-ref> </jboss-web>
web.xml...
<web-app> <display-name>mamoth Blue</display-name> <description>mamoth Blue web site</description> <security-constraint> <web-resource-collection> <web-resource-name>Mamoth</web-resource-name> <description>Mamoth Blue security</description> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>Admin</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>Mamoth Blue</realm-name> </login-config> <security-role> <role-name>Admin</role-name> </security-role> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/MamothDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> <!-- //--> </web-app>
db structure...
# Host: localhost # Database: mamoth # Table: 'principals' # CREATE TABLE `principals` ( `PrincipalID` varchar(64) NOT NULL default '', `Password` varchar(64) NOT NULL default '', PRIMARY KEY (`PrincipalID`) ) TYPE=MyISAM; # Host: localhost # Database: mamoth # Table: 'roles' # CREATE TABLE `roles` ( `PrincipalID` varchar(64) NOT NULL default '', `Role` varchar(32) NOT NULL default '', `RoleGroup` varchar(32) NOT NULL default '', PRIMARY KEY (`PrincipalID`) ) TYPE=MyISAM;