Package com.sun.xacml.attr

Examples of com.sun.xacml.attr.AttributeValue


            Node node = nodes.item(i);
            if (node.getNodeName().equals("AttributeAssignment")) {
                try {
                    URI attrId = new URI(node.getAttributes().getNamedItem("AttributeId")
                            .getNodeValue());
                    AttributeValue attrValue = attrFactory.createValue(node);
                    assignments.add(new Attribute(attrId, null, null, attrValue));
                } catch (URISyntaxException use) {
                    throw new ParsingException("Error parsing URI", use);
                } catch (UnknownIdentifierException uie) {
                    throw new ParsingException("Unknown AttributeId", uie);


        // setup the two bags we'll be using
        BagAttribute[] bags = new BagAttribute[2];
        bags[0] = (BagAttribute) (argValues[0]);
        bags[1] = (BagAttribute) (argValues[1]);

        AttributeValue result = null;
        Set<AttributeValue> set = new HashSet<AttributeValue>();

        switch (getFunctionId()) {

        // *-intersection takes two bags of the same type and returns
        // a bag of that type
        case ID_BASE_INTERSECTION:
            // create a bag with the common elements of both inputs, removing
            // all duplicate values

            Iterator<AttributeValue> it = bags[0].iterator();

            // find all the things in bags[0] that are also in bags[1]
            while (it.hasNext()) {
                AttributeValue value = (AttributeValue) (it.next());
                if (bags[1].contains(value)) {
                    // sets won't allow duplicates, so this addition is ok
                    set.add(value);
                }
            }

        EvaluationResult result = evalArgs(inputs, context, argValues);
        if (result != null)
            return result;

        // Now that we have real values, perform the date math operation.
        AttributeValue attrResult = null;

        switch (getFunctionId()) {
        // These two functions are basically the same except for sign.
        // And they both need to deal with sign anyway, so they share
        // their code.

            // Evaluate the argument
            EvaluationResult result = eval.evaluate(context);
            if (result.indeterminate())
                return result;

            AttributeValue value = result.getAttributeValue();
            boolean argBooleanValue = ((BooleanAttribute) value).getValue();

            switch (getFunctionId()) {
            case ID_OR:
                if (argBooleanValue)

        if (result != null)
            return result;

        // *-is-in takes a bag and an element of baseType and
        // returns a single boolean value
        AttributeValue item = (AttributeValue) (argValues[0]);
        BagAttribute bag = (BagAttribute) (argValues[1]);

        return new EvaluationResult(BooleanAttribute.getInstance(bag.contains(item)));
    }

                short nodeType = node.getNodeType();

                // see if this is straight text, or a node with data under
                // it and then get the values accordingly

                AttributeValue attrValue = null;

                if ((nodeType == Node.CDATA_SECTION_NODE) || (nodeType == Node.COMMENT_NODE)
                        || (nodeType == Node.TEXT_NODE) || (nodeType == Node.ATTRIBUTE_NODE)) {
                    // there is no child to this node
                    text = node.getNodeValue();

                System.err.println("Resource may contain only one " + "resource-scope Attribute");
                throw new ParsingException("too many resource-scope attrs");
            }

            Attribute attr = (Attribute) (set.iterator().next());
            AttributeValue attrValue = attr.getValue();

            // scope must be a string, so throw an exception otherwise
            if (!attrValue.getType().toString().equals(StringAttribute.identifier))
                throw new ParsingException("scope attr must be a string");

            String value = ((StringAttribute) attrValue).getValue();

            if (value.equals("Immediate")) {

                    if (value instanceof Geometry) {
                        if (((Geometry) value).getUserData() == null)
                            throw new RuntimeException("Property: " + propertyName
                                    + " : Geometry must have srs name as userdata");
                    }
                    AttributeValue attrValue = createAttributeValueFromObject(value);
                    Attribute xacmlAttr = new Attribute(attr.getId(), null, null, attrValue);
                    role.getAttributes().add(xacmlAttr);
                }
            }
        }

        }

    }

    protected AttributeValue createAttributeValueFromObject(Serializable object) {
        AttributeValue retVal = null;

        if (object instanceof String)
            retVal = new StringAttribute((String) object);
        if (object instanceof URI)
            retVal = new AnyURIAttribute((URI) object);

TOP

Related Classes of com.sun.xacml.attr.AttributeValue

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.