bitfiction / extjs-mvc-rest-java-hibernate-application-template

Ready to use application template using ExtJS 4.2, MVC approach, REST interface to Java, EJBs and Hibernate for ORM. Includes authentication code and other useful samples.
MIT License
12 stars 4 forks source link

Adding security-domain and insert database on local jboss setup #1

Open quangtin3 opened 10 years ago

quangtin3 commented 10 years ago

Before we can running this extjs-rest-java-hibernate application on local jBoss, some works need to be done:

Setup DataSource

<datasources>
    <datasource jndi-name="java:jboss/datasources/MysqlDS" pool-name="extjsDS" enabled="true" use-java-context="true">
        <connection-url>jdbc:mysql://localhost:3306/extjs?zeroDateTimeBehavior=convertToNull&amp;useUnicode=true&amp;characterEncoding=utf8</connection-url>
        <driver>mysql</driver>
        <security>
        <user-name>extjs</user-name>
        <password>extjs</password>
        </security>
    </datasource>
    <drivers>
        <driver name="mysql" module="com.mysql">
                <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
        </driver>
    </drivers>
</datasources>

Add security domain, again, in your jBoss's standalone.xml add security domain as following:

<security-domain name="ExtjsMVCTemplateRealm" cache-type="default">
    <authentication>
        <login-module code="Database" flag="required">
            <module-option name="dsJndiName" value="java:jboss/datasources/MysqlDS"/>
            <module-option name="principalsQuery" value="select password from user where username=?"/>
            <module-option name="rolesQuery" value="select role.rolename, 'Roles' from role, userrole where role.id = userrole.roles_id and userrole.users_username=?"/>
            <module-option name="hashAlgorithm" value="MD5"/>
            <module-option name="hashEncoding" value="hex"/>
        </login-module>
    </authentication>
</security-domain>
osevce commented 10 years ago

Thank you very much! I linked to the issue from our website http://www.bitfiction.com/extjs-mvc-rest-java-hibernate-application-template-jboss-setup/