Community

Realm configuration problems using DataSourceRealm

reply from Patrick Mingard in Datasource Configuration - View the full discussion

Hi again,

 

After a while on french forums, someone gave me a hint to resolve my problem. In fact, I did not really resolve it but changed completely to something similar. I post here for the case someone searching for the same answer falls on my topic.

 

Here is the configuration of the WEB-INF/web.xml file (security part only) :

 

<security-constraint>
  <display-name>Security constraint for Currency Manager</display-name>
  <web-resource-collection>
   <web-resource-name>Protected area</web-resource-name>
   <url-pattern>/servlet/CurrencyConverter</url-pattern>
  </web-resource-collection>
  <auth-constraint>
   <role-name>admin</role-name>
  </auth-constraint>
</security-constraint>
<login-config>
  <auth-method>FORM</auth-method>
  <realm-name>CurrencyManager</realm-name>
  <form-login-config>
   <form-login-page>/login.jsp</form-login-page>
   <form-error-page>/loginerror.jsp</form-error-page>
  </form-login-config>
</login-config>
<security-role>
  <role-name>admin</role-name>
</security-role>

 

Here is the WEB-INF/jboss-web.xml file I placed

 

<jboss-web>
     <security-domain>java:/jaas/currencysecurity</security-domain>
</jboss-web>

 

Here is where it becomes really different, I did change the server\default\conf\login-config.xml file of my JBoss config. Just add a new application-policy with this configuration and I worked perfectly well for me.

 

<application-policy name="currencysecurity"> 
    <authentication>
        <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
                         flag="required">
            <module-option name="dsJndiName">java:/DefaultDS</module-option>
            <module-option name="principalsQuery">  
                select user_pass from users where user_name=?
            </module-option>
            <module-option name="rolesQuery">
                select role_name,'Roles' from user_roles where user_name=?
            </module-option>
        </login-module>
    </authentication>
</application-policy>

 

Hope this will help someone some day ;)

 

Cya soon for new questions !

Reply to this message by going to Community

Start a new discussion in Datasource Configuration at Community