Package org.jboss.security.xacml.interfaces

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


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

      RequestContext requestCtx = RequestResponseContextFactory.createRequestCtx();
      requestCtx.setRequest(request);
      if (debug)
         requestCtx.marshall(System.out);

      return requestCtx;
   }
View Full Code Here


  private static final String SUBJECT_IDENTIFIER_SSN = "urn:oasis:names:tc:xacml:2.0:subject:urn:altinn:ssn";
  //private final String SUBJECT_ROLE_IDENTIFIER = "urn:oasis:names:tc:xacml:2.0:subject:role";

  public static String createXACMLRequest(String fodselsNr, String orgNr, String serviceCode, String serviceEditionCode, String environment) {
    String xacmlString = null;
    RequestContext requestContext = RequestResponseContextFactory.createRequestCtx();

    // Subject
    SubjectType subject = new SubjectType();
    subject.getAttribute().add(RequestAttributeFactory.createStringAttributeType(SUBJECT_IDENTIFIER_SSN, "jboss_org", fodselsNr));

    // Resources
    ResourceType resourceType = new ResourceType();
    resourceType.getAttribute().add(RequestAttributeFactory.createStringAttributeType(RESOURCE_IDENTIFIER_ORGNR, "jboss_org", orgNr));
    resourceType.getAttribute().add(RequestAttributeFactory.createStringAttributeType(RESOURCE_IDENTIFIER_SERVICECODE, "jboss_org", serviceCode));
    resourceType.getAttribute().add(RequestAttributeFactory.createStringAttributeType(RESOURCE_IDENTIFIER_SERVICEEDITIONCODE, "jboss_org", serviceEditionCode));

    // Action
    ActionType actionType = new ActionType();
    actionType.getAttribute().add(RequestAttributeFactory.createStringAttributeType(ACTION_IDENTIFIER, "jboss.org", "Read"));

    // Environment
    EnvironmentType environmentType = new EnvironmentType();
    environmentType.getAttribute().add(RequestAttributeFactory.createStringAttributeType(ENVIRONMENT_IDENTIFIER, "jboss.org", environment));

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

    try {
      requestContext.setRequest(requestType);
    } catch (IOException e) {
      e.printStackTrace();
      throw new AccessControlException("Could not authorize. Failed to create RequestContext.");
    }

    try {
      Node doc = requestContext.getDocumentElement();
      TransformerFactory tf = TransformerFactory.newInstance();
      Transformer transformer = tf.newTransformer();

      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
      transformer.setOutputProperty(OutputKeys.INDENT, "no");
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

         if(xacmlRequest == null)
            throw new IOException("XACML Request not parsed");

         RequestType requestType = xacmlRequest.getRequest();
        
         RequestContext requestContext = new JBossRequestContext();
         requestContext.setRequest(requestType);
        
         //pdp evaluation is thread safe
         ResponseContext responseContext = pdp.evaluate(requestContext)
        
         ResponseType responseType = new ResponseType();
View Full Code Here

    public synchronized static org.picketlink.identity.federation.saml.v2.protocol.ResponseType handleXACMLQuery(
            PolicyDecisionPoint pdp, String issuer, XACMLAuthzDecisionQueryType xacmlRequest) throws ProcessingException,
            ConfigurationException {
        RequestType requestType = xacmlRequest.getRequest();

        RequestContext requestContext = new JBossRequestContext();
        try {
            requestContext.setRequest(requestType);
        } catch (IOException e) {
            throw new ProcessingException(e);
        }

        // pdp evaluation is thread safe
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.