Package com.sun.xacml.attr

Examples of com.sun.xacml.attr.AttributeValue


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

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

        switch (getFunctionId()) {

        // *-one-and-only takes a single bag and returns a
        // single value of baseType


     * @return a response based on the contents of the context
     */
    public ResponseCtx evaluate(EvaluationCtx context) {
        // see if we need to call the resource finder
        if (context.getScope() != EvaluationCtx.SCOPE_IMMEDIATE) {
            AttributeValue parent = context.getResourceId();
            ResourceFinderResult resourceResult = null;

            if (context.getScope() == EvaluationCtx.SCOPE_CHILDREN)
                resourceResult = resourceFinder.findChildResources(parent, context);
            else

        // 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;

        switch (getFunctionId()) {
        // *-at-least-one-member-of takes two bags of the same type and
        // returns a boolean
        case ID_BASE_AT_LEAST_ONE_MEMBER_OF:

        // get the name, which is a required attribute
        String name = root.getAttributes().getNamedItem("ParameterName").getNodeValue();

        // get the attribute value, the only child of this element
        AttributeFactory attrFactory = AttributeFactory.getInstance();
        AttributeValue value = null;

        try {
            value = attrFactory.createValue(root.getFirstChild());
        } catch (UnknownIdentifierException uie) {
            throw new ParsingException("Unknown AttributeId", uie);

     */
    public static TargetMatch getInstance(Node root, int matchType, PolicyMetaData metaData)
            throws ParsingException {
        Function function;
        Evaluatable eval = null;
        AttributeValue attrValue = null;

        AttributeFactory attrFactory = AttributeFactory.getInstance();

        // get the function type, making sure that it's really a correct
        // Target function

            result = new EvaluationResult(BooleanAttribute.getInstance(false));
            Iterator<AttributeValue> it = ((BagAttribute) args[0]).iterator();
            BagAttribute bag = (BagAttribute) (args[1]);

            while (it.hasNext()) {
                AttributeValue value = it.next();
                result = any(value, bag, function, context, false);

                if (result.indeterminate())
                    return result;

                if (((BooleanAttribute) (result.getAttributeValue())).getValue())
                    break;
            }
            break;
        }

        case ID_ALL_OF_ANY: {

            // param: boolean-function, bag, bag of same type
            // return: boolean
            // iterate through the first bag, and if for each of those values
            // one of the values in the second bag matches then return true,
            // otherwise return false

            result = allOfAny((BagAttribute) (args[1]), (BagAttribute) (args[0]), function, context);
            break;
        }

        case ID_ANY_OF_ALL: {

            // param: boolean-function, bag, bag of same type
            // return: boolean
            // iterate through the second bag, and if for each of those values
            // one of the values in the first bag matches then return true,
            // otherwise return false

            result = anyOfAll((BagAttribute) (args[0]), (BagAttribute) (args[1]), function, context);
            break;
        }

        case ID_ALL_OF_ALL: {

            // param: boolean-function, bag, bag of same type
            // return: boolean
            // iterate through the first bag, and for each of those values
            // if every value in the second bag matches using the given
            // function, then return true, otherwise return false

            result = new EvaluationResult(BooleanAttribute.getInstance(true));
            Iterator<AttributeValue> it = ((BagAttribute) args[0]).iterator();
            BagAttribute bag = (BagAttribute) (args[1]);

            while (it.hasNext()) {
                AttributeValue value = it.next();
                result = all(value, bag, function, context);

                if (result.indeterminate())
                    return result;

    private EvaluationResult allAnyHelper(BagAttribute anyBag, BagAttribute allBag,
            Function function, EvaluationCtx context, boolean argumentsAreSwapped) {
        Iterator<AttributeValue> it = allBag.iterator();

        while (it.hasNext()) {
            AttributeValue value = it.next();
            EvaluationResult result = any(value, anyBag, function, context, argumentsAreSwapped);

            if (result.indeterminate())
                return result;

                // if (value != null)
                // throw new ParsingException("Too many values in Attribute");

                // now get the value
                try {
                    AttributeValue value = attrFactory.createValue(node, type);
                    valueList.add(value);
                } catch (UnknownIdentifierException uie) {
                    throw new ParsingException("Unknown AttributeId", uie);
                }
            }

                    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.