-
1. Re: How to let
changemylife Sep 3, 2007 9:46 PM (in response to bjolletz)I think that @SecurityDomain annotation can resolve this problem. You can declare it in your code or XML configuration file. Then, you edit login-config.xml inside xxx/server/conf.
-
2. Re: How to let
bjolletz Sep 4, 2007 5:51 AM (in response to bjolletz)Thanks for your reply!
I am already using a security domain. I'll try to describe my problem better:
For example, I have a bean like this:@StateLess @SecurityDomain("MySecurityDomain") public class MyEntityManagerSLB { @RolesAllowed({"admin", "developer"}) public void foo() { // Method that a user with admin or developer roles may use ... } @RolesAllowed("system") public void bar() { // Method that only "the system" may use. "The system" referring to scheduled tasks run by a timer. ... } }
The problem is to make "the system" able to run the bar method. I can't figure out how to make "the system" authenticated in the "MySecurityDomain".
My first idea was to use @RunAs("system") in the scheduled timer methods , but to be able to use @RunAs in a class, that class must also have a security domain. If I put @SecurityDomain("MySecurityDomain") on the timer class I will get an Authentication Exception. This is understandable, since the code in this class is really not being run by someone logged in to the sucurity domain, but rather from "the system", which is not authenticated in the security domain.
I don't know if I've made this any more understandable, but maybe you understand what I'm trying to do.
/Daniel -
3. Re: How to let
changemylife Sep 4, 2007 10:02 PM (in response to bjolletz)I don't sure that I understand your problem. "system" is a role that you declared in code. If SecurityDoamin is valid, all things are Ok.
-
4. Re: How to let
bjolletz Sep 5, 2007 5:05 AM (in response to bjolletz)I guess the problem is how to let "the system" be authenticated in MySecurityDomain. I've figured out that "the system" somehow needs to log in programmatically to gain access to my security domain.
It seems like I've found a solution, although I'm not sure it's how you're supposed to handle this problem...
I simply let "the system" log in programmatically with the following code:SecurityAssociation.setPrincipal(new SimplePrincipal("system")); SecurityAssociation.setCreddentials("systemPassword");