Package org.jboss.security.xacml.interfaces

Examples of org.jboss.security.xacml.interfaces.RequestContext


      }
      if(childElement.getLocalName().equals("Request")
            && childElement.getNamespaceURI().equals(XACMLConstants.CONTEXT_SCHEMA))
      {
         //process the xacml request
         RequestContext requestContext = RequestResponseContextFactory.createRequestCtx();
         try
         {
            requestContext.readRequest(childElement);
         }
         catch (IOException e)
         {
            throw new RuntimeException(e);
         }
View Full Code Here


     * @param requestStr
     * @return
     * @throws Exception
     */
    private int getDecisionForStr(PolicyDecisionPoint pdp, String requestStr) throws Exception {
        final RequestContext request = RequestResponseContextFactory.createRequestCtx();
        request.readRequest(IOUtils.toInputStream(requestStr));
        return getDecision(pdp, request);
    }
View Full Code Here

     * @param requestFileLoc a file where the xacml request is stored
     * @return
     * @throws Exception
     */
    private int getDecision(PolicyDecisionPoint pdp, String requestFileLoc) throws Exception {
        final RequestContext request = RequestResponseContextFactory.createRequestCtx();
        LOGGER.info("Creating request from " + requestFileLoc);
        final InputStream requestStream = JBossPDPInteroperabilityTestCase.class
                .getResourceAsStream(XACMLTestUtils.TESTOBJECTS_REQUESTS + "/" + requestFileLoc);
        if (requestStream == null) {
            LOGGER.warn("INPUT IS NULL");
        }
        request.readRequest(requestStream);
        return getDecision(pdp, request);
    }
View Full Code Here

        request.getSubject().add(createSubject(reqTradeAppr, reqCreditAppr, buyPrice));
        request.getResource().add(createResource());
        request.setAction(createAction());
        request.setEnvironment(new EnvironmentType());

        final RequestContext requestCtx = RequestResponseContextFactory.createRequestCtx();
        requestCtx.setRequest(request);

        return requestCtx;
    }
View Full Code Here

        if (userP == null)
            throw new IllegalStateException("User Principal is null");

        final WebXACMLUtil util = new WebXACMLUtil();
        try {
            final RequestContext requestCtx = util.createXACMLRequest(request, role);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(toString(requestCtx));
            }
            final ResponseContext response = pdp.evaluate(requestCtx);
            result = response.getDecision() == XACMLConstants.DECISION_PERMIT ? AuthorizationContext.PERMIT
View Full Code Here

            //Don't do this in the real world!
            return AuthorizationContext.PERMIT;
        }
        final EJBXACMLUtil util = new EJBXACMLUtil();
        try {
            final RequestContext requestCtx = util.createXACMLRequest(ejbResource.getEjbName(), ejbResource.getEjbMethod(),
                    ejbResource.getPrincipal(), role);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(toString(requestCtx));
            }
            final ResponseContext response = pdp.evaluate(requestCtx);
