karthik chellappan

Ranch Hand
+ Follow
since Jul 01, 2007
Merit badge: grant badges
For More
India
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by karthik chellappan

I successfully completed login module of my application using spring security's inbuilt authentication & authorization mechanism.But later i was told to check if i can integrate `WSO2` (`SOA solution as external Authorization mechanism`) with `Spring` security so that i can use Spring security's authentication mechanism alone and `WSO2` for authorization instead of using Spring security provided Authorization.

I did search & read the documentation and i could get details about using External authentication with Spring security & nothing about External authorization.I would like to know if i can do the same and also how i can do it.
10 years ago
Hi Kathleen,

Thanks for the reply. I've tried in-memory authentication and it worked fine for me. But for D/B Authentication i always keep on getting 'Bad credentials' error. I did check the link which you've referred and executed the query manually to check if its working. I found query working without any problem as there was no trailing space issues.

Now I've following 'users_detail' table in D/B :

USER_ID INTEGER

USERNAME VARCHAR2 (50 Byte)

PASSWORD VARCHAR2 (50 Byte)

ENABLED INTEGER

Data in the 'users_detail' table :

USER_ID USERNAME PASSWORD ENABLED

100 user 123456 1

My query is in security-context.xml :

"select username,password, enabled from users_detail where username=?"

when i execute the query manually i.e. select username,password,enabled from users_detail where username='user'. i get the resultsets.

Where am i going wrong ? Why is it that JdbcUserDetailsManager class always return 'Query returned no results for user 'user' ' even though there is an entry for the same in D/B.

DEBUG: org.springframework.security.provisioning.JdbcUserDetailsManager - Query returned no results for user 'user'
DEBUG: org.springframework.security.authentication.dao.DaoAuthenticationProvider - User 'user' not found

Debug mode doesn't show which method of JdbcUserDetailsManager class is being executed when i get the above error. How can i know that? Also, does spring internally do any encryption/decryption technique while saving password field?
10 years ago
I'm trying to do a basic spring security D/B authentication program.I tried this by two ways i.e.

Method 1 : Using custom tables for Spring Security authentication.
Method 2 : Using Spring security specific database tables for user authentication and authorization.

File Locations:
1. index.jsp -> webapp/index.jsp
2. welcome.jsp -> webapp/pages/welcome.jsp
3. login.jsp -> webapp/pages/login.jsp

For method 1,Spring security was not intercepting request and i didn't see errors in console.Instead of intercepting the request i was directly taken to welcome.jsp.

P.S - Since i was not trying authorization, i didn't use 'authorities-by-username-query' attribute below in security context xml. I'm not sure if its mandatory to create a table for authorization as well.

Below is my security-context.xml:



web.xml



BaseController


login.jsp


index.jsp


How can i debug this kind of scenarios effectively if errors are not shown in console. I've already SL4J logging enabled through maven.

For method 2, i created spring specific database tables in the name of “USERS” and “AUTHORITIES” after following linklink. Here SQL query is not used in xml as shown below.

Every thing remains same except for security-context.xml.



when i tried the above way, even though i enter correct user name & password, i was getting 'bad credentials' message [But yes, in this case spring security is intercepting the request]. I'm using Oracle database.

Please guide me where i'm going wrong in both the cases. Advance thanks.
11 years ago

Saif Asif wrote:
First I want to make it clear that maven is a build and project management tool and it has absolutely no link to deploying your application to any web-server. Even if you look at the tomcat-plugin , it just issues a move command to move your war file to your desired location ( webapps of tomcat ). The same goes for tomcat:start and tomcat:run commands of maven ( they just issue the startup.sh and shutdown.sh commands , no magic ) .



If thats the case then when i give 'tomcat:run' command i see only one 'javaw' process running which is the server and under 'services' i see 'Tomcat6' as stopped status. Doesn't that indicate that i'm actually not using tomcat server in my machine. Please clarify.
11 years ago
I'm using eclipse indigo IDE, apache tomcat 6.0 server, m2e plugin,jdk 1.6 softwares in my project.

