Answer the question
In order to leave comments, you need to log in
An example of how the Subject.doAs method works in JAAS?
Good afternoon!
JAAS has a Subject class which, among other things, has two static methods doAs and doAsPrivileged. With the second, everything is more or less clear, we managed to write a working example.
With the first one, which is doAs, nothing comes out.
So the situation. There are application security settings (set via -Djava.security.policy==) that prohibit reading the property, let's say "test.property". There is a principal, let's say "Jon", to whom such permission is given (via -Djava.security.auth.policy==). According to the description, calling Subject.doAs(subjectJon, privilegedAction) using DomainCombiner should make a new ProtectionDomain from the current one and the one that the specific principal has. But this does not happen and a SecurityException is thrown (it is impossible to read). When using doAsPrivileged(subjectJon, privilegedAction, null) everything works, and the permissions are really mixed, as expected.
Comrades, who are in the subject, write, pliz, a small example of how the doAs method works. Or describe the situations in which it works, maybe I'm trying to misuse it.
PS: the examples found on the Internet and in the Java Security book do not work, and up to replacing doAs with doAsPrivileged.
Thanks,
Alexei
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question