Examples of BagAttribute


Examples of com.sun.xacml.attr.BagAttribute

        try {
            subject = context.getSubjectAttribute(new URI(StringAttribute.identifier), new URI(
                    "urn:oasis:names:tc:xacml:1.0:subject:subject-id"), subjectCategory);
            if (subject.getAttributeValue().isBag()) {
                BagAttribute attr = (BagAttribute) subject.getAttributeValue();
                for (Iterator iterator = attr.iterator(); iterator.hasNext();) {
                    AttributeValue val = (AttributeValue) iterator.next();
                    subjectId = val.encode();
                    if (log.isDebugEnabled()) {
                        log.debug(String.format("Finding attributes for the subject %1$s",
                                subjectId));
                    }
                    break;
                }

            }

            resource = context.getResourceAttribute(new URI(StringAttribute.identifier), new URI(
                    "urn:oasis:names:tc:xacml:1.0:resource:resource-id"), null);
            if (resource.getAttributeValue().isBag()) {
                BagAttribute attr = (BagAttribute) resource.getAttributeValue();
                for (Iterator iterator = attr.iterator(); iterator.hasNext();) {
                    AttributeValue val = (AttributeValue) iterator.next();
                    resourceId = val.encode();
                    if (log.isDebugEnabled()) {
                        log.debug(String.format("Finding attributes for the resource %1$s",
                                resourceId));
                    }
                    break;
                }

            }

            for (Iterator iterator = finders.iterator(); iterator.hasNext();) {
                PIPAttributeFinder pipAttributeFinder = (PIPAttributeFinder) iterator.next();
                if (log.isDebugEnabled()) {
                    log.debug(String.format(
                            "Finding attributes with the PIP attribute handler %1$s",
                            pipAttributeFinder.getClass()));
                }
                Set<String> attrs = pipAttributeFinder.getAttributeValues(subjectId, resourceId,
                        attributeId.toString());
                if (attrs != null) {
                    for (Iterator iterAttr = attrs.iterator(); iterAttr.hasNext();) {
                        final String attr = (String) iterAttr.next();
                        AttributeValue attribute = getAttribute(attr, attributeType.toString());
                        attrBag.add(attribute);
                    }
                }
            }

        } catch (Exception e) {
            log.error("Error occured while finding attributes via PIP", e);
            return new EvaluationResult(BagAttribute.createEmptyBag(attributeType));
        }

        return new EvaluationResult(new BagAttribute(attributeType, attrBag));
    }
View Full Code Here

Examples of com.sun.xacml.attr.BagAttribute

    AttributeValue value = subjectID.getAttributeValue();
    if(value == null)
      {return errorResult("Could not find user for context: null subject-id");}
    if(value.isBag())
    {
      final BagAttribute bag = (BagAttribute)value;
      if(bag.isEmpty())
        {return errorResult("Could not find user for context: no subject-id found");}
      if(bag.size() > 1)
        {return errorResult("Error finding attribute: Subject-id attribute is not unique.");}
     
      value = (AttributeValue)bag.iterator().next();
    }
    if(!(value instanceof StringAttribute))
      {return errorResult("Error finding attribute: Subject-id attribute must be a string.");}
   
    final String uid = ((StringAttribute)value).getValue();
View Full Code Here

Examples of com.sun.xacml.attr.BagAttribute

    final String[] groupArray = user.getGroups();
    final int size = (groupArray == null) ? 0 : groupArray.length;
    final Set<StringAttribute> groupAttributes = new HashSet<StringAttribute>(size);
    for(int i = 0; i < size; ++i)
      groupAttributes.add(new StringAttribute(groupArray[i]));
    final AttributeValue value = new BagAttribute(XACMLConstants.STRING_TYPE, groupAttributes);
    return new EvaluationResult(value);
   
  }
View Full Code Here

Examples of com.sun.xacml.attr.BagAttribute

                    + "couldn't get resource attribute from xacml request "
                    + "no bag");
            return null;
        }

        BagAttribute bag = (BagAttribute) attributeValue;
        if (1 != bag.size()) {
            logger.debug("AttributeFinder:getAttributeFromEvaluationCtx" + iAm()
                    + " exit on "
                    + "couldn't get resource attribute from xacml request "
                    + "wrong bag n=" + bag.size());
            return null;
        }

        Iterator it = bag.iterator();
        Object element = it.next();

        if (element == null) {
            logger.debug("AttributeFinder:getAttributeFromEvaluationCtx" + iAm()
                    + " exit on "
View Full Code Here

Examples of com.sun.xacml.attr.BagAttribute

        AttributeValue attributeValue = attribute.getAttributeValue();
        if (!(attributeValue instanceof BagAttribute)) {
            return null;
        }

        BagAttribute bag = (BagAttribute) attributeValue;
        if (1 != bag.size()) {
            return null;
        } else {
            return bag.iterator().next();
        }
    }
View Full Code Here

Examples of com.sun.xacml.attr.BagAttribute

                    } catch (Throwable t) {
                    }
                }
            }
        }
        return new EvaluationResult(new BagAttribute(attributeType, set));
    }
View Full Code Here

Examples of com.sun.xacml.attr.BagAttribute

        } catch (Exception e) {
            logger.error("Error getting evaluation result", e);
            return new EvaluationResult(BagAttribute.createEmptyBag(type));
        }

        BagAttribute bag = new BagAttribute(type, bagValues);

        return new EvaluationResult(bag);
    }
View Full Code Here

Examples of com.sun.xacml.attr.BagAttribute

        EvaluationResult result =
                finder.getEvaluationResult("nishen",
                                           "eduPersonEntitlement",
                                           type);
        BagAttribute bag = (BagAttribute) result.getAttributeValue();

        Iterator i = bag.iterator();
        while (i.hasNext()) {
            AttributeValue a = (AttributeValue) i.next();
            logger.info("value: " + a.encode());
        }
    }
View Full Code Here

Examples of com.sun.xacml.attr.BagAttribute

                             + "] " + s);
            }

        }

        BagAttribute bag = new BagAttribute(type, bagValues);
        return new EvaluationResult(bag);

    }
View Full Code Here

Examples of com.sun.xacml.attr.BagAttribute

                             + "] " + s);
            }

        }

        BagAttribute bag = new BagAttribute(type, bagValues);
        return new EvaluationResult(bag);

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.