Package org.jboss.security.xacml.sunxacml.ctx

Examples of org.jboss.security.xacml.sunxacml.ctx.ResponseCtx


                // error this is, so we're treating it as a processing error
                ArrayList code = new ArrayList();
                code.add(Status.STATUS_PROCESSING_ERROR);
                String msg = "Couldn't find any resources to work on.";
               
                return new
                    ResponseCtx(new Result(Result.DECISION_INDETERMINATE,
                                           new Status(code, msg),
                                           context.getResourceId().encode()));
            }

            // setup a set to keep track of the results
            HashSet results = new HashSet();

            // at this point, we need to go through all the resources we
            // successfully found and start collecting results
            Iterator it = resourceResult.getResources().iterator();
            while (it.hasNext()) {
                // get the next resource, and set it in the EvaluationCtx
                AttributeValue resource = (AttributeValue)(it.next());
                context.setResourceId(resource);
               
                // do the evaluation, and set the resource in the result
                Result result = evaluateContext(context);
                result.setResource(resource.encode());

                // add the result
                results.add(result);
            }

            // now that we've done all the successes, we add all the failures
            // from the finder result
            Map failureMap = resourceResult.getFailures();
            it = failureMap.keySet().iterator();
            while (it.hasNext()) {
                // get the next resource, and use it to get its Status data
                AttributeValue resource = (AttributeValue)(it.next());
                Status status = (Status)(failureMap.get(resource));

                // add a new result
                results.add(new Result(Result.DECISION_INDETERMINATE,
                                       status, resource.encode()));
            }

            // return the set of results
            return new ResponseCtx(results);
        } else {
            // the scope was IMMEDIATE (or missing), so we can just evaluate
            // the request and return whatever we get back
            return new ResponseCtx(evaluateContext(context));
        }
    }
View Full Code Here


     *
     * @return a stream that contains an XML ResponseType
     */
    public OutputStream evaluate(InputStream input) {
        RequestCtx request = null;
        ResponseCtx response = null;

        try {
            request = RequestCtx.getInstance(input);
        } catch (Exception pe) {
            // the request wasn't formed correctly
            ArrayList code = new ArrayList();
            code.add(Status.STATUS_SYNTAX_ERROR);
            Status status = new Status(code, "invalid request: " +
                                       pe.getMessage());

            response =
                new ResponseCtx(new Result(Result.DECISION_INDETERMINATE,
                                           status));
        }

        // if we didn't have a problem above, then we should go ahead
        // with the evaluation
        if (response == null)
            response = evaluate(request);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        response.encode(out, new Indenter());

        return out;
    }
View Full Code Here

      {
         String[] policyFiles = new String[]
         {getPolicyFile(i)};
         PDP pdp = new PDP(new PDPConfig(XACMLUtil.getAttributeFinder(), XACMLUtil.getPolicyFinder(policyFiles), null));
         assertNotNull("PDP != null", pdp);
         ResponseCtx first = processRequest(pdp, getRequestFile(i));
         assertNotNull("Response != null", first);
         if(debug)
            System.out.println("Test:"+i);
         //Print out the response to the System.Out
         XACMLUtil.logResponseCtxToSystemOut(first, debug);
         ResponseCtx second = ResponseCtx.getInstance(new FileInputStream(getResponseFile(i)));
         try
         {
            XACMLUtil.assertEquals(first, second);
         }
         catch (Exception e)
View Full Code Here

    * @return
    * @throws Exception
    */
   private ResponseCtx processRequest(PDP pdp, String requestFile) throws Exception
   {
      ResponseCtx response = null;

      try
      {
         response = pdp.evaluate(RequestCtx.getInstance(new FileInputStream(requestFile)));
      }
View Full Code Here

   {
      ArrayList code = new ArrayList();
      code.add(Status.STATUS_SYNTAX_ERROR);
      Status status = new Status(code);

      return new ResponseCtx(new Result(Result.DECISION_INDETERMINATE, status));
   }
View Full Code Here

         String requestFile = null;
         if(i < 10)
            requestFile = mandatoryBase + "IIA00" + i + "Request.xml";
         else
            requestFile = mandatoryBase + "IIA0" + i + "Request.xml";
         ResponseCtx actualResponse = pdp.evaluate(requestFile);
         assertNotNull("Response for" + i,actualResponse);
        
         String responseFile = null;
         if(i < 10)
            responseFile = mandatoryBase + "IIA00" + i + "Response.xml";
         else
            responseFile = mandatoryBase + "IIA0" + i + "Response.xml";
         InputStream responseStream = new FileInputStream(responseFile);
         if(responseStream  == null)
            throw new IllegalStateException("responseStream for IIA00"+ i + " is null");
         ResponseCtx expectedResponse = ResponseCtx.getInstance(responseStream);
         
         Result actualResult = (Result) actualResponse.getResults().iterator().next();
         Result expectedResult = (Result) expectedResponse.getResults().iterator().next();
         assertEquals("IIA00"+i, expectedResult.getDecision(),actualResult.getDecision())
      }
   }
View Full Code Here

         String requestFile = null;
         if(i < 10)
            requestFile = mandatoryBase + "IIB00" + i + "Request.xml";
         else
            requestFile = mandatoryBase + "IIB0" + i + "Request.xml";
         ResponseCtx actualResponse = pdp.evaluate(requestFile);
         assertNotNull("Response for" + i,actualResponse);
        
         String responseFile = null;
         if(i < 10)
            responseFile = mandatoryBase + "IIB00" + i + "Response.xml";
         else
            responseFile = mandatoryBase + "IIB0" + i + "Response.xml";
        
         InputStream responseStream = new FileInputStream(responseFile);
         if(responseStream  == null)
            throw new IllegalStateException("responseStream for IIB0"+ i + " is null");
         ResponseCtx expectedResponse = ResponseCtx.getInstance(responseStream);

         Result actualResult = (Result) actualResponse.getResults().iterator().next();
         Result expectedResult = (Result) expectedResponse.getResults().iterator().next();
         assertEquals("IIB0"+i, expectedResult.getDecision(),actualResult.getDecision());
      }
   }
View Full Code Here

         else if(i < 100)
            requestFile = mandatoryBase + "IIC0" + i + "Request.xml";
         else
            requestFile = mandatoryBase + "IIC" + i + "Request.xml";
        
         ResponseCtx actualResponse = pdp.evaluate(requestFile);
         assertNotNull("Response for" + i,actualResponse);
        
         String responseFile = null;
         if(i < 10)
            responseFile = mandatoryBase + "IIC00" + i + "Response.xml";
         else if( i < 100)
            responseFile = mandatoryBase + "IIC0" + i + "Response.xml";
         else
            responseFile = mandatoryBase + "IIC" + i + "Response.xml";
        
         InputStream responseStream = new FileInputStream(responseFile);
         if(responseStream  == null)
            throw new IllegalStateException("responseStream for IIC0"+ i + " is null");
         ResponseCtx expectedResponse = ResponseCtx.getInstance(responseStream);

         Result actualResult = (Result) actualResponse.getResults().iterator().next();
         Result expectedResult = (Result) expectedResponse.getResults().iterator().next();
         assertEquals("IIC0"+i, expectedResult.getDecision(),actualResult.getDecision());
      }
   }
View Full Code Here

         String requestFile = null;
         if(i < 10)
            requestFile = mandatoryBase + "IID00" + i + "Request.xml";
         else
            requestFile = mandatoryBase + "IID0" + i + "Request.xml";
         ResponseCtx actualResponse = pdp.evaluate(requestFile);
         assertNotNull("Response for" + i,actualResponse);
        
         String responseFile = null;
         if(i < 10)
            responseFile = mandatoryBase + "IID00" + i + "Response.xml";
         else
            responseFile = mandatoryBase + "IID0" + i + "Response.xml";
        
         InputStream responseStream = new FileInputStream(responseFile);
         if(responseStream  == null)
            throw new IllegalStateException("responseStream for IID0"+ i + " is null");
         ResponseCtx expectedResponse = ResponseCtx.getInstance(responseStream);

         Result actualResult = (Result) actualResponse.getResults().iterator().next();
         Result expectedResult = (Result) expectedResponse.getResults().iterator().next();
         assertEquals("IID0"+i, expectedResult.getDecision(),actualResult.getDecision());
      }
   }
View Full Code Here

         pdp.createInternalPDP();
        
         String requestFile = null;
         if(i < 10)
            requestFile = mandatoryBase + "IIE00" + i + "Request.xml";
         ResponseCtx actualResponse = pdp.evaluate(requestFile);
         assertNotNull("Response for" + i,actualResponse);
        
         String responseFile = null;
         if(i < 10)
            responseFile = mandatoryBase + "IIE00" + i + "Response.xml";
        
         InputStream responseStream = new FileInputStream(responseFile);
         if(responseStream  == null)
            throw new IllegalStateException("responseStream for IIE0"+ i + " is null");
         ResponseCtx expectedResponse = ResponseCtx.getInstance(responseStream);

         Result actualResult = (Result) actualResponse.getResults().iterator().next();
         Result expectedResult = (Result) expectedResponse.getResults().iterator().next();
         assertEquals("IIE0"+i, expectedResult.getDecision(),actualResult.getDecision());
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.security.xacml.sunxacml.ctx.ResponseCtx

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.