Package org.jboss.security.xacml.sunxacml

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


         return PolicySet.getInstance(root, finder);
      }
      else
      {
         // this isn't a root type that we know how to handle
         throw new ParsingException("Unknown root document type: " + name);
      }
   }
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

        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

        String resourceContent;

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

            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 attributes = parseAttributes(node);
View Full Code Here

    public static HexBinaryAttribute getInstance(String value)
        throws ParsingException {
        byte [] bytes = hexToBin(value);

        if (bytes == null)
            throw new ParsingException("Couldn't parse purported " +
                                       "hex string: " + value);

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

            if (value.indexOf('[') == 0)
                return IPv6AddressAttribute.getV6Instance(value);
            else
                return IPv4AddressAttribute.getV4Instance(value);
        } catch (UnknownHostException uhe) {
            throw new ParsingException("Failed to parse an IPAddress", uhe);
        }
    }
View Full Code Here

      AttributeFactory attrFactory = AttributeFactory.getInstance();

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

      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 (SunxacmlUtil.getNodeName(node).equals("AttributeValue")) {
            // only one value can be in an Attribute
           
            /*
             * SECURITY-157: multiple values
             *
             * if (value != null)
               throw new ParsingException("Too many values in Attribute");
             */
            // now get the value
            try {
               value = attrFactory.createValue(node, type);
            } catch (UnknownIdentifierException uie) {
               throw new ParsingException("Unknown AttributeId", uie);
            }
            if(valueSet == null)
               valueSet = new HashSet<AttributeValue>();
            valueSet.add(value);
         }
      }

      // make sure we got a value
      if (value == null)
         throw new ParsingException("Attribute must contain a value");

      return new Attribute(id, type, issuer, issueInstant, valueSet);
   }
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

            }

            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

            DocumentBuilder db = factory.newDocumentBuilder();
            Document doc = db.parse(new ByteArrayInputStream(bytes));

            return doc.getDocumentElement();
        } catch (Exception e) {
            throw new ParsingException("invalid XML for status detail");
        }
    }
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.