9.4.3. Securing Access to JNDI over HTTP

One benefit to accessing JNDI over HTTP is that it is easy to secure access to the JNDI InitialContext factory as well as the naming operations using standard web declarative security. This is possible because the server side handling of the JNDI/HTTP transport is implemented with two servlets. These servlets are included in the http-invoker.sar/invoker.war directory found in the default and all server profile deploy directories as shown previously. To enable secured access to JNDI you need to edit the invoker.war/WEB-INF/web.xml descriptor and remove all unsecured servlet mappings. For example, the web.xml descriptor shown in Example 9.3, “An example web.xml descriptor for secured access to the JNDI servlets” only allows access to the invoker.war servlets if the user has been authenticated and has a role of HttpInvoker.

Example 9.3. An example web.xml descriptor for secured access to the JNDI servlets

<?xml version="1.0" encoding="UTF-8"?>
          "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    <!-- ### Servlets -->
    </servlet>   <servlet>
    <!-- ### Servlet Mappings -->
    </servlet-mapping>   <security-constraint>
            <description>An example security config that only allows users with
                the role HttpInvoker to access the HTTP invoker servlets </description>
        <realm-name>JBoss HTTP Invoker</realm-name>
    </login-config>   <security-role>
The web.xml descriptor only defines which servlets are secured, and which roles are allowed to access the secured servlets. You must additionally define the security domain that will handle the authentication and authorization for the war. This is done through the jboss-web.xml descriptor, and an example that uses the http-invoker security domain is given below.
The security-domain element defines the name of the security domain that will be used for the JAAS login module configuration used for authentication and authorization.