Sun Java System Access Manager 7.1 管理指南

建立策略

您可透過策略 API 與 Access Manager 主控台建立、修改和刪除策略,並透過 amadmin 指令行工具建立和刪除策略。您也可以使用 amadmin 公用程式在 XML 中取得和列出策略。本節重點在透過 amadmin 指令行公用程式與透過 Access Manager 主控台建立策略。如需有關策略 API 的更多資訊,請參閱「Sun Java System Access Manager 7.1 Developer’s Guide」

策略通常是以 XML 檔案建立,並透過 amadmin 指令行公用程式增加至 Access Manager,然後透過 Access Manager 主控台管理 (但可透過主控台建立策略)。這是因為不能直接使用 amadmin 修改策略。若要修改策略,必須先從 Access Manager 刪除策略,然後使用 amadmin 加入修改後的策略。

通常策略是在範圍 (或子範圍) 層級建立,可在範圍的整個樹狀結構中使用。

Procedure使用 amadmin 建立策略

  1. 根據 amadmin.dtd 建立策略 XML 檔。此檔案位於下列目錄:

    AccessManager-base/SUNWam/dtd

    下列是策略 XML 檔的範例。此範例包含所有預設的主體及條件值。如需這些值的定義,請參閱策略類型

    <Policy name="bigpolicy" referralPolicy="false" active="true" >
    <Rule name="rule1">
    <ServiceName name="iPlanetAMWebAgentService" />
    <ResourceName name="http://thehost.thedomain.com:80/*.html" />
    <AttributeValuePair>
    <Attribute name="POST" />
    <Value>allow</Value>
    </AttributeValuePair>
    <AttributeValuePair>
    <Attribute name="GET" />
    <Value>allow</Value>
    </AttributeValuePair>
    </Rule>
    <Subjects name="subjects" description="desccription">
    <Subject name="webservicescleint" type="WebServicesClients" includeType="inclusive">
    <AttributeValuePair><Attribute name="Values"/><Value>CN=sun-unix, 
    OU=SUN Java System Access Manager, O=Sun, C=US</Value>
    </AttributeValuePair>
    </Subject>
    <Subject name="amrole" type="IdentityServerRoles" includeType="inclusive">
    <AttributeValuePair><Attribute name="Values"/><Value>
    cn=organization admin role,o=realm1,dc=red,dc=iplanet,dc=com</Value>
    </AttributeValuePair>
    </Subject>
    <Subject name="au" type="AuthenticatedUsers" includeType="inclusive">
    </Subject>
    <Subject name="ldaporganization" type="Organization" includeType="inclusive">
    <AttributeValuePair><Attribute name="Values"/>
    <Value>dc=red,dc=iplanet,dc=com</Value>
    </AttributeValuePair>
    </Subject>
    <Subject name="ldapuser" type="LDAPUsers" includeType="inclusive">
    <AttributeValuePair><Attribute name="Values"/>
    <Value>uid=amAdmin,ou=People,dc=red,dc=iplanet,dc=com</Value>
    </AttributeValuePair>
    </Subject>
    <Subject name="ldaprole" type="LDAPRoles" includeType="inclusive">
    <AttributeValuePair><Attribute name="Values"/>
    <Value>cn=Organization Admin Role,o=realm1,dc=red,dc=iplanet,dc=com</Value>
    </AttributeValuePair>
    </Subject>
    <Subject name="ldapgroup" type="LDAPGroups" includeType="inclusive">
    <AttributeValuePair><Attribute name="Values"/>
    <Value>cn=g1,ou=Groups,dc=red,dc=iplanet,dc=com</Value>
    </AttributeValuePair>
    </Subject>
    <Subject name="amidentitysubject" type="AMIdentitySubject" includeType="inclusive">
    <AttributeValuePair><Attribute name="Values"/>
    <Value>id=amAdmin,ou=user,dc=red,dc=iplanet,dc=com</Value>
    </AttributeValuePair>
    </Subject>
    </Subjects>
    <Conditions name="conditions" description="description">
    <Condition name="ldapfilter" type="LDAPFilterCondition">
    <AttributeValuePair><Attribute name="ldapFilter"/>
    <Value>dept=finance</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="authlevelge-nonrealmqualified" type="AuthLevelCondition">
    <AttributeValuePair><Attribute name="AuthLevel"/>
    <Value>1</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="authlevelle-realmqaulfied" type="LEAuthLevelCondition">
    <AttributeValuePair><Attribute name="AuthLevel"/>
    <Value>/:2</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="sessionproperties" type="SessionPropertyCondition">
    <AttributeValuePair><Attribute name="valueCaseInsensitive"/>
    <Value>true</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="a"/><Value>10</Value>
    <Value>20</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="b"/><Value>15</Value>
    <Value>25</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="activesessiontime" type="SessionCondition">
    <AttributeValuePair><Attribute name="TerminateSession"/>
    <Value>session_condition_false_value</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="MaxSessionTime"/>
    <Value>30</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="authelevelle-nonrealmqualfied" 
               type="LEAuthLevelCondition">
    <AttributeValuePair><Attribute name="AuthLevel"/>
    <Value>2</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="ipcondition" type="IPCondition">
    <AttributeValuePair><Attribute name="DnsName"/>
    <Value>*.iplanet.com</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="EndIp"/>
    <Value>145.15.15.15</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="StartIp"/>
    <Value>120.10.10.10</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="authchain-realmqualfied"
              type="AuthenticateToServiceCondition">
    <AttributeValuePair><Attribute name="AuthenticateToService"/>
    <Value>/:ldapService</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="auth to realm" 
          type="AuthenticateToRealmCondition">
    <AttributeValuePair><Attribute name="AuthenticateToRealm"/>
    <Value>/</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="authlevelge-realmqualified"
          type="AuthLevelCondition">
    <AttributeValuePair><Attribute name="AuthLevel"/>
    <Value>/:2</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="authchain-nonrealmqualfied" 
         type="AuthenticateToServiceCondition">
    <AttributeValuePair><Attribute name="AuthenticateToService"/>
    <Value>ldapService</Value>
    </AttributeValuePair>
    </Condition>
    <Condition name="timecondition" type="SimpleTimeCondition">
    <AttributeValuePair><Attribute name="EndTime"/>
    <Value>17:00</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="StartTime"/>
    <Value>08:00</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="EndDate"/>
    <Value>2006:07:28</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="EnforcementTimeZone"/>
    <Value>America/Los_Angeles</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="StartDay"/>
    <Value>mon</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="StartDate"/>
    <Value>2006:01:02</Value>
    </AttributeValuePair>
    <AttributeValuePair><Attribute name="EndDay"/>
    <Value>fri</Value>
    </AttributeValuePair>
    </Condition>
    </Conditions>
    <ResponseProviders name="responseproviders"
           description="description">
    <ResponseProvider name="idresponseprovidere" 
         type="IDRepoResponseProvider">
    <AttributeValuePair>
    <Attribute name="DynamicAttribute"/>
    </AttributeValuePair>
    <AttributeValuePair>
    <Attribute name="StaticAttribute"/>
    <Value>m=10</Value>
    <Value>n=30</Value>
    </AttributeValuePair>
    </ResponseProvider>
    </ResponseProviders>
    </Policy>
  2. 策略 XML 檔案開發完成後,您可使用下列指令加以載入:


    AccessManager-base/SUNWam/bin/amadmin
    --runasdn "uid=amAdmin,ou=People,default_org,
    root_suffix"
    --password password
    --data policy.xml
    

    若要同時加入多重策略,請將這些策略放在一個 XML 檔案中,這一點與在每個 XML 檔案中放一個策略相反。如果使用多重 XML 檔案連續快速載入策略,則內部策略索引可能會損毀,而且某些策略可能不參與策略評估。

    透過 amadmin 建立策略時請確定:當建立認證方案條件時認證模組是以範圍註冊;當建立範圍、LDAP 群組、LDAP 角色和 LDAP 使用者時對應的 LDAP 物件範圍、群組、角色和使用者存在;當建立 IdentityServerRoles 主體時 Access Manager 角色存在;當建立子範圍或同級範圍參照時相關範圍存在。

    請注意,在 SubrealmReferralPeerRealmReferral 的 Value 元素之內容中,Realm 主體、IdentityServerRoles 主體、LDAPGroups 主體、LDAPRoles 主體和 LDAPUsers 主體必須為完整的 DN。

