Configuring Oracle Identity Federation for the Custom Action

12-10 Oracle Fusion Middleware Administrators Guide for Oracle Identity Federation For example, the following commands, in the WLST script environment for the Oracle Identity Federation instance, configure a post-processing plug-in to be invoked after all the authentication engines: setConfigPropertyserverconfig, authncontext, rootcontext, string setConfigPropertyserverconfig, authnpath, relativepath, string

12.3.3 Example of a Post-processing Custom Action

This section shows a simple post-processing plug-in that is invoked by all the built-in authentication engines before the user is redirected to Oracle Identity Federation at the end of a local authentication operation. This plug-in accesses a custom cookie presented by the browser, extracts data from it, and sets it as Oracle Identity Federation session attributes that can then be used during the operation that creates the assertion. Oracle Identity Federation supports the concept of session attributes set by the authentication engine during a local authentication operation: ■ Oracle Identity Federation acts as an IdP ■ The authentication engine flow sets some attributes as session attributes called attr1 and attr2 ■ Oracle Identity Federation is configured to send the session attributes referenced as attr1 and attr2 when creating an assertion for specific service provider partners This sample shows how a post-processing plug-in can set session attributes in a local authentication flow where a built-in authentication engine is used. In this sample, the plug-in adds the following attributes, extracted from a custom cookie that is previously set by another component, after a successful authentication: ■ cookie-language, containing the preferred language of the user ■ cookie-homepage, containing the preferred home page of the user

12.3.3.1 Set-up

A custom component sets the cookie used in this example.

12.3.3.2 Packaging

The post-processing plug-in consists of a Web application with a root context set to plugin, and contains one JSP page, cookieextract.jsp, which extracts the data from the custom cookie and set it as session attributes; the plug-in redirects the user to the federation server by means of an internal forward to resume the flow.

12.3.3.3 Oracle Identity Federation Configuration

To configure Oracle Identity Federation to invoke the post-processing plug-in before the Oracle Identity Federation server at the end of local authentication flow, take these steps: 1. Enter the WLST script environment for the Oracle Identity Federation instance. 2. Set the authncontext property containing the root context of the post-processing plug-in page: setConfigPropertyserverconfig, authncontext, plugin, string Custom Actions 12-11 3. Set the authnpath property containing the relative path of the post-processing plug-in page: setConfigPropertyserverconfig, authnpath, cookieextract.jsp, string 4. Exit the WLST script environment.

12.3.3.4 Implementation of cookieextract.jsp

The JSP looks like this: page buffer=5 autoFlush=true session=false page language=java import=java.util., javax.naming., javax.naming.directory., java.net. response.setHeaderCache-Control, no-cache; response.setHeaderPragma, no-cache; response.setHeaderExpires, Thu, 29 Oct 1969 17:04:19 GMT; check if authentication was successful if request.getAttributeoracle.security.fed.authn.authntime = null { authentication was successful. Attributes will be added Map attributes = Maprequest.getAttributeoracle.security.fed.authn.attributes; if attributes == null { attributes = new HashMap; request.setAttributeoracle.security.fed.authn.attributes, attributes; } get the cookie Cookie[] cookies = request.getCookies; String cookieValue = null; forint i = 0; i cookies.length; i++ { Cookie cookie = cookies[i]; if cookie.getName.equalscustomcookie cookieValue = cookie.getValue; } if cookieValue = null cookieValue.length 0 { StringTokenizer st = new StringTokenizercookieValue, +; String language = st.nextToken; String homepage = st.nextToken; Set languageValues = new HashSet; languageValues.addlanguage; attributes.putcookie-language, languageValues; Set homepageValues = new HashSet; homepageValues.addhomepage; attributes.putcookie-homepage, homepageValues; } } forward to the OIF server to resume the flow request.getSession.getServletContext.getContextfed.getRequestDispatcher userloginsso.forwardrequest, response;