Posted on

Securing Oracle Weblogic applications

Configuring Security for Web applications

Configuring security for Oracle WLS Web applications is done in two separate points:

  1. Inside the standard web application configuration file (web.xml) you will define the authorized Roles, the secured URL Pattern and the Authorization method.
  2. Inside the weblogic.xml you will map these roles to actual principals defined in the WebLogic Server security realm.

Let’s define at first in your web.xml how to apply security constraints using BASIC authentication:




                            <description>Our Secure Area</description>




                            <description>Constraints for secure area</description>





                            <description>SSL is not required</description>





              <auth-method>              BASIC</auth-method>



We have restricted access to all Web Context resources so that only users with the role admin and poweruser can access them, but we are not requiring the use of SSL transport for access.

Setting the <transport-guarantee> to CONFIDENTIAL or INTEGRAL would further restrict access to only those users in one of the specified roles who are using SSL to access the page.

If we stopped here, WebLogic Server would try to map these roles to principals (either users or groups) with the same name, as defined in the active security realm’s authentication provider. In most cases, you don’t actually want this, so you need to define the mapping from these roles to actual principals defined in the WebLogic Server security realm.

In order to map these roles to principals in the underlying security realm, you use the <security-role-assignment> element in the weblogic.xml deployment descriptor. In the following example, we are mapping the “admin” role to the “webuser” user and the “poweruser” role to “john”.











Configuring Security for EJB applications

Configuring security for EJB applications is similar to Web applications; just it is uses different files.

Inside your Java EE’s ejb-jar.xml deployment descriptor, define your access control policy by using the <security-role> and <method-permission> elements. In the following example, we restrict access to the SecuredEJB’s getData method to users which are granted the admin role:













EJB 3.0 and later also allows for declaration of EJB security constraints through annotations found in the package, as in the following example:



public class SecuredEJB {


  public Data getData() { … } }

Next, configure into weblogic-ejb-jar.xml the actual mapping data. The following example maps the admin role to ejbuser user. Additionally, you can use the <externally-defined> element to force a role to be defined in the role mapping security provider.







              <externally-defined />