Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Perhaps my answer may not be correct and can be incomplete. But it can be found in this reference <a href="http://openejb.apache.org/3.0/security-annotations.html" rel="nofollow">http://openejb.apache.org/3.0/security-annotations.html</a></p> <p>DeclareRoles can only be used in class level You need to update the @DeclareRoles when referencing roles via isCallerInRole(roleName).</p> <p>Basic idea</p> <ul> <li><p>By default all methods of a business interface are accessible, logged in or not</p></li> <li><p>The annotations go on the bean class, not the business interface</p></li> <li><p>Security annotations can be applied to entire class and/or individual methods</p></li> <li><p><strong>The names of any security roles used must be declared via @DeclareRoles</strong></p></li> </ul> <p>@RolesAllowed Can be used both in class level and methods level to restrict the access level.</p> <p>one example Mixing class and method level restrictions Security annotations can be used at the class level and method level at the same time. These rules do not stack, so marking 'submitPatch' overrides the default of "committers".</p> <pre><code>@Stateless @DeclareRoles({"committer", "contributor"}) @RolesAllowed({"committer"}) public class OpenSourceProjectBean implements Project { public String svnCommit(String s) { return s; } public String svnCheckout(String s) { return s; } @RolesAllowed({"contributor"}) public String submitPatch(String s) { return s; } } </code></pre> <p><strong>EDIT:</strong></p> <p>Here is the code snippet for <a href="http://www.java2s.com/Open-Source/Java-Document/EJB-Server/geronimo/security/org/apache/geronimo/security/realm/providers/SQLLoginModule.java.htm" rel="nofollow">SQLLoginModule</a>. You can use this module to be the login module. In this way,you can follow the JAAS standard.</p> <p>In commit , it will call this to add principals.</p> <pre><code>subject.getPrincipals().addAll(allPrincipals); </code></pre> <p>Also you can check here for more details <a href="http://openejb.apache.org/3.0/security.html" rel="nofollow">http://openejb.apache.org/3.0/security.html</a>.</p> <p>It lists other options you can choose.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload