Home > Articles > Operating Systems, Server > Solaris

  • Print
  • + Share This
Like this article? We recommend

Adding and Removing Rewriter Rules

This section describes how to add, remove, and view rewriter rules through both the administration interface and the command line interface. Maintaining the rewriter rule set and understanding how the gateway interprets content based on the values contained within the different rewriter attributes in the case of the CLI and fields in the case of the administration console are essential to successfully deploying the gateway in front of complex web applications.

To Access and Modify the Gateway Profile Using the Administrative GUI

  1. Go to http://ips-server.iplanet.com:8080/console, and log in as the administrator.

    This is the superuser UNIX™ login by default. Be sure to specify the port number, hostname, and domain relative to your own Portal Server installation.

  2. Select the Gateway Management Link under the Portal Server Services Heading.

  3. Select the Manage Gateway Profile link.

    After this page comes up, there will be a long list of component attributes. For details about attributes not related directly to the rewriter, refer to the Sun ONE Portal Server Administration Guide.

    All gateway component attributes directly related to the rewriter contain Rewrite as the first word in the field name. Rules can be added by typing the rule information in the text field just below the option list of the field to be changed and selecting the Add button. The new value is not added to the gateway profile until the Submit button at the bottom of the page has been clicked.

    To delete a rule, first select it, then select the Delete button just bellow the text input field. Again, the changes are not actually made to the profile until the Submit button has been clicked.

    Do not mix and match additions and deletions prior to a submittal so that you are sure that the profile is updated correctly. Also, you should verify that your changes have been made by going back to the gateway profile page.

To Access and Modify the Gateway Profile Using the Command Line Interface

The gateway profile can be modified and viewed by importing and exporting the iwtGateway component using the ipsadmin command.

  1. Dump the component for viewing and editing to an XML file by typing the following commands:

    root@ips-server: PATH=$PATH:/opt/SUNWips/bin;export PATH
    root@ips-server: ipsadmin get component iwtGateway > /tmp/iwtGateway.xml

    where /opt is the Portal Server install directory.

    The rewriter-specific gateway attribute fields that correspond to what is seen on the administration GUI can be seen by typing the following command:

    root@ips-server: grep "desc=\"Rewrite" /tmp/iwtGateway.xml
      desc="Rewrite JavaScript Function Parameters In JavaScript"
      desc="Rewrite JavaScript Variables Function"
      desc="Rewrite Form Input Tags List"
      desc="Rewrite JavaScript Function Parameters In HTML"
      desc="Rewrite JavaScript Function Parameters"
      desc="Rewrite JavaScript Function Parameters Function"
      desc="Rewrite HTML Attributes"
      desc="Rewrite Applet/Object Parameter Values List"
      desc="Rewrite JavaScript System Variables Function"
      desc="Rewrite JavaScript Variables In JavaScript"
      desc="Rewrite HTML Attributes Containing JavaScript"
      desc="Rewrite Attribute value of XML document"
      desc="Rewrite JavaScript Variables In URLs"
      desc="Rewrite Text data of XML document"
      desc="Rewrite JavaScript Variables In HTML"
      desc="Rewrite All URLs Enabled"

    Each of these entries is the description field for the actual attribute name, which might be something like iwtGateway-JavaScriptVariables.

  2. To add a value to an attribute, copy everything between the attribute tags including the tags themselves into a new XML file.

    root@ips-server: /usr/bin/cat <<EOF >/tmp/iwtGateway-JavaScriptVariables.xml
    <iwt:Att name="iwtGateway-JavaScriptVariables"
      type="stringlist"
      desc="Rewrite JavaScript Variables In URLs"
      idx="a5"
      userConfigurable="false"
      >
      <Val>g_szBaseURL</Val>
      <Val>g_szVirtualRoot</Val>
      <Val>szViewClassURL</Val>
      <Val>g_szExWebDir</Val>
      <Val>g_szPublicFolderUrl</Val>
      <Val>g_szUserBase</Val>
      <Val>imgsrc</Val>
      <Val>location.href</Val>
      <Val>_fr.location</Val>
      <Val>mf.location</Val>
      <Val>parent.location</Val>
      <Val>self.location</Val>
      <Val>lnk</Val>
      <Val>tabURL</Val>
      <Val>document.location.href</Val>
      <Val>window.status</Val>
      <Val>window.location.href</Val>
      <Wperm>ADMIN</Wperm>
      <Rperm>ADMIN</Rperm>
      <Rperm>OWNER</Rperm>
     </iwt:Att>
    EOF
  3. Edit the XML file, and add the value or values you want.

  4. Type the ipsadmin command to update the gateway profile with the new attribute values.

    root@ips-server: ipsadmin change component iwtGateway
    /tmp/iwtGateway-JavaScriptVariables.xml
    Operation completed successfully.
  5. Verify that the new value was imported successfully by typing the following command:

    root@ips-server: ipsadmin get component iwtGateway | grep
    window.location.href
    <Val>window.location.href</Val>

    NOTE

    Multiple rules with the same name cannot be specified for the same environment and interpretation. For example, a variable called my_URL cannot be present in both the Rewrite JavaScript Variables in URLs section and the Rewrite JavaScript Variables Function section of the gateway profile. Only the first instance of the rule encountered by the gateway will be used.

After updating the gateway profile, it is a good idea to keep a backup of the profile data. You can do this by using the ipsadmin command (as in the following example) to dump the gateway profile and wrap component tags around the result. The component tags are required in the event that the entire component has to be deleted and re-imported.

root@ips-server: cp /etc/opt/SUNWips/xml/iwtGateway.xml
/etc/opt/SUNWips/xml/iwtGateway.xml.bak
root@ips-server: /usr/bin/cat <<EOF >/tmp/iwtGateway.xml
<iwt:Component name="iwtGateway"
  ver="1.0"
  desc="Gateway Profile"
  resB="iwtGateway"
  idx="">
EOF
root@ips-server: ipsadmin get component iwtGateway >> /tmp/iwtGateway.xml
root@ips-server: /usr/bin/sed '$d' /tmp/iwtGateway.xml >
/etc/opt/SUNWips/xml/iwtGateway.xml
root@ips-server: /usr/bin/cat <<EOF >>/etc/opt/SUNWips/xml/iwtGateway.xml
</iwt:Component>
EOF

Follow the same guidelines to remove a value from an attribute list. If the gateway profile becomes corrupted for any reason, you might be able to delete the component entirely and re-import it using one of the backed up iwtGateway.xml files, as in the following example.

root@ips-server: ipsadmin delete component iwtGateway
Operation completed successfully.
root@ips-server: ipsadmin get component iwtGateway.xml
Profile get failed. More info: Unable to get attribute or privilege value from data store 
root@ips-server: ipsadmin -chkxml /etc/opt/SUNWips/xml/iwtGateway.xml
Operation completed successfully.
root@ips-server: ipsadmin -import /etc/opt/SUNWips/xml/iwtGateway.xml
Operation completed successfully.
root@ips-server: ipsadmin get component iwtGateway > /dev/null 2>&1
root@ips-server: if [ $? -eq 0 ]; then { echo "Success"; } else { echo
"Failure"; } fi
Success

NOTE

The gateway component must be restarted after any modifications to its profile data.

  • + Share This
  • 🔖 Save To Your Account