Package com.sun.xacml.ctx

Examples of com.sun.xacml.ctx.RequestCtx


     */
    @Override
    public RequestCtx handleRequest(HttpServletRequest request,
                                    HttpServletResponse response)
            throws IOException, ServletException {
        RequestCtx req = null;

        Map<URI, AttributeValue> resAttr;
        Map<URI, AttributeValue> actions = new HashMap<URI, AttributeValue>();

        try {
View Full Code Here


     * @return the hash
     * @throws CacheException
     */
    @SuppressWarnings("unchecked")
    private String makeHash(String request) throws CacheException {
        RequestCtx reqCtx = null;
        try {
            reqCtx = m_contextUtil.makeRequestCtx(request);
        } catch (MelcoeXacmlException pe) {
            throw new CacheException("Error converting request", pe);
        }
        byte[] hash = null;
        // ensure thread safety, don't want concurrent invocations of this method all modifying digest at once
        // (alternative is to construct a new digest for each(
        synchronized(digest) {
            digest.reset();

            Set<Attribute> attributes = null;

            Set<Subject> subjects = new TreeSet(new SubjectComparator());
            subjects.addAll(reqCtx.getSubjects());
            for (Subject s : subjects) {
                attributes = new TreeSet(new AttributeComparator());
                attributes.addAll(s.getAttributes());
                for (Attribute a : attributes) {
                    hashAttribute(a, digest);
                }
            }

            attributes = new TreeSet(new AttributeComparator());
            attributes.addAll(reqCtx.getResource());
            for (Attribute a : attributes) {
                hashAttribute(a, digest);
            }

            attributes = new TreeSet(new AttributeComparator());
            attributes.addAll(reqCtx.getAction());
            for (Attribute a : attributes) {
                hashAttribute(a, digest);
            }

            attributes = new TreeSet(new AttributeComparator());
            attributes.addAll(reqCtx.getEnvironmentAttributes());
            for (Attribute a : attributes) {
                hashAttribute(a, digest);
            }

            hash = digest.digest();
View Full Code Here

      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 subjectAttrSet = new HashSet();
      subjectAttrSet.add(subjectAttr);
      subjectAttrSet.addAll(getXACMLRoleSet(roles));
     
      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 StringAttribute(ejbName));
      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)));
     
     
      //TODO: Get hold of the invocation arguments and populate in the xacml request
     
      //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

      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(roles));
     
      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,am, am.getUserRoles(userP));
         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,
               am.getUserRoles(principal));
         String contextID = PolicyContext.getContextID();
         if(contextID == null)
            throw new IllegalStateException("Context ID is null");
View Full Code Here

    @Override
    public RequestCtx handleRequest(SOAPMessageContext context)
            throws OperationHandlerException {
        logger.debug("PurgeDatastreamHandler/handleRequest!");

        RequestCtx req = null;
        Object oMap = null;

        String pid = null;
        String dsID = null;
        String startDT = null;
View Full Code Here

    @Override
    public RequestCtx handleRequest(SOAPMessageContext context)
            throws OperationHandlerException {
        logger.debug("GetNextPIDHandler/handleRequest!");

        RequestCtx req = null;
        Object oMap = null;

        BigInteger numPids = null;
        String pidNamespace = null;
View Full Code Here

    @Override
    public RequestCtx handleRequest(SOAPMessageContext context)
            throws OperationHandlerException {
        logger.debug("ModifyObjectHandler/handleRequest!");

        RequestCtx req = null;
        Object oMap = null;

        String pid = null;
        String state = null;
        String ownerId = null;
View Full Code Here

    @Override
    public RequestCtx handleRequest(SOAPMessageContext context)
            throws OperationHandlerException {
        logger.debug("ModifyDatastreamByReferenceHandler/handleRequest!");

        RequestCtx req = null;
        Object oMap = null;

        String pid = null;
        String dsID = null;
        String mimeType = null;
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.