Package org.jboss.security.xacml.sunxacml

Examples of org.jboss.security.xacml.sunxacml.ParsingException


                        break;
                    }
                }

                if (decision == -1)
                    throw new ParsingException("Unknown Decision: " + type);
            } else if (name.equals("Status")) {
                status = Status.getInstance(node);
            } else if (name.equals("Obligations")) {
                obligations = parseObligations(node);
            }
View Full Code Here


            if (SunxacmlUtil.getNodeName(node).equals("Obligation"))
                set.add(Obligation.getInstance(node));
        }

        if (set.size() == 0)
            throw new ParsingException("ObligationsType must not be empty");
       
        return set;
    }
View Full Code Here

        boolean mustBePresent = false;
        String xpathVersion = metaData.getXPathIdentifier();

        // make sure we were given an xpath version
        if (xpathVersion == null)
            throw new ParsingException("An XPathVersion is required for "+
                                       "any policies that use selectors");

        NamedNodeMap attrs = root.getAttributes();

        try {
            // there's always a DataType attribute
            type = new URI(attrs.getNamedItem("DataType").getNodeValue());
        } catch (Exception e) {
            throw new ParsingException("Error parsing required DataType " +
                                       "attribute in AttributeSelector", e);
        }

        try {
            // there's always a RequestPath
            contextPath =
                attrs.getNamedItem("RequestContextPath").getNodeValue();
        } catch (Exception e) {
            throw new ParsingException("Error parsing required " +
                                       "RequestContextPath attribute in " +
                                       "AttributeSelector", e);
        }

        try {
            // there may optionally be a MustBePresent
            Node node = attrs.getNamedItem("MustBePresent");
            if (node != null)
                if (node.getNodeValue().equals("true"))
                    mustBePresent = true;
        } catch (Exception e) {
            // this shouldn't happen, since we check the cases, but still...
            throw new ParsingException("Error parsing optional attributes " +
                                       "in AttributeSelector", e);
        }

        // as of 1.2 we need the root element of the policy so we can get
        // the namespace mapping, but in order to leave the APIs unchanged,
View Full Code Here

        if (pattern == null) {
            try {
                pattern = Pattern.compile(patternString);
            } catch (PatternSyntaxException e) {
                // This should never happen
                throw new ParsingException("unexpected pattern syntax 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 yearMonthDuration");
        }

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

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

            // If the months group matched, parse that value.
            months = parseGroup(matcher, GROUP_MONTHS);
        } 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 new ParsingException("Unable to handle number size");
        }

        // If parsing went OK, create a new YearMonthDurationAttribute
        // object and return it.
        return new YearMonthDurationAttribute(negative, years, months);
View Full Code Here

        if (proxy != null) {
            try {
                return proxy.getInstance(root);
            } catch (Exception e) {
                throw new ParsingException("couldn't create " + type +
                                           " attribute based on DOM node",e);
            }
        } else {
            throw new UnknownIdentifierException("Attributes of type " + type +
                                                 " aren't supported.");
View Full Code Here

       
        if (proxy != null) {
            try {
                return proxy.getInstance(value);
            } catch (Exception e) {
                throw new ParsingException("couldn't create " + type +
                                           " attribute from input: " + value , e);
            }
        } else {
            throw new UnknownIdentifierException("Attributes of type " + type +
                                                 " aren't supported.");
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,
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

        try {
            // there's always an Id
          Node attributeIdNode = attrs.getNamedItem("AttributeId");
          if(attributeIdNode == null)
            throw new ParsingException("Required AttributeId missing in " +
                        "AttributeDesignator ->" + root.getNodeName() );
            id = new URI(attributeIdNode.getNodeValue());
        } catch (Exception e) {
            throw new ParsingException("Required AttributeId missing in " +
                                       "AttributeDesignator", e);
        }
       
        try {
            // there's always a data type
          Node dataTypeNode = attrs.getNamedItem("DataType");
          if(dataTypeNode == null)
            throw new IllegalStateException("Required DataType missing in " +
                        "AttributeDesignator ->"  + root.getNodeName());
            type = new URI(dataTypeNode.getNodeValue());
        } catch (Exception e) {
            throw new ParsingException("Required DataType missing in " +
                                       "AttributeDesignator", e);
        }
       
        try {
            // there might be an issuer
            Node node = attrs.getNamedItem("Issuer");
            if (node != null)
                issuer = new URI(node.getNodeValue());

            // if it's for the Subject section, there's another attr
            if (target == SUBJECT_TARGET) {
                Node scnode = attrs.getNamedItem("SubjectCategory");
                if (scnode != null)
                    subjectCategory = new URI(scnode.getNodeValue());
                else
                    subjectCategory = new URI(SUBJECT_CATEGORY_DEFAULT);
            }

            // there might be a mustBePresent flag
            node = attrs.getNamedItem("MustBePresent");
            if (node != null)
                if (node.getNodeValue().equals("true"))
                    mustBePresent = true;
        } catch (Exception e) {
            // this shouldn't ever happen, but in theory something could go
            // wrong in the code in this try block
            throw new ParsingException("Error parsing AttributeDesignator " +
                                       "optional attributes", e);
        }

        AttributeDesignator ad =
            new AttributeDesignator(target, type, id, mustBePresent, issuer);
View Full Code Here

        if (proxy != null) {
            try {
                return proxy.getInstance(root);
            } catch (Exception e) {
                throw new ParsingException("couldn't create " + type +
                                           " attribute based on DOM node",e);
            }
        } else {
            throw new UnknownIdentifierException("Attributes of type " + type +
                                                 " aren't supported.");
View Full Code Here

TOP

Related Classes of org.jboss.security.xacml.sunxacml.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.