Package com.sun.xacml.attr

Examples of com.sun.xacml.attr.AttributeFactory


  public AttributeValue getValue()
  {
    if(attribute == null || currentValue == null)
      {return null;}
   
    final AttributeFactory factory = AttributeFactory.getInstance();
    try
    {
      final String textValue = currentValue.toString();
      if(textValue == null || textValue.length() == 0)
        {return null;}
      final AttributeValue value = factory.createValue(attribute.getType(), textValue);
      for(final AttributeHandler handler : attributeHandlers)
        handler.checkUserValue(value, attribute);
      return value;
    }
    catch(final UnknownIdentifierException e)
View Full Code Here


    public AttributeFactory useStandardDatatypes(){
        return StandardAttributeFactory.getNewFactory();
    }
    public AttributeFactory useAttributeProxies(Map<String,AttributeProxy> proxies) {
        AttributeFactory result = new BaseAttributeFactory();
        for (String id:proxies.keySet()){
            result.addDatatype(id, proxies.get(id));
        }
        return result;
    }
View Full Code Here

    public static CombinerParameter getInstance(Node root) throws ParsingException {
        // 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);
        }

        return new CombinerParameter(name, value);
View Full Code Here

            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
        String funcName = root.getAttributes().getNamedItem("MatchId").getNodeValue();
        FunctionFactory factory = FunctionFactory.getTargetInstance();
        try {
            URI funcId = new URI(funcName);
            function = factory.createFunction(funcId);
        } catch (URISyntaxException use) {
            throw new ParsingException("Error parsing TargetMatch", use);
        } catch (UnknownIdentifierException uie) {
            throw new ParsingException("Unknown MatchId", uie);
        } catch (FunctionTypeException fte) {
            // try to create an abstract function
            try {
                URI funcId = new URI(funcName);
                function = factory.createAbstractFunction(funcId, root);
            } catch (Exception e) {
                // any exception here is an error
                throw new ParsingException("invalid abstract function", e);
            }
        }

        // next, get the designator or selector being used, and the attribute
        // value paired with it
        NodeList nodes = root.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            String name = node.getNodeName();

            if (name.equals(NAMES[matchType] + "AttributeDesignator")) {
                eval = AttributeDesignator.getInstance(node, matchType, metaData);
            } else if (name.equals("AttributeSelector")) {
                eval = AttributeSelector.getInstance(node, metaData);
            } else if (name.equals("AttributeValue")) {
                try {
                    attrValue = attrFactory.createValue(node);
                } catch (UnknownIdentifierException uie) {
                    throw new ParsingException("Unknown Attribute Type", uie);
                }
            }
        }
View Full Code Here

        String issuer = null;
        DateTimeAttribute issueInstant = null;
        // AttributeValue value = null;
        List<AttributeValue> valueList = new ArrayList<AttributeValue>();

        AttributeFactory attrFactory = AttributeFactory.getInstance();

        // First check that we're really parsing an Attribute
        if (!root.getNodeName().equals("Attribute")) {
            throw new ParsingException("Attribute object cannot be created "
                    + "with root node of type: " + root.getNodeName());
        }

        NamedNodeMap attrs = root.getAttributes();

        try {
            id = new URI(attrs.getNamedItem("AttributeId").getNodeValue());
        } catch (Exception e) {
            throw new ParsingException("Error parsing required attribute "
                    + "AttributeId in AttributeType", e);
        }

        try {
            type = new URI(attrs.getNamedItem("DataType").getNodeValue());
        } catch (Exception e) {
            throw new ParsingException("Error parsing required attribute "
                    + "DataType in AttributeType", e);
        }

        try {
            Node issuerNode = attrs.getNamedItem("Issuer");
            if (issuerNode != null)
                issuer = issuerNode.getNodeValue();

            Node instantNode = attrs.getNamedItem("IssueInstant");
            if (instantNode != null)
                issueInstant = DateTimeAttribute.getInstance(instantNode.getNodeValue());
        } catch (Exception e) {
            // shouldn't happen, but just in case...
            throw new ParsingException("Error parsing optional AttributeType" + " attribute", e);
        }

        // now we get the attribute value
        NodeList nodes = root.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            if (node.getNodeName().equals("AttributeValue")) {
                // only one value can be in an Attribute
                // 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);
                }
            }
