Menu

about sun's xacml implementation

2010-04-20
2013-06-04
  • Kuang-Yu Chen

    Kuang-Yu Chen - 2010-04-20

    Hello,
    recently I 'm using sun's xacml 1.2 by eclipse
    I made up a Xacml_PDP.java to run it for testing policy and request to get the right response.

    Xacml_PDP.java

    import java.io.FileInputStream;
    import java.util.ArrayList;
    import java.util.HashSet;
    import java.util.List;
    import java.util.Set;
    import com.sun.xacml.PDP;
    import com.sun.xacml.PDPConfig;
    import com.sun.xacml.ctx.RequestCtx;
    import com.sun.xacml.ctx.ResponseCtx;
    import com.sun.xacml.finder.AttributeFinder;
    import com.sun.xacml.finder.PolicyFinder;
    import com.sun.xacml.finder.impl.CurrentEnvModule;
    import com.sun.xacml.finder.impl.FilePolicyModule;
    public class Xacml_PDP {
        public String GenResponse() throws Exception {
            // load the policies
            FilePolicyModule policyModule = new FilePolicyModule();
            policyModule.addPolicy("policy.xml");
            // setup the policy finder
            PolicyFinder policyFinder = new PolicyFinder();
            Set policyModules = new HashSet();
            policyModules.add(policyModule);
            policyFinder.setModules(policyModules);
            // module to provide the current date & time
            CurrentEnvModule envModule = new CurrentEnvModule();
            // setup the attribute finder
            AttributeFinder attrFinder = new AttributeFinder();
            List attrModules = new ArrayList();
            attrModules.add(envModule);
            attrFinder.setModules(attrModules);
            // create the PDP
            PDP pdp = new PDP(new PDPConfig(attrFinder, policyFinder, null));
            // now work on the request
            RequestCtx RBACrequest = RequestCtx.getInstance(new FileInputStream(
                    "request.xml"));
            ResponseCtx response = pdp.evaluate(RBACrequest);
            return response.encode();
        }
    }
    

    Fortuately I get the permit response by using the policy and request in
    http://wiki.orbeon.com/forms/community/contributions/xacml-pdp-processor

    But if I create the Xacml_PDP into webservice and create a client.
    In client side I'll always get the strange response like this

    <Response>
    <Result ResourceID=http://localhost:8280/services/echo/echoString>
    <Decision>NotApplicable</Decision>
    <Status>
    <StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
    </Status>
    </Result>
    </Response>
    

    Even though I delete the files policy.xml and request.xml, the client side will still get the strange response.

    I don't know how to debug.
    Is there somebody know what's the problem?
    Please help me, thank you.

     
  • Kuang-Yu Chen

    Kuang-Yu Chen - 2010-04-20

    Hello,
    please don't look at the sentences between "Xacml_PDP.java" and "import java.io.FileInputStream;"

    thanks

     
  • Kuang-Yu Chen

    Kuang-Yu Chen - 2010-04-29

    hello again,
    I tried again in netbeans, and I got the message like this

    "com.sun.xml.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: XML reader error: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element at :  "

    I put policy.xml and request.xml in webservice server side. And I want to get the response in client side. But it shows exception error for xml reader.

    How could I get the right response

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.