Customizing DirX Access Components

DirX Access allows you to customize the DirX Access Authentication Application, DirX Access OAuth Client and Server FEPs and DirX Access SAML FEPs Web components. You can change the layout of Web pages generated by these components.

Customizing FEPs

Although OAuth and SAML FEPs are primarily backend components, they get in touch with a user and sometimes they send an HTTP response directly to the user. Rendering of these HTTP responses is delegated to dedicated generic components with a well-defined API. You can replace the default implementation of these rendering components with custom ones and thus customize the FEPs output and integrate them into your own Web applications environment and layout.

When to Use Externalized Rendering

The following situations require the externalized rendering services:

Presenting an error page. Please note that unexpected errors (either implementation errors; or unusual and fatal runtime conditions like “out of memory”) are handled by the Web container itself, not with the use of the error page renderer.

Redirecting to an URL.

Presenting the WAYF (Where Are You From?) page.

Using the Rendering Interface

The HTTP response-rendering delegation is implemented with the servlet forwarding technique. When the FEP needs to render the output, it prepares all possibly useful data for the renderer, stores them in the request attributes and forwards the request (and response) to the rendering servlet. See Java Servlet API, servlet forwarding, especially RequestDispatcher.forward() method, which is the cornerstone of the technique.

For the parameters and parameter types that the SAML FEP uses for passing the data to the rendering servlets, see com.siemens.dxa.common.web.rendering.api package JavaDoc documentation in dirxaccess-base-javadoc.zip which is available on the DirX Access product DVD under Documentation\DirXAccess. The forwarding is always performed by the servlet name and the FEPs use the default names. The deployment descriptor (web.xml) of the Web application that hosts the FEP must define these servlets.

Using the Parameter Sanitization Servlet Filter

The purpose of the parameter sanitization servlet filter is to prevent the possibility of cross-site scripting attacks. To accomplish this task:

The administrator chooses HTTP request parameters (sent via an HTTP URL query or an HTTP request body) that might be displayed at the Web page and lists them in the Web application’s configuration file.

The servlet filter removes potentially harmful characters without replacing them using a regular expression pattern to specify the filtered characters.

A custom filter can be set individually for each parameter or for a list of parameters.

For a single parameter use the following format: filtered.keys..

For a list of parameters use the following format: filtered.keys.[,].

A default filter can be used, to filter every other unlisted parameter, the configuration parameter to be used is “defaultFilter”.

If the default filter is empty or omitted, only the listed parameters will be filtered.

Note: The parameters names are case sensitive!

To set up the servlet filter:

Uncomment the filter definition and the filter mapping in web.xml. Example filters can be found in the filter definition. Remove or change these to match your needs.

Customize the defaultFilter parameter to filter all non-specified parameters. If the default filter is omitted or empty, only the listed parameters will be filtered.

Customize the specific filter names, either one-by-one or as a list.

Restart the service for the changes to take effect.

Example

The default implementation, which uses JSP for rendering the visual output, is a good starting point that demonstrates the use of the API. Modifying only the default JSP pages or only their style sheets can be sufficient in many cases, too, without the need to create the renderer from scratch.

Regarding the look and feel customization, DirX Access Client SDK offers a nice customization in the ClientSDK\Integration\webapps\saml‑fep folder under the DirX Access installation folder. It is a good starting point for your own customization or an example of how the minimalistic and very basic user interface, which is deployed by default, can be extended into a usable presentation to the user. Note that the DirX Access Client SDK customization is written with minimal JSP support required, thus avoiding some advanced constructs.

Note that the name of the rendering servlet used by the SAML FEPs is currently hardcoded (the SAML FEP uses the default). Because SAML specification requires using XHTML for form-based redirection responses, the default HTML form redirection servlet must return XHTML to be compliant with the specification. This behavior can cause problems if the servlet is shared with another component that has different requirements but uses the default name. However, such a situation is very unlikely.

Integrating Custom HTML Login Forms

DirX Access supports custom HTML login forms. The corresponding Web pages (providing the HTML login form) can be static or can be created dynamically. To process these custom HTML login forms, DirX Access expects the following input variables:

Username: The username must be provided as name/value pair in the HTML form.

The name of this field is determined by a configurable keyword. For example, *username*.

The value of this field needs to be provided by the user who is to be authenticated.

Password: The password must be provided as a name/value pair in the HTML form.

The name of this field is determined by a configurable keyword. For example, *password*.

The value of this field needs to be provided by the user who is to be authenticated.

Target URI: The target URI must be provided as a name/value pair in the HTML form.

The name of this field is determined by a configurable keyword. For example, *target*.

The value needs to be provided by the login page or application. Note that this URI may be either absolute or relative, and that its value may be static (such as a static welcome page) or dynamic (such as a login application).

In addition to these keyname/value pairs, DirX Access requires another parameter that determines the URI for which DirX Access provides the functionality of the login form action.

For an illustration of this integration, see the DirX Access Web Sample Scenario Guide. The Servlet applications for Tomcat and the sample Web pages for IIS contain examples of static login pages. The following ASP snippet demonstrates a method for taking the target URI value dynamically from a query parameter. Similar mechanisms are available in other Web scripting languages.

TargetPage = Request.Querystring("target")
Action = "/formAuthnAction"

Response.Write "<html>"
Response.Write "<head>"
Response.Write "<title>my-company – Login Form</title>"
Response.Write "</head>"
Response.Write "<body>"
Response.Write "<table border=""0"" width=""100%"" height=""100%""><tr><td align=""center"" valign=""middle"">"
Response.Write "<h1>my-company<p>"
Response.Write "Login Form</h1>"
Response.Write "Please enter your my-company username and password."
Response.Write "<form name=""loginform"" action=""" & Action & """ method=""post"">"
Response.Write "<input type=""hidden"" name=""target"" value=""" & TargetPage & """>"
Response.Write "<table border=0>"
Response.Write " <tr>"
Response.Write " <td width=""120"">Username:</td>"
Response.Write " <td><input type=""text"" name=""username"" value=""user01""></td>"
Response.Write " </tr>"
Response.Write " <tr>"
Response.Write " <td>Password:</td>"
Response.Write " <td><input type=""password"" name=""password"" value=""dirxaccess""></td>"
Response.Write " </tr>"
Response.Write " <tr>"
Response.Write " <td></td>"
Response.Write " <td align=""right""><input type=""submit"" name=""submit"" value=""Submit""></td>"
Response.Write " </tr>"
Response.Write "</form>"
Response.Write "</td></tr></table>"
Response.Write "<hr>"
Response.Write "<b>Action:</b> " & Action & " | <b>Target:</b> " & TargetPage
Response.Write "</body>"

Response.Write "</html>"