Author: anil.saldhana(a)jboss.com
Date: 2009-03-17 11:40:56 -0400 (Tue, 17 Mar 2009)
New Revision: 369
Modified:
identity-federation/trunk/identity-bindings/src/main/java/org/jboss/identity/federation/bindings/servlets/SOAPSAMLXACMLServlet.java
Log:
workaround if there is a xsi:type error
Modified:
identity-federation/trunk/identity-bindings/src/main/java/org/jboss/identity/federation/bindings/servlets/SOAPSAMLXACMLServlet.java
===================================================================
---
identity-federation/trunk/identity-bindings/src/main/java/org/jboss/identity/federation/bindings/servlets/SOAPSAMLXACMLServlet.java 2009-03-16
12:54:47 UTC (rev 368)
+++
identity-federation/trunk/identity-bindings/src/main/java/org/jboss/identity/federation/bindings/servlets/SOAPSAMLXACMLServlet.java 2009-03-17
15:40:56 UTC (rev 369)
@@ -29,6 +29,7 @@
import java.security.PrivilegedExceptionAction;
import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -37,6 +38,7 @@
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.helpers.DefaultValidationEventHandler;
import org.apache.log4j.Logger;
import org.jboss.identity.federation.api.saml.v2.common.IDGenerator;
@@ -61,6 +63,7 @@
import org.jboss.security.xacml.interfaces.PolicyDecisionPoint;
import org.jboss.security.xacml.interfaces.RequestContext;
import org.jboss.security.xacml.interfaces.ResponseContext;
+import org.w3c.dom.Element;
/**
* Servlet that can read SOAP 1.1 messages that contain
@@ -78,21 +81,41 @@
String issuerId = null;
String issuer = null;
+
+ boolean debug = false;
public void init() throws ServletException
{
- issuerId = getServletContext().getInitParameter("issuerID");
+ ServletContext servletContext = getServletContext();
+ issuerId = servletContext.getInitParameter("issuerID");
if(issuerId == null)
issuerId = "issue-id:1";
- issuer = getServletContext().getInitParameter("issuer");
+ issuer = servletContext.getInitParameter("issuer");
if(issuer == null)
issuer = "urn:jboss-identity";
- policyConfigFileName =
getServletContext().getInitParameter("policyConfigFileName");
+ policyConfigFileName =
servletContext.getInitParameter("policyConfigFileName");
if(policyConfigFileName == null)
policyConfigFileName = "policyConfig.xml";
+ String debugStr = servletContext.getInitParameter("debug");
+ try
+ {
+ debug = Boolean.parseBoolean(debugStr);
+ }
+ catch(Exception ignore)
+ {
+ debug = false;
+ }
+
+ log.trace("PolicyConfig File:" + policyConfigFileName);
+ log.trace("Debug="+debug);
+
+ if(debug)
+ {
+ SecurityActions.setSystemProperty("jaxb.debug", "true");
+ }
super.init();
}
@@ -114,6 +137,9 @@
try
{
Unmarshaller un = SOAPSAMLXACMLUtil.getUnmarshaller();
+ if(debug)
+ un.setEventHandler(new DefaultValidationEventHandler());
+
Object unmarshalledObject = un.unmarshal(req.getInputStream());
if(unmarshalledObject instanceof JAXBElement)
@@ -124,8 +150,20 @@
{
envelope = (Envelope)element;
Body soapBody = envelope.getBody();
- jaxbRequestType =
(JAXBElement<RequestAbstractType>)soapBody.getAny().get(0);
- xacmlRequest = (XACMLAuthzDecisionQueryType) jaxbRequestType.getValue();
+ 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)
+ {
+ log.trace("Problem in the input file: Working on the
element.");
+ Element elem = (Element) samlRequest;
+ xacmlRequest = SOAPSAMLXACMLUtil.getWorkaround(elem);
+ }
}
else if(element instanceof XACMLAuthzDecisionQueryType)
{