Please help me out for the below mentioned scenario….
applicationContext-security.xml
<authentication-manager>
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="SELECT username, password FROM myLibrary.user WHERE username=?" />
</authentication-provider>
</authentication-manager>
database-end(MySQL)
CREATE TABLE `myLibrary`.`user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`enabled` bit(1) DEFAULT NULL,
`fullName` varchar(255) DEFAULT NULL,
`password` varchar(120) DEFAULT NULL,
`username` varchar(40) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
UNIQUE KEY `username` (`username`)
);
xml-user
<user-service>
<user name="admin" password="amdin" authorities="supervisor, user" />
<user name="counter1" password="counter1" authorities="user" />
</user-service>
“dataSource”; values as perfect too…!!! And there is no exception in any logs….which means library integration is perfect. In fact while using XML based user definitions it works great….but in database access it falis.
My login page sticks to the same; i mean login fails. Pls help friends….!!!!
Sorry for the delay….!!! so the problem is at the table responsible for users and that must have to be
users. And it’s running awesome…..!!! thanks friends…..thanks a lot…!!!!Before the above xml-lines; make sure the table for the users must have to be
usersand also another tableauthoritiesmust exists with foreign key tousers - username. Ok..allow me to put the database part too..!!Please note that;
authorities(allowed)is not mandatory….it’s part of my code..as i want to show the user….all of it’s authorities regardless of it’s permission to use.I am using
hibernateand so i am gettingIDfield…and off-course it’s upto you as fas as it’s usability is concerned.Have a nice day…!!!!
🙂