예제 #1
0
  /**
   * Parse Attribute value
   *
   * @param xmlEventReader
   * @return
   * @throws ParsingException
   */
  public static Object parseAttributeValue(XMLEventReader xmlEventReader) throws ParsingException {
    StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
    StaxParserUtil.validate(startElement, JBossSAMLConstants.ATTRIBUTE_VALUE.get());

    Attribute type =
        startElement.getAttributeByName(
            new QName(JBossSAMLURIConstants.XSI_NSURI.get(), "type", "xsi"));
    if (type == null) {
      return StaxParserUtil.getElementText(xmlEventReader);
    }

    String typeValue = StaxParserUtil.getAttributeValue(type);
    if (typeValue.contains(":string")) {
      return StaxParserUtil.getElementText(xmlEventReader);
    }

    throw logger.parserUnknownXSI(typeValue);
  }
예제 #2
0
  /**
   * Parse Attribute value
   *
   * @param xmlEventReader
   * @return
   * @throws ParsingException
   */
  public static Object parseAttributeValue(XMLEventReader xmlEventReader) throws ParsingException {
    StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
    StaxParserUtil.validate(startElement, JBossSAMLConstants.ATTRIBUTE_VALUE.get());

    Attribute type =
        startElement.getAttributeByName(
            new QName(JBossSAMLURIConstants.XSI_NSURI.get(), "type", "xsi"));
    if (type == null) {
      if (StaxParserUtil.hasTextAhead(xmlEventReader)) {
        return StaxParserUtil.getElementText(xmlEventReader);
      }
      // Else we may have Child Element
      XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
      if (xmlEvent instanceof StartElement) {
        startElement = (StartElement) xmlEvent;
        String tag = StaxParserUtil.getStartElementName(startElement);
        if (tag.equals(JBossSAMLConstants.NAMEID.get())) {
          return parseNameIDType(xmlEventReader);
        }
      } else if (xmlEvent instanceof EndElement) {
        return "";
      }

      throw logger.unsupportedType(StaxParserUtil.getStartElementName(startElement));
    }
    //      RK Added an additional type check for base64Binary type as calheers is passing this type
    String typeValue = StaxParserUtil.getAttributeValue(type);
    if (typeValue.contains(":string")) {
      return StaxParserUtil.getElementText(xmlEventReader);
    } else if (typeValue.contains(":anyType")) {
      // TODO: for now assume that it is a text value that can be parsed and set as the attribute
      // value
      return StaxParserUtil.getElementText(xmlEventReader);
    } else if (typeValue.contains(":base64Binary")) {
      return StaxParserUtil.getElementText(xmlEventReader);
    }

    throw logger.parserUnknownXSI(typeValue);
  }