> > calling Ejb2.methodB using
> AccessController.doPrivileged from Ejb1.methodA
> cannot ensure that the call would have the role
> required. Did you see this documented somewhere.
>
> What is the purpose of AccessController.doPrivileged
> then?
If there is codebase B which has higher permissions then codebase A (say in terms of accessing a protected resource C) and if codebase A is invoking codebase B to access the resource C. Then normally this would fail if the security manager is ON. But codebase B can allow its callers to access the resource C by executing the access to the resource inside AccessController.doPrivileged
The permissions that apply to a codebase can be specified in the policy files which are read in by the VM.
> How do I then call methodB in this scenario,
> Subject.runAs?
>
For the scenario you described Subject.runAs will not help as well, becasue as i understand, Ejb1.methodA is not secure whereas Ejb2.methodB requires caller to be in some role.
If you can ensure that the caller of Ejb1.methodA is in the required role only then the invocation of Ejb2.methodB from Ejb1.methodA will work.
One thing you could do is try a ProgrammaticLogin inside Ejb1.methodA before you call Ejb2.methodB. And don't forget to logout after you finish the call to Ejb2.methodB. You will need to login with a principal which is the role required by Ejb2.methodB.
> > So the roles would still need to be defined either
> by Annotations or in xml
> I have the roles declared via annotations on the
> beans where they are used.
[Message sent by forum member 'kumarjayanti' (kumarjayanti)]
http://forums.java.net/jive/thread.jspa?messageID=332219