创建基于 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>
策略 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 角色;以及创建子领域或对等领域引用项时存在相关领域。
请注意,SubrealmReferral、PeerRealmReferral、Realm 主题、IdentityServerRoles 主题、LDAPGroups 主题、 LDAPRoles 主题和 LDAPUsers 主题中的值元素的文本中需要完整 DN。