以文本方式查看主题 - 中文XML论坛 - 专业的XML技术讨论区 (http://bbs.xml.org.cn/index.asp) -- 『 XML安全 』 (http://bbs.xml.org.cn/list.asp?boardid=27) ---- XACML J2SE[TM] Platform Policy Profile(2) (http://bbs.xml.org.cn/dispbbs.asp?boardid=27&rootid=&id=23047) |
-- 作者:菜籽 -- 发布时间:10/14/2005 10:39:00 AM -- XACML J2SE[TM] Platform Policy Profile(2) XACML Policy Provider Implementation This proposal suggests using Sun's XACML Implementation [1] as the basis for the XACML Policy Provider. This is an Open Source implementation with a non-viral BSD license. It was written by Seth Proctor and other members of the Internet Security Research Group (ISRG) in Sun Labs. The following description of the XACML Policy Provider is couched in terms of the structure and APIs in this implementation, but should be adaptable to other implementations. Internal Structure | ^ The components of this structure are explained in the subsequent sections. PDP Interface Module The PDP Interface Module also allows the J2SE-Specific Attribute Finder Module access to objects passed via the Policy API. J2SE-Specific Attribute Finder Module Additional AttributeIds can be supported by other Attribute Finder Modules. For example, support for several Environment Attributes such as the current date and time are built into Sun's XACML Implementation, allowing J2SE Applications to make use of policies that allow different permissions based on the time of day. Other attributes of the environment, such as the day of the week, can be provided by new modules. Other attributes of a subject, such as various roles, can be retrieved from an external repository indexed by the subject identity. Resource labels on the resource being accessed can be accessed from an external repository indexed by the resource identity. This extensibility is part of the design of the XACML policy language. Policy API Support The java.security.Policy Class is the abstract base class that exports the Policy API. It supports the following methods: boolean implies(ProtectionDomain domain, Permission implies The preceding sections of this Proposal describe the specific mappings that are performed. The PDP Interface Module could try to maintain a cache of PermissionCollections indexed by ProtectionDomain and representing previously requested Permissions that have evaluated to "Permit" for the indexed ProtectionDomain. The Interface Module would need to screen out Permissions that were obtained based on time of day or other dynamic attributes, and this may be difficult to implement. If a safe cache can be created, then before invoking the PDP.evaluate() API, the PDP Interface Module can test a requested Permission against any PermissionCollection located in this cache for the input ProtectionDomain. getPermissions refresh PolicyFile to XACML Translator This translator makes the following translations. A PolicyFile grant statement has the following general syntax: grant [signedBy signer_name, ...] [, codebase URL], Each grant statement is translated into one XACML Rule. Each type of phrase in the grant statement generates one <Apply> element in the Rule's <Condition> as follows. <Rule RuleId="[UNIQUE-ID]" Effect="Permit"> <!-- each grant ... signedBy [ALIAS] generates --> <Apply FunctionId="j2se#function:certificate-is-in"> <!-- each grant ... codeBase "[URL]" generates --> <Apply FunctionId="anyURI-is-in"> <!-- each grant ... principal "[ALIAS]" generates --> <Apply FunctionId="x500Name-is-in"> <!-- each grant ... principal [CLASS] "[NAME]" generates --> <Apply FunctionId="string-is-in"> <Apply FunctionId="or"> <!-- each <Apply FunctionId="and"> <Apply <!-- following Apply omitted if no signedBy "[ALIAS]" --> </Apply> </Apply> See Appendix 1: Example of a Translated Simple PolicyFile and Example of a Translated Full PolicyFile for examples. Issues and Rationale getPermissions In XACML, a Policy is evaluated on the basis of attributes of the subjects, resources, and actions, returning a result of "Permit" or "Deny", "Indeterminate", or "NotApplicable". XACML policies are not designed to allow easy extraction of a static collection of resources and associated actions "permitted" for a given set of subject attributes. In fact, many XACML policies would not be able to return a set of permitted resources and actions, since the set would only be permitted at certain times of day or under combinations of conditions that can not be captured in a simple set of attributes. Work is now in progress within the XACML TC to define a way of evaluating an XACML policy in order to return a set of Attribute values. Since this work is very preliminary, and will probably use a very constrained form of the XACML syntax, it should not be considered a solution to the problem of supporting a PermissionCollection as returned from getPermissions. Some existing custom Policy Providers return a live PermissionCollection that does not encapsulate a specific collection of individual permissions. The implies method of such a PermissionCollection is used to test specific Permission requests dynamically. In such cases, the PermissionCollection that is returned may not be an instance of the Permissions class. Such live PermissionCollection objects typically do not support the elements method. The XACML Policy Provider could support the getPermissions() methods using such a custom PermissionCollection. For example, it could return an XACMLPermissionCollection subclass that encapsulates the ProtectionDomain or CodeSourcefor which the request was made. This subclass would implement its implies(Permission) method by invoking the Policy.implies() method, causing a full XACML policy evaluation to occur. If new Permission instances are added to the XACMLPermissionCollection, they could be saved in an internal PermissionCollection that would be tested before invoking Policy.implies(). (Note that this technique would not support the overlapping Permissions semantics of a PermissionCollection). In order to support the return of individual Permissions from XACMLPermissionCollection.elements() API, the XACMLPermissionCollection could return a single element consisting of a custom Permission subclass instance. This XACMLPermission subclass would store its associated ProtectionDomain or CodeSource as a class variable. When its implies(Permission) method was invoked, XACMLPermission would use its cached ProtectionDomain or CodeSource, along with the Permission passed as the argument to the implies method, to invoke Policy.implies. XACMLPermission would have to be compatible with all other Permission and PermissionCollection subclasses in order to allow an XACMLPermission to be included inside any homogeneous or heterogeneous PermissionCollection. While it would be possible to support the getPermissions methods using such a technique, this proposal recommends that we not try to do so. This recommendation is made in light of the ways in which the PermissionCollection returned from getPermissions is used. The PermissionCollection returned by the getPermissions(ProtectionDomain) method is used by the standard ClassLoader to obtain Permission objects that have been granted to a particular ProtectionDomain, independent of any Principal objects that may later be combined with the ProtectionDomain. These Permission objects are stored in the ProtectionDomain. At runtime, this cache of pre-evaluated, static Permissions is used as an optimization. If a requested Permission is implied by the PermissionCollection stored in the ProtectionDomain, then the Permission is granted. Otherwise, the Policy.implies() method is invoked to make use of any Permissions that depend on Principal associations or on Permissions that may have been added to the policy since the ClassLoader obtained the static set. The result of evaluating an XACMLPermissionCollection would be exactly equivalent to the result of evaluating Policy.implies. A cached PermissionCollection in the ProtectionDomain implies that these are pre-evaluated, or optimized Permissions, but, in the case of XACML, this is not the case. Thus it seems more direct to return an empty PermissionCollection from Policy.getPermissionCollection, forcing all run-time evaluations to use the Policy.implies API. One more difficulty with trying to support Policy.getPermissions as described above is that the combine method of the JAAS SubjectDomainCombiner does not preserve custom PermissionCollections. This means the late binding effects would be extinguished by this combiner. Solving this problem would require creating and using a custom DomainCombiner that would preserve the custom XACMLPermissionCollection. Again, it just seems more straightforward to force use of Policy.implies() at runtime. Overlapping Permissions The J2SE Policy model is somewhat different from the XACML Policy model. In the J2SE platform, a Policy is evaluated on the basis of the attributes of the subjects (ProtectionDomain) making the request to return a collection of the resources and associated actions (PermissionCollection) to which the subjects have access. Each requested Permission is then evaluated against this PermissionCollection to return a result of "True" (grant access) or "False" (deny access). A requested Permission may be granted by a PermissionCollection even if it is not implied by any single Permission in the collection. One simple example of this behavior is a J2SE policy that grants a particular subject access to two different FilePermissions for a given file: one with action "read, delete", and the other with action "write". If the subject requests permission to "read, write" this file, this request is granted because the aggregate PermissionCollection recognizes that the two individual Permission actions can be merged into a set of actions, of which the requested action is a subset. This aggregate behavior of Permissions in a PermissionCollection is referred to as overlapping Permissions. There are few constraints on how Permission subclasses implement this aggregate behavior. There can be complex interactions not only between different Permissions of the same subclass, but even interactions between Permissions of different subclasses. The following preliminary proposal describes one potential way of supporting overlapping Permissions in an XACML J2SE Policy Provider. Comments are invited. This approach to handling overlapping Permissions is based on the observation that, when an XACML Rule is in Disjunction Normal Form (an OR of AND predicates), then all the Permission objects used in a single AND predicate can be collected into a single PermissionCollection. This PermissionCollection captures any overlapping Permission semantics that should be allowed to affect the evaluation of the Rule. The procedure is as follows. Put the XACML Rule into Disjunctive Normal Form. See [9] for a nice description of the standard algorithm. Start evaluation of the Rule. When evaluating each AND predicate, first create a new Permissions object. Whenever an expression of the form <Apply FunctionId="j2se#method:implies"> is encountered in the AND predicate, where X and Y are subclasses of java.security.Permission, construct a new Permission object from the AttributeValue. Pass this new Permission object to the add method of the Permissions object. Now treat the original Apply expression as if it had evaluated to "true". At the end of evaluation of the AND predicate, if the result is "true" so far, then invoke the implies method of the Permissions object, passing it the requested Permission object. If this method returns "true", then the AND predicate evaluates to "true" and the Rule evaluation can terminate by returning the specified Effect. Otherwise, the AND predicate evaluates to "false", and evaluation of the next AND predicate begins with creation of a new, empty Permissions object. This proposal recommends that overlapping Permissions not be supported for the first release of the XACML Policy Provider due to the difficulty of implementing support for these complex semantics. KeyStores Keystore aliases may be used in PolicyFile to specify the following. signedBy fields The public key certificate associated with the alias is retrieved and matched against the "signer" certificates associated with a ProtectionDomain, either that of the requested Permission class or the ProtectionDomain of the application Class object that made the access request. principal entries The subject distinguished name is retrieved from the public key certificate associated with the alias; the certificate is assumed to be of type java.security.cert.X509Certificate A new J2SE-specific AttributeId has been proposed above to reference either the signer certificates for the codebase class or the signer certificates for the requested Permission class. The problem is in how, in XACML, to specify certificates located in a keystore for use in comparing with the certificates referenced by this AttributeId. This proposal recommends specifying the location and type of the keystore file as an argument to each invocation of a new getCertificateFromKeyStore function. An alternative solution would be some sort of setKeyStore function taking as arguments the location and type of the keystore. Such a function would return true if a keystore of the specified type could be accessed at the specified location. As a side-effect, the function would establish the keystore to be used by invocations of the getCertificateFromKeyStore function within some specified scope. While it is inconvenient to have to specify the keystore location and type each time a certificate is retrieved, the use of side effects to establish state is not good language design and violates the stateless nature of other XACML constructs. The use of a keystore alias to express a "principal" name is just a convenience, saving the user from typing out the entire name. If this functionality is important, it can be accomplished by using the new j2se#function:getCertificateFromKeyStore function, and using the result as the argument to an invocation of the j2se#method:getSubjectDN function. It does not seem worth the clutter to define a new j2se#function:getPrincipalFromKeyStoreAlias function, although this is certainly possible to do. Multiple Actions This proposal recommends that instances of certain standard Permission subclasses, such as java.io.FilePermission and java.net.SocketPermission, be recognized by the PDP Interface Module and tested for multiple actions. When multiple actions are being requested, the PDP Interface Module submits a separate Request to the PDP.evaluate() API for each action in the list. The PDP Interface Module returns "True" as the Policy API response only if ALL such evaluations result in "Permit". Policies that compare a Permission using the j2ee#method:implies function handle multiple actions correctly. Multiple actions per Permission will be supported otherwise only if custom code is added to the J2SE-extended XACML PDP implementation for each such Permission subclass. Property Expansion permission java.io.FilePermission "${user.home}", "read"; becomes permission java.io.FilePermission "/home/cathy", "read"; if the current value of the user.home system property is "/home/cathy". This could be handled directly in several ways. Extend the XACML PDP to support a syntax for embedding the value retrieved by one AttributeDescriptor inside a literal AttributeValue. For example, ${Subject, j2se#attribute:user.home, string, access-subject} could be expanded to insert the value of the <SubjectAttributeDesignator> with AttributeId="j2se#attribute:user.home", DataType="http://www.w3.org/2001/XMLSchema#string", and SubjectCategory="access-subject" into the literal value where this expression occurred (assuming there is only one Attribute that matches this Designator). Extend the XACML PDP to support J2SE ${some.property} syntax inside literal values. Define J2SE-specific functions for comparing values in which such expressions might occur such that they recognize and expand these expressions. This proposal recommends the last method - providing J2SE-specific functions - and specifically proposes implementing such expansion capability in the j2se#function:file-path-match function. Extending the XACML PDP to recognize any sort of AttributeId insertion should be done in a standardized way for XACML as a whole. Confining the use of an expansion syntax to J2SE-specific functions avoids having policies use a syntax for general attributes that is not supported on all platforms. General Expansion This proposal recommends that this functionality not be implemented in the first release of the J2SE XACML Policy Provider. Based on actual customer requirements, this functionality could be supported within literal values used with J2SE-specific functions in a later release. As with the Property Expansion syntax described above, this functionality is too specific to the J2SE platform for the XACML PDP itself to be expanded to recognize this syntax in general. References [2] OASIS XACML Version 1.0 Standard Specification , 18 February 2003. [3] OASIS XACML Version 1.0 Policy Schema, 18 February 2003. [4] OASIS XACML Version 1.0 Request and Response Context Schema , 18 February 2003. [5] Default Policy Implementation and Policy File Syntax, 20 April 2002. [6] Permissions in the Java[TM] 2 SDK. [7] Java[TM] Access Control Mechanisms, by Anne Anderson, Sun Microsystems Laboratories Technical Report #2002-0134, Mar 15, 2002. [8] XACML RBAC Profile, profile for use of XACML with role based access control policies, Working Draft 01, 5 June 2003. [9] KeyNote Policy Files and Conversion to Disjunctive Normal Form for Use in IPsec , by E. Spyropoulou, et al., Center for Information Systems Security Studies and Research, Computer Science Department, Naval Postgraduate School, Monterey, CA, January 2002. [10] A Brief Introduction to XACML , 14 March 2003. Contributors Gary Ellison -------------------------------------------------------------------------------- Appendix 1: Example of a Translated Simple PolicyFile The translation was done manually, and so may contain errors. Standard XACML URNs and "wordy" syntax have been shortened slightly to make this example more readable, but anyone familiar with XACML should be able to convert this to a schema-compliant form easily. PolicyFile grant codeBase "http://my/classes" XACML Policy <Policy PolicyId="a1bc2f890" RuleCombiningAlgId="permit-overrides"> <Target> <Rule RuleId="a1bc2f890.1" Effect="Permit"> <!-- grant codeBase "http://my/classes" --> <Apply FunctionId="anyURI-is-in"> <!-- permission java.io.FilePermission <Apply </Apply> </Condition> Appendix 2: Example of a Translated Full PolicyFile The translation was done manually, and so may contain errors. Standard XACML URNs and "wordy" syntax have been shortened slightly to make this example more readable, but anyone familiar with XACML should be able to convert this to a schema-compliant form easily. PolicyFile keystore "file:/opt/keystores/.keystore" "JKS"; grant codeBase "http://my/classes" grant signedBy "duke,sysadmin", XACML Policy <Policy PolicyId="f234ab56c" RuleCombiningAlgId="permit-overrides"> <Target> <Rule RuleId="f234ab56c.1" Effect="Permit"> <!-- grant codeBase "http://my/classes" --> <Apply FunctionId="anyURI-is-in"> <!-- permission java.io.FilePermission <Apply </Apply> </Condition> <Rule RuleId="f234ab56c.2" Effect="Permit"> <!-- grant signedBy "duke" --> <Apply FunctionId="j2se#function:certificate-is-in"> <!-- grant signedBy "sysadmin" --> <Apply FunctionId="j2se#function:certificate-is-in"> <!-- grant codeBase "http://my/classes" --> <Apply FunctionId="anyURI-is-in"> <!-- grant principal "bob" --> <Apply FunctionId="x500Name-is-in"> <!-- grant principal javax.security.auth.x500.X500Principal "cn=Alice" --> <!-- "and" in case "permission ... signedBy" --> <!-- permission java.io.FilePermission <Apply <!-- signedBy "FooSoft"; --> <Apply FunctionId="j2se#function:certificate-is-in"> </Apply> <!-- "and" in case "permission ... signedBy" --> <!-- permission java.security.SecurityPermission "Security.insertProvider.*" --> <Apply </Apply> </Apply> Appendix 3: Mappings for Standard J2SE Permission Subclasses java.security.AllPermission name: ignored javax.sound.sampled.AudioPermission name: a permitted action, such as "play" or "record" resource:resource-id: "audio" name: name of a security config parameter (doAsPrivileged, etc.) java.awt.AWTPermission name: symbolic action (accessClipboard, accessEventQueue, etc.) ava.security.BasicPermission name: name of permission javax.security.auth.kerberos.DelegationPermission name: specifies a pair of Kerberos service principals. The first is the subordinate service principal being entrusted to use the TGT. The second service principal designates the target service the subordinate service principal is to interact with on behalf of the initiating KerberosPrincipal. This latter service principal is specified to restrict the use of a proxiable ticket. the name of the subordinate and target principals java.io.FilePermission name: path (ends in "/*" (where "/" is the file separator character, File.separatorChar) indicates a directory and all the files contained in that directory. A pathname that ends with "/-" indicates a directory and (recursively) all files and subdirectories contained in that directory. The special pathname "<<ALL FILES>>" matches all files. A pathname consisting of a single "*" indicates all the files in the current directory, while a pathname consisting of a single "-" indicates all the files in the current directory and (recursively) all files and subdirectories contained in the current directory. resource:resource-id = value of "name" name: must be "control" java.net.NetPermission name: permission name (setDefaultAuthenticator, requestPasswordAuthentication, specify StreamHandler) java.security.Permission Mapped: no javax.security.auth.PrivateCredentialPermission name: the name specifying the Credential class and Principal Set. java.util.PropertyPermission name: the name of the system property (user.home, etc.) java.lang.reflect.ReflectPermission name: suppressAccessChecks java.lang.RuntimePermission name: createClassLoader, setSecurityManager, etc. java.security.SecurityPermission name: createAccessControlContext, setPolicy, setProperty.{key}, etc. java.io.SerializablePermission name: enableSubclassImplementation, enableSubstitution javax.security.auth.kerberos.ServicePermission name: Kerberos service principal name resource:resource-id = value of "name" name: host DNS name or IP address, with optional port range resource:resource-id = value of "name" name: setLog javax.net.ssl.SSLPermission name: setHostnameVerifier, getSSLSessionContext java.security.UnresolvedPermission Used by Policy implementation to hold Permissions for which class does not yet exist when Policy is instantiated. Appendix 4: Notices
-------------------------------------------------------------------------------- |
W 3 C h i n a ( since 2003 ) 旗 下 站 点 苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》 |
156.250ms |