Sun Java System Portal Server Secure Remote Access 7.2 관리 설명서

규칙 집합 작성

규칙 집합 정의에 대한 자세한 내용은 Portal Server 관리 설명서를 참조하십시오. 새 규칙 집합을 만든 후 필수 규칙을 정의해야 합니다.

이 부분에서는 다음 주제를 다룹니다.

공용 인터페이스(규칙 집합 DTD)

규칙 집합 DTD:

<?xml version="1.0" encoding="UTF-8"?>
<!--
The following constraints are not represented in DTD, but taken care of programmatically
    1. In a Rule, All Mandatory attributes cannot be "*".
    2. Only one instance of the below elements is allowed, but in any order.
    1)HTMLRules
    2)JSRules
    3)XMLRules
    3. ID should always be in lower case.
-->
<!ENTITY % eURL ’URL’>
<!ENTITY % eEXPRESSION ’EXPRESSION’>
<!ENTITY % eDHTML ’DHTML’>
<!ENTITY % eDJS ’DJS’>
<!ENTITY % eSYSTEM ’SYSTEM’>

<!ENTITY % ruleSetElements ’(HTMLRules | JSRules | XMLRules)?’>
<!ENTITY % htmlElements ’(Form | Applet | Attribute)*’>
<!ENTITY % jsElements ’(Variable | Function)*’>
<!ENTITY % xmlElements ’(Attribute | TagText)*’>

<!ELEMENT RuleSet (%ruleSetElements;,%ruleSetElements;,%ruleSetElements;)>
<!ATTLIST RuleSet
    id ID #REQUIRED
    extends CDATA "none"
>

<!-- Rules for identifying rules in HTML content -->
<!ELEMENT HTMLRules (%htmlElements;)>
<!ELEMENT Form EMPTY>
<!ATTLIST Form
    name CDATA #REQUIRED
    field CDATA #REQUIRED
    valuePatterns CDATA ""
    source CDATA "*"
>

<!ELEMENT Applet EMPTY>
<!ATTLIST Applet
    code CDATA #REQUIRED
    param CDATA "*"
    valuePatterns CDATA ""
    source CDATA "*"
>

<!-- Rules for identifying rules in JS content -->
<!ELEMENT JSRules (%jsElements;)>
<!ELEMENT Variable EMPTY>
<!ATTLIST Variable
    name CDATA #REQUIRED
    type (%eURL; | %eEXPRESSION; | %eDHTML; | %eDJS; | %eSYSTEM;) "EXPRESSION"
    source CDATA "*"
>

<!ELEMENT Function EMPTY>
<!ATTLIST Function
    name CDATA #REQUIRED
    paramPatterns CDATA #REQUIRED
    type (%eURL; | %eEXPRESSION; | %eDHTML; | %eDJS;) "EXPRESSION"
    source CDATA "*"
>

<!-- Rules for identifying rules in XML content -->
<!ELEMENT XMLRules (%xmlElements;)>
<!ELEMENT TagText EMPTY>
<!ATTLIST TagText
    tag CDATA #REQUIRED
    attributePatterns CDATA ""
    source CDATA "*"
>

<!ELEMENT Attribute EMPTY>
<!ATTLIST Attribute
    name CDATA #REQUIRED
    tag CDATA "*"
    valuePatterns CDATA ""
    type (%eURL; | %eDHTML; | %eDJS; ) "URL"
    source CDATA "*"
>

주 –

*를 규칙 값의 일부로 사용할 수 있지만 필수 속성 값에는 *만 사용할 수 없습니다. 이러한 규칙은 무시되지만 RuleSetInfo 로그 파일에 메시지가 기록됩니다. 이 로그 파일에 대한 자세한 내용은 디버깅 파일 이름을 참조하십시오.


예제 XML DTD

이 절에는 예제 규칙 집합이 들어 있습니다. 140페이지의 "사례 연구"를 통해 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 name="URL"> _fr.location </Variable>
<Variable name="URL"> g_szUserBase </Variable>
<Variable name="URL"> g_szPublicFolderUrl </Variable>
<Variable name="URL"> g_szExWebDir </Variable>
<Variable name="URL"> g_szViewClassURL </Variable>
<Variable name="URL"> g_szVirtualRoot </Variable>
<Variable name="URL"> g_szBaseURL </Variable>
<Variable name="URL"> g_szURL </Variable>
<Function name="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>

규칙 작성을 위한 절차

규칙을 작성하는 일반적인 절차는 다음과 같습니다.

규칙 집합 관련 지침

규칙 집합을 작성하는 경우 다음 사항을 주의하십시오.

규칙 집합의 루트 요소 정의

규칙 집합의 루트 요소에는 두 가지 속성이 있습니다.

재귀적 기능 사용

Rewriter에서는 재귀적 기능을 사용하여 대응되는 문자열 패턴의 끝까지에서 같은 패턴을 검색합니다.

예를 들어 Rewriter에서 다음 문자열을 구문 분석하는 경우

<a href="src=abc.jpg,src=bcd.jpg,src=xyz.jpg>

규칙

<Attribute name="href" valuePatterns="*src=**"/>

은 처음 나타나는 패턴만을 다시 작성하며 그 결과는 다음과 같습니다.

<a href="src=http://jane.sun.com/abc.jpg>

재귀적 옵션을 사용하는 경우

<Attribute name="href" valuePatterns="REC:*src=**"/>;

Rewriter는 대응되는 문자열 패턴에서 끝까지 같은 패턴을 찾기 때문에 다음과 같은 출력을 얻게 됩니다.

<a href="src=http://jane.sun.com/abc.jpg,src=http://jane.sun.com/bcd.jpg,src=http://jane.sun.com/xyz.jpg>