Package com.sun.xacml.ctx

Examples of com.sun.xacml.ctx.RequestCtx


      if(principal == null)
         throw new IllegalArgumentException("principal is null");
     
      String action = methodName;
     
      RequestCtx requestCtx = null
      String username = principal.getName();
     
      //Create the subject set
      URI subjectAttrUri = new URI(XACMLConstants.SUBJECT_IDENTIFIER);
      Attribute subjectAttr = new Attribute(subjectAttrUri,null,null,
            new StringAttribute(username));
      Set<Attribute> subjectAttrSet = new HashSet<Attribute>();
      subjectAttrSet.add(subjectAttr);
      subjectAttrSet.addAll(getXACMLRoleSet(roles));
     
      Set<Subject> subjectSet = new HashSet<Subject>();
      subjectSet.add(new Subject(subjectAttrSet));
     
      //Create the resource set
      URI resourceUri = new URI(XACMLConstants.RESOURCE_IDENTIFIER);
      Attribute resourceAttr = new Attribute(resourceUri,null,null,
            new StringAttribute(ejbName));
      Set<Attribute> resourceSet = new HashSet<Attribute>();
      resourceSet.add(resourceAttr);
     
      //Create the action set
      Set<Attribute> actionSet = new HashSet<Attribute>();
      actionSet.add(new Attribute(new URI(XACMLConstants.ACTION_IDENTIFIER),
             null,null, new StringAttribute(action)));
     
     
      //TODO: Get hold of the invocation arguments and populate in the xacml request
     
      //Create the Environment set
      Set<Attribute> environSet = new HashSet<Attribute>();
      //Current time
      URI currentTimeUri = new URI(XACMLConstants.CURRENT_TIME_IDENTIFIER);
      Attribute currentTimeAttr = new Attribute(currentTimeUri,null,null,
            new TimeAttribute());
      environSet.add(currentTimeAttr);
     
      //Create the request context
      requestCtx = new RequestCtx(subjectSet,resourceSet,actionSet,environSet);
     
      if(trace)
      {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         requestCtx.encode(baos, new Indenter());
         log.trace("XACML Request:"+baos.toString());
         baos.close();
      }
      return requestCtx;
   }
View Full Code Here


      if(roles == null)
         throw new IllegalArgumentException("roles is null");
     
      String action = methodName;
     
      RequestCtx requestCtx = null
      String username = principal.getName();
     
      //Create the subject set
      URI subjectAttrUri = new URI(XACMLConstants.SUBJECT_IDENTIFIER);
      Attribute subjectAttr = new Attribute(subjectAttrUri,null,null,
            new StringAttribute(username));
      Set<Attribute> subjectAttrSet = new HashSet<Attribute>();
      subjectAttrSet.add(subjectAttr);
      subjectAttrSet.addAll(getXACMLRoleSet(roles));
     
      Set<Subject> subjectSet = new HashSet<Subject>();
      subjectSet.add(new Subject(subjectAttrSet));
     
      //Create the resource set
      URI resourceUri = new URI(XACMLConstants.RESOURCE_IDENTIFIER);
      Attribute resourceAttr = new Attribute(resourceUri,null,null,
            new StringAttribute(ejbName));
      Set<Attribute> resourceSet = new HashSet<Attribute>();
      resourceSet.add(resourceAttr);
     
      //Create the action set
      Set<Attribute> actionSet = new HashSet<Attribute>();
      actionSet.add(new Attribute(new URI(XACMLConstants.ACTION_IDENTIFIER),
             null,null, new StringAttribute(action)));
     
      //TODO: Get hold of the invocation arguments and populate in the xacml request
     
      //Create the Environment set
      Set<Attribute> environSet = new HashSet<Attribute>();
      //Current time
      URI currentTimeUri = new URI(XACMLConstants.CURRENT_TIME_IDENTIFIER);
      Attribute currentTimeAttr = new Attribute(currentTimeUri,null,null,
            new TimeAttribute());
      environSet.add(currentTimeAttr);
     
      //Create the request context
      requestCtx = new RequestCtx(subjectSet,resourceSet,actionSet,environSet);
     
      if(trace)
      {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         requestCtx.encode(baos, new Indenter());
         log.trace("XACML Request:"+baos.toString());
         baos.close();
      }
      return requestCtx;
   }
