2017-05-18 16 views
0

XACML을 처음 사용합니다. 나는 Balana을 사용하고 있는데, 나는 기본을 가지고 있다고 생각하여 Target, RuleCondition을 실험하고 있습니다. 내 정책은 두 가지 규칙으로 이루어집니다. 모든 사람에게 첫 번째 규칙이 적용됩니다. 예를 들어 OASIS가 제공하는 기본 예제 인 med.example.com이 주어지며 피험자의 이름이 [email protected] 인 경우 PERMIT가 응답으로받습니다. 나는 그것이 중복이라는 것을 알고 있었다. 두 번째 규칙은 모두가 첫 번째 규칙의 조건을 만족시키지 않을 것이라고 말하면서 부인을 되 찾을 것입니다. 내가하고 싶은 일은 속성을 TargetCondition에 모두 사용하는 것입니다. 가능한가? 이것은 내 정책 정의입니다 :XACML 3.0 및 rfc822Name 특성

<?xml version="1.0" encoding="UTF-8"?> 
<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 
    http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd" 
    PolicyId="urn:oasis:names:tc:xacml:3.0:example:PolicyWithDENYRule" 
    RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" 
Version="1.0"> 
<Description> 
    Medi Corp access control policy 
</Description> 
<Target /> 
<Rule RuleId="urn:oasis:names:tc:xacml:3.0:example:OnlyJimShallPass" 
    Effect="Permit"> 
    <Description>Any subject with an e-mail name in the med.example.com domain can perform any action on any resource.</Description> 
    <Target> 
     <AnyOf> 
      <AllOf> 
       <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:rfc822Name-match"> 
        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">med.example.com</AttributeValue> 
        <AttributeDesignator MustBePresent="false" 
         Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" 
         AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" 
         DataType="urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name" /> 
       </Match> 
      </AllOf> 
     </AnyOf> 
    </Target> 
    <Condition> 
     <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:any-of"> 
      <Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal"/> 
      <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">[email protected]</AttributeValue> 
        <AttributeDesignator MustBePresent="false" 
         Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" 
         AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" 
         DataType="urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name" /> 
     </Apply> 
    </Condition> 
</Rule> 
<Rule Effect="Deny" RuleId="defaultRule" /> 

나는이 예외 가지고 내 요청을 평가하기 위해 시도하는 동안 :

java.lang.IllegalArgumentException: second arg has to be a bag 
2017-05-19 09:33:34 ERROR FileBasedPolicyFinderModule:248 - Fail to load policy : /home/pezzati/workspace/SecurityProofOfConcept/src/test/resources/policywithdenyrule/policy.xml 
java.lang.IllegalArgumentException: illegal parameter 
at org.wso2.balana.cond.FunctionBase.checkInputsNoBag(FunctionBase.java:419) 
at org.wso2.balana.cond.HigherOrderFunction.checkInputs(HigherOrderFunction.java:421) 
at org.wso2.balana.cond.Apply.<init>(Apply.java:89) 
at org.wso2.balana.cond.Apply.getInstance(Apply.java:227) 
at org.wso2.balana.cond.Apply.getInstance(Apply.java:188) 
at org.wso2.balana.cond.ExpressionHandler.parseExpression(ExpressionHandler.java:53) 
at org.wso2.balana.cond.Condition.getInstance(Condition.java:177) 
at org.wso2.balana.Rule.getInstance(Rule.java:237) 
at org.wso2.balana.Policy.<init>(Policy.java:303) 
at org.wso2.balana.Policy.getInstance(Policy.java:382) 
at org.wso2.balana.finder.impl.FileBasedPolicyFinderModule.loadPolicy(FileBasedPolicyFinderModule.java:242) 
at org.wso2.balana.finder.impl.FileBasedPolicyFinderModule.loadPolicies(FileBasedPolicyFinderModule.java:202) 
at org.wso2.balana.finder.impl.FileBasedPolicyFinderModule.init(FileBasedPolicyFinderModule.java:91) 
at org.wso2.balana.finder.PolicyFinder.init(PolicyFinder.java:149) 
at org.wso2.balana.PDP.<init>(PDP.java:97) 
at edu.pezzati.sec.xaml.XacmlTest.getPDP(XacmlTest.java:20) 
at edu.pezzati.sec.xaml.PolicyWithDenyRule.init(PolicyWithDenyRule.java:37) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) 
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) 
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 

왜이 예외? XACML 3.0에서는 Condition에 AttributeDesignator를 사용할 수 있다고 말합니다. 내가 놓친 제한이 있습니까? 전체 프로젝트는 here입니다. PolicyWithDenyRule 테스트를보십시오.

답변

0

나는 그것을 만들었다. 다른 유형의 두 값에 직면했습니다.

<Condition> 
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:any-of"> 
    <Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:rfc822Name-equal"/> 
    <AttributeValue DataType="urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name">[email protected]</AttributeValue> 
    <AttributeDesignator MustBePresent="false" 
     Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" 
     AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" 
     DataType="urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name" /> 
    </Apply> 
</Condition> 

내가 rfc822Name-equalstring-equal에서 주요 기능을 변경하고 string에서 rfc822Name[email protected]을 보유하고있는 AttributeValue을 변경 : 내 Condition이 방법을 변경했습니다. 이런 식으로 주 조건의 함수는 rfc822Name 속성에 대해 rfc822Name 속성을 예상대로 작동 할 수 있는지 확인할 수 있습니다. github에서 프로젝트를 업데이트합니다. 이제 작동합니다.

+0

설명 : Balana의 오류 메시지'java.lang.IllegalArgumentException : 두 번째 arg는 가방이어야합니다. '가 잘못되어 있으므로 여기서는 도움이되지 않습니다. 사실, 원래 정책의 두 번째 인수는 항상 가방을 반환하는 AttributeDesignator이므로이 점에서 올바른 것입니다. 함수 (string-equal)와 첫 번째 arg 데이터 유형 (rfc822Name 대신 문자열) 만 정확하지 않습니다. – cdan

+0

@CyrilDangerville 안녕하세요. 나는 AuthZ에서 경험이있는 것을 본다. 어떤 문서 나 코드 예제를 가르쳐 주시겠습니까? 고맙습니다. – Francesco

+1

XACML에 대한 경험이 있지만 Balana 구현 그 자체가 아닙니다. 적어도 최근에는 없었습니다 (몇 년 전에 시도했지만 너무 많은 문제를 일으켜서 포기했습니다.). 나는 다른 오픈 소스 대안을 사용한다 : [AuthzForce] (https://authzforce.ow2.org) (나는 관리자 중 한 명이다). Java API로 일부 코드 샘플을 원할 경우 _Example of usage ... _ 섹션이 있습니다. REST API도 지원됩니다 ([sample code] (https://gitlab.ow2.org/authzforce/server#examples-of-usage-and-pep-code-with-a-web-service-authorization- 모듈)도 포함됩니다. – cdan