Procedure以 Access Manager 主控台建立一般策略

  1. 選擇您要為其建立策略的範圍。

  2. 按一下 [策略] 標籤。

  3. 按一下 [策略] 清單中的 [新建策略]。

  4. 增加策略的名稱與說明。

  5. 若您要策略為使用中,請選取 [使用中] 屬性中的 [是]。

  6. 此時無需定義一般策略的所有欄位。您可以建立策略,隨後再加入規則、主體、條件和回應等。如需更多資訊,請參閱管理策略

  7. 按一下 [確定]。

Procedure以 Access Manager 主控台建立參照策略

  1. 選擇您要建立策略的範圍。

  2. 於 [策略] 標籤中按一下 [新增參考]。

  3. 增加策略的名稱與說明。

  4. 若您要策略為使用中,請選取 [使用中] 屬性中的 [是]。

  5. 此時無需定義參照策略的所有欄位。您可以建立策略,隨後再加入規則和參照等。如需更多資訊,請參閱管理策略

  6. 按一下 [確定]。

建立同級範圍與子範圍的策略

要為同級組織或子範圍建立策略,必須先在父系範圍 (或另一個同級範圍) 中建立參照策略。參照策略的規則定義中必須包含正由子範圍管理的資源前綴。在父系範圍 (或另一個同級範圍) 中建立參照策略後,可在子範圍 (或另一個同級範圍) 建立一般策略。

