shiro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ipas <mipa...@gmail.com>
Subject Re: Shiro Jdbc Realm Mysql.
Date Wed, 16 Nov 2011 16:37:58 GMT
Ok this issue is resolved. It is up and running now. 
I just used  https://github.com/eneuwirt/vaadin-shiro-simple
vaadin-shiro-simple  as a background and made changes to use Shiro
jdbcRealm. It is obvious that there is no need to make changes in Java code.
So changes made only in shiro.ini and in particular MySql database.

Content of shiro.ini is :
[main]
jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.permissionsLookupEnabled = true
jdbcRealm.authenticationQuery = SELECT password FROM users WHERE username =
?
jdbcRealm.userRolesQuery = SELECT role_name FROM user_roles WHERE username =
?
jdbcRealm.permissionsQuery = SELECT roleper FROM roles_permissions WHERE
role_name = ?
ds = com.jolbox.bonecp.BoneCPDataSource
ds.driverClass=com.mysql.jdbc.Driver
ds.jdbcUrl=jdbc:mysql://localhost:3306/dbname
ds.username = username
ds.password = password
jdbcRealm.dataSource=$ds

database:
CREATE TABLE IF NOT EXISTS `roles_permissions` (
 `roleper` char(50) NOT NULL,
 `role_name` char(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `users` (
 `username` char(50) NOT NULL,
 `password` char(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `user_roles` (
 `role_name` char(50) NOT NULL,
 `username` char(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

For maven users pom.xml dependencies:

<repository>
		  <releases>
                                  <enabled>true</enabled>
                  </releases>
    		 <id>bonecp-repo</id>
 		 <name>BoneCP Repository</name>
		 <url>http://jolbox.com/bonecp/downloads/maven</url>
</repository>

                <dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-core</artifactId>
			<version>1.1.0</version>
		</dependency>

		<dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-web</artifactId>
			<version>1.1.0</version>
		</dependency>

		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>1.6.1</version>
		</dependency>
		<dependency>
			<groupId>com.jolbox</groupId>
			<artifactId>bonecp</artifactId>
			<version>0.6.5</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.18</version>
		</dependency>
		<dependency>
			<groupId>commons-logging</groupId>
			<artifactId>commons-logging</artifactId>
			<version>1.1.1</version>
		</dependency>

Thats it , it is working just like shiro-vaadin-simple.

--
View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro-Jdbc-Realm-Mysql-tp6519616p7000979.html
Sent from the Shiro User mailing list archive at Nabble.com.

Mime
View raw message