8 Replies Latest reply on Jul 4, 2012 2:04 AM by jaysensharma

    How to setup jdbcRealm in JBoss AS 7

    hfluz

      Hi, I'm beginning to use JBoss 7 AS my application server (I was using glassfish v3 before).

       

      I already migrated my J2EE (JSF 2, EJB 3, JPA 2, CDI) to AS 7, but I'm stuck in the security realm configuration.

       

      In glassfish I was used to configure the domain.xml like below:

       

      <auth-realm name="ati" classname="com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm">  
                <property name="jaas-context" value="jdbcRealm"></property>  
                <property name="password-column" value="senha"></property>  
                <property name="assign-groups" value="aluno"></property>  
                <property name="datasource-jndi" value="jdbc/security"></property>  
                <property name="group-table" value="grupo"></property>  
                <property name="user-table" value="usuario"></property>  
                <property name="group-name-column" value="nome"></property>  
                <property description="null" name="digest-algorithm" value="MD5"></property>  
                <property name="user-name-column" value="nome"></property>  
      
      </auth-realm>  
      
      

       

      But in JBoss AS 7 I'm a bit confused. I tried to add this to standalone.xml:

       

      <security-domain name="portalAuth">  
      <authentication>  
                <login-module code="Database" flag="required">  
                     <module-option name="dsJndiName" value="java:jboss/datasources/portal"/>  
                     <module-option name="principalsQuery" value="SELECT senha FROM Usuario WHERE email=?"/>  
                     <module-option name="hashAlgorithm">SHA-256</module-option>  
                     <module-option name="hashEncoding">base64</module-option>  
                </login-module>  
           </authentication>  
      </security-domain>  
      
      

       

      But I can't access the portalAuth security domain as a realm in my web application.

       

      There's also a secction to configure realms in standalone.xml:

       

      <security-realms>  
                  <security-realm name="PropertiesMgmtSecurityRealm">  
                      <authentication>  
                          <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>  
                      </authentication>  
                  </security-realm>  
      </security-realms>  
      
      

       

      But I don't know how to configure it. How should I proceed in order to configure a simple jdbcRealm (as in glassfish)? Do I need to use both security-realm and security-domain? Only one of them? How should I access them through my application's web.xml?

       

      Obs. In case my english isn't clear enough I apologize in advance.