Sample form login stylesheet
You can use this sample stylesheet to generate the HTML form login page or error page when creating rules to define an HTML forms-based authentication policy.
You provide a custom stylesheet when defining rule mpgw-form_rule_2. See Rules for HTML forms-based authentication, Table 4.
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:dp="http://www.datapower.com/extensions"
xmlns:re="http://exslt.org/regular-expressions"
extension-element-prefixes="dp re"
exclude-result-prefixes="dp re">
<xsl:output method="html" omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:choose>
<xsl:when test="contains(dp:variable('var://service/URI' ), 'LoginPage.htm')">
<xsl:variable name="uri_temp" select="dp:decode( dp:variable('var://service/URI' ), 'url')" />
<xsl:variable name="uri">
<xsl:choose>
<xsl:when test="contains($uri_temp, 'originalUrl')">
<xsl:value-of select="$uri_temp" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="dp:decode(dp:http-request-header('Cookie'), 'url')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="redirect_uri_preprocess">
<xsl:for-each select="re:match($uri, '(.*)originalUrl=(.*)')">
<xsl:if test="position()=3">
<xsl:value-of select="." />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="redirect_uri">
<xsl:choose>
<xsl:when test="contains($redirect_uri_preprocess, ';')">
<xsl:value-of select="substring-before($redirect_uri_preprocess, ';')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$redirect_uri_preprocess" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<html>
<head>
<meta http-equiv="Pragma" content="no-cache" />
<title>Login Page</title>
</head>
<body>
<h2>DataPower/Worklight Form Login</h2>
<form name="LoginForm" method="post" action="j_security_check">
<p>
<strong>Please enter your user ID and password.</strong>
<br />
<font size="2" color="grey">If you have forgotten your user ID or password, please contact the server administrator.</font>
</p>
<p>
<table>
<tr>
<td>User ID:</td>
<td>
<input type="text" size="20" name="j_username" />
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input type="password" size="20" name="j_password" />
</td>
</tr>
</table>
</p>
<p>
<input type="hidden" name="originalUrl">
<xsl:attribute name="value">
<xsl:value-of select="$redirect_uri" />
</xsl:attribute>
</input>
<input type="submit" name="login" value="Login" />
</p>
</form>
</body>
</html>
</xsl:when>
<xsl:otherwise>
<!-- error -->
<html>
<head>
<meta http-equiv="Pragma" content="no-cache" />
<title>Error Page</title>
</head>
<body>
<h2>DataPower/Worklight Error</h2>
You must provide a valid user identity.
</body>
</html>
</xsl:otherwise>
</xsl:choose>
<dp:set-response-header name="'Content-Type'" value="'text/html'" />
<dp:set-variable name="'var://service/mpgw/skip-backside'" value="true()" />
</xsl:template>
</xsl:stylesheet>