View Full Code Here

   {
      int result = AuthorizationContext.DENY;
      EJBXACMLUtil util = new EJBXACMLUtil();
      try
      {
         RequestContext requestCtx = util.createXACMLRequest(this.ejbName,
               this.ejbMethod.getName(),this.ejbPrincipal, callerRoles);
        
         PolicyDecisionPoint pdp = util.getPDP(policyRegistration, this.policyContextID);
         if(pdp == null)
            throw new IllegalStateException("PDP is null");
View Full Code Here

      if(principal == null)
         throw new IllegalArgumentException("principal is null");

      String action = methodName;

      RequestContext requestCtx = RequestResponseContextFactory.createRequestCtx();

      //Create a subject type
      SubjectType subject = new SubjectType();
      subject.getAttribute().add(
            RequestAttributeFactory.createStringAttributeType(
                  XACMLConstants.ATTRIBUTEID_SUBJECT_ID, "jboss.org",
                  principal.getName()));

      List<Role> rolesList = callerRoles.getRoles();
      if(rolesList != null)
      {
         for(Role role:rolesList)
         {
            String roleName = role.getRoleName();
            AttributeType attSubjectID = RequestAttributeFactory.createStringAttributeType(
                  XACMLConstants.ATTRIBUTEID_ROLE, "jboss.org", roleName);
            subject.getAttribute().add(attSubjectID);
         }
      }

      //Create a resource type
      ResourceType resourceType = new ResourceType();
      resourceType.getAttribute().add(
            RequestAttributeFactory.createStringAttributeType(
                  XACMLConstants.ATTRIBUTEID_RESOURCE_ID,
                  null,
                  ejbName));

      //Create an action type
      ActionType actionType = new ActionType();
      actionType.getAttribute().add(
            RequestAttributeFactory.createStringAttributeType(
                  XACMLConstants.ATTRIBUTEID_ACTION_ID,
                  "jboss.org",
                  action))

      //Create an Environment Type (Optional)
      EnvironmentType environmentType = new EnvironmentType();
      environmentType.getAttribute().add(
            RequestAttributeFactory.createDateTimeAttributeType(
            XACMLConstants.ATTRIBUTEID_CURRENT_TIME, null));

      //Create a Request Type
      RequestType requestType = new RequestType();
      requestType.getSubject().add(subject);
      requestType.getResource().add(resourceType);
      requestType.setAction(actionType);
      requestType.setEnvironment(environmentType);

      requestCtx.setRequest(requestType);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      if(trace)
      {
         requestCtx.marshall(baos);
         log.trace(new String(baos.toByteArray()));        
      }
      return requestCtx;
  }  
View Full Code Here

      String actionURIBase = "urn:oasis:names:tc:xacml:2.0:request-param:attribute:";
     
      Principal principal = request.getUserPrincipal();
     
     
      RequestContext requestCtx = RequestResponseContextFactory.createRequestCtx();

      //Create a subject type
      SubjectType subject = new SubjectType();
      subject.getAttribute().add(
            RequestAttributeFactory.createStringAttributeType(
                  XACMLConstants.ATTRIBUTEID_SUBJECT_ID,
                  "jboss.org",
                  principal.getName()));
     
      List<Role> rolesList = callerRoles.getRoles();
      if(rolesList != null)
      {
         for(Role role:rolesList)
         {
            String roleName = role.getRoleName();
            AttributeType attSubjectID = RequestAttributeFactory.createStringAttributeType(
                  XACMLConstants.ATTRIBUTEID_ROLE, "jboss.org", roleName);
            subject.getAttribute().add(attSubjectID);
         }
      }

      //Create a resource type
      ResourceType resourceType = new ResourceType();
      resourceType.getAttribute().add(
            RequestAttributeFactory.createAnyURIAttributeType(
                  XACMLConstants.ATTRIBUTEID_RESOURCE_ID,
                  null,
                  new URI(request.getRequestURI())));

      //Create an action type
      ActionType actionType = new ActionType();
      actionType.getAttribute().add(
            RequestAttributeFactory.createStringAttributeType(
                  XACMLConstants.ATTRIBUTEID_ACTION_ID,
                  "jboss.org",
                  action));

      Enumeration<String> enumer = request.getParameterNames();
      while(enumer.hasMoreElements())
      {
         String paramName = enumer.nextElement();
         String paramValue = request.getParameter(paramName);
         URI actionUri = new URI(actionURIBase + paramName);
         actionType.getAttribute().add(
               RequestAttributeFactory.createStringAttributeType(
                     actionUri.toASCIIString(),
                     "jboss.org",
                     paramValue))
      }
     
     
      //Create an Environment Type (Optional)
      EnvironmentType environmentType = new EnvironmentType();
      environmentType.getAttribute().add( RequestAttributeFactory.createDateTimeAttributeType(
                                       XACMLConstants.ATTRIBUTEID_CURRENT_TIME, null));

      //Create a Request Type
      RequestType requestType = new RequestType();
      requestType.getSubject().add(subject);
      requestType.getResource().add(resourceType);
      requestType.setAction(actionType);
      requestType.setEnvironment(environmentType);

      requestCtx.setRequest(requestType);
     
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
     
      if(trace)
      {
         requestCtx.marshall(baos);
         log.trace(new String(baos.toByteArray()));        
      }
      return requestCtx;
View Full Code Here

     
      int result = AuthorizationContext.DENY;
      WebXACMLUtil util = new WebXACMLUtil();
      try
      {
         RequestContext requestCtx = util.createXACMLRequest(request,callerRoles);
         if(this.policyContextID == null)
           this.policyContextID = PolicyContext.getContextID();
         
         PolicyDecisionPoint pdp = util.getPDP(this.policyRegistration, this.policyContextID);
         ResponseContext response = pdp.evaluate(requestCtx);
View Full Code Here

TOP

Related Classes of org.jboss.security.xacml.interfaces.RequestContext

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.