• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

isUserInRole problem in glassfish (Solved)

 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've created a a web project in Netbeans which contains a Web Service on Glassfish 2.1 as follows


I'm doing programmatic login of glassfish using the class com.sun.appserv.security.ProgrammaticLogin.login() (I had to do it because of some logging requirement). After I do the login, I call the serviceContext.isUserInRole() method to see if the user is in the correct role. The "Default Principal To Role Mapping" is checked in glassfish (I tried after disabling it too). Still I've mapped the user role to group names in the sun-web.xml file as follows (I have tried it without this code in the sun-web.xml too)


Still the isUserInRole method is returning false. If I declare <principal-name> elements to define individual principals, then it works fine. A similar approach is working fine on a simple servlet where I'm using programmatic login with HttpServletRequest.isUserInRole in a filter. Am I doing something wrong here??

Edit: one more detail, another EJB based web service is injected into this web service. The code looks like this

 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stupid of me, I just created a filter for the web service and it was solved, the WebServiceContext.isUserInRole was creating the problem, I still don't know what the problem was but its at least solved for now...
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic