Package com.sun.xacml.ctx

Examples of com.sun.xacml.ctx.ResponseCtx


        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.parse(req.getInputStream());

        RequestCtx request = RequestCtx.getInstance(doc.getDocumentElement());
        ResponseCtx response = pdp.evaluate(request);

        response.encode(resp.getOutputStream(), new Indenter(0), true);
        return null;
    }
View Full Code Here


            if (mode != null)
                return mode;

            RequestCtx requestCtx = GeoXACMLConfig.getRequestCtxBuilderFactory()
                    .getCatalogRequestCtxBuilder().createRequestCtx();
            ResponseCtx responseCtx = GeoXACMLConfig.getXACMLTransport().evaluateRequestCtx(
                    requestCtx);

            Result result = responseCtx.getResults().iterator().next();
            if (result == null || result.getDecision() != Result.DECISION_PERMIT) {
                Log.severe("Geserver cannot access its catalog !!!");
                Log.severe(XACMLUtil.asXMLString(requestCtx));
                return useDefaultMode();
            }
View Full Code Here

     * @throws com.sun.xacml.ParsingException
     * @throws java.io.IOException
     */
    public ResponseCtx evaluate(Element xamlRequest) throws IOException, ParsingException {
        RequestCtx request = RequestCtx.getInstance(xamlRequest);
        ResponseCtx response = null;

        if ((response = getFromCache(request)) != null) {
            return response;
        }

View Full Code Here

     * @return
     * @throws IOException
     * @throws ParsingException
     */
    public ResponseCtx evaluate(RequestCtx request) throws IOException, ParsingException {
        ResponseCtx response = null;
        if ((response = getFromCache(request)) != null) {
            return response;
        }
        // evaluate the request
        response = pdp.evaluate(request);
View Full Code Here

     */
    public String getDecision(String request) throws Exception {
        PolicyRequestBuilder policyRequestBuilder = null;
        PolicyResponseBuilder policyResponseBuilder = null;
        Element xacmlReq = null;
        ResponseCtx response = null;

        try {

            if (log.isDebugEnabled()) {
                log.debug("XACML request" + request);
View Full Code Here

    * @throws Exception
    */
   public static synchronized int checkXACMLAuthorization(RequestCtx request,
         Policy policy) throws Exception
   {
      ResponseCtx response = getXACMLResponse(request,policy);
      return analyzeResponseCtx(response);
   }
View Full Code Here

      final ByteArrayOutputStream out = new ByteArrayOutputStream();
      request.encode(out, new Indenter(4));
      LOG.debug("Processing request:");
      LOG.debug(out.toString());
    }
    final ResponseCtx response = pdp.evaluate(request);
    if(LOG.isDebugEnabled())
    {
      final ByteArrayOutputStream out = new ByteArrayOutputStream();
      response.encode(out, new Indenter(4));
      LOG.debug("PDP response to request:");
      LOG.debug(out.toString());
    }
    handleResponse(response);
  }
View Full Code Here

                throw new AuthzDeniedException("all requests are currently denied");
            } else if (!ENFORCE_MODE_ENFORCE_POLICIES.equals(m_enforceMode)) {
                logger.debug("denying request because enforceMode is invalid");
                throw new AuthzOperationalException("invalid enforceMode from config \"" + m_enforceMode + "\"");
            } else {
                ResponseCtx response = null;
                String contextIndex = null;
                try {
                    contextIndex = (new Integer(next())).toString();
                    logger.debug("context index set={}", contextIndex);
                    Set<Subject> subjects = wrapSubjects(subjectId);
                    Set<Attribute> actions = wrapActions(action, api, contextIndex);
                    Set<Attribute> resources = wrapResources(pid, namespace);

                    RequestCtx request =
                            new RequestCtx(subjects,
                                           resources,
                                           actions,
                                           Collections.EMPTY_SET);
                    Iterator<Attribute> tempit = actions.iterator();
                    while (tempit.hasNext()) {
                        Attribute tempobj = tempit.next();
                        logger.debug("request action has {}={}", tempobj.getId(), tempobj.getValue().toString());
                    }
                    m_registry.registerContext(contextIndex, context);
                    long st = System.currentTimeMillis();
                    try {
                        response = m_pdp.evaluate(request);
                    } finally {
                        long dur = System.currentTimeMillis() - st;
                        logger.debug("Policy evaluation took {}ms.", dur);
                    }

                    logger.debug("in pep, after evaluate() called");
                } catch (Throwable t) {
                    logger.error("Error evaluating policy", t);
                    throw new AuthzOperationalException("");
                } finally {
                    m_registry.unregisterContext(contextIndex);
                }
                logger.debug("in pep, before denyBiasedAuthz() called");
                if (!denyBiasedAuthz(response.getResults())) {
                    throw new AuthzDeniedException("");
                }
            }
            if (context.getNoOp()) {
                throw new AuthzPermittedException("noOp");
View Full Code Here

        } catch (ParsingException pe) {
            logger.error("Error parsing request:\n" + request, pe);
            throw new EvaluationException("Error parsing request:\n" + request);
        }

        ResponseCtx res = m_pdp.evaluate(req);
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        res.encode(os, new Indenter());

        logger.debug("response is: {}", os.toString());

        return os.toString();
    }
View Full Code Here

            logger.debug("evaluating request batch");

        Set<Result> results = new HashSet<Result>();

        for (String req : requests) {
            ResponseCtx resCtx = null;
            String response = evaluate(req);
            ByteArrayInputStream is =
                    new ByteArrayInputStream(response.getBytes());
            try {
                resCtx = ResponseCtx.getInstance(is);
            } catch (ParsingException pe) {
                logger.error("Error parsing response:\n" + response, pe);
                throw new EvaluationException("Error parsing response:\n"
                        + response);
            }

            @SuppressWarnings("unchecked")
            Set<Result> r = resCtx.getResults();
            results.addAll(r);
        }

        ResponseCtx combinedResponse = new ResponseCtx(results);
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        combinedResponse.encode(os, new Indenter());

        return os.toString();
    }
View Full Code Here

TOP

Related Classes of com.sun.xacml.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.