Package com.sun.xacml.ctx

Examples of com.sun.xacml.ctx.Attribute


        addAction(actions);

        Set<Attribute> environment = new HashSet<Attribute>(1);
        try {
            if (remoteHost != null) {
                environment.add(new Attribute(XACMLConstants.DNSNameEnvironmentURI, null, null,
                        new DNSNameAttribute(remoteHost)));
            }
            if (remoteIP != null) {
                InetAddress addr = InetAddress.getByName(remoteIP);
                if (addr instanceof Inet4Address)
                    environment.add(new Attribute(XACMLConstants.IPAddressEnvironmentURI, null, null,
                            new IPv4AddressAttribute(addr)));
                if (addr instanceof Inet6Address) {
                    environment.add(new Attribute(XACMLConstants.IPAddressEnvironmentURI, null, null,
                            new IPv6AddressAttribute(addr)));
                }
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex); // should not happen
View Full Code Here


            @Override
            public String encode() {
                return value;
            }
        };
        Attribute attribute = new Attribute(new URI(uri), null, null, attrValues);
        attrs.add(attribute);
        return attrs;
    }
View Full Code Here

            @Override
            public String encode() {
                return value;
            }
        };
        return new Attribute(new URI(uri), null, null, attrValues);
    }
View Full Code Here

      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);
View Full Code Here

      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);
View Full Code Here

   }
  
   private Attribute getRoleAttribute(String roleName) throws URISyntaxException
   {
      URI roleURI = new URI(XACMLConstants.SUBJECT_ROLE_IDENTIFIER);
      return new Attribute(roleURI,null,null, new StringAttribute(roleName));
   }
View Full Code Here

      Set<Attribute> roleset = new HashSet<Attribute>();
      Iterator<Principal> iter = roles != null ? roles.iterator(): null;
      while(iter != null && iter.hasNext())
      {
         Principal role = iter.next();
         Attribute roleAttr = new Attribute(roleURI,null,null,
               new StringAttribute(role.getName()));
           roleset.add(roleAttr)
      }
      return roleset;
   }
View Full Code Here

      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);
View Full Code Here

      Set<Attribute> roleset = new HashSet<Attribute>();
      List<Role> croles = roles.getRoles();
     
      for(Role r: croles)
      {
         Attribute roleAttr = new Attribute(roleURI,null,null,
            new StringAttribute(r.getRoleName()));
         roleset.add(roleAttr);
      }
      return roleset;
   }
View Full Code Here

  * @return A <code>Subject</code> for use in a <code>RequestCtx</code>
  */
  public Subject createUserSubject(Account user)
  {
    final AttributeValue value = new StringAttribute(user.getName());
    final Attribute attr = new Attribute(XACMLConstants.SUBJECT_ID_ATTRIBUTE, null, null, value);
    return new Subject(XACMLConstants.ACCESS_SUBJECT, Collections.singleton(attr));
  }
View Full Code Here

TOP

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

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.