/**
   * Parse the attributes that are common to all SAML Request Types
   *
   * @param startElement
   * @param request
   * @throws ParsingException
   */
  protected void parseBaseAttributes(StartElement startElement, RequestAbstractType request)
      throws ParsingException {
    Attribute destinationAttr =
        startElement.getAttributeByName(new QName(JBossSAMLConstants.DESTINATION.get()));
    if (destinationAttr != null)
      request.setDestination(URI.create(StaxParserUtil.getAttributeValue(destinationAttr)));

    Attribute consent =
        startElement.getAttributeByName(new QName(JBossSAMLConstants.CONSENT.get()));
    if (consent != null) request.setConsent(StaxParserUtil.getAttributeValue(consent));
  }
  protected void parseCommonElements(
      StartElement startElement, XMLEventReader xmlEventReader, RequestAbstractType request)
      throws ParsingException {
    if (startElement == null) throw new IllegalArgumentException(ErrorCodes.NULL_START_ELEMENT);
    String elementName = StaxParserUtil.getStartElementName(startElement);

    if (JBossSAMLConstants.ISSUER.get().equals(elementName)) {
      startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
      NameIDType issuer = new NameIDType();
      issuer.setValue(StaxParserUtil.getElementText(xmlEventReader));
      request.setIssuer(issuer);
    } else if (JBossSAMLConstants.SIGNATURE.get().equals(elementName)) {
      request.setSignature(StaxParserUtil.getDOMElement(xmlEventReader));
    }
  }
  protected void parseRequiredAttributes(StartElement startElement) throws ParsingException {
    Attribute idAttr = startElement.getAttributeByName(new QName(JBossSAMLConstants.ID.get()));
    if (idAttr == null) throw new RuntimeException(ErrorCodes.REQD_ATTRIBUTE + "ID");

    id = StaxParserUtil.getAttributeValue(idAttr);

    Attribute versionAttr =
        startElement.getAttributeByName(new QName(JBossSAMLConstants.VERSION.get()));
    if (versionAttr == null) throw new RuntimeException(ErrorCodes.REQD_ATTRIBUTE + "Version");
    version = StaxParserUtil.getAttributeValue(versionAttr);

    Attribute issueInstantAttr =
        startElement.getAttributeByName(new QName(JBossSAMLConstants.ISSUE_INSTANT.get()));
    if (issueInstantAttr == null)
      throw new RuntimeException(ErrorCodes.REQD_ATTRIBUTE + "IssueInstant");
    issueInstant = XMLTimeUtil.parse(StaxParserUtil.getAttributeValue(issueInstantAttr));
  }