After i make some changes in java code i do clean & maven build and the start the tomcat embedded server using maven i.e. 'tomcat:run' plugin command. But after following all steps i don't see my changes reflecting at all.

Now after i build all classes i see that all the class files are generated inside 'target' folder which i confirmed with the time at which it was generated.So i believe these class files are not getting published to embedded tomcat server of maven for some reasons.

P.S - I don't start/stop or use tomcat server configured in eclipse as i believe embedded tomcat server of maven doesn't use tomcat server in eclipse and it works by itself.Please correct me if i'm wrong here.

Please help me out.
11 years ago
I changed the code (like shown below) from above and now i'm getting the desired output. But i see that too much string object is created in loop which is not good. Can any one please tell me how i can optimize it and make it efficient.

11 years ago
Yes. I want to know if i should be inserting all 'values' in Map in a for loop with 'id' as 'key'.If some one can give a code snippet of the remaining logic i can try it out.

Thanks.
11 years ago
Hi,

I've two text files:

File1: (id,name,role)

10,karthik,Developer
20,Arya,Tester

File2: (id,salary)

20,15000
10,10000

Expected Output:

10 Karthik Developer 10000
20 Arya Tester 15000

I've the following code so far:


I'm now stuck on how to use String arrays along with collections to get the desired result. i.e. if i have to use Map, then i'm not sure how to use key,value pair for the above scenario so that i can join 'salary' in file2 to other file1 data's based on 'id' value. Please guide me.
11 years ago
I was going through 'Serialization of Singleton objects' concept.I got few threads where every one was saying it's possible using readResolve() method.

For e.g. Elvis is name of class for which we are going to create singleton object and we instantiate object with static modifier like shown below:



In first place,Serialization is for instance variables and not for class variables.static variables are not serialized/deserialized and hence a new object shouldn't be created right?

But then in the link i got, few guys are saying that a new object will be created by deserialization process and it is this new object which readResolve method ensures that nothing ever sees it.

Please clarify what exactly is happening behind the scenes when we are serializing/deserializing static variables?
11 years ago
Thanks Stefan.

Earlier i was getting 'The value for the useBean class attribute is invalid' error and on googling i got links which said that there should be a public default constructor without arguments in the java bean class. But for me issue was with class files not under WEB_INF directory.

Is it necessary that i include a public default constructor without arguments in the java bean class? As i see that above code runs fine without the constructor also.
11 years ago
JSP
I'm trying to do a simple example of UseBean Tag in JSP.

UserBean.java


firstAdditional.jsp:



secondAdditional.jsp:


thirdAdditional.jsp:


also tried using expression, which also returned null.


I'm not sure how to debug this. Please point out where i'm going wrong.
11 years ago
JSP
I was encountering this problem intermittently and on googling i got below link where they say it could be a bug in Tomcat.

EL

So to avoid this problem i have to include
in jsp page or add in web.xml even though EL is enabled by default for Servlet 2.4 spec and above.

11 years ago
JSP
Bear,

I just changed my root declaration in web.xml to version 2.5 and for my surprise, it worked perfectly fine. I checked source in the browser and saw that EL was evaluated properly which was not happening earlier for version 2.5. When i changed to 2.4 version i didn't get exception (it worked fine) and now i'm not getting exception in 2.5 version as well. So i'm quite confused and not sure why i was getting initially this error.
11 years ago
JSP
Rob,

I'm using Apache Tomcat/5.5.27.
11 years ago
JSP
Rob,

Servlet version i had was : 2.4
JSP version : 2.0
Server : Apache Tomcat/5.5.27

I saw following in web.xml of the above application:


when i created new web application, the default declaration was of version 2.4 i.e.


I used the above line of code in place of existing code in web.xml and it worked. Thanks for the reply.
11 years ago
JSP