@SuppressWarnings("unchecked")
private XACMLAuthzDecisionQueryType parseXACMLAuthzDecisionQuery(StartElement startElement, XMLEventReader xmlEventReader)
throws ParsingException {
super.parseRequiredAttributes(startElement);
XACMLAuthzDecisionQueryType xacmlQuery = new XACMLAuthzDecisionQueryType(id, issueInstant);
super.parseBaseAttributes(startElement, xacmlQuery);
String inputContextOnly = StaxParserUtil.getAttributeValue(startElement, JBossSAMLConstants.INPUT_CONTEXT_ONLY.get());
if (inputContextOnly != null) {
xacmlQuery.setInputContextOnly(Boolean.parseBoolean(inputContextOnly));
}
String returnContext = StaxParserUtil.getAttributeValue(startElement, JBossSAMLConstants.RETURN_CONTEXT.get());
if (returnContext != null) {
xacmlQuery.setReturnContext(Boolean.parseBoolean(returnContext));
}
// Go thru the children
while (xmlEventReader.hasNext()) {
XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
if (xmlEvent instanceof EndElement) {
EndElement endElement = (EndElement) xmlEvent;
if (!(StaxParserUtil.matches(endElement, JBossSAMLConstants.REQUEST_ABSTRACT.get()) || StaxParserUtil.matches(
endElement, JBossSAMLConstants.XACML_AUTHZ_DECISION_QUERY.get())))
throw logger.parserExpectedEndTag("RequestAbstract or XACMLAuthzDecisionQuery");
break;
}
startElement = StaxParserUtil.peekNextStartElement(xmlEventReader);
if (startElement == null)
break;
super.parseCommonElements(startElement, xmlEventReader, xacmlQuery);
String tag = StaxParserUtil.getStartElementName(startElement);
if (tag.equals(JBossSAMLConstants.REQUEST.get())) {
Element xacmlRequest = StaxParserUtil.getDOMElement(xmlEventReader);
// xacml request
String xacmlPath = "org.jboss.security.xacml.core.model.context";
try {
JAXBContext jaxb = JAXBContext.newInstance(xacmlPath);
Unmarshaller un = jaxb.createUnmarshaller();
un.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
JAXBElement<RequestType> jaxbRequestType = (JAXBElement<RequestType>) un.unmarshal(DocumentUtil
.getNodeAsStream(xacmlRequest));
RequestType req = jaxbRequestType.getValue();
xacmlQuery.setRequest(req);
} catch (Exception e) {
throw logger.parserException(e);
}
}
}