Calling a SLSB with Seam security from a servlet

Posted by wilth on Stack Overflow See other posts from Stack Overflow or by wilth
Published on 2010-06-06T10:26:52Z Indexed on 2010/06/06 17:22 UTC
Read the original article Hit count: 352

Filed under:
|
|
|
|

Hello,

I have an existing application written in SEAM that uses SEAM Security (http://docs.jboss.org/seam/2.1.1.GA/reference/en-US/html/security.html). In a stateless EJB, I might find something like this:

@In
Identity identity;

... 

if(identity.hasRole("admin"))
  throw new AuthException();

As far as I understand, Seam injects the Identity object from the SessionContext of the servlet that invokes the EJB (this happens "behind the scenes", since Seam doesn't really use servlets) and removes it after the call. Is this correct?

Is it now possible to access this EJB from another servlet (in this case, that servlet is the server side of a GWT application)? Do I have to "inject" the correct Identity instance? If I don't do anything, Seam injects an instance, but doesn't correctly correlate the sessions and instances of Identity (so the instances of Identity are shared between sessions and sometimes calls get new instances etc.).

Any help and pointers are very welcome - thanks!

Technology: EJB3, Seam 2.1.2. The servlets are actually the server-side of a GWT app, although I don't think this matters much. I'm using JBoss 5.

© Stack Overflow or respective owner

Related posts about security

Related posts about session