aspose file tools*
The moose likes Spring and the fly likes Spring security - Mysql - problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring security - Mysql - problem" Watch "Spring security - Mysql - problem" New topic
Author

Spring security - Mysql - problem

camilo lopes
Ranch Hand

Joined: Aug 08, 2007
Posts: 202
hi guys,
I am having problem with change ROLE_ prefix. I have BD mysql with some function like: Manager, Vendor etc. So, i would like to use on my


this way:



how can i do it?

anyone could i help me, please?

this my code:


thanks!


Brazil - Sun Certified Java Programmer - SCJP 5
http://www.camilolopes.com/ About Java - Update every Week.
Guide SCJP - tips that you need know http://blog.camilolopes.com.br/livrosrevistaspalestras/
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

I have bad news. You can't

For some reason your Roles in Spring Security must be prefixed with "ROLE_"

I figured this out tearing my hair out for hours a year ago.

So in your query to load the data just prepend the "ROLE_"

like

SELECT username, 'ROLE_' || real_role_field FROM myRoleTable where username = ?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
camilo lopes
Ranch Hand

Joined: Aug 08, 2007
Posts: 202
Hi Mark,

ohh my god, bad news. I spent my all day with this and i did not find any solution. i do not get understand why required we have ROLE_ like prefix, legacy app does not record on BD ROLE_ADMIN.

Now i have this code:



So, if i use your sugesst i will get to fix?




thanks for your help...
camilo lopes
Ranch Hand

Joined: Aug 08, 2007
Posts: 202
Hi Mark,

I got to fix, look:
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Cool, I didn't know about the concat function in MySql, the sql I wrote works in Oracle, so assumed it would work elsewhere.

Congrats on getting it to work.

Mark
camilo lopes
Ranch Hand

Joined: Aug 08, 2007
Posts: 202
hi mark,

Yes, looks good with concat function. I have not tested in other BD. but it seems to work ok.

thanks for your help
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Spring security - Mysql - problem