• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Why doesn't EJBContext offer a method like getCallerRole to obtain the caller's role?

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJBContext has isCallerInRole() and getCallerPrincipal(), but how could I get the caller's role?
[ December 17, 2008: Message edited by: Mellon Sun ]
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

how could I get the caller's role?

You can recover it through evaluating isCallerInRole: Though not very elegant, but works.
 
Mellon Sun
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a method to get all the roles?
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is there a method to get all the roles?


No. Moreover you have to declare each role you want to use in isCallerInRole in the @DeclareRoles annotation. If you use a different one you'll get an error.
[ December 17, 2008: Message edited by: Ralph Jaus ]
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to add:

To my understanding the EJB role model goes in the other direction: First, the bean provider defines appropriate roles for his or her application. Then he or she specifies which role is allowed to use which business methods (@RolesAllowed) or how the business logic depends on the role of the caller (isCallerInRole).

In this point of view there is no need to determine the possible roles in a business method.

But my understanding may be a little bit limited. Interesting topic anyway.
[ December 17, 2008: Message edited by: Ralph Jaus ]
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic