Sun ONE Portal Server, Secure Remote Access 6.1 Administrator's Guide |
Chapter 5
Configuring RewriterThe Rewriter scans the contents of web pages and rewrites all the URLs embedded in the web pages.
This chapter covers the following topics:
Overview of RewriterIn a secure environment, when a user is trying to access intranet pages from home, direct access to intranet pages may not be possible. However, after authentication, Rewriter enables end-users to browse the intranet by making links and other URL references on those pages operate correctly. Rewriter scans the content of the webpages that a user wants to view and identifies the URLs in those pages.
Rewriter has two main functions:
For the functioning of Rewriter, you need to:
Expanding Relative URLs to Absolute URLs
Rewriter expands relative URLs to absolute URLs. For example, if a user is trying to access the site:
<a href="../mypage.html">
Rewriter translates this to:
<a href="http://yahoo.com/mypage.html">
where http://yahoo.com/test/ is the base URL of the page.
In a non-gateway scenario, the URL Scraper provider handles this functionality. See Chapter 7, Administering Rewriter in the Sun ONE Portal Server Administrator’s Guide for details on the URL Scraper provider.
Prefixing the Gateway URL to the Existing URL
If a user is trying to access intranet web pages through the gateway, Rewriter needs to prefix the gateway URL to the existing URL. For example, a user who is trying to access an html page on mymachine types:
<a href="http://mymachine.intranet.com/mypage.html>"
Rewriter prefixes this URL with a reference to the gateway as follows:
<a href="https://gateway.company.com/http://mymachine.intranet.com/ mypage.html>"
When the user clicks a link associated with this anchor, the browser contacts the gateway. The gateway fetches the content of mypage.html from mymachine.intranet.com.
The gateway uses several rules to determine the elements of a fetched web page that will be rewritten.
Target AudienceYou need to read this guide if you are an administrator who needs to set up Rewriter to rewrite the intranet content as required for your organization.
You need the following to be able to write the required rules, and get Rewriter to work as expected:
Supported URLs and ExceptionsThis section lists the types of URLs that are rewritten by Rewriter. It also lists exceptions that Rewriter does not handle.
Supported URLs
All standard URLs, as specified in RFC-1738, and with protocol either HTTP or HTTPS, are rewritten by Rewriter.
Standard URLs
All URLs with the protocol as either HTTP or HTTPS are recognized. This is not case-sensitive. For example, hTtP, HTtp, and httP are all valid. Some sample URLs are listed below:
http://www.my.work.com/
http://www.w3.org:8000/imaginary/test
http://www.myu.edu/org/admin/people#andy
http://info.my.org/AboutUs/Index/Phonebook?dobbins
http://www.w3.org/RDB/EMP?where%20name%3Ddobbins
http://info.my.org/AboutUs/Phonebook
http://user:password@abc.com
Non-standard URLs
Rewriter supports the rewriting of some basic non-standard URLs.
The information required to convert the non-standard URL to a standard format is taken from the base URL of the page where the URL displays. This information could include:
The back slash is supported only if it is part of a relative URL, not an absolute URL. For example, http://abc.sesta.com\index.html is rewritten, but http:\\abc.sesta.com is not rewritten.
Exceptions
These URLs are not rewritten.
http:/abc.com
Defining Rewriter Rules and RulesetsRewriter is designed to modify the URL portions of various elements that appear on a web page. You need to write specific rules for Rewriter to decide what portions of the web pages to rewrite, and how it needs to be rewritten. The types of rules required, and the exact syntax are described in the following sections.
A collection of rules for various categories and subcategories is stored in XML format, and is called a Ruleset.
You need to create a ruleset and administer rules in the Rewriter section of the Portal Server Configuration in the admin console.
Secure Remote Access includes two pre-packaged rulesets to rewrite each of these elements. These rules are stored in XML format on the portal server. The rulesets are:
InstallDir/SUNWps/export/DefaultGatewayRuleSet.xml
InstallDir/SUNWps/export/GenericRuleSet.xml
See the section "Pre-packaged Rulesets" for details.
You need to define multiple rules based on the content type in the web pages. For example, the rules required to rewrite HTML content would be different from the rules required to rewrite JavaScript content.
When a page is being parsed by Rewriter, the rules in the ruleset are applied in order to each statement in the page, until a rule matches a particular statement.
Based on the content, Rewriter rules fall into the following broad categories:
Pre-packaged RulesetsSecure Remote Access comes with two pre-packaged rulesets to rewrite the elements in a web page. These rules are stored in XML format. The rulesets are:
InstallDir/SUNWps/export/DefaultGatewayRuleSet.xml
InstallDir/SUNWps/export/GenericRuleSet.xml
These rulesets are useful in rewriting web pages with commonly used URL naming conventions and referencing techniques.
In addition, these rulesets also contain the rules required for the proper functioning of the gateway, and applications such as NetMail, Netlet and NetFile.
Note
For customizations, create a new ruleset with the required additional rules, along with the rules in the generic ruleset.
Restoring the Pre-packaged Rulesets
In case you accidentally delete either the default gateway ruleset or the generic ruleset, you can restore it as follows:
rwadmin store --runasdn "username" --password "password" InstallDir/SUNWps/export/DefaultGatewayRuleSet.xml
rwadmin store --runasdn "username" --password "password" InstallDir/SUNWps/export/GenericRuleSet.xml
where username and password are the same as that supplied for amadmin.
Note
The default gateway ruleset or generic ruleset that is packaged with the installation is restored. If you have customized the rulesets, the changes are not restored.
Creating a Ruleset and Defining Rules
See Chapter 7, Administering Sun ONE Portal Server Rewriter in the Sun ONE Portal Server Administrator’s Guide for details on creating a ruleset.
After creating a new ruleset, you need to define the required rules. Keep the following in mind while writing the rules:
- All rules need to be enclosed within the <RuleSet> </RuleSet> tags
- Include all rules that need to rewrite HTML content in the <HTMLRules> </HTMLRules> section of the ruleset
- Include all rules that need to rewrite JavaScript content in the <JSRules> </JSRules> section of the ruleset
- Include all rules that need to rewrite XML content in the <XMLRules> </XMLRules> section of the ruleset
- In your intranet pages, identify the URLs that need to be rewritten, and include the required rules in the appropriate sections (HTML, JSRules, or XMLRules) of the ruleset
- Assign the ruleset to the required domain. See "Assigning Rulesets to Domains" for details.
- Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n gateway profile name start
Configuring the Rewriter in the Gateway ServiceThe Rewrite all URLs checkbox and the Proxies for Domains and Subdomains list in the gateway service determine the behavior of Rewriter.
The Proxies for Domains and Subdomains list tells the gateway which URLs it may rewrite. Only references to hosts in the specified domains and subdomains are candidates for rewriting. Enabling the Rewrite All URLs option overrides the entries in the Proxies for Domains and Subdomains list.
See Chapter 2, "Administering the Gateway" for details on proxy management.
Rewriting all URLs
If you enable the Rewrite All URLs option in the gateway service, Rewriter rewrites any URL without checking against the entries in the Proxies for Domains and Subdomains list. Entries in the Proxies for Domains and Subdomains list are ignored.
To Enable the Gateway to Rewrite all URLs
- Log in to the Sun ONE Identity Server admin console as administrator.
- Select the Service Configuration tab.
- Click the arrow next to Gateway under SRAP Configuration.
The Gateway Profile page displays.
- Click Edit... for the gateway profile for which you want to set the attribute.
The Edit Gateway Profile page displays.
- Select the Rewrite All URLs checkbox to enable the gateway to rewrite all URLs.
- Click Save at the top or bottom of the page to record the change.
- For the changes to take effect, restart the gateway by typing:
InstallDir/SUNWps/bin/gateway -n gateway profile name start
Assigning Rulesets to Domains
You can specify a particular ruleset to be used by certain domains. Depending on the domain a particular page is fetched from, the corresponding ruleset is used.
Assigning a specific ruleset improves the speed of operation since the specified ruleset contains only the relevant rules. If you assign a common ruleset for all domains, the time taken for Rewriter to run through all the rules in that ruleset will be much higher, than if you have a small subset of the rules for specific pages.
Create the required ruleset in the Rewriter service under Portal Server Configuration in the identity server admin console. See the Sun ONE Portal Server Administrator’s Guide for details.
The following two entries are added by default to the Domain-based Rulesets list:
default domain|default_gateway_ruleset
*|generic_ruleset
This means that for all pages from the default domain, the default gateway ruleset is applied. For all other pages, the generic ruleset is applied. The default gateway ruleset and the generic ruleset are pre-packaged rulesets. See "Pre-packaged Rulesets" for details.
Note
The domain for which you specify a ruleset must be listed in the Proxies for Domains and Subdomains list.
To Assign a Ruleset for a Domain
- Log in to the identity server admin console as administrator.
- Select the Service Configuration tab.
- Click the arrow next to Gateway under SRAP Configuration.
The Gateway Profile page displays.
- Click the gateway profile for which you want to set the attribute.
The Gateway - profilename page displays.
- Type the required domain or host name and the ruleset in the Domain-based Rulesets field and click Add. The entry is added to the Domain-based Rulesets list.
The format for specifying the domain or host name and the ruleset is as follows:
domain name|ruleset name
For example:
eng.sesta.com|default
- Click Save at the top or bottom of the page to record the change.
- For the changes to take effect, restart the gateway by typing:
InstallDir/SUNWps/bin/gateway -n gateway profile name start
Ruleset for Outlook Web Access
Secure Remote Access supports Outlook Web Access 2000 sp3 on the Sun ONE web server and the IBM application server.
To configure the OWA Ruleset
- Log in to the identity server admin console as administrator.
- Select the Service Configuration tab.
- Click the arrow next to Gateway under SRAP Configuration.
The Gateway Profile page displays.
- Click the gateway profile for which you want to set the attribute.
The Gateway - profilename page displays.
- In the Domain-based Rulesets box, enter the server name where Exchange 2000 is installed followed by the exchange 2000 Service Pack 3 OWA ruleset.
For example:
exchange.domain.com|exchange_2000sp3_owa_ruleset.
Specifying the MIME MappingsRewriter has four different parsers to parse the web pages based on the content type - HTML, JAVASCRIPT, XML and WML. Common MIME types are associated with these parsers by default. You can associate new MIME types with these parsers in the MIME mappings field of the gateway service. This extends Rewriter functionality to other MIME types.
Separate multiple entries with a semicolon or a comma (";" or ",".)
To Specify the MIME Mappings
- Log in to the identity server admin console as administrator.
- Select the Service Configuration tab.
- Click the arrow next to Gateway under SRAP Configuration.
The Gateway Profile page displays.
- Click the gateway profile for which you want to set the attribute.
The Gateway - profilename page displays.
- Scroll down to the MIME mappings field, and add the required MIME type in the edit box. Use a semicolon or comma to separate multiple entries.
Specify the entry in the format HTML=text/html;text/htm
- Click Add to add the required entry to the list.
- Click Save at the top or bottom of the page to record the change.
- For the changes to take effect, restart the gateway by typing:
InstallDir/SUNWps/bin/gateway -n gateway profile name start
Using Pattern-matching in RulesYou can use valuePatterns to achieve pattern-matching and identify the specific parts of a statement that need to be rewritten.
If you have specified valuePatterns as part of a rule, all the content that follows the matched pattern is rewritten.
Consider the sample form rule below.
<Form source="*/source.html" name="form1" field="visit" [valuePatterns="0|1234|"]/>
where,
source is the URL of the html page where the form displays
name is the name of the form
field is the field in the form whose value needs to be rewritten
valuePatterns indicates the part of the field value that needs to be rewritten. All the content that follows 0|1234| is rewritten.
Using Wild Cards in valuePatterns
You can use the * character to achieve pattern matching for rewriting.
You cannot specify just a * in the valuePatterns field. Since * indicates a match with everything, nothing will follow the valuePattern, and hence Rewriter will have nothing left to rewrite. You can use * in conjunction with another string such as *abc. In this case, all content that follows *abc is rewritten.
You can use a * or ** along with the separation character that displays in the original statement to separate multiple fields. One wildcard (*) matches any field that is not to be rewritten, and two wildcards (**) match any field that needs to be rewritten.
Table 5-1 lists some sample usages of the * wildcard. The table has three columns. The first column lists the sample statement to be rewritten. The second column lists the sample valuePatterns value. The third column describes the rewriting.
Rules for HTML ContentHTML content in web pages can be further classified into attributes, JavaScript tokens, forms and applets. Accordingly, the rules for HTML content are classified as:
Attribute Rules for HTML Content
This rule identifies the attributes of a tag whose value needs to be rewritten. These tags include:
Rewriter modifies the values of these attributes by prefixing the gateway URL.
Syntax
<Attribute name="attributename" [tag="*" valuePatterns=""]/>
where,
name specifies the name of the attribute.
tag specifies the tag to which the attribute belongs
valuePatterns specifies the possible patterns to match with the attribute.
See "Using Pattern-matching in Rules" for details on valuePatterns.
Example
Assume the base URL of the page to be:
http://mymachine.intranet.com/mypage.html
Page Content
<a href="http://mymachine.intranet.com/mypage.html>
Rules
<Attribute name="href"/>
or
<Attribute name="href" tag="a"/>
Output
<a href=gateway URL/http://mymachine.intranet.com/mypage.html>
Description
Since the URL to be rewritten is already an absolute URL, only the gateway URL is prefixed to the URL.
JavaScript Token Rules for HTML Content
HTML attributes whose value contains JavaScript that needs to be parsed by the JavaScript parser to determine what needs to be rewritten.
In most cases, the rules provided in the default gateway ruleset are sufficient to rewrite the URLs in JavaScript tokens.
Syntax
<JSToken>token name</JSToken>
where
token name is an attribute whose value is JavaScript that needs to be translated.
Example
Assume the base URL of the page to be:
http://abc.sesta.com/focus.html
Page content
<Form>
<input TYPE=TEXT SIZE=20 value=focus onClick="Check('/focus.html','focus');return;">
</Form>
Rules
<JSToken>onClick</JSToken>
<Function type="URL" name="Check" paramPatterns="y,"/>
Output
<Form>
<INPUT TYPE=TEXT SIZE=20 value=focus onClick="Check('gateway URL/http://abc.sesta.com/focus.html','focus');return;">
</Form>
Description
Two rules are required to rewrite the specified page content. The first rule identifies the onClick JavaScript token. The second rule identifies the parameter of the check function that needs to be rewritten. In this case, only the first parameter is rewritten since paramPatterns has the value y.
The gateway URL and the base URL of the page on which the JavaScript tokens appear are prefixed to the required parameter.
Form Rules for HTML Content
The HTML pages that a user browses through may contain forms. Some form elements may take a URL as the value.
Syntax
<Form source="*/source.html" name="form1" field="visit" [valuePatterns="0|1234|"]/>
where
Form source is the URL of the html page where the form displays
name is the name of the form
field is the field in the form whose value needs to be rewritten
valuePatterns indicates the part of the field value that needs to be rewritten. All the content that follows valuePatterns is rewritten.
See "Using Pattern-matching in Rules" for details on valuePatterns.
Example
Assume the base URL of the page to be:
http://test.siroe.com/testcases/html/form.html
Page Content
Assume the page URI to be form.html and is located in the root directory of the server.
<form name=form1 method=POST action="http://test.siroe.com/testcases/html/form.html">
<input type=hidden name=abc1 value="0|1234|/test.html">
</form>
Rules
<Form source="*/form.html" name="form1" field="abc1" valuePatterns="0|1234|"/>
<Attribute name="action"/>
Output
<FORM name=form1 method=POST action="gateway URL://test.siroe.com/testcases/html/form.html">
<input type=hidden name=abc1 value="0|1234|gateway URL/http://test.siroe.com/test.html">
</FORM>
Description
The action tag is rewritten using some defined HTML attribute rule.
The form value is rewritten as shown in the output. The specified valuePatterns is located, and all content following valuePatterns is rewritten by prefixing the gateway URL, and the base URL of the page where the form displays.
See "Using Pattern-matching in Rules" for details on valuePatterns.
Applet Rules for HTML Content
A single web page may contain many applets, and each applet may contain many parameters. The Rewriter rule for URLs in applets should contain pattern matching information as explained in the syntax:
Rewriter matches the values specified in the rule with the content of the applet and modifies the URLs as required. This replacement is carried out at the server and not when the user is browsing the particular web page.
A wildcard character (*) can also be used as part of the rule. For example, the parameter name could be *, in which case, Rewriter does not compare the parameter name in the applet.
Syntax
<Applet source="*/somehtml.jsp" code="classname.class" param="parametername" [valuePatterns="*"] />
where
source is the URL of the page that contains the applet
code is the name of the applet class
param is the name of the parameter whose value needs to be rewritten
valuePatterns is the pattern to be matched for rewriting
See "Using Pattern-matching in Rules" for details on valuePatterns.
Example
Assume the base URL of the page to be:
http://abc.siroe.com/casestudy/test/HTML/applet/rule1.html
Page Content
<applet codebase=appletcode code=RewriteURLinApplet.class archive=/test.jar>
<param name=Test1 value="/index.html">
</applet>
Rules
<Applet source="*/rule1.html" code="RewriteURLinApplet.class" param="Test*"/>
Output
<APPLET codebase=gateway URL://abc.siroe.com/casestudy/test/HTML/applet/appletcode code=RewriteURLinApplet.class archive=/test.jar>
<param name=Test1 value="gateway URL://abc.siroe.com/index.html">
</APPLET>
Description
codebase=appletcode is rewritten since <Attribute name="codebase"/> is a defined rule in the default gateway ruleset.
All parameters whose names begin with Test are rewritten. The base URL of the page on which the applet code displays, and the gateway URL are prefixed to the value field.
Rules for JavaScript ContentJavaScript can contains URLs in various locations. Rewriter cannot directly parse the JavaScript and determine the URL portion. A special set of rules need to be written to help the JavaScript processor to translate the URL.
JavaScript elements that contain URLs are classified as follows:
Variables in JavaScript
JavaScript variables are again classified into 5 categories:
URL Variables in JavaScript
URL variables have a URL string on the right hand side.
Syntax
<Variable type="URL">variablename</Variable>
where
variablename specifies the name of the variable. The value of the variablename is rewritten.
Example
Assume the base URL of the page to be:
http://abc.siroe.com/tmp/page.html
Page Content
<script LANGUAGE="Javascript">
<!--
//URL Variables
var imgsrc="/tmp/tmp.jpg";
var imgsrc="http://srap.sesta.com/tmp/tmp.jpg";
//-->
</SCRIPT>
Rules
<Variable type="URL">imgsrc</Variable>
Output
var imgsrc="gateway URL://abc.siroe.com/tmp/tmp.jpg";
var imgsrc="gateway URL://srap.sesta.com/tmp/tmp.jpg";
Description
All variables of type URL and with the name imgsrc are rewritten. For the first line of the output, the gateway URL and the base URL of the page on which the variable displays are prefixed. The second line already contains the absolute path, and hence only the gateway URL is prefixed.
EXPRESSION Variables in JavaScript
Expression variables have an expression on the right hand side. The result of this expression is a URL. Rewriter appends a JavaScript function (psSRAPRewriter_convert_expression) to the HTML page as it cannot evaluate such expressions on the server. This function takes the expression as a parameter and evaluates it to the required URL at the client browser.
If you are not sure whether a statement contains a simple URL or an EXPRESSION URL, it is recommended that you use EXPRESSION rules since it can handle both scenarios.
Syntax
<Variable type="EXPRESSION">y1</Variable>
where
y1 is the JavaScript expression variable.
Example
Assume the base URL of the page to be:
http://abc.siroe.com/dir1/dir2/page.html
Page Content
<script LANGUAGE="Javascript">
<!--
//Expression variables
var expvar="../../images/graphics"+".gif";
document.write("<A HREF="+expvar+">EXPRESSION</A><P>")
var expvar="/images/graphics"+".gif";
//-->
</SCRIPT>
Rules
<Variable type="EXPRESSION">expvar</Variable>
Output
var expvar=psSRAPRewriter_convert_expression("../../images/graphics"+". gif");
document.write("<A HREF="+expvar+">EXPRESSION</A><P>")
var expvar=psSRAPRewriter_convert_expression("/images/graphics"+".gif") ;
Description
The function psSRAPRewriter_convert_expression is prefixed to the right hand side of the expression variable expvar. The function processes the expression and rewrites the content at runtime.
DHTML Variables in JavaScript
These are JavaScript variables that hold HTML content.
Syntax
<Variable type="DHTML">y1</Variable>
where
y1 is the JavaScript DHTML variable.
Example
Assume the base URL of the page to be:
http://abc.sesta.com/graphics/set1/graphics/jsscript/JSVAR/page.htm l
Page Content
<script LANGUAGE="Javascript">
<!--
//DHTML Var
var dhtmlVar="<a href=../../images/test.html>"
var dhtmlVar="<a href=/images/test.html>"
var dhtmlVar="<a href=images/test.html>"
//-->
</SCRIPT>
Rules
<Variable type="DHTML">dhtmlVar</Variable>
<Attribute name="href"/>
or
<Attribute name="href" tag="a"/>
Output
//DHTML Var
var dhtmlVar="<a href=gateway URL://abc.sesta.com/graphics/set1/graphics/images/test.html>"
var dhtmlVar="<a href=gateway URL://abc.sesta.com/images/test.html>"
var dhtmlVar="<a href=gateway URL://abc.sesta.com/graphics/set1/graphics/jscript/JSVAR/images/tes t.html>"
//-->
Description
The JavaScript parser reads the value of dhtmlVar as HTML content. When HTML rules are applied to the page, the second rule (Attribute name="href") is applied and the URL is rewritten.
DJS (Dynamic JavaScript) Variables in JavaScript
These are JavaScript variables that hold JavaScript content.
Syntax
<Variable type="DJS">y1</Variable>
where
y1 is the JavaScript DHTML variable.
Example
Assume the base URL of the page to be:
http://abc.sesta.com/dir1/dir2/dir3/jscript/dir4/page.html
Page Content
//DJS Var
var dJSVar="var dJSimgsrc='/tmp/tmp.jpg';"
var dJSVar="var dJSimgsrc='../tmp/tmp.jpg';"
var dJSVar="var dJSimgsrc='http://abc.sesta.com/tmp/tmp.jpg';"
Rules
<Variable type="DJS">dJSVar</Variable>
<Variable type="URL">dJSimgsrc</Variable>
Output
//DJS Var - need 2 rules
var dJSVar="var dJSimgsrc='gateway URL://abc.sesta.com/tmp/tmp.jpg';"
var dJSVar="var dJSimgsrc='gateway URL://abc.sesta.com/dir1/dir2/dir3/jscript/tmp/tmp.jpg';"
var dJSVar="var dJSimgsrc='gateway URL://abc.sesta.com/tmp/tmp.jpg';"
Description
Two rules are required here. The first rule locates the dynamic JavaScript variable dJSVar. The value of this variable is again a JavaScript of type URL. The second rule is applied to rewrite the value of this JavaScript variable.
System Variables in JavaScript
These are variables that are not declared by the user, but that are available as a part of the JavaScript standard. For example, window.location.pathname.
Syntax
<Variable type="SYSTEM">variable.name</Variable>
where
variable.name is the system variable
Example
Assume the base URL of the page to be:
http://abc.siroe.com/dir1/page.html
Page Content
<script LANGUAGE="Javascript">
<!--
//SYSTEM Var
alert(window.location.pathname);
//-->
</SCRIPT>
Rules
<Variable type="SYSTEM">window.location.pathname</Variable>
Output
</SCRIPT>
<SCRIPT LANGUAGE="Javascript">
<!--
//SYSTEM Var
alert(psSRAPRewriter_convert_pathname(window.location.pathname));
//-->
</SCRIPT>
Description
Rewriter locates the system variable specified in the rule, and the psSRAPRewriter_convert_pathname function is prefixed. This function processes the system variable at runtime, and rewrites the resulting URL accordingly.
Function Parameters in JavaScript
Function parameters are classified into 4 categories:
URL Parameters in JavaScript
These are string parameters that directly contain the URL.
Syntax
<Function type="URL" name="test" paramPatterns="y,y," />
where
type is the type of the function
name is the name of the function that needs to be evaluated
paramPatterns specifies the parameters in the function that need to be rewritten
y - The position of y indicates the parameter that needs to be rewritten. For example, in the syntax, the first and second parameter need to be rewritten, but the third parameter should not be rewritten.
Example
Assume the base URL of the page to be:
http://abc.sesta.com/test/rewriter/test1/jscript/test2/page.html
Page Content
<script language="JavaScript">
<!--
function test(one,two,three){
alert(one + "##" + two + "##" +three);
}
test("/test.html","../test.html","123");
window.open("/index.html","gen",width=500,height=500);
//-->
</SCRIPT>
Rules
<Function type="URL" name="test" paramPatterns="y,y,"/>
<Function type="URL" name="window.open" paramPatterns="y,,,"/>
Output
<SCRIPT language="JavaScript">
<!--
function test(one,two,three) {
alert(one + "##" + two + "##" +three);
}
test("gateway URL://abc.sesta.com/test.html","gateway URL://abc.sesta.com/test/rewriter/test1/jscript/test.html","123");
window.open("gateway URL://abc.sesta.com/index.html","gen",width=500,height=500);
//-->
</SCRIPT>
Description
The first rule specifies that the first two parameters in the function test need to be rewritten. Hence the first two parameters of the test function are rewritten. The second rule specifies that the first parameter of the window.open function needs to be written. The URL within the window.open function is prefixed with the gateway URL and the base URL of the page that contains the function parameters.
EXPRESSION Parameters in JavaScript
These are variables within a function that result in a URL when they are evaluated.
Syntax
<Function type="EXPRESSION" name="jstest1" paramPatterns="y"/>
where
jstest1 is the name of the function.
y - The position of y indicates the function parameter that needs to be rewritten. In the syntax above, only the first parameter is rewritten.
Example
Assume the base URL of the page to be:
http://abc.sesta.com/dir1/dir2/page.html
Page Content
<script language="JavaScript">
<!--
function jstest2(){
return ".html";
}
function jstest1(one){
return one;
}
var dir="/images/test"
var test1=jstest1(dir+"/test"+jstest2());
document.write("<a HREF="+test1+">TEST</a>");
alert(test1);
//-->
</SCRIPT>
Rules
<Function type="EXPRESSION" name="jstest1" paramPatterns="y"/>
Output
function jstest2(){
return ".html";
}
function jstest1(one){
return one;
}
var dir="/images/test"
var test1=jstest1(psSRAPRewriter_convert_expression(dir+"/test"+jstest2 ()));
document.write("<a HREF="+test1+">TEST</a>");
alert(test1);
Description
The rule specifies that the first parameter of the jstest1 function needs to be rewritten. In the sample page content, the first parameter is an expression that will be evaluated only at runtime. Rewriter prefixes this expression with the psSRAPRewriter_convert_expression function. The expression is evaluated, and the psSRAPRewriter_convert_expression function rewrites the output at runtime.
Note
In the above example, it is not required to have the variable test1 as a part of the JavaScript variable rule. The function rule for jstest1 takes care of the rewriting.
DHTML Parameters in JavaScript
Native JavaScript methods such as document.write() that generate an HTML page dynamically fall under this category.
Syntax
<Function type="DHTML" name="name" paramPatterns="y"/>
where
name is the name of the function.
y - The position of y indicates the function parameter that needs to be rewritten. In the syntax above, only the first parameter is rewritten.
Example
Assume the base URL of the page to be:
http://xyz.siroe.com/test/rewriter/test1/jscript/JSFUNC/page.html
Page Content
<script>
<!--
document.write('<a href="/index.html">write</a><BR>')
document.writeln('<a href="index.html">writeln</a><BR>')
document.write("http://abc.sesta.com/index.html<BR>")
document.writeln("http://abc.sesta.com/index.html<BR>")
//-->
</SCRIPT>
Rules
<Function type="DHTML" name="document.write" paramPatterns="y"/>
<Function type="DHTML" name="document.writeln" paramPatterns="y"/>
<Attribute name="href"/>
Output
<SCRIPT>
<!--
document.write('<a href="gateway URL://xyz.siroe.com/index.html">write</a><BR>')
document.writeln('<a href="gateway URL://xyz.siroe.com/test/rewriter/test1/jscript/JSFUNC/index.html"> writeln</a><BR>')
document.write("http://abc.sesta.com/index.html<BR>")
document.writeln("http://abc.sesta.com/index.html<BR>")
//-->
</SCRIPT>
Description
The first rule specifies that the first parameter in the function document.write needs to be rewritten. The second rule specifies that the first parameter in the function document.writeln needs to be rewritten. The third rule is a simple HTML rule that specifies that all attributes with the name href need to be rewritten. In the example, the DHTML parameter rules identify the parameters in the functions that need to be rewritten. Then the HTML attribute rule is applied to actually rewrite the identified parameter.
DJS Parameters in JavaScript
Dynamic JavaScript parameters need two rules for the output to be rewritten as required.
Syntax
<Function type="DJS" name="name" paramPatterns="y"/>
where
name is the name of the function.
y - The position of y indicates the function parameter that needs to be rewritten. In the syntax above, only the first parameter is rewritten.
Example
Assume the base URL of the page to be:
http://abc.sesta.com/page.html
Page Content
<script>
menu.addItem(new NavBarMenuItem("All Available Information","JavaScript:top.location='http://abc.sesta.com'"));
</script>
Rules
<Function type="DJS" name="NavBarMenuItem" paramPatterns=",y"/>
<Variable type="URL">top.location</Variable>
Output
<script>
menu.addItem(new NavBarMenuItem("All Available Information","JavaScript:top.location='gateway URL://abc.sesta.com'"));
</script>
Description
The first rule specifies that the second parameter of the function NavBarMenuItem which contains JavaScript needs to be rewritten. Within the JavaScript, the variable top.location also needs to be rewritten. This variable is rewritten using the second rule.
Rules for XML ContentWeb pages may contain XML content which in turn can contain URLs. XML content that needs to be rewritten is classified into two categories:
Tag Text in XML
Rewriter translates XML content based on the TAG name.
Syntax
<TagText tag="attribute" attributePatterns="name=src"/>
where
attribute is the name of the tag
name=src where src indicates the name of the attribute
Example
Assume the base URL of the page to be:
http://abc.sesta.com/test/rewriter/test1/xml/page.html
Page Content
<xml><attribute name="src">test.html</attribute></xml>
<xml><attribute>abc.html</attribute></xml>
Rules
<TagText tag="attribute" attributePatterns="name=src"/>
Output
<xml><attribute name="src">gateway URL://abc.sesta.com/test/rewriter/test1/xml/test.html</attribute></ xml>
<xml><attribute>abc.html</attribute></xml>
Description
The first line in the page content has an attribute with the name src, and hence is rewritten based on the rule specified. The second line in the page content does not contain an attribute with the name src, and hence no rewriting is done.
Attributes in XML
The rules for XML attributes are similar to the attribute rules for HTML. See "Attribute Rules for HTML Content".
Rewriter translates the attribute value based on the attribute and the tag names.
Syntax
<Attributes>
<Attribute name="href" [tag="abc" valuePatterns="123|45|*"]/>
</Attributes>
where
name is the name of the attribute
tag is the name of the tag
valuePatterns indicates the portion of the string that needs to be rewritten. All content appearing after the valuePatterns is rewritten.
See "Using Pattern-matching in Rules" for details on valuePatterns.
Example
Assume the base URL of the page to be:
http://abc.sesta.com/test/rewriter/test1/xml/page.html
Page Content
<xml><baseroot href="/root.html"/></xml>
<xml><img href="image.html"/></xml>
<xml><string href="1234|substring.html"/></xml>
<xml><check href="1234|string.html"/></xml>
Rules
<Attribute name="href"tag="check" valuePatterns="1234|"/>
Output
<xml><baseroot href="/root.html"/></xml>
<xml><img href="image.html"/></xml>
<xml><string href="1234|substring.html"/></xml>
<xml><check href="1234|gateway URL://abc.sesta.com/test/rewriter/test1/xml/string.html"/></xml>
Description
In the above example, only the fourth line is rewritten since it meets all the conditions specified in the rule.
See "Using Pattern-matching in Rules" for details on valuePatterns.
Cascading Style SheetsThe Cascading Style Sheets in HTML pages are also translated. There are no rules defined for this translation as the URL displays only in the url() function of the CSS.
Client-side RewritingThe value of variables and function parameters in JavaScript cannot be determined on the server side. This value needs to be determined and rewritten, if required, at runtime on the client side. Rewriter handles such variables by prefixing a wrapper function to the variables.
Two such functions are provided in Rewriter:
psSRAPRewriter_convert_expression
This function is appended to EXPRESSION variables and EXPRESSION functions in JavaScript. This function takes the expression as a parameter and evaluates it to the required URL at the client browser.
psSRAPRewriter_convert_pathname
This function is used for system variables that are available as part of the JavaScript standard. Rewriter locates the system variable specified in the rule, and the psSRAPRewriter_convert_pathname function is prefixed. This function processes the system variable at runtime, and rewrites the resulting URL accordingly.
Sample RulesetThis section contains a sample rule set. The "Case Study" is used to illustrate how these rules are interpreted by Rewriter.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Rules for integrating a mail client with the gateway.
-->
<!DOCTYPE RuleSet SYSTEM "jar://rewriter.jar/resources/RuleSet.dtd">
<RuleSet type="GROUPED" id="owa">
<HTMLRules>
<Attribute name="action" />
<Attribute name="background" />
<Attribute name="codebase" />
<Attribute name="href" />
<Attribute name="src" />
<Attribute name="lowsrc" />
<Attribute name="imagePath" />
<Attribute name="viewClass" />
<Attribute name="emptyURL" />
<Attribute name="draftsURL" />
<Attribute name="folderURL" />
<Attribute name="prevMonthImage" />
<Attribute name="nextMonthImage" />
<Attribute name="style" />
<Attribute name="content" tag="meta" />
</HTMLRules>
<JSRules>
<!-- Rules for Rewriting JavaScript variables in URLs -->
<Variable type="URL"> _fr.location </Variable>
<Variable type="URL"> g_szUserBase </Variable>
<Variable type="URL"> g_szPublicFolderUrl </Variable>
<Variable type="URL"> g_szExWebDir </Variable>
<Variable type="URL"> g_szViewClassURL </Variable>
<Variable type="URL"> g_szVirtualRoot </Variable>
<Variable type="URL"> g_szBaseURL </Variable>
<Variable type="URL"> g_szURL </Variable>
<Function type="EXPRESSION" name="NavigateTo" paramPatterns="y"/>
</JSRules>
<XMLRules>
<Attribute name="xmlns"/>
<Attribute name="href" tag="a"/>
<TagText tag="baseroot" />
<TagText tag="prop2" />
<TagText tag="prop1" />
<TagText tag="img" />
<TagText tag="xsl:attribute"
attributePatterns="name=src" />
</XMLRules>
</RuleSet>
Case StudyThis section includes the source HTML pages for a sample mail client. This case study will not cover all possible scenarios and rules. This is just a sample ruleset to help you put together the rules for your intranet pages.
Assumptions
The following assumptions are made for this case study:
Sample page 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0053)http://abc.siroe.com/mailclient/destin/?Cmd=navbar -->
<HTML XMLNS:WM><HEAD>
<META http-equiv=Content-Type content="text/html; CHARSET=utf-8">
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Expires content=0><!--Copyright (c) 2000 Microsoft Corporation. All rights reserved.--><!--CURRENT FILE== "IE5" "WIN32" navbar -->
<STYLE>WM\:DROPMENU {
BEHAVIOR: url(http://abc.siroe.com/mailweb/controls/dropmenu.htc)
}
</STYLE>
<LINK href="destin_files/navbar.css" type=text/css rel=stylesheet>
<SCRIPT language=javascript>
var g_szUserBase= "http://abc.siroe.com/mailclient/destin"+"/";
var g_szFolder= ".";
var g_szVirtualRoot= "http://abc.siroe.com/mailweb";
var g_szImagePath= g_szVirtualRoot + "/img/";
</SCRIPT>
<SCRIPT src="/destin_files/navbar.js"></SCRIPT>
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY oncontextmenu=return(event.ctrlKey); onselectstart=return(false);
id=outbar_mainbody style="BACKGROUND-COLOR: appworkspace" leftMargin=0
topMargin=0 scroll=no>
<TABLE class=nbTableMain id=nbTableMain style="HEIGHT: 100%" cellSpacing=0
cols=1 cellPadding=0 rows="2">
<TBODY>
<TR>
<TD class=treeBrand>
<DIV class=treeOFLOW><IMG
style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px"
src="/destin_files/logo-ie5.gif" border=0></DIV></TD></TR>
<TR height="100%">
<TD>
<TABLE class=nbTable cellSpacing=0 cols=1 cellPadding=0 rows="4">
<TBODY>
<TR>
<TD class=nbFlybar id=show_navbar onkeydown=flybar_keydown()
onclick=ToggleTab(this.id) tabIndex=0 noWrap>
<DIV class=treeOFLOW>Shortcuts</DIV></TD></TR>
<TR style="HEIGHT: 100%">
<TD id=idOutbarpane style="TEXT-ALIGN: center" vAlign=top><A
id=inbox
href="http://abc.siroe.com/mailclient/destin/Inbox/?Cmd=contents&am p;Page=1"
target=viewer alt="Go to inbox"><IMG class=nbImage alt="Go to inbox"
src="destin_files/navbar-inbox.gif"></A>
<DIV class=nbLabel>Inbox</DIV><BR><A id=calendar
href="http://abc.siroe.com/mailclient/destin/Calendar/?Cmd=contents "
target=viewer alt="Go to calendar"><IMG class=nbImage
alt="Go to calendar" src="destin_files/navbar-calendar.gif"></A>
<DIV class=nbLabel>Calendar</DIV><BR><A id=contacts
href="http://abc.siroe.com/mailclient/destin/Contacts/?Cmd=contents "
target=viewer alt="Go to contacts"><IMG class=nbImage
alt="Go to contacts" src="destin_files/navbar-contacts.gif"></A>
<DIV class=nbLabel>Contacts</DIV><BR><A id=options
href="http://abc.siroe.com/mailclient/destin/?Cmd=options"
target=viewer alt="Go to options"><IMG class=nbImage
alt="Go to options" src="destin_files/navbar-options.gif"></A>
<DIV class=nbLabel>Options</DIV></TD></TR>
<TR style="HEIGHT: 1.5em">
<TD class=nbFlybar id=show_folders onkeydown=flybar_keydown()
onclick=ToggleTab(this.id) tabIndex=0 noWrap>
<DIV class=treeOFLOW>Folders</DIV></TD></TR>
<TR>
<TD class=nbTreeProgress id=treeProgress style="DISPLAY: none"
vAlign=top noWrap><SPAN id=idLoading
style="OVERFLOW: hidden">Loading...</SPAN>
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</BODY></HTML>
Description
Table 5-2 Mapping Between Sample Ruleset and Case Study
Page Content
Rule Applied
Rewriter Output
Description
var g_szVirtualRoot="http: //abc.siroe.com/mailwe b";
JSRules section of the "Sample Ruleset":
<Variable type="URL"> g_szVirtualRoot </Variable>
var g_szVirtualRoot= "http://gateway.sesta. com/http://abc.siroe.c om/mailweb";
g_szVirtualRoot is a variable whose value is a simple URL.
This rule tells Rewriter to search for a variable g_szVirtualRoot of type URL. If such a variable exists in the web page, Rewriter converts this to an absolute URL, and prefixes the gateway URL.
src="/destin_files/log o-ie5.gif"
HTMLRules section of the "Sample Ruleset":
<Attribute name="src" />
src="http://gateway.se sta.com/http://abc.sir oe.com/destin_files/lo go-ie5.gif
src is the name of an attribute, and does not have any tag or valuePattern attached to it.
This rule tells the Rewriter to search for all attributes with the name src, and rewrite the value of that attribute.
href="http://abc.siroe .com/mailclient/destin /Inbox/?Cmd=contents&a mp;Page=1"
HTMLRules section of the "Sample Ruleset":
<Attribute name="href"/>
href="http://gateway.sesta.com/http://abc.siroe.com/mailclient/destin/Inbox/?Cmd=contents&Page=1"
href is the name of an attribute, and does not have any tag or valuePattern attached to it.
This rule tells Rewriter to search for all attributes with the name href, and rewrite the value of that attribute.
Writing Rules for the RewriterFor the proper functioning of Rewriter, you need to write a comprehensive set of rules to cover all conditions in your intranet pages. Listed below is a general procedure that you can follow to write the rules.
- Identify the directories that contain the HTML pages whose content needs to be rewritten.
- In these directories, identify the pages that need to be rewritten.
- Identify the URLs that need to be rewritten on each page. An easy way of identifying most of the URLs is by searching for "http" and "/".
- Identify the content type of the URL - HTML, JavaScript or XML. See the following sections for details on each content type, further classifications, and the rule syntax for each type of URL:
- Write the rule required to rewrite each of these URLs by editing the required ruleset in the Rewriter service under Portal Server Configuration in the identity server admin console.
- Combine all these rules into a ruleset for that domain
Working SamplesThis section includes simple HTML pages with content that needs to be rewritten. The section also explains the rules required to rewrite the content for each sample HTML page, and the corresponding rewritten HTML page.
All these sample pages are available in the portal server URL/rewriter directory. You can browse through the page before the rule is applied, and then view the file with the rewritten output through your gateway to see how the rule works. In some samples, the rule is already a part of the default gateway ruleset. In some samples, you may have to include the rule in the default gateway ruleset. This is mentioned at the appropriate places.
The following samples are available:
Sample for Forms
This sample can be accessed from:
portal server URL/rewriter/HTML/forms/formrule.html
Ensure that abc.sesta.com is defined in the Proxies for Domains and Subdomains list in the gateway service. If this is not defined, a direct connection is assumed, and the gateway URL is not prefixed.
Add the rule specified in this sample to the default_gateway_ruleset in the section "Rules for Rewriting HTML Attributes". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Page Before Rewriting
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
RW_START
<p>
<form name="form1" method="Post" action="http://abc.sesta.com/casestudy/html/form.html">
<input type="hidden" name="name1" value="0|1234|/test.html">
<input type="hidden" name="name3" value="../../html/test.html">
<form name="form2" method="Post" action="http://abc.sesta.com/testcases/html/form.html"><br>
<input type="hidden" name="name1" value="0|1234|../../html/test.html"></form>
RW_END </p>
</body>
</html>
Rule
<Form source="*" name="form1" field="name1" valuePatterns="0|1234|"/>
HTML Page After Rewriting
<HTML>
<HEAD>
RW_START
</HEAD>
<BODY>
<P>
<FORM name=form1 method=POST action="gateway URL://abc.sesta.com/casestudy/html/form.html">
// This URL is rewritten since <Attribute name="action"/> is defined as part of the HTML rules in the default gateway ruleset. Since the URL is already absolute, only the gateway URL needs to be prefixed. Ensure that abc.sesta.com is defined in the Proxies for Domains and Subdomains list in the gateway service. Else, the gateway URL is not prefixed, since a direct connection is assumed.
<input type=hidden name=name1 value="0|1234|gateway URL/portal server URL/test.html">
// Here the form name is form1, and the field name is name1. This matches the form name and field name specified in the rule. The rule states the valuePatterns as 0|1234| which matches the value in this statement. Hence the URL occurring after the valuePattern is rewritten. The portal server URL and the gateway URL are prefixed. See "Using Pattern-matching in Rules" for details on valuePatterns.
<input type=hidden name=name3 value="../../html/test.html">
// This URL is not rewritten since the name does not match the field name specified in the rule.
</FORM>
<FORM name=form2 method=POST action="gateway URL://abc.sesta.com/casestudy/html/form.html"><BR>
// This URL is rewritten since <Attribute name="action"/> is defined as part of the HTML rules in the default ruleset. Since the URL is already absolute, only the gateway URL needs to be prefixed.
<input type=hidden name=name1 value="0|1234|../../html/test.html">
// This URL is not rewritten since the form name does not match the name specified in the rule.
</FORM>
</BODY>
RW_END
</HTML>
Sample for HTML Attributes
This sample can be accessed from:
portal server URL/rewriter/HTML/attrib/attribrule.html
Ensure that abc.sesta.com and host1.siroe.com are defined in the Proxies for Domains and Subdomains list in the gateway service. If this is not defined, a direct connection is assumed, and the gateway URL is not prefixed.
You need not add the rule specified in this sample to the default gateway ruleset since it is already defined in the "Rules for Rewriting HTML Attributes" section.
HTML Before Rewriting
<html>
Rewriting starts
<head>
<title>TEST PAGE () </title>
</head>
ID-htmlattr.1
<br><br>
1.a href <a href="http://abc.sesta.com/images/logo.gif">http://..</a>
<br><br>
2 href <a href="https://host1.siroe.com">https://..</a>
<br><br>
3 href <a href="../images/logo.gif">../images/</a>
<br><br>
4 href <a href="images/logo.gif">images/..</a> <br><br>
5 href <a href="../../images/logo.gif">../../images/</a> <br><br>
Rewriting ends
</html>
Rule
<Attribute name="href"/>
HTML After Rewriting
<html>
Rewriting starts
<head>
<title>TEST PAGE () </title>
</head>
ID-htmlattr.1
<br><br>
1 a href <a href="gateway URL/http://abc.sesta.com/images/logo.gif">http://..</a> <br>
// This URL is rewritten since the <Attrib name="href"/> rule is already defined in the default gateway ruleset. Since the URL is already absolute, only the gateway URL is prefixed. Ensure that abc.sesta.com is defined in the Proxies for Domains and Subdomains list in the gateway service. Else, the gateway URL is not prefixed, since a direct connection is assumed.
2 href <a href="gateway URL/https://host1.siroe.com">https://..</a>
// Again, host1.siroe.com needs to be defined in the Proxies for Domains and Subdomains list in the gateway service. Else, the gateway URL is not prefixed, since a direct connection is assumed.
<br><br>
3 href <a href="gateway URL/portal server URL/rewriter/HTML/images/logo.gif">../images/</a>
// Since a relative path is specified, the gateway URL and the portal server URL are prefixed along with the required subdirectories. This link will not work since there is no directory called images under the HTML directory in the sample structure provided.
<br><br>
4 href <a href="gateway URL/portal server URL/rewriter/HTML/attrib/images/logo.gif">images/..</a> <br><br>
// Since a relative path is specified, the gateway URL and the portal server URL are prefixed along with the required subdirectories.
5 href <a href="gateway URL/portal server URL/rewriter/images/logo.gif">../../images/</a> <br><br>
// Since a relative path is specified, the gateway URL and the portal server URL are prefixed along with the required subdirectories. This link will not work since there is no directory called images under the rewriter directory in the sample structure provided.
Rewriting ends
</html>
Sample for Applets
The base URL of the page where the applet code is present is:
portal server URL/rewriter/HTML/applet/rule1.html
The RewriteURLinApplet.class file is present in the following location:
portal server URL/rewriter/HTML/applet/appletcode
Add the rule specified in this sample to the default_gateway_ruleset in the section "Rules for Rewriting HTML Attributes". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Before Rewriting
<html>
Rewriting starts
<br>
<applet codebase=appletcode code=RewriteURLinApplet.class archive=/test>
<param name=Test1 value="/index.html">
<param name=Test2 value="../index.html">
<param name=Test3 value="../../index.html">
</applet>
Rewriting ends
</html>
Rule
<Applet source="*/rule1.html" code="RewriteURLinApplet.class" param="Test*" />
HTML After Rewriting
<HTML>
Rewriting starts
<BR>
<APPLET codebase=gateway URL/portal server URL/rewriter/HTML/applet/appletcode=RewriteURLinApplet.class archive=/test>
// This URL is rewritten since the rule <Attribute name="codebase"/> is already present as part of the default gateway ruleset. The gateway and the portal server URLs are prefixed along with the path up to the appletcode directory.
<param name=Test1 value="gateway URL/portal server URL/index.html">
// This URL is rewritten since the base URL of the page is rule1.html, and the param name matches the param Test* specified in the rule. Since index.html is specified to be at the root level, the gateway and portal server URLs are prefixed directly.
<param name=Test2 value="gateway URL/portal server URL/rewriter/HTML/index.html">
// This URL is rewritten since the base URL of the page is rule1.html, and the param name matches the param Test* specified in the rule. The path is prefixed as required.
<param name=Test3 value="gateway URL/portal server URL/rewriter/index.html">
// This URL is rewritten since the base URL of the page is rule1.html, and the param name matches the param Test* specified in the rule. The path is prefixed as required.
</APPLET>
Rewriting ends
</HTML>
Sample for HTML JavaScript Tokens
This sample can be accessed from:
portal server URL/rewriter/HTML/jstokens/JStokens.html
Add the rule specified in this sample to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Before Rewriting
<html>
<head>
Rewriting starts
<script language="javascript">
function Check(test,ind){
if (ind == 'blur')
{alert("testing onBlur")}
if (ind == 'focus')
{alert("testing onFocus")}
}
</SCRIPT>
</head>
<body>
<form>
<input TYPE=TEXT SIZE=20 value=blur onAbort="Check('/indexblur.html','blur');return;">
<input TYPE=TEXT SIZE=20 value=blur onBlur="Check('/indexblur.html','blur');return;">
<input TYPE=TEXT SIZE=20 value=focus onFocus="Check('/focus.html','focus');return;">
<input TYPE=TEXT SIZE=20 value=focus onChange="Check('/focus.html','focus');return;">
<input TYPE=TEXT SIZE=20 value=focus onClick="Check('/focus.html','blur');return;">
<br><br>
</form>
</body>
Rewriting ends
</html>
Rule
<JSToken>onClick</JSToken>
<Function type="URL" name="Check" paramPatterns="y"/>
Note
<Function type="URL" name="Check" paramPatterns="y"/> is a JavaScript function rule and is explained in detail in the JavaScript function sample.
HTML After Rewriting
<html>
<head>
Rewriting starts
<script language="javascript">
function Check(test,ind){
if (ind == 'blur')
{alert("testing onBlur")}
if (ind == 'focus')
{alert("testing onFocus")}
}
</SCRIPT>
</head>
<body>
<form>
<input TYPE=TEXT SIZE=20 value=blur onAbort="Check('gateway URL/portal server URL/indexblur.html','blur');return;">
<input TYPE=TEXT SIZE=20 value=blur onBlur="Check('gateway URL/portal server URL/indexblur.html','blur');return;">
<input TYPE=TEXT SIZE=20 value=focus onFocus="Check('gateway URL/portal server URL/focus.html','focus');return;">
<input TYPE=TEXT SIZE=20 value=focus onChange="Check('gateway URL/portal server URL/focus.html','focus');return;">
<input TYPE=TEXT SIZE=20 value=focus onClick="Check('gateway URL/portal server URL/focus.html','blur');return;">
// All the statements are rewritten in this sample. The gateway and portal server URLs are prefixed in each case. This is because rules for onAbort, onBlur, onFocus, onChange, and onClick are defined in the default gateway ruleset. Rewriter detects the JavaScript tokens and passes it to the JavaScript function rules for further processing. The second rule listed in the sample tells Rewriter which parameter to rewrite.
</body>
<br>
Rewriting ends
</html>
Sample for JavaScript URL Variables
This sample can be accessed from:
portal server URL/rewriter/JavaScript/variables/url/js_urls.html
Ensure that abc.sesta.com is defined in the Proxies for Domains and Subdomains list in the gateway service. If this is not defined, a direct connection is assumed, and the gateway URL is not prefixed.
Add the rule specified in this sample to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
If you added the rule, restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Page Before Rewriting
<html>
Rewriting starts
<head>
<title>JavaScript Variable test page</title>
</head>
<body>
<script LANGUAGE="Javascript">
<!--
//URL Variables
var imgsrc="/tmp/tmp.jpg";
var imgsrc="./tmp/tmp.jpg";
var imgsrc="../tmp/tmp.jpg";
var imgsrc="../../tmp/tmp.jpg";
var imgsrc="http://abc.sesta.com/tmp/tmp.jpg";
var imgsrc="../../../tmp/tmp.jpg";
var imgsrc="tmp/tmp.jpg";
//-->
</SCRIPT>
<br>
Testing JavaScript variables!
<br>
<img src="images/logo.gif">
<br>
Image
</body>
<br>
Rewriting ends
</html>
Rule
<Variable type="URL">imgsrc</Variable>
HTML Page After Rewriting
<html>
Rewriting starts
<head>
<title>JavaScript Variable test page</title>
</head>
<body>
<script LANGUAGE="Javascript">
<!--
//URL Variables
var imgsrc="gateway URL/portal server URL/tmp/tmp.jpg";
var imgsrc="gateway URL/portal server URL/rewriter/JavaScript/variables/url/tmp/tmp.jpg";
var imgsrc="gateway URL/portal server URL/rewriter/JavaScript/variables/tmp/tmp.jpg";
var imgsrc="gateway URL/portal server URL/rewriter/JavaScript/tmp/tmp.jpg";
var imgsrc="gateway URL/http://abc.sesta.com/tmp/tmp.jpg";
var imgsrc="gateway URL/portal server URL/rewriter/tmp/tmp.jpg";
var imgsrc="gateway URL/portal server URL/rewriter/JavaScript/variables/url/tmp/tmp.jpg";
// All the above URLs are JavaScript variables of type URL and name imgsrc as specified in the rule. Hence they are prefixed with the gateway and the portal server URLs. The path following the portal server URL is prefixed as required.
//-->
</SCRIPT>
<br>
Testing JavaScript variables!
<br>
<img src="gateway URL/portal server URL/rewriter/JavaScript/variables/url/images/logo.gif">
// This line is rewritten since the rule <Attribute name="src"/> is defined in the default gateway ruleset under the section "Rules for Rewriting HTML Attributes".
<br>
Image
</body>
<br>
Rewriting ends
</html>
Sample for JavaScript EXPRESSION Variables
This sample can be accessed from:
portal server URL/rewriter/JavaScript/variables/expr/expr.html
Add the rule specified in this sample (if it does not already exist) to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
If you added the rule, restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Page Before Rewriting
<html>
<head>
<title>JavaScript EXPRESSION Variables Test Page</title>
</head>
<body>
<script LANGUAGE="Javascript">
<!--
//Expression variables
var expvar1="images";
var expvar2="/logo.gif";
var expvar = expvar1 + expvar2;
document.write("<A HREF="+expvar+">EXPRESSION</A><P>")
var expvar="/images/logo"+".gif";
document.write("<A HREF="+expvar+">EXPRESSION</A><P>")
//-->
</SCRIPT>
Testing JavaScript EXPRESSION variables
</body>
</html>
Rule
<Variable type="EXPRESSION">expvar</Variable>
HTML Page After Rewriting
<html>
<head>
<title>JavaScript EXPRESSION Variables Test Page</title>
</head>
<body>
<SCRIPT>
// Rewriter appends the wrapper function psSRAPRewriter_convert_expression here
</SCRIPT>
<script LANGUAGE="Javascript">
<!--
//Expression variables
var expvar1="images";
var expvar2="/logo.gif";
var expvar =psSRAPRewriter_convert_expression( expvar1 + expvar2);
// The rewriter recognizes the right hand side of this statement to be a JavaScript EXPRESSION variable. The rewriter is not able to resolve the value of this expression at the server end. Hence, the psSRAPRewriter_convert_expression function is prefixed to the expression. The expression is evaluated at the client end, and rewritten as required.
document.write("<A HREF="+expvar+">EXPRESSION</A><P>")
// The rewritten value of expvar from the previous statement is used to arrive at the value of this expression. Since the result is a valid URL (a graphic exists at this location in the sample), the link will work.
var expvar="gateway URL/portal server URL/images/logo"+".gif";
// The rewriter recognizes the right hand side of expvar to be a string expression. This can be resolved at the server side, and hence is rewritten directly.
document.write("<A HREF="+expvar+">EXPRESSION</A><P>")
// The rewritten value of expvar from the previous statement is used to arrive at the value of this expression. Since the result is a not a valid URL (a graphic does not exist at the resultant location), the link will not work.
//-->
</SCRIPT>
Testing JavaScript EXPRESSION variables
</body>
</html>
Sample for JavaScript DHTML Variables
This sample can be accessed from:
portal server URL/rewriter/JavaScript/variables/dhtml/dhtml.html
Ensure that abc.sesta.com is defined in the Proxies for Domains and Subdomains list in the gateway service. If this is not defined, a direct connection is assumed, and the gateway URL is not prefixed.
Add the rule specified in this sample (if it does not already exist) to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
If you added the rule, restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Page Before Rewriting
<html>
<head>
<title>JavaScript DHTML Variable Test Page</title>
</head>
<body>
<script LANGUAGE="Javascript">
<!--
//DHTML Var
var dhtmlVar="<a href=../../images/test.html>"
var dhtmlVar="<a href=/../images/test.html>"
var dhtmlVar="<a href=/images/test.html>"
var dhtmlVar="<a href=images/test.html>"
var dhtmlVar="<a href=http://abc.sesta.com/images/test.html>"
var dhtmlVar="<img src=http://abc.sesta.com/images/test.html>"
//-->
</SCRIPT>
<br><br>
Testing DHTML Variables
<br><br>
<img src="images/logo.gif">IMAGE
</body>
</html>
Rule
<Variable type="DHTML">dhtmlVar</Variable>
HTML Page After Rewriting
<html>
<head>
<title>JavaScript DHTML Variable Test Page</title>
</head>
<body>
<script LANGUAGE="Javascript">
<!--
//DHTML Var
var dhtmlVar="<a href=gateway URL/portal server URL/rewriter/JavaScript/images/test.html>"
// The JavaScript DHTML rule identifies the right hand side of the dhtmlVar as dynamic HTML content. So the HTML rules in the default gateway ruleset are applied. The dynamic HTML contains a href attribute. The default gateway ruleset defines the rule <Attribute name="href"/>. Hence the value of the href attribute is rewritten. But the URL is not absolute. So, the relative URL is replaced with the base URL of the page, and the required subdirectories. This is in turn prefixed with the gateway URL to derive the final rewritten output.
var dhtmlVar="<a href=gateway URL/portal server URL/../images/test.html>"
// Although the base URL of the page is appended, and the gateway URL is prefixed, the resultant URL will not work. This is because the initial URL /../images/test.html is inaccurate.
var dhtmlVar="<a href=gateway URL/portal server URL/images/test.html>"
// Here again, the JavaScript DHTML rule identifies the right hand side to be dynamic HTML content, and passes it to the HTML rules. The HTML rule <Attribute name="href"/> from the default gateway ruleset is applied, and the statement is rewritten as shown. The gateway URL and Portal Server URL are prefixed.
var dhtmlVar="<a href=gateway URL/portal server URL/rewriter/JavaScript/variables/dhtml/images/test.html>"
var dhtmlVar="<a href=gateway URL/http://abc.sesta.com/images/test.html>"
var dhtmlVar="<img src=gateway URL/http://abc.sesta.com/images/test.html>"
// The JavaScript DHTML rule identifies the dynamic HTML content on the right hand side, and passes the statement to the HTML rules. The <Attribute name="src"/> rule in the default gateway ruleset is applied. Since the URL is absolute, only the gateway URL needs to be prefixed. Ensure that abc.sesta.com is defined in the Proxies for Domains and Subdomains list for this URL to be rewritten.
//-->
</SCRIPT>
<br><br>
Testing DHTML Variables
<br><br>
<img src="gateway URL/portal server URL/rewriter/JavaScript/variables/dhtml/images/logo.gif">
// This line is rewritten since the rule <Attribute name="src"/> is defined in the default gateway ruleset under the section "Rules for Rewriting HTML Attributes".
<br><br>
Image
</body>
</html>
Sample for JavaScript DJS Variables
This sample can be accessed from:
portal server URL/rewriter/JavaScript/variables/djs/djs.html
Ensure that abc.sesta.com is defined in the Proxies for Domains and Subdomains list in the gateway service. If this is not defined, a direct connection is assumed, and the gateway URL is not prefixed.
Add the two rules specified in this sample (if it does not already exist) to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Page Before Rewriting
<html>
<head>
<title>Dynamic JavaScript Variable Test Page</title>
</head>
<body>
<script LANGUAGE="Javascript">
<!--
var dJSVar="var dJSimgsrc='/tmp/tmp/jpg';"
var dJSVar="var dJSimgsrc='../../../tmp/tmp/jpg';"
var dJSVar="var dJSimgsrc='http://abc.sesta.com/tmp/tmp/jpg';"
//-->
</SCRIPT>
<br>
Testing Dynamic JavaScript Variables
<br>
<img src="images/logo.gif">
<br>
Image
</body>
</html>
Rule
<Variable type="DJS">dJSVar</Variable>
<Variable type="URL">dJSimgsrc</Variable>
HTML Page After Rewriting
<html>
<head>
<title>Dynamic JavaScript Variable Test Page</title>
</head>
<body>
<script LANGUAGE="Javascript">
<!--
var dJSVar="var dJSimgsrc='gateway URL/portal server URL/tmp/tmp/jpg';"
var dJSVar="var dJSimgsrc='gateway URL/portal server URL/rewriter/tmp/tmp/jpg';"
var dJSVar="var dJSimgsrc='gateway URL/http://abc.sesta.com/tmp/tmp/jpg';"
// All the above statements are rewritten with the gateway and portal server URLs. The required path is prefixed as appropriate. The first rule identifies the right hands side of dJSVar as a dynamic JavaScript variable. This is then passed to the second rule which identifies the right hand side of dJSimgsrc as a JavaScript variable of type URL. This is rewritten accordingly.
//-->
</SCRIPT>
<br>
Testing Dynamic JavaScript Variables
<br>
<img src="gateway URL/portal server URL/rewriter/JavaScript/variables/djs/images/logo.gif">
// This line is rewritten since the rule <Attribute name="src"/> is defined in the default gateway ruleset under the section "Rules for Rewriting HTML Attributes".
<br>
Image
</body>
</html>
Sample for JavaScript SYSTEM Variables
This sample can be accessed from:
portal server URL/rewriter/JavaScript/variables/system/system.html
Add the rule specified in this sample (if it does not already exist) to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Page Before Rewriting
<html>
<head>
<title>JavaScript SYSTEM Variables Test Page</title>
</head>
<body>
<script LANGUAGE="Javascript">
<!--
//SYSTEM Var
alert(window.location.pathname);
//document.write("<A HREF="+window.location.pathname+">SYSTEM</A><P>")
//-->
</SCRIPT>
Testing JavaScript SYSTEM Variables
<br>
This page displays the path where the current page is located when it is loaded.
</body>
</html>
Rule
<Variable type="SYSTEM">window.location.pathname</Variable>
HTML After Rewriting
<html>
<head>
<title>JavaScript SYSTEM Variables Test Page</title>
</head>
<body>
<SCRIPT>
<!--
function psSRAPRewriter_convert_pathname(aPSPath)
{
var lPSPath = aPSPath.substr( aPSPath.indexOf( "/",
aPSPath.lastIndexOf("://") + 3 ) );
return lPSPath;
}//psSRAPRewriter_convert_pathname()
//-->
</SCRIPT>
<script LANGUAGE="Javascript">
<!--
//SYSTEM Var
alert(psSRAPRewriter_convert_pathname(window.location.pathname));
// The rewriter identifies window.location.pathname as a JavaScript SYSTEM variable. The value of this variable cannot be determined at the server end. So the rewriter prefixes the variable with the psSRAPRewriter_convert_pathname function. This wrapper function determines the value of the variable at the client end and rewrites as required.
//-->
</SCRIPT>
Testing JavaScript SYSTEM Variables
<br>
This page displays the path where the current page is located when it is loaded.
</body>
</html>
Sample for JavaScript URL Functions
This sample can be accessed from:
portal server URL/rewriter/JavaScript/functions/url/url.html
Add the rule specified in this sample (if it does not already exist) to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Page Before Rewriting
<html>
<body>
JavaScript URL Function Test Page
<br>
<script language="JavaScript">
<!--
function test(one,two,three)
{
alert(one + "##" + two + "##" +three);
}
test("/test.html","../test.html","123");
window.open("/index.html","gen",width=500,height=500);
//-->
</SCRIPT>
</body>
</html>
Rule
<Function type="URL" name="test" paramPatterns="y,y"/>
<Function type="URL" name="window.open" paramPatterns="y"/>
HTML Page After Rewriting
<html>
<body>
JavaScript URL Function Test Page
<br>
<script language="JavaScript">
<!--
function test(one,two,three)
{
alert(one + "##" + two + "##" +three);
}
test("/test.html","../test.html","123");
window.open("gateway URL/portal server URL/index.html","gen",width=500,height=500);
//-->
</SCRIPT>
</body>
</html>
Sample for JavaScript EXPRESSION Functions
This sample can be accessed from:
portal server URL/rewriter/JavaScript/functions/expr/expr.html
Add the rule specified in this sample (if it does not already exist) to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Page Before Rewriting
<html>
<body>
JavaScript EXPRESSION Function Test Page
<br><br><br>
<script language="JavaScript">
<!--
function jstest2()
{
return ".html";
}
function jstest1(one)
{
return one;
}
var dir="/images/test"
var test1=jstest1(dir+"/test"+jstest2());
document.write("<a HREF="+test1+">Test</a>");
alert(test1);
//-->
</SCRIPT>
</body>
</html>
Rule
<Function type="EXPRESSION" name="jstest1" paramPatterns="y"/>
HTML Page After Rewriting
<html>
<body>
JavaScript EXPRESSION Function Test Page
<br><br><br>
<script>
<!--
// various functions including psSRAPRewriter_convert_expression appear here.
//-->
</SCRIPT>
<script language="JavaScript">
<!--
function jstest2()
{
return ".html";
}
function jstest1(one)
{
return one;
}
var dir="/images/test"
var test1=jstest1(psSRAPRewriter_convert_expression(dir+"/test"+jstest2 ()));
// The rule states that the first parameter in the function jstest1 which is of type EXPRESSION needs to be rewritten. The value of this expression is /test/images/test.html. This is prefixed with the portal server and the gateway URLs.
document.write("<a HREF="+test1+">Test</a>");
alert(test1);
//-->
</SCRIPT>
</body>
</html>
Sample for JavaScript DHTML Functions
This sample can be accessed from:
portal server URL/rewriter/JavaScript/functions/dhtml/dhtml.html
Add the rule specified in this sample (if it does not already exist) to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Page Before Rewriting
<html>
<head>
Testing JavaScript DHTML Functions
<br>
<br>
<script>
<!--
document.write('<a href="/index.html">write</a><BR>')
document.writeln('<a href="index.html">writeln</a><BR>')
document.write("http://abc.sesta.com/index.html<BR>")
document.writeln("http://abc.sesta.com/index.html<BR>")
//-->
</SCRIPT>
</head>
<body BGCOLOR=white>
<br><br>
Testing document.write and document.writeln
</body>
</html>
Rule
<Function type="DHTML" name=" document.write" paramPatterns="y"/>
<Function type="DHTML" name=" document.writeln" paramPatterns="y"/>
HTML Page After Rewriting
<html>
<head>
Testing JavaScript DHTML Functions
<br>
<br>
<script>
<!--
document.write('<a href="gateway URL/portal server URL/index.html">write</a><BR>')
// The first rule specifies that the first parameter of the DHTML JavaScript function document.write needs to be rewritten. The rewriter identifies the first parameter to be a simple HTML statement. The HTML rules section in the default gateway ruleset has the rule <Attribute name="href" /> which indicates that the statement needs to be rewritten.
document.writeln('<a href="gateway URL/portal server URL/rewriter/JavaScript/functions/dhtml/index.html">writeln</a><BR> ')
// The second rule specifies that the first parameter of the DHTML JavaScript function document.writeln needs to be rewritten. The rewriter identifies the first parameter to be a simple HTML statement. The HTML rules section in the default gateway ruleset has the rule <Attribute name="href" /> which indicates that the statement needs to be rewritten.
document.write("http://abc.sesta.com/index.html<BR>")
document.writeln("http://abc.sesta.com/index.html<BR>")
// The above statements are not rewritten although the DHTML rule identifies the functions document.write and document.writeln. This is because the first parameter in this case is not simple HTML. It could be any string, and the rewriter does not know how to rewrite this.
//-->
</SCRIPT>
</head>
<body BGCOLOR=white>
<br><br>
Testing document.write and document.writeln
</body>
</html>
Sample for JavaScript DJS Functions
This sample can be accessed from:
portal server URL/rewriter/JavaScript/functions/djs/djs.html
Ensure that abc.sesta.com is defined in the Proxies for Domains and Subdomains list in the gateway service. If this is not defined, a direct connection is assumed, and the gateway URL is not prefixed.
Add the rule specified in this sample (if it does not already exist) to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Page Before Rewriting
<html>
Test for JavaScript DJS Functions
<br>
<script>
menu.addItem(new NavBarMenuItem("All Available
Information","JavaScript:top.location='http://abc.sesta.com'"));
//menu.addItem(new NavBarMenuItem("All Available Information","http://abc.sesta.com"));
</script>
</html>
Rules
<Function type="DJS" name="NavBarMenuItem" paramPatterns=",y"/>
<Variable type="URL">top.location</Variable>
HTML Page After Rewriting
<html>
Testing JavaScript DJS Functions
<br>
<script>
menu.addItem(new NavBarMenuItem("All Available Information","javaScript:top.location='gateway URl/http://abc.sesta.com'"));
// abc.sesta.com is an entry in the Proxies for Domains and Subdomains list in the gateway service. Hence the rewriter needs to rewrite this URL. But since it is an absolute URL, the portal server URL need not be prefixed. The DJS rule states that the second parameter of the DJS function NavBarMenuItem needs to be rewritten. But the second parameter if the function is again a JavaScript variable. A second rule is required to rewrite the value of this variable. The second rule specifies that the value of the JavaScript variable top.location needs to be rewritten. Since all these conditions are met, the URL is rewritten.
//menu.addItem(new NavBarMenuItem("All Available Information","http://abc.sesta.com"));
// Although the DJS rule specifies that the second parameter of the function NavBarMenuItem needs to be rewritten, it does not happen in this statement. This is because the rewriter does not recognize the second parameter as simple HTML.
</script>
</html>
Sample for XML Attributes
This sample can be accessed from:
portal server URL/rewriter/XML/attrib.html
Add the rule specified in this sample (if it does not already exist) to the default_gateway_ruleset in the section "Rules for Rewriting XML Source". Edit the default_gateway_ruleset in the Rewriter service of the Portal Server Configuration in the identity server admin console.
Restart the gateway using:
InstallDir/SUNWps/bin/gateway -n profilename start
for the changes to take effect.
HTML Before Rewriting
<html>
RW_START
<body>
<xml>
<baseroot href="/root.html"/>
</xml>
<xml>
<img href="image.html"/>
</xml>
<xml>
<string href="1234|substring.html"/>
</xml>
<xml>
<check href="1234|string.html"/>
</xml>
</body>
RW_END
</html>
Rule
<Attribute name="href" tag="check" valuePatterns="1234|"/>
HTML After Rewriting
<html>
Rewriting starts
<br>
<br>
<body>
<xml><baseroot href="/root.html"/></xml>
<xml><img href="image.html"/></xml>
<xml><string href="1234|substring.html"/></xml>
<xml><check href="1234|gateway URL/portal server URL/rewriter/XML/string.html"/></xml>
// This statement is rewritten since it matches the conditions specified in the rule. The attribute name is href, tag is check and the valuePatterns is 1234. The string following valuePatterns is rewritten. See "Using Pattern-matching in Rules" for details on valuePatterns.
</body>
Rewriting ends
</html>
Ruleset DTD<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY % gtype ’GROUPED’>
<!ENTITY % stype ’SCATTERED’>
<!ENTITY % jURL ’URL’>
<!ENTITY % jEXPRESSION ’EXPRESSION’>
<!ENTITY % jDHTML ’DHTML’>
<!ENTITY % jDJS ’DJS’>
<!ENTITY % jSYSTEM ’SYSTEM’>
<!ENTITY % ruleSetElements ’(HTMLRules | JSRules | XMLRules)? ’>
<!ENTITY % htmlElements ’(Form | Applet | Attribute | JSToken)*’>
<!ENTITY % jsElements ’(Variable | Function)*’>
<!ENTITY % xmlElements ’(Attribute | TagText)*’>
<!ELEMENT RuleSet (%ruleSetElements;,%ruleSetElements;,%ruleSetElements;)>
<!ATTLIST RuleSet
type (%gtype; | %stype;) "GROUPED"
id ID #REQUIRED
>
<!--
The following constraints are not represented in DTD, but are handled programatically
1. ID should alway be in lower case.
2. In a rule, all mandatory attributes cannot be "*".
3. Only one instance of the below elements is allowed. They can be in any order.
1)HTMLRules
2)JSRules
3)XMLRules
-->
<!ELEMENT HTMLRules (%htmlElements;)>
<!ATTLIST HTMLRules
type (%gtype; | %stype;) "GROUPED"
id CDATA "html_rules"
>
<!ELEMENT Form EMPTY>
<!ATTLIST Form
source CDATA #REQUIRED
name CDATA #REQUIRED
field CDATA #REQUIRED
valuePatterns CDATA ""
>
<!ELEMENT JSToken (#PCDATA)>
<!ELEMENT Applet EMPTY>
<!ATTLIST Applet
source CDATA #REQUIRED
code CDATA #REQUIRED
param CDATA "*"
valuePatterns CDATA ""
>
<!ELEMENT JSRules (%jsElements;)>
type (%gtype; | %stype;) "GROUPED"
id CDATA "js_rules"
>
<!ELEMENT Variable (#PCDATA)>
<!ATTLIST Variable
type (%jURL; | %jEXPRESSION; | %jDHTML; | %jDJS; | %jSYSTEM;) "URL"
>
<!ELEMENT Function EMPTY>
<!ATTLIST Function
type (%jURL; | %jEXPRESSION; | %jDHTML; | %jDJS;) "URL"
name CDATA #REQUIRED
paramPatterns CDATA #REQUIRED
>
<!ELEMENT XMLRules (%xmlElements;)>
<!ATTLIST XMLRules
type (%gtype; | %stype;) "GROUPED"
id CDATA "xml_rules"
>
<!ELEMENT TagText EMPTY>
<!ATTLIST TagText
tag CDATA #REQUIRED
attributePatterns CDATA ""
>
<!ELEMENT Attribute EMPTY>
<!ATTLIST Attribute
name CDATA #REQUIRED
tag CDATA "*"
valuePatterns CDATA ""
>
Note
You can use * as a part of the rule. But all the mandatory attributes cannot be *. Such rules are ignored, and no error message is displayed.
Enabling Rewriter Debug InformationThis file contains logs about warning messages. These are just warnings and do not critically affect the functioning of Rewriter.
To enable Rewriter debug
- Log in as root to the gateway machine and edit the following file:
InstallDir/SUNWam/lib/AMConfig.properties
- Set the debug level:
com.iplanet.services.debug.level=
The debug levels are:
error - Only serious errors are logged in the debug file. Rewriter usually stops functioning when such errors occur.
warning - Warning messages are logged.
message - All debug messages are logged.
off - No debug messages are logged.
- Specify the directory for the debug files in the following property of the AMConfig.properties file:
com.iplanet.services.debug.directory=/var/opt/SUNWam/debug
where /var/opt/SUNWam/debug is the default debug directory.
- Change the permission of the debug directory as follows:
chmod -fR 777 debug directory
- Restart the gateway for the changes take effect:
InstallDir/SUNWps/bin/gateway -n profilename start
Debug Files
The following table lists the Rewriter files and the information contained within them after a page has been rewritten.
Mapping of Rules with SP4The following table lists the mapping of the Sun ONE Portal Server, Secure Remote Access Rewriter rules with the previous releases of the Sun ONE Portal Server.