Package com.sun.xacml

Examples of com.sun.xacml.ParsingException


        byte[] bytes = null;

        try {
            bytes = Base64.decode(value, false);
        } catch (IOException e) {
            throw new ParsingException("Couldn't parse purported " + "Base64 string: " + value, e);
        }

        return new Base64BinaryAttribute(bytes);
    }
View Full Code Here


        if (entry != null) {
            if (entry instanceof FunctionProxy) {
                try {
                    return ((FunctionProxy) entry).getInstance(root, xpathVersion);
                } catch (Exception e) {
                    throw new ParsingException(
                            "couldn't create abstract" + " function " + identity, e);
                }
            } else {
                // this is actually a concrete function, which means that
                // the other create method should have been called
View Full Code Here

        // String resourceContent;

        // First check to be sure the node passed is indeed a Request node.
        String tagName = root.getNodeName();
        if (!tagName.equals("Request")) {
            throw new ParsingException("Request cannot be constructed using " + "type: "
                    + root.getNodeName());
        }

        // Now go through its child nodes, finding Subject,
        // Resource, Action, and Environment data
        NodeList children = root.getChildNodes();

        for (int i = 0; i < children.getLength(); i++) {
            Node node = children.item(i);
            String tag = node.getNodeName();

            if (tag.equals("Subject")) {
                // see if there is a category
                Node catNode = node.getAttributes().getNamedItem("SubjectCategory");
                URI category = null;

                if (catNode != null) {
                    try {
                        category = new URI(catNode.getNodeValue());
                    } catch (Exception e) {
                        throw new ParsingException("Invalid Category URI", e);
                    }
                }

                // now we get the attributes
                Set<Attribute> attributes = parseAttributes(node);
View Full Code Here

        if (pattern == null) {
            try {
                pattern = Pattern.compile(patternString);
            } catch (PatternSyntaxException e) {
                // This should never happen
                throw new ParsingException("unexpected pattern match error");
            }
        }

        // See if the value matches the pattern.
        Matcher matcher = pattern.matcher(value);
        boolean matches = matcher.matches();

        // If not, syntax error!
        if (!matches) {
            throw new ParsingException("Syntax error in dayTimeDuration");
        }

        // If the negative group matched, the value is negative.
        if (matcher.start(GROUP_SIGN) != -1)
            negative = true;

        try {
            // If the days group matched, parse that value.
            days = parseGroup(matcher, GROUP_DAYS);

            // If the hours group matched, parse that value.
            hours = parseGroup(matcher, GROUP_HOURS);

            // If the minutes group matched, parse that value.
            minutes = parseGroup(matcher, GROUP_MINUTES);

            // If the seconds group matched, parse that value.
            seconds = parseGroup(matcher, GROUP_SECONDS);

            // Special handling for fractional seconds, since
            // they can have any resolution.
            if (matcher.start(GROUP_NANOSECONDS) != -1) {
                String nanosecondString = matcher.group(GROUP_NANOSECONDS);

                // If there are less than 9 digits in the fractional seconds,
                // pad with zeros on the right so it's nanoseconds.
                while (nanosecondString.length() < 9)
                    nanosecondString += "0";

                // If there are more than 9 digits in the fractional seconds,
                // drop the least significant digits.
                if (nanosecondString.length() > 9) {
                    nanosecondString = nanosecondString.substring(0, 9);
                }

                nanoseconds = Integer.parseInt(nanosecondString);
            }
        } catch (NumberFormatException e) {
            // If we run into a number that's too big to be a long
            // that's an error. Really, it's a processing error,
            // since one can argue that we should handle that.
            throw e;
        }

        // Here's a requirement that's not checked for in the pattern.
        // The designator 'T' must be absent if all the time
        // items are absent. So the string can't end in 'T'.
        // Note that we don't have to worry about a zero length
        // string, since the pattern won't allow that.
        if (value.charAt(value.length() - 1) == 'T')
            throw new ParsingException("'T' must be absent if all" + "time items are absent");

        // If parsing went OK, create a new DayTimeDurationAttribute object and
        // return it.
        return new DayTimeDurationAttribute(negative, days, hours, minutes, seconds, nanoseconds);
    }
View Full Code Here

        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);
                }
            }
        }

        // make sure we got a value
        // if (value == null)
        // throw new ParsingException("Attribute must contain a value");
        if (valueList.isEmpty())
            throw new ParsingException("Attribute must contain a value");
        else if (valueList.size() == 1)
            return new Attribute(id, type, issuer, issueInstant, valueList.get(0));
        else {
            BagAttribute bag = new BagAttribute(type, valueList);
            return new Attribute(id, type, issuer, issueInstant, bag);
View Full Code Here

            String nanoString = value.substring(dotIndex + 1, secondsEnd);
            // Check that all those characters are ASCII digits.
            for (int i = nanoString.length() - 1; i >= 0; i--) {
                char c = nanoString.charAt(i);
                if ((c < '0') || (c > '9'))
                    throw new ParsingException("non-ascii digit found");
            }
            // If there are less than 9 digits in the fractional seconds,
            // pad with zeros on the right so it's nanoseconds.
            while (nanoString.length() < 9)
                nanoString += "0";
View Full Code Here

                results.add(Result.getInstance(node));
            }
        }

        if (results.size() == 0)
            throw new ParsingException("must have at least one Result");

        return new ResponseCtx(results);
    }
View Full Code Here

        if (value.equals("true"))
            return trueInstance;
        if (value.equals("false"))
            return falseInstance;

        throw new ParsingException("Boolean string must be true or false");
    }
View Full Code Here

            }

            Document doc = builder.parse(input);
            nodes = doc.getElementsByTagName(rootTag);
        } catch (Exception e) {
            throw new ParsingException("Error tring to parse " + rootTag + "Type", e);
        }

        if (nodes.getLength() != 1)
            throw new ParsingException("Only one " + rootTag + "Type allowed "
                    + "at the root of a Context doc");

        return nodes.item(0);
    }
View Full Code Here

                        Function function = factory.createAbstractFunction(funcName, root);
                        returnType = function.getReturnType();
                        break;
                    } catch (Exception e) {
                        // any exception here is an error
                        throw new ParsingException("invalid abstract map", e);
                    }
                } catch (Exception e) {
                    // any exception that's not function type is an error
                    throw new ParsingException("couldn't parse map body", e);
                }
            }
        }

        // see if we found the return type
        if (returnType == null)
            throw new ParsingException("couldn't find the return type");

        return new MapFunction(returnType);
    }
View Full Code Here

TOP

Related Classes of com.sun.xacml.ParsingException

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.