Note that there are some explanatory texts on larger screens.

plurals
  1. POJava EE 5 security annotations getting ignored on methods in glassfish v2
    primarykey
    data
    text
    <p>I have a simple EE5 application with a web client and and an ejb module running glassfish 2. The security annotations in the ejbs on methods are getting ignored, but not those on class level.</p> <p>For example I have following bean:</p> <pre><code> @Stateful(mappedName = "ejb/PurchaseOrderDao") @DeclareRoles("employees") @RolesAllowed(value = { "employees" }) public class PurchaseOrderDao implements PurchaseOrderDaoLocal { @Resource private EJBContext ejbContext; @DenyAll public final void add(final PurchaseOrder instance) { log.debug("Is User in Role employees: {}", ejbContext.isCallerInRole("employees")); delegate.add(instance); } [...] } </code></pre> <p>Every user can call this method. The debug statement returns the correct value.</p> <p>The security constraints on web resources in the webclient defined in the web.xml are working as expected but not those defined in the annotations on mwthods.</p> <p>In my application.xml I am defining the realm and the roles. I am mapping them in the sun-application.xml.</p> <p>What can be the cause? Is it a known issue of glassfish v2? It works correctly in glassfish v3.</p> <p><strong>Other resources:</strong></p> <p><strong>sun-ejb-jar.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd"&gt; &lt;sun-ejb-jar&gt; &lt;enterprise-beans&gt; &lt;/enterprise-beans&gt; &lt;/sun-ejb-jar&gt; </code></pre> <p><strong>ejb-jar.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0"&gt; &lt;display-name&gt;ejb&lt;/display-name&gt; &lt;/ejb-jar&gt; </code></pre> <p><strong>application.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" id="ocea" version="5"&gt; &lt;display-name&gt;ocea&lt;/display-name&gt; &lt;module&gt; &lt;ejb&gt;ejb.jar&lt;/ejb&gt; &lt;/module&gt; &lt;module&gt; &lt;web&gt; &lt;web-uri&gt;web.war&lt;/web-uri&gt; &lt;context-root&gt;ocea&lt;/context-root&gt; &lt;/web&gt; &lt;/module&gt; &lt;security-role&gt; &lt;description&gt;Employees&lt;/description&gt; &lt;role-name&gt;employees&lt;/role-name&gt; &lt;/security-role&gt; &lt;security-role&gt; &lt;description&gt;Suppliers&lt;/description&gt; &lt;role-name&gt;suppliers&lt;/role-name&gt; &lt;/security-role&gt; &lt;library-directory&gt;/lib&lt;/library-directory&gt; &lt;/application&gt; </code></pre> <p><strong>sun-application.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE sun-application PUBLIC '-//Sun Microsystems, Inc.//DTD Application Server 9.0 Java EE Application 5.0//EN' 'http://www.sun.com/software/appserver/dtds/sun-application_5_0-0.dtd'&gt; &lt;sun-application&gt; &lt;security-role-mapping&gt; &lt;role-name&gt;employees&lt;/role-name&gt; &lt;group-name&gt;employees&lt;/group-name&gt; &lt;/security-role-mapping&gt; &lt;security-role-mapping&gt; &lt;role-name&gt;suppliers&lt;/role-name&gt; &lt;group-name&gt;suppliers&lt;/group-name&gt; &lt;/security-role-mapping&gt; &lt;/sun-application&gt; </code></pre> <p><strong>web.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt; &lt;display-name&gt;web&lt;/display-name&gt; &lt;!-- [...] --&gt; &lt;login-config&gt; &lt;auth-method&gt;FORM&lt;/auth-method&gt; &lt;form-login-config&gt; &lt;form-login-page&gt;/login&lt;/form-login-page&gt; &lt;form-error-page&gt;/loginfailed&lt;/form-error-page&gt; &lt;/form-login-config&gt; &lt;/login-config&gt; &lt;security-constraint&gt; &lt;web-resource-collection&gt; &lt;web-resource-name&gt;PublicContent&lt;/web-resource-name&gt; &lt;description&gt;Publically available Content needs no authorization.&lt;/description&gt; &lt;url-pattern&gt;/static/*&lt;/url-pattern&gt; &lt;url-pattern&gt;/logout&lt;/url-pattern&gt; &lt;url-pattern&gt;/loggedout&lt;/url-pattern&gt; &lt;url-pattern&gt;/decorator&lt;/url-pattern&gt; &lt;/web-resource-collection&gt; &lt;/security-constraint&gt; &lt;security-constraint&gt; &lt;web-resource-collection&gt; &lt;web-resource-name&gt;Add Requests&lt;/web-resource-name&gt; &lt;description&gt;accessible by employees&lt;/description&gt; &lt;url-pattern&gt;/requestadd&lt;/url-pattern&gt; &lt;url-pattern&gt;/requestaddreal&lt;/url-pattern&gt; &lt;url-pattern&gt;/orderadd&lt;/url-pattern&gt; &lt;/web-resource-collection&gt; &lt;auth-constraint&gt; &lt;role-name&gt;employees&lt;/role-name&gt; &lt;/auth-constraint&gt; &lt;/security-constraint&gt; &lt;security-constraint&gt; &lt;web-resource-collection&gt; &lt;web-resource-name&gt;Add Bids&lt;/web-resource-name&gt; &lt;description&gt;accessible by suppliers&lt;/description&gt; &lt;url-pattern&gt;/bidadd&lt;/url-pattern&gt; &lt;/web-resource-collection&gt; &lt;auth-constraint&gt; &lt;role-name&gt;suppliers&lt;/role-name&gt; &lt;/auth-constraint&gt; &lt;/security-constraint&gt; &lt;security-constraint&gt; &lt;web-resource-collection&gt; &lt;web-resource-name&gt;Webapplication&lt;/web-resource-name&gt; &lt;description&gt;accessible by authorized users&lt;/description&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/web-resource-collection&gt; &lt;auth-constraint&gt; &lt;description&gt;For Employees and Suppliers&lt;/description&gt; &lt;role-name&gt;employees&lt;/role-name&gt; &lt;role-name&gt;suppliers&lt;/role-name&gt; &lt;/auth-constraint&gt; &lt;/security-constraint&gt; &lt;!-- [...] --&gt; &lt;ejb-local-ref&gt; &lt;ejb-ref-name&gt;ejb/Dao&lt;/ejb-ref-name&gt; &lt;local&gt;ejb.dao.DaoLocal&lt;/local&gt; &lt;/ejb-local-ref&gt; &lt;!-- [... other ejb-local-ref ...] --&gt; &lt;/web-app&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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