Friday Apr 06, 2012

Securing an ADF Application using OES11g: Part 2

To validate the integration with OES we need a sample ADF Application that is rich enough to allow us to test securing the various ADF elements.  To achieve this we can add some items including bounded task flows to the application developed in this tutorial. A sample JDeveloper project is available here. It depends on the Fusion Order Demo (FOD) database schema which is easily created using the FOD build scripts.

In the deployment we have chosen to enable only ADF Authentication as we will delegate Authorization, mostly, to OES.  It is possible to integrate ADF authentication with Oracle Access Manager, as explained here, for example.

The welcome page of the application with all the links exposed looks as follows:

The Welcome, Browse Products, Browse Stock and System Administration links go to pages while the Supplier Registration and Update Stock are bounded task flows.  The Login link goes to a basic login page and once logged in a link is presented that goes to a logout page.  Only the Browse Products and Browse Stock pages are really connected to the database--the other pages and task flows do not really perform any operations on the database.

Required Security Policies

We make use of a set of test users and roles as decscribed on the welcome page of the application.  In order to exercise the different authorization possibilities we would like to enforce the following sample policies:

  1. Anonymous users can see the Login, Welcome and Supplier Registration links. They can also see the Welcome page, the Login page and follow the Supplier Registration task flow.  They can see the icon adjacent to the Login link indicating whether they have logged in or not.
  2. Authenticated users can see the Browse Product page.
  3. Only staff granted the right can see the Browse Product page cost price value returned from the database and then only if the value is below a configurable limit.
  4. Suppliers and staff can see the Browse Stock links and pages.  Customers cannot.
  5. Suppliers can see the Update Stock link but only those with the update permission are allowed to follow the task flow that it launches.  We could hide the link but leave it exposed here so we can easily demonstrate the method call activity protecting the task flow.
  6. Only staff granted the right can see the System Administration link and the System Administration page it accesses.

Implementing the required policies

In order to secure the application we will make use of the following techniques:

  • EL Expressions and Java backing beans: JSF has the notion of EL expressions to reference data from backing Java classes.  We use these to control the presentation of links on the navigation page which respect the security contraints.  So a user will not see links that he is not allowed to click on into. These Java backing beans can call on to OES for an authorization decision.  Important Note: naturally we would configure the WLS domain where our ADF application is running as an OES WLS SM, which would allow us to efficiently query OES over the PEP API.  However versioning conflicts between OES and ADF mean that this is not possible.  Nevertheless, we can make use of the OES RESTful gateway technique from this posting in order to call into OES.