View Full Code Here

      String action = "GET".equals(httpMethod)?"read":"write";
     
      //Non-standard uri
      String actionURIBase = XACMLConstants.JBOSS_RESOURCE_PARAM_IDENTIFIER;
     
      RequestCtx requestCtx = null;
      Principal principal = request.getUserPrincipal();
      String username = principal.getName()
      //Create the subject set
      URI subjectAttrUri = new URI(XACMLConstants.SUBJECT_IDENTIFIER);
      Attribute subjectAttr = new Attribute(subjectAttrUri,null,null,
            new StringAttribute(username));
      Set subjectAttrSet = new HashSet();
      subjectAttrSet.add(subjectAttr);
      subjectAttrSet.addAll(getXACMLRoleSet(callerRoles));
     
      Set subjectSet = new HashSet();
      subjectSet.add(new Subject(subjectAttrSet));
     
      //Create the resource set
      URI resourceUri = new URI(XACMLConstants.RESOURCE_IDENTIFIER);
      Attribute resourceAttr = new Attribute(resourceUri,null,null,
            new AnyURIAttribute(new URI(request.getRequestURI())));
      Set resourceSet = new HashSet();
      resourceSet.add(resourceAttr);
     
      //Create the action set
      Set actionSet = new HashSet();
      actionSet.add(new Attribute(new URI(XACMLConstants.ACTION_IDENTIFIER),
             null,null, new StringAttribute(action)));
     
      Enumeration<String> enumer = request.getParameterNames();
      while(enumer.hasMoreElements())
      {
         String paramName = enumer.nextElement();
         String paramValue = request.getParameter(paramName);
         URI actionUri = new URI(actionURIBase + paramName);
         Attribute actionAttr = new Attribute(actionUri,null,null,
               new StringAttribute(paramValue));
         actionSet.add(actionAttr);
      }
      //Create the Environment set
      Set environSet = new HashSet();
      //Current time
      URI currentTimeUri = new URI(XACMLConstants.CURRENT_TIME_IDENTIFIER);
      Attribute currentTimeAttr = new Attribute(currentTimeUri,null,null,
            new TimeAttribute());
      environSet.add(currentTimeAttr);
     
      //Create the request context
      requestCtx = new RequestCtx(subjectSet,resourceSet,actionSet,environSet);
     
      if(trace)
      {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         requestCtx.encode(baos, new Indenter());
         log.trace("XACML Request:"+baos.toString());
         baos.close();
      }
      return requestCtx;
   }
View Full Code Here

     
      int result = AuthorizationContext.DENY;
      WebXACMLUtil util = new WebXACMLUtil();
      try
      {
         RequestCtx requestCtx = util.createXACMLRequest(request,callerRoles);
         String contextID = PolicyContext.getContextID();
         Policy policy = (Policy)policyRegistration.getPolicy(contextID,null);
         if(policy == null)
            throw new IllegalStateException("Missing xacml policy for contextid:"+contextID);
         result = JBossXACMLUtil.checkXACMLAuthorization(requestCtx,policy);
View Full Code Here

   {
      int result = AuthorizationContext.DENY;
      EJBXACMLUtil util = new EJBXACMLUtil();
      try
      {
         RequestCtx requestCtx = util.createXACMLRequest(this.ejbName,
               this.ejbMethod.getName(),this.principal, callerRoles);
        
         Policy policy = (Policy)policyRegistration.getPolicy(policyContextID,null);
         if(policy == null)
         {
View Full Code Here

        //check access to the query
        final XACMLSource source = expression.getSource();
        try {
            final ExistPDP pdp = context.getPDP();
            if(pdp != null) {
                final RequestCtx request = pdp.getRequestHelper().createQueryRequest(context, source);
                pdp.evaluate(request);
            }
        } catch(final PermissionDeniedException pde) {
            throw new XPathException("Permission to execute query: " + source.createId() + " denied.", pde);
        }
View Full Code Here

    //check access to the method
    try {
      final ExistPDP pdp = context.getPDP();
      if(pdp != null) {
        final RequestCtx request = pdp.getRequestHelper().createReflectionRequest(context, null, myClass.getName(), name);
        pdp.evaluate(request);
      }
    } catch (final PermissionDeniedException pde) {
      throw new XPathException(this, "Access to method '" + name + "' in class '" + myClass.getName() + "' denied.", pde);
    }
View Full Code Here

    final Set<Subject> subjects = createQuerySubjects(context.getUser(), null);
    final Set<Attribute> resourceAttributes = createQueryResource(source);
    final Set<Attribute> actionAttributes = createBasicAction(XACMLConstants.EXECUTE_QUERY_ACTION);
    final Set<Attribute> environmentAttributes = createEnvironment(context.getAccessContext());

    return new RequestCtx(subjects, resourceAttributes, actionAttributes, environmentAttributes);
  }
View Full Code Here

    final Set<Subject> subjects = createQuerySubjects(user, contextModule);
    final Set<Attribute> resourceAttributes = createReflectionResource(className, methodName);
    final Set<Attribute> actionAttributes = createBasicAction(XACMLConstants.INVOKE_METHOD_ACTION);
    final Set<Attribute> environmentAttributes = createEnvironment(context.getAccessContext());

    return new RequestCtx(subjects, resourceAttributes, actionAttributes, environmentAttributes);
  }
View Full Code Here

    addStringAttribute(resourceAttributes, XACMLConstants.RESOURCE_ID_ATTRIBUTE, functionName.getLocalName());

    final Set<Attribute> actionAttributes = createBasicAction(XACMLConstants.CALL_FUNCTION_ACTION);
    final Set<Attribute> environmentAttributes = createEnvironment(context.getAccessContext());

    return new RequestCtx(subjects, resourceAttributes, actionAttributes, environmentAttributes);
  }
View Full Code Here

TOP

Related Classes of com.sun.xacml.ctx.RequestCtx

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.