簡體   English   中英

如何使用JAXB解組該XACML XML代碼段?

[英]How do I unmarshall this XACML XML snippet using JAXB?

<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
    PolicyId="ClientType"
    RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable"
    Version="1.0">
<Target>
<AnyOf>
            <AllOf>
                <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Reply</AttributeValue>
                    <AttributeDesignator
                        AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id"
                        Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action"
                        DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
                </Match>
            </AllOf>
        </AnyOf>
    </Target>

    <Rule Effect="Permit" RuleId="Rule_for_all">
        <Target>
            <AnyOf>
                <AllOf>
                    <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">A</AttributeValue>
                        <AttributeDesignator AttributeId="Reply"
                            Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
                            DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
                    </Match>
                </AllOf>
            </AnyOf>
        </Target>
    </Rule>
    <Rule Effect="deny" RuleId="Rule_deny_all" />
</Policy>

請幫助我使用JAXB解組該xml。 我嘗試這樣做,但在此之間我感到困惑和出錯。 我有一個很大的xml文件,但是這個片段可以幫助我理解。

您發送的片段實際上是不完整的XML片段。 例如,缺少</Policy>元素。

您發送的片段與XACML 3.0策略相對應。 這意味着在關閉策略之前,您還應該具有1個或多個規則(從技術上講,該模式確實允許零個規則,但這沒有任何意義)。

要使用JAX-B進行編組和解組,您需要使用XACML 3.0模式,您可以在此處找到。 配置JAXB以基於該架構創建Java對象非常簡單。 您將需要創建一個簡單的XJB文件來配置編組。

就是說,考慮到那里有多個XACML引擎(開源和供應商,例如我為之工作的Axiomatics ),您自己實現XACML解析器的依據是什么?

干杯,大衛。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM