Comments (4)
Also how can I store the policy XML files as it needs to be stored in JSON with MongoDB? I tried to convert XML to JSON using JSON maven dependency, but I have a problem of converting back to XML. For example with the policy XML file like this it will create the JSON file something like this:
{"Policy": {
"xmlns": "urn:oasis:names:tc:xacml:3.0:core:schema:wd-17",
"Target": "",
"Description": "Policy for Conformance Test IIA001.",
"Version": 1,
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"RuleCombiningAlgId": "urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides",
"Rule": {
"Target": {"AnyOf": [
{"AllOf": {"Match": {
"AttributeValue": {
"DataType": "http://www.w3.org/2001/XMLSchema#string",
"content": "Julius Hibbert"
},
"AttributeDesignator": {
"Category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
"AttributeId": "urn:oasis:names:tc:xacml:1.0:subject:subject-id",
"MustBePresent": false,
"DataType": "http://www.w3.org/2001/XMLSchema#string"
},
"MatchId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
}}},
{"AllOf": {"Match": {
"AttributeValue": {
"DataType": "http://www.w3.org/2001/XMLSchema#anyURI",
"content": "http://medico.com/record/patient/BartSimpson"
},
"AttributeDesignator": {
"Category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"MustBePresent": false,
"DataType": "http://www.w3.org/2001/XMLSchema#anyURI"
},
"MatchId": "urn:oasis:names:tc:xacml:1.0:function:anyURI-equal"
}}},
{"AllOf": [
{"Match": {
"AttributeValue": {
"DataType": "http://www.w3.org/2001/XMLSchema#string",
"content": "read"
},
"AttributeDesignator": {
"Category": "urn:oasis:names:tc:xacml:3.0:attribute-category:action",
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"MustBePresent": false,
"DataType": "http://www.w3.org/2001/XMLSchema#string"
},
"MatchId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
}},
{"Match": {
"AttributeValue": {
"DataType": "http://www.w3.org/2001/XMLSchema#string",
"content": "write"
},
"AttributeDesignator": {
"Category": "urn:oasis:names:tc:xacml:3.0:attribute-category:action",
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"MustBePresent": false,
"DataType": "http://www.w3.org/2001/XMLSchema#string"
},
"MatchId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
}}
]}
]},
"Description": "Julius Hibbert can read or write Bart Simpson's medical record.",
"RuleId": "urn:oasis:names:tc:xacml:2.0:conformance-test:IIA1:rule",
"Effect": "Permit"
},
"PolicyId": "urn:oasis:names:tc:xacml:2.0:conformance-test:IIA1:policy"
}}
but when I try to convert it back to XML it becomes entirely different XML file like this:
<Policy><xmlns>urn:oasis:names:tc:xacml:3.0:core:schema:wd-17</xmlns><Target/><Description>Policy for Conformance Test IIA001.</Description><Version>1</Version><xmlns:xsi>http://www.w3.org/2001/XMLSchema-instance</xmlns:xsi><RuleCombiningAlgId>urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides</RuleCombiningAlgId><Rule><Target><AnyOf><AllOf><Match><AttributeValue><DataType>http://www.w3.org/2001/XMLSchema#string</DataType>Julius Hibbert</AttributeValue><AttributeDesignator><Category>urn:oasis:names:tc:xacml:1.0:subject-category:access-subject</Category><AttributeId>urn:oasis:names:tc:xacml:1.0:subject:subject-id</AttributeId><MustBePresent>false</MustBePresent><DataType>http://www.w3.org/2001/XMLSchema#string</DataType></AttributeDesignator><MatchId>urn:oasis:names:tc:xacml:1.0:function:string-equal</MatchId></Match></AllOf></AnyOf><AnyOf><AllOf><Match><AttributeValue><DataType>http://www.w3.org/2001/XMLSchema#anyURI</DataType>http://medico.com/record/patient/BartSimpson</AttributeValue><AttributeDesignator><Category>urn:oasis:names:tc:xacml:3.0:attribute-category:resource</Category><AttributeId>urn:oasis:names:tc:xacml:1.0:resource:resource-id</AttributeId><MustBePresent>false</MustBePresent><DataType>http://www.w3.org/2001/XMLSchema#anyURI</DataType></AttributeDesignator><MatchId>urn:oasis:names:tc:xacml:1.0:function:anyURI-equal</MatchId></Match></AllOf></AnyOf><AnyOf><AllOf><Match><AttributeValue><DataType>http://www.w3.org/2001/XMLSchema#string</DataType>read</AttributeValue><AttributeDesignator><Category>urn:oasis:names:tc:xacml:3.0:attribute-category:action</Category><AttributeId>urn:oasis:names:tc:xacml:1.0:action:action-id</AttributeId><MustBePresent>false</MustBePresent><DataType>http://www.w3.org/2001/XMLSchema#string</DataType></AttributeDesignator><MatchId>urn:oasis:names:tc:xacml:1.0:function:string-equal</MatchId></Match></AllOf><AllOf><Match><AttributeValue><DataType>http://www.w3.org/2001/XMLSchema#string</DataType>write</AttributeValue><AttributeDesignator><Category>urn:oasis:names:tc:xacml:3.0:attribute-category:action</Category><AttributeId>urn:oasis:names:tc:xacml:1.0:action:action-id</AttributeId><MustBePresent>false</MustBePresent><DataType>http://www.w3.org/2001/XMLSchema#string</DataType></AttributeDesignator><MatchId>urn:oasis:names:tc:xacml:1.0:function:string-equal</MatchId></Match></AllOf></AnyOf></Target><Description>Julius Hibbert can read or write Bart Simpson's medical record.</Description><RuleId>urn:oasis:names:tc:xacml:2.0:conformance-test:IIA1:rule</RuleId><Effect>Permit</Effect></Rule><PolicyId>urn:oasis:names:tc:xacml:2.0:conformance-test:IIA1:policy</PolicyId></Policy>
So now how can I store the XML file in MongoDB? Also how to ensure that pdp engine core could find the correct policy to be compared? I saw there is a mentioned about the json adapter in README like this but I am not sure how to implement it normally.
from core.
Similar question on the restful-pdp project. Please check it out. Basically, in the code we use the jongo library which relies on Jackson to map the PolicyPojo class to JSON. The XML content of the policy corresponds to the PolicyPojo's content
string field, therefore simply mapped to JSON string.
Quote:
At the moment, the best way to understand how to use the MongoDbRefPolicyProvider - and how policies must be set up in MongoDB for this - is to look at the corresponding test class, esp. the setupBeforeClass method. As the code shows in Java, each policy should be inserted as a PolicyPojo in the Mongo collection specified by your policy provider's configuration (pdp.xml). So if you reused the example of pdp.xml blindly, this is the collection
policies
in the databaseTest
. The code shows how to create the PolicyPojo from a XACML Policy(Set) document.
from core.
From the PolicyPOJO class, you can pretty much guess the storage format of policies in JSON: it is a JSON object with the following fields (key-value pairs):
- "id" (string): the Policy(Set) ID
- "version" (string): the Policy(Set) version
- "type" (string): the Policy(Set) type, i.e. '{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Policy' (resp. '{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}PolicySet') for XACML 3.0 Policy (resp. PolicySet)
- "content" (string): the actual Policy(Set)'s XML document as string (plain text)
The xml content is automatically escaped properly by the Java library (Jongo/Jackson) to fit in a JSON string. But if you use another library/language, make sure it is the case as well.
from core.
No further comment from OP for 15 days. Closing.
from core.
Related Issues (20)
- Test failed on authzforce-ce-core-pdp-testutils module version 17.0.0 HOT 1
- Compilation failure due to XacmlJsonUtils.canonicalizeResponse method signature issue HOT 1
- Use latest parent version to benefit from dependency-check-maven fix
- Implementation help HOT 8
- org.ow2.authzforce.core.pdp.testutil.ext.xsd MongoDBPolicyProvider ServerHost Pattern HOT 2
- Question about Evaluating Requests in XACML/JSON format HOT 4
- Support XACML <VariableRef> in <Match> via AttributeDesignator workaround
- Refactor BasePdpEngine - Move the StandardEnvironmentAttribute* code to dedicated AttributeProvider
- Mutli requests in the use of CLI HOT 2
- Issue in building the project using cmd HOT 3
- Enable PDP extensions (e.g. Functions) to return an error about invalid attribute values in form of XACML <StatusDetail> / <MissingAttributeDetail>s HOT 3
- org.ow2.authzforce.domains.xacmlJsonSchemaRelativePath has no effect HOT 1
- clientRequestErrorVerbosityLevel > 0 throws startup exception HOT 1
- ConditionEvaluators.java -> throwing exception when conditional evaluates to false.
- The permit-unless-deny in policySet and policy produce an error HOT 3
- Is it possible to bound a jaxb scope for authzforce HOT 3
- Timeline for migrating the javax namespace HOT 2
- Migrate to Java 17+
- Deny-overrides rule combining algorithm - Missing obligations in case of multiple Permit Rules and no Deny Rule HOT 1
- Comparison by issuer even if it is not defined in AttributeDesignator HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.