View Full Code Here

    /**
     * Private helper that handles the attributeFactory elements.
     */
    private AttributeFactory parseAttributeFactory(Node root) throws ParsingException {
        AttributeFactory factory = null;

        // check if we're starting with the standard factory setup
        if (useStandard(root, "useStandardDatatypes")) {
            logger.config("Starting with standard Datatypes");

            factory = StandardAttributeFactory.getNewFactory();
        } else {
            factory = new BaseAttributeFactory();
        }

        // now look for all datatypes specified for this factory, adding
        // them as we go
        NodeList children = root.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);

            if (child.getNodeName().equals("datatype")) {
                // a datatype is a class with an identifier
                String identifier = child.getAttributes().getNamedItem("identifier").getNodeValue();
                AttributeProxy proxy = (AttributeProxy) (loadClass("datatype", child));

                try {
                    factory.addDatatype(identifier, proxy);
                } catch (IllegalArgumentException iae) {
                    throw new ParsingException("duplicate datatype: " + identifier, iae);
                }
            }
        }
View Full Code Here

     * convenience, and any registration that may involve identifier clashes should be done by
     * registering each factory individually.
     */
    public void registerAttributeFactories() {
        for (String id : attributeMap.keySet()) {
            AttributeFactory af = attributeMap.get(id);

            try {
                AttributeFactory.registerFactory(id, new AFProxy(af));
            } catch (IllegalArgumentException iae) {
                logger.log(Level.WARNING, "Couldn't register AttributeFactory:" + id
View Full Code Here

        FunctionFactory.setDefaultFactory(factoryProxy);
    }

    private static void registerGeoXACMLAttributes() {

        final AttributeFactory fac = StandardAttributeFactory.getNewFactory();

        fac.addDatatype(GeometryAttribute.identifier, new GeometryAttributeProxy());

        AttributeFactory.setDefaultFactory(new AttributeFactoryProxy() {
            public AttributeFactory getFactory() {
                return fac;
            }
View Full Code Here

    public static Obligation getInstance(Node root) throws ParsingException {
        URI id;
        int fulfillOn = -1;
        List<Attribute> assignments = new ArrayList<Attribute>();

        AttributeFactory attrFactory = AttributeFactory.getInstance();
        NamedNodeMap attrs = root.getAttributes();

        try {
            id = new URI(attrs.getNamedItem("ObligationId").getNodeValue());
        } catch (Exception e) {
            throw new ParsingException("Error parsing required attriubte " + "ObligationId", e);
        }

        String effect = null;

        try {
            effect = attrs.getNamedItem("FulfillOn").getNodeValue();
        } catch (Exception e) {
            throw new ParsingException("Error parsing required attriubte " + "FulfillOn", e);
        }

        if (effect.equals("Permit")) {
            fulfillOn = Result.DECISION_PERMIT;
        } else if (effect.equals("Deny")) {
            fulfillOn = Result.DECISION_DENY;
        } else {
            throw new ParsingException("Invlid Effect type: " + effect);
        }

        NodeList nodes = root.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            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);
View Full Code Here

        }

        // there was at least one match, so try to generate the values
        try {
            ArrayList<AttributeValue> list = new ArrayList<AttributeValue>();
            AttributeFactory attrFactory = AttributeFactory.getInstance();

            for (int i = 0; i < matches.getLength(); i++) {
                String text = null;
                Node node = matches.item(i);
                short nodeType = node.getNodeType();

                // see if this is straight text, or a node with data under
                // it and then get the values accordingly
                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();
                } else {
                    // the data is in a child node
                    text = node.getFirstChild().getNodeValue();
                }

                list.add(attrFactory.createValue(type, text));
            }

            return new EvaluationResult(new BagAttribute(type, list));
        } catch (ParsingException pe) {
            return createProcessingError(pe.getMessage());
View Full Code Here

TOP

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

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.