在此範例中,o=isp 是父系範圍,o=example.com 是子範圍,該子範圍管理 http://www.example.com 的資源和子資源。

Procedure建立子範圍的策略

  1. o=isp 建立參照策略。如需參照策略的相關資訊,請參閱程序修改參照策略

    參照策略必須定義 http://www.example.com 做為規則中的資源,且必須包含以 example.com 做為參照中的值之 SubRealmReferral

  2. 瀏覽至子範圍 example.com

  3. 目前,isp 將資源參考為 example.com,可以為資源 http://www.example.com 或任何以 http://www.example.com 開頭的資源建立一般策略。

    若要定義由 example.com 管理的其他資源之策略,必須在 o=isp 建立額外的參考策略。

將策略匯出到其他 Access Manager 實例

Access Manager 可讓您使用 amadmin 指令行工具匯出策略。當您想要將許多現有策略移到另一個 Access Manager 實例,或希望檢查您以批次模式對現有實例所做的變更時,這個工具很有用。若要匯出策略,請使用 amadmin 指令行公用程式將指定的策略匯出到檔案。語法為:

amamdin - u username —w password —ofilename output_file.xml —t policy_data_file.xml

您可以在策略名稱中使用萬用字元 (*) 來符合任何字元的字串。

下列是 policy_data_file.xml 的範例:


<?xml version="1.0" encoding="ISO-8859-1"?>

<!--
    Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved
    Use is subject to license terms.
-->

<!DOCTYPE Requests
    PUBLIC "-//iPlanet//Sun Java System Access Manager 6.2 Admin CLI DTD//EN"
    "/opt/SUNWam/dtd/amAdmin.dtd"
>>

<!--  CREATE REQUESTS -->

<!-- to export to file use option -ofilename fileName -->

<Requests>    

<RealmRequests >    
<RealmGetPolicies realm="/" >
<AttributeValuePair>
<Attribute name="policyName"/>
<Value>p*</Value>
</AttributeValuePair>
</RealmGetPolicies>
</RealmRequests>

<RealmRequests >    
<RealmGetPolicies realm="/" >
<AttributeValuePair>
<Attribute name="policyName"/>
<Value>g10</Value>
<Value>g11</Value>
</AttributeValuePair>
</RealmGetPolicies>

</RealmRequests>
<RealmRequests >    
<RealmGetPolicies realm="/realm1" >
<AttributeValuePair>
<Attribute name="policyName"/>
<Value>*</Value>
</AttributeValuePair>
</RealmGetPolicies>
</RealmRequests>

</Requests>

策略將匯出至 Output_file.xml 檔案。現在可以對檔案中包含的策略定義進行任何變更。您必須修改輸出檔案,使它與 amadmin 指令公用程式相容,然後才能將策略匯入到另一個 Access Manager 實例。如需如何匯入策略的說明,包括 amadmin 相容策略資料檔的範例,請參閱使用 amadmin 建立策略