You can easily create and manage backing beans in Jdeveloper as follows:

  • Custom ADF Phase Listener: ADF extends the JSF page lifecycle flow and allows one to hook into the flow to intercept page rendering.  We use this to put a check prior to rendering any protected pages, again calling on to OES via the backing bean.  Phase listeners are configured in the adf-settings.xml file.  See the class in the project.  Here, for example,  is the code we use in the listener to check for allowed access to the sysadmin page, navigating back to the welcome page if authorization is not granted:

                        if (page != null && (page.equals("/system.jspx") || page.equals("/system"))){
                             System.out.println("MyPageListener: Checking Authorization for /system");

                             if (getValue("#{oesBackingBean.UIAccessSysAdmin}").toString().equals("false") ){ 
                                 System.out.println("MyPageListener: Forcing navigation away from system" +

                                       "to welcome");
                                 NavigationHandler nh = fc.getApplication().getNavigationHandler(); 
                                 nh.handleNavigation(fc, null, "welcome");
                              } else {
                                 System.out.println("MyPageListener: access allowed");

  • Method call activity: our app makes use of bounded task flows to implement the sequence of pages that update the stock or allow suppliers to self register.  ADF takes care of ensuring that a bounded task flow can be entered by only one page.  So a way to protect all those pages is to make a call to OES in the first activity and then either exit the task flow or continue depending on the authorization decision.  The method call returns a String which contains the name of the transition to effect. This is where we configure the method call activity in JDeveloper:

We implement each of the policies using the above techniques as follows:

  • Policies 1 and 2: as these policies concern the coarse grained notions of controlling access to anonymous and authenticated users we can make use of the container’s security constraints which can be defined in the web.xml file.  The allPages constraint is added automatically when we configure Authentication for the ADF application.  We have added the “anonymousss” constraint to allow access to the the required pages, task flows and icons:
  • Policy 3: we can place an EL expression on the element representing the cost price on the products.jspx page: #{oesBackingBean.dataAccessCostPrice}. This EL Expression references a method in a Java backing bean that will call on to OES for an authorization decision.  In OES we model the authorization requirement by requiring the view permission on the resource /MyADFApp/data/costprice and granting it only to the staff application role.  We recover any obligations to determine the limit. 
  • Policy 4: is implemented by putting an EL expression on the Browse Stock link #{oesBackingBean.UIAccessBrowseStock} which checks for the view permission on the /MyADFApp/ui/stock resource. The stock.jspx page is protected by checking for the same permission in a custom phase listener—if the required permission is not satisfied then we force navigation back to the welcome page.
  • Policy 5: the Update Stock link is protected with the same EL expression as the Browse Link: #{oesBackingBean.UIAccessBrowseStock}.  However the Update Stock link launches a bounded task flow and to protect it the first activity in the flow is a method call activity which will execute an EL expression #{oesBackingBean.isUIAccessSupplierUpdateTransition}  to check for the update permission on the /MyADFApp/ui/stock resource and either transition to the next step in the flow or terminate the flow with an authorization error.
  • Policy 6: the System Administration link is protected with an EL Expression #{oesBackingBean.UIAccessSysAdmin} that checks for view access on the /MyADF/ui/sysadmin resource.  The system page is protected in the same way at the stock page—the custom phase listener checks for the same permission that protects the link and if not satisfied we navigate back to the welcome page.

Testing the Application

To test the application:

  • deploy the OES11g Admin to a WLS domain
  • deploy the OES gateway in a another domain configured to be a WLS SM. You must ensure that the jps-config.xml file therein is configured to allow access to the identity store, otherwise the gateway will not be able to resolve the principals for the requested users.  To do this ensure that the following elements appear in the jps-config.xml file:
    • <serviceProvider type="IDENTITY_STORE" name="idstore.ldap.provider" class="">
                   <description>LDAP-based IdentityStore Provider</description>
    • <serviceInstance name="idstore.ldap" provider="idstore.ldap.provider">
                   <property name="idstore.config.provider" value=""/>
                   <property name="CONNECTION_POOL_CLASS" value=""/>
    • <serviceInstanceRef ref="idstore.ldap"/>
  • download the sample application and change the URL to the gateway in the MyADFApp OESBackingBean code to point to the OES Gateway and deploy the application to an WLS domain that has been extended with the ADF JRF files. You will need to configure the FOD database connection to point your database which contains the FOD schema.
  • populate the OES Admin and OES Gateway WLS LDAP stores with the sample set of users and groups.  If  you have configured the WLS domains to point to the same LDAP then it would only have to be done once.  To help with this there is a directory called ldap_scripts in the sample project with ldif files for the test users and groups.
  • start the OES Admin console and configure the required OES authorization policies for the MyADFApp application and push them to the WLS SM containing the OES Gateway.
  • Login to the MyADFApp as each of the users described on the login page to test that the security policy is correct.
  • You will see informative logging from the OES Gateway and the ADF application to their respective WLS consoles.
  • Congratulations, you may now login to the OES Admin console and change policies that will control the behaviour of your ADF application--change the limit value in the obligation for the cost price for example, or define Role Mapping policies to determine staff access to the system administration page based on user profile attributes.

Some ADF Development Notes

Some general notes on ADF development which I encountered while developing the sample application:

  • May need this on WLS startup in order to allow us to overwrite credentials for the database, the signal here is that there is an error trying to access the data base:
  • Best to call Bounded Task flows via a CommandLink (as opposed to a go link) as you cannot seem to start them again from a go link, even having completed the task flow correctly with a return activity.
  • Once a bounded task flow (BTF) is initated it must complete correctly  via a return activity—attempting to click on any other link whilst in the context of a  BTF has no effect.  See here for example:
  • When using the ADF Authentication only security approach it seems to be awkward to allow anonymous access to the welcome and registration pages.  We can achieve anonymous access using the web.xml security constraint shown above (where no auth-constraint is specified) however it is not clear what needs to be listed in there….for example the /afr/* and /adf/* are in there by trial and error as sometimes the welcome page will not render if we omit those items.  I was not able to use the default allPages constraint with for example the anonymous-role or the everyone WLS group in order to be able to allow anonymous access to pages.
  • The ADF security best practice advises placing all pages under the public_html/WEB-INF folder as then ADF will not allow any direct access to the .jspx pages but will only allow acces via a link of the form /faces/welcome rather than /faces/welcome.jspx.  This seems like a very good practice to follow as having multiple entry points to data is a source of confusion in a web application (particulary from a security point of view).
  • In Authentication+Authorization mode only pages with a Page definition file are protected.  In order to add an empty one right click on the page and choose Go to Page Definition.  This will create an empty page definition and now the page will require explicit permission to be seen.
  • It is advisable to give a unique context root via the weblogic.xml for the application, as otherwise the application will clash with any other application with the same context root and it will not deploy

Securing an ADF Application using OES11g: Part 1

Future releases of the Oracle stack should allow ADF applications to be secured natively with Oracle Entitlements Server (OES).

In a sequence of postings here I explore one way to achive this with the current technology, namely OES and ADF

ADF Security Basics

ADF Bascis

The Application Development Framework (ADF) is Oracle’s preferred technology for developing GUI based Java applications.  It can be used to develop a UI for Swing applications or, more typically in the Oracle stack, for Web and J2EE applications.  ADF is based on and extends the Java Server Faces (JSF) technology.  To get an idea, Oracle provides an online demo to showcase ADF components.

ADF can be used to develop just the UI part of an application, where, for example, the data access layer is implemented using some custom Java beans or EJBs.  However ADF also has it’s own data access layer, ADF Business Components (ADF BC) that will allow rapid integration of data from data bases and Webservice interfaces to the ADF UI component.   In this way ADF helps implement the MVC  approach to building applications with UI and data components.

The canonical tutorial for ADF is to open JDeveloper, define a connection to a database, drag and drop a table from the database view to a UI page, build and deploy.  One has an application up and running very quickly with the ability to quickly integrate changes to, for example, the DB schema.

ADF allows web pages to be created graphically and components like tables, forms, text fields, graphs and so on to be easily added to a page.  On top of JSF Oracle have added drag and drop tooling with JDeveloper and declarative binding of the UI to the data layer, be it database, WebService or Java beans.  An important addition is the bounded task flow which is a reusable set of pages and transitions.   ADF adds some steps to the page lifecycle defined in JSF and adds extra widgets including powerful visualizations.

It is worth pointing out that the Oracle Web Center product (portal, content management and so on) is based on and extends ADF.

ADF Security

ADF comes with it’s own security mechanism that is exposed by JDeveloper at development time and in the WLS Console and Enterprise Manager (EM) at run time.

The security elements that need to be addressed in an ADF application are: authentication, authorization of access to web pages, task-flows, components within the pages and data being returned from the model layer.

One  typically relies on WLS to handle authentication and because of this users and groups will also be handled by WLS.  Typically in a Dev environment, users and groups are stored in the WLS embedded LDAP server.

One has a choice when enabling ADF security (Application->Secure->Configure ADF Security) about whether to turn on ADF authorization checking or not:

In the case where authorization is enabled for ADF one defines a set of roles in which we place users and then we grant access to these roles to the different ADF elements (pages or task flows or elements in a page).

An important notion here is the difference between Enterprise Roles and Application Roles. The idea behind an enterprise role is that is defined in terms of users and LDAP groups from the WLS identity store.  “Enterprise” in the sense that these are things available for use to all applications that use that store.  The other kind of role is an Application Role and the idea is that  a given application will make use of Enterprise roles and users to build up a set of roles for it’s own use.  These application roles will be available only to that application.   The general idea here is that the enterprise roles are relatively static (for example an Employees group in the LDAP directory) while application roles are more dynamic, possibly depending on time, location, accessed resource and so on.  One of the things that OES adds that is that we can define these dynamic membership conditions in Role Mapping Policies.

To make this concrete, here is how, at design time in Jdeveloper, one assigns these rights in Jdeveloper, which puts them into a file called jazn-data.xml:

When the ADF app is deployed to a WLS this JAZN security data is pushed to the system-jazn-data.xml file of the WLS deployment for the policies and application roles and to the WLS backing LDAP for the users and enterprise roles.  Note the difference here: after deploying the application we will see the users and enterprise roles show up in the WLS LDAP server.  But the policies and application roles are defined in the system-jazn-data.xml file. 

Consult the embedded WLS LDAP server to manage users and enterprise roles by going to the domain console and then Security Realms->myrealm->Users and Groups:

For production environments (or in future to share this data with OES) one would then perform the operation of “reassociating” this security policy and application role data to a DB schema (or an LDAP).  This is done in the EM console by reassociating the Security Provider.  This blog posting has more explanations and references on this reassociation process.

If ADF Authentication and Authorization are enabled then the Security Policies for a deployed application can be managed in EM.  Our goal is to be able to manage security policies for the applicaiton rather via OES and it's console.

Security Requirements for an ADF Application

With this package tour of ADF security we can see that to secure an ADF application with we would expect to be able to take care of at least the following items:

  1. Authentication, including a user and user-group store
  2. Authorization for page access
  3. Authorization for bounded Task Flow access.  A bounded task flow has only one point of entry and so if we protect that entry point by calling to OES then all the pages in the flow are protected. 
  4. Authorization for viewing data coming from the data access layer

In the next posting we will describe a sample ADF application and required security policies.


  1. ADF Dev Guide: Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework: Enabling ADF Security in a Fusion Web Application
  2. Oracle tutorial on securing a sample ADF application, appears to require ADF 11.1.2
  3. Now, securely deploying your secured ADF application

Tuesday Apr 03, 2012

Downloading stuff from Oracle: an example


Oracle has a lot of software on offer.  Components of the stack can evolve at different rates and different versions of the components may be in use at any given time.  All this means that even the process of downloading the bits you need can be somewhat daunting.  Here, by way of example, and hopefully to convince you that there is method in the downloading madness,  we describe how to go about downloading the bits for Oracle Identity Manager  (OIM)

Firstly, a couple of preliminary points:

  • Folks with Oracle products already installed and looking for bug fixes, patch bundles or patch sets would go directly to the Oracle support website.

Downloading Oracle Identity Manager    

To be sure we download the right versions, first locate the Certification Matrix for OIM first go to the Fusion Certification Page then go to the “System Requirements and Supported Platforms for Oracle Identity and Access Management 11gR1” link.

Let’s assume you have a 64 bit Linux Machine and an Oracle database already.  Then our  goal is to end up with a list of files like the following:

jdk-6u29-linux-x64.bin                    (Java JDK)                             (the Repository Creation Utility to create the DB schemas)
wls1035_generic.jar                       (the Weblogic Application Server) (the Identity Managament bits) (the SOA bits)
jdevstudio11115install.exe                (optional: JDeveloper IDE)                    (optional: SOA extensions for JDeveloper)

Downloading the bits

1.    Download the Java JDK, 64 bit version 1.6.0_24+.
2.    Download the RCU: here you will see that the RCU is mentioned on the Identity Management home page but no link is provided.  Do not panic.  Due to the amount and turnover of software available only the latest versions are available for download from the main Oracle site.  Over time software gets moved on to the Oracle edelivery site and it is here that we find the RCU version we require:

a.    Go to edelivery:
b.    Choose Pack ‘ Oracle Fusion Middleware’ and ‘Linux x86-64’
c.    Click on ‘Oracle Fusion Middleware 11g Media Pack for Linux x86-64’
d.    Download: ‘Oracle Fusion Middleware Repository Creation Utility 11g ( for Linux x86’ (

3.    Download the Weblogic Application Server: in this step we will take the "Generic" distribution (with no bundled JVM) which is suitable for use on 64 bit systems: WLS 10.3.5
4.    Download the Oracle Identity Manager bits: one point to clarify here is that currently  the Identity Management bits come in two trains, essentially one for the Directory Services piece and the other for the Access Management and Identity Management parts.  We need to be careful not to confuse the two, in particular to be clear which of the trains is being referred to by  the documentation:

a.   So, with this in mind, go to ‘ Oracle Identity and Access Management (’ and download Disk1.

5.    Download the SOA bits:

a.    Go to the edelivery area as for the RCU in step 2 and download:
i.    Oracle SOA Suite 11g Patch Set 4 ( (Part 1 of 2)
ii.    Oracle SOA Suite 11g Patch Set 4 ( (Part 2 of 2)

6.    You will want to download some development tooling (for plugins or BPEL workflow development):

a.    Download Jdeveloper ( may work but best to stick to the versions that correspond to the WLS version we are using)
b.    Go to the site for  SOA tools and download the SOA Composite Editor

That’s it, you may proceed to the installation




« April 2012