protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
JAXBElement<RequestAbstractType> jaxbRequestType = null;
Envelope envelope = null;
XACMLAuthzDecisionQueryType xacmlRequest = null;
try
{
Document inputDoc = DocumentUtil.getDocument(req.getInputStream());
if(debug)
log.trace("Received SOAP:"+DocumentUtil.getDocumentAsString(inputDoc));
Unmarshaller un = JAXBUtil.getUnmarshaller(SOAPSAMLXACMLUtil.getPackage());
if(debug)
un.setEventHandler(new DefaultValidationEventHandler());
Object unmarshalledObject = un.unmarshal(DocumentUtil.getNodeAsStream(inputDoc));
if(unmarshalledObject instanceof JAXBElement)
{
JAXBElement<?> jaxbElement = (JAXBElement<?>) unmarshalledObject;
Object element = jaxbElement.getValue();
if(element instanceof Envelope)
{
envelope = (Envelope)element;
Body soapBody = envelope.getBody();
Object samlRequest = soapBody.getAny().get(0);
if(samlRequest instanceof JAXBElement)
{
jaxbRequestType = (JAXBElement<RequestAbstractType>)samlRequest;
jaxbRequestType = (JAXBElement<RequestAbstractType>)samlRequest;
xacmlRequest = (XACMLAuthzDecisionQueryType) jaxbRequestType.getValue();
}
else
if(samlRequest instanceof Element)
{
Element elem = (Element) samlRequest;
xacmlRequest = SOAPSAMLXACMLUtil.getXACMLQueryType(elem);
}
}
else if(element instanceof XACMLAuthzDecisionQueryType)
{
xacmlRequest = (XACMLAuthzDecisionQueryType) element;
}
}
if(xacmlRequest == null)
throw new IOException("XACML Request not parsed");
RequestType requestType = xacmlRequest.getRequest();
RequestContext requestContext = new JBossRequestContext();
requestContext.setRequest(requestType);
//pdp evaluation is thread safe