Commit 342bf501 authored by Administrator's avatar Administrator

Updates the README file for easier datasource configuration

The datasource configuration now is done through the standalone.xml
instead of deploying the configuration.
parent 7cda9769
...@@ -17,12 +17,17 @@ Install Maven 3 in your system, if it was not installed (the `mvn` command must ...@@ -17,12 +17,17 @@ Install Maven 3 in your system, if it was not installed (the `mvn` command must
be available). If you are in a Debian-based OS, install the `maven` package (**don't install `maven2` package!!**). be available). If you are in a Debian-based OS, install the `maven` package (**don't install `maven2` package!!**).
### Git ### Git
First, install git in your system if it was not installed (the `git` command First, install Git in your system if it was not installed (the `git` command
must be available). We will work with Git to get updates of these sample. must be available). We will work with Git to get updates of these sample.
Concretely, we will work with a Git repository inside Concretely, we will work with a Git repository inside
[our Gitlab server](http://sing.ei.uvigo.es/dt/gitlab). [our Gitlab server](http://sing.ei.uvigo.es/dt/gitlab).
Git URL: `http://sing.ei.uvigo.es/dt/gitlab/dgss-1617/xcs-sample.git` Once Git is installed in your system, clone the project:
```bash
git clone http://sing.ei.uvigo.es/dt/gitlab/dgss-1617/xcs-sample.git
```
### Eclipse ### Eclipse
...@@ -53,41 +58,43 @@ FLUSH PRIVILEGES; ...@@ -53,41 +58,43 @@ FLUSH PRIVILEGES;
If you want to add some data to this database to run the application, you can If you want to add some data to this database to run the application, you can
also execute: also execute:
```sql ```sql
DROP TABLE IF EXISTS `User`;
CREATE TABLE `User` ( DROP TABLE IF EXISTS `User`;
`role` varchar(5) NOT NULL, CREATE TABLE `User` (
`login` varchar(100) NOT NULL, `role` varchar(5) NOT NULL,
`password` varchar(32) NOT NULL, `login` varchar(100) NOT NULL,
PRIMARY KEY (`login`) `password` varchar(32) NOT NULL,
); PRIMARY KEY (`login`)
);
DROP TABLE IF EXISTS `Pet`;
CREATE TABLE `Pet` ( DROP TABLE IF EXISTS `Pet`;
`id` int(11) NOT NULL AUTO_INCREMENT, CREATE TABLE `Pet` (
`animal` varchar(4) NOT NULL, `id` int(11) NOT NULL AUTO_INCREMENT,
`birth` datetime NOT NULL, `animal` varchar(4) NOT NULL,
`name` varchar(100) NOT NULL, `birth` datetime NOT NULL,
`owner` varchar(100) NOT NULL, `name` varchar(100) NOT NULL,
PRIMARY KEY (`id`), `owner` varchar(100) NOT NULL,
KEY `FK_6mfctqh1tpytabbk1u4bk1pym` (`owner`), PRIMARY KEY (`id`),
CONSTRAINT `FK_6mfctqh1tpytabbk1u4bk1pym` FOREIGN KEY (`owner`) REFERENCES `User` (`login`) KEY `FK_6mfctqh1tpytabbk1u4bk1pym` (`owner`),
); CONSTRAINT `FK_6mfctqh1tpytabbk1u4bk1pym` FOREIGN KEY (`owner`) REFERENCES `User` (`login`)
);
-- All the passwords are "<login>pass".
INSERT INTO `User` -- All the passwords are "<login>pass".
VALUES ('ADMIN','jose','A3F6F4B40B24E2FD61F08923ED452F34'), INSERT INTO `User`
('OWNER','pepe','B43B4D046860B2BD945BCA2597BF9F07'), VALUES ('ADMIN','jose','A3F6F4B40B24E2FD61F08923ED452F34'),
('OWNER','juan','B4FBB95580592697DC71488A1F19277E'), ('OWNER','pepe','B43B4D046860B2BD945BCA2597BF9F07'),
('OWNER','ana','22BEEAE33E9B2657F9610621502CD7A4'), ('OWNER','juan','B4FBB95580592697DC71488A1F19277E'),
('OWNER','lorena','05009E420932C21E5A68F5EF1AADD530'); ('OWNER','ana','22BEEAE33E9B2657F9610621502CD7A4'),
('OWNER','lorena','05009E420932C21E5A68F5EF1AADD530');
INSERT INTO `Pet` (animal, birth, name, owner)
VALUES ('CAT','2000-01-01 01:01:01','Pepecat','pepe'), INSERT INTO `Pet` (animal, birth, name, owner)
('CAT','2000-01-01 01:01:01','Max','juan'), VALUES ('CAT','2000-01-01 01:01:01','Pepecat','pepe'),
('DOG','2000-01-01 01:01:01','Juandog','juan'), ('CAT','2000-01-01 01:01:01','Max','juan'),
('CAT','2000-01-01 01:01:01','Anacat','ana'), ('DOG','2000-01-01 01:01:01','Juandog','juan'),
('DOG','2000-01-01 01:01:01','Max','ana'), ('CAT','2000-01-01 01:01:01','Anacat','ana'),
('BIRD','2000-01-01 01:01:01','Anabird','ana'); ('DOG','2000-01-01 01:01:01','Max','ana'),
('BIRD','2000-01-01 01:01:01','Anabird','ana');
``` ```
### Wildfly 8 ### Wildfly 8
...@@ -96,31 +103,28 @@ the datasource used by the application and the security configuration. ...@@ -96,31 +103,28 @@ the datasource used by the application and the security configuration.
#### Datasource #### Datasource
There are several ways to add a datasource to a WildFly server. We are going to There are several ways to add a datasource to a WildFly server. We are going to
use the simplest way: add the datasource as a deployment. To do so, you have to add a new datasource to the `standalone/configuration/standalone.xml`
add a XML file to the `standalone/deployments` folder of the WildFly server with configuration file of the server. To do so, you have to edit this file and add
the following content: the following content to the `<datasources>` element:
```xml ```xml
<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.ironjacamar.org/doc/schema" <datasource jndi-name="java:jboss/datasources/xcs" pool-name="MySQLPool">
xsi:schemaLocation="http://www.ironjacamar.org/doc/schema http://www.ironjacamar.org/doc/schema/datasources_1_1.xsd"> <connection-url>jdbc:mysql://localhost:3306/xcs</connection-url>
<driver>mysql-connector-java-5.1.21.jar</driver>
<datasource jndi-name="java:jboss/datasources/xcs" pool-name="MySQLPool"> <pool>
<max-pool-size>30</max-pool-size>
<connection-url>jdbc:mysql://localhost:3306/xcs</connection-url> </pool>
<driver>mysql-connector-java-5.1.21.jar</driver> <security>
<pool> <user-name>xcs</user-name>
<max-pool-size>30</max-pool-size> <password>xcs</password>
</pool> </security>
<security> </datasource>
<user-name>xcs</user-name>
<password>xcs</password>
</security>
</datasource>
</datasources>
``` ```
In addition, you also have to add to the same folder the MySQL driver that can In addition, you also have to add the MySQL driver to the deployments folder
be downloaded from [here](http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar). (`standalone/deployments`). You can download it form [here](http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar)
to the deployments folder and Wildfly will automatically deploy it.
#### Security configuration #### Security configuration
All the WildFly security configuration is done in the All the WildFly security configuration is done in the
...@@ -128,34 +132,38 @@ All the WildFly security configuration is done in the ...@@ -128,34 +132,38 @@ All the WildFly security configuration is done in the
Inside the `<security-reamls>` element you have to add: Inside the `<security-reamls>` element you have to add:
```xml ```xml
<security-realm name="RemotingRealm">
<authentication> <security-realm name="RemotingRealm">
<jaas name="AppRealmLoopThrough"/> <authentication>
</authentication> <jaas name="AppRealmLoopThrough"/>
</security-realm> </authentication>
</security-realm>
``` ```
And inside the `<security-domains>` element you have to add: And inside the `<security-domains>` element you have to add:
```xml ```xml
<security-domain name="AppRealmLoopThrough" cache-type="default">
<authentication> <security-domain name="AppRealmLoopThrough" cache-type="default">
<login-module code="Client" flag="required"> <authentication>
<module-option name="multi-threaded" value="true"/> <login-module code="Client" flag="required">
</login-module> <module-option name="multi-threaded" value="true"/>
</authentication> </login-module>
</security-domain> </authentication>
<security-domain name="xcs-sample-security-domain"> </security-domain>
<authentication> <security-domain name="xcs-sample-security-domain">
<login-module code="Database" flag="required"> <authentication>
<module-option name="dsJndiName" value="java:jboss/datasources/xcs"/> <login-module code="Database" flag="required">
<module-option name="principalsQuery" value="SELECT password FROM User WHERE login=?"/> <module-option name="dsJndiName" value="java:jboss/datasources/xcs"/>
<module-option name="rolesQuery" value="SELECT role, 'Roles' FROM User WHERE login=?"/> <module-option name="principalsQuery" value="SELECT password FROM User WHERE login=?"/>
<module-option name="hashAlgorithm" value="MD5"/> <module-option name="rolesQuery" value="SELECT role, 'Roles' FROM User WHERE login=?"/>
<module-option name="hashEncoding" value="hex"/> <module-option name="hashAlgorithm" value="MD5"/>
<module-option name="ignorePasswordCase" value="true"/> <module-option name="hashEncoding" value="hex"/>
</login-module> <module-option name="ignorePasswordCase" value="true"/>
</authentication> </login-module>
</security-domain> </authentication>
</security-domain>
``` ```
#### Deploying the application #### Deploying the application
...@@ -283,5 +291,7 @@ and the 10990 as the management port). ...@@ -283,5 +291,7 @@ and the 10990 as the management port).
The offset of a Wildfly server can be changed using the system property `jboss.socket.binding.port-offset`. For example, starting Wildfly with the The offset of a Wildfly server can be changed using the system property `jboss.socket.binding.port-offset`. For example, starting Wildfly with the
command: command:
```bash ```bash
$WILDFLY_HOME/bin/standalone.sh -Djboss.socket.binding.port-offset=1000
$WILDFLY_HOME/bin/standalone.sh -Djboss.socket.binding.port-offset=1000
``` ```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment