Sun Java System Portal Server Secure Remote Access 7.2 管理指南

JavaScript DJS 函數的範例

Procedure使用 JavaScript DJS 函數範例

  1. 您可自下列路徑存取此範例:

    portal-server-URL /rewriter/JavaScript/functions/djs/djs.html

  2. 請確定您已於閘道服務的 [網域與子網域的代理伺服器] 清單中定義 abc.sesta.com

    若未定義,則會採用直接連接,且不前置閘道 URL。

  3. 將此範例中指定的規則新增 (若尚不存在) 至 [重新寫入 JavaScript 來源的規則] 部分的 default_gateway_ruleset 中。在 Portal Server 管理主控台的 Portal Server 配置下,編輯 Rewriter 服務中的 default_gateway_ruleset

  4. 重新啟動閘道:


    ./psadmin start-sra-instance –u amadmin – f  <password file> –N <profile name>– t  <gateway>
    

重新寫入前的 HTML 網頁

<html>
Test for JavaScript DJS Functions
<br>
<script>
menu.addItem(new NavBarMenuItem("All Available
Information","JavaScript:top.location=\qhttp://abc.sesta.com\q"));
//menu.addItem(new NavBarMenuItem("All Available Information","http://abc.sesta.com"));
</script>
</html>

規則

<Function type="DJS" name="NavBarMenuItem" paramPatterns=",y"/>
<Variable type="URL" name="top.location"/>

重新寫入後的 HTML 網頁

<html>
Testing JavaScript DJS Functions
<br>
<script>
menu.addItem(new NavBarMenuItem
("All Available Information","javaScript:top.location=
\qgateway-URL/http://abc.sesta.com\q"));

// abc.sesta.com 是閘道服務的 [網域與子網域的代理伺服器] 清單中的一項。因此 Rewriter 需要重新寫入此 URL。但因為是絕對 URL,因此不需前置 Portal Server URL。DJS 規則指出 DJS 函數 NavBarMenuItem 的第二個參數需重新寫入。但是第二個參數又是 JavaScript 變數。重新寫入此變數的值需要第二個規則。第二個規則指出 JavaScript 變數 top.location 的值需重新寫入。由於符合所有條件,因此重新寫入 URL。

//menu.addItem(new NavBarMenuItem("All Available Information","http://abc.sesta.com"));

// 雖然 DJS 規則指出函數 NavBarMenuItem 的第二個參數需要重新寫入,但此陳述式中並未進行重新寫入。這是因為 Rewriter 未將第二個參數識別為簡單 HTML。

</script>
</html>