Author: anil.saldhana(a)jboss.com
Date: 2009-03-21 22:51:39 -0400 (Sat, 21 Mar 2009)
New Revision: 393
Modified:
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java
Log:
parse the xacml query
Modified:
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java
===================================================================
---
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java 2009-03-20
13:57:54 UTC (rev 392)
+++
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java 2009-03-22
02:51:39 UTC (rev 393)
@@ -68,20 +68,23 @@
}
/**
- * When the input xacml request has issues, try to work around
- * @param element
+ * Parse the XACML Authorization Decision Query from the Dom Element
+ * @param samlRequest
* @return
* @throws Exception
*/
- public static XACMLAuthzDecisionQueryType getWorkaround(Element element) throws
Exception
+ public static XACMLAuthzDecisionQueryType getXACMLQueryType(Element samlRequest)
throws Exception
{
- String str = DocumentUtil.getDOMElementAsString(element);
- str = str.replaceFirst(":XACMLAuthzDecisionQuery",
":XACMLAuthzDecisionQueryType");
- str = str.replaceFirst("xacml-context:Request",
"xacml-context:Request
xmlns=\"urn:oasis:names:tc:xacml:2.0:context:schema:os\"" );
- log.trace("Updated Element="+str);
- //Reparse
- JAXBElement<?> jx = (JAXBElement<?>) getUnmarshaller().unmarshal(new
StringReader(str));
- return (XACMLAuthzDecisionQueryType) jx.getValue();
+ //We reparse it because the document may have issues with namespaces
+ String elementString = DocumentUtil.getDOMElementAsString(samlRequest);
+ Unmarshaller um = SOAPSAMLXACMLUtil.getUnmarshaller();
+ um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
+
+ JAXBElement<?> obj = (JAXBElement<?>) um.unmarshal(new
StringReader(elementString));
+ Object xacmlObject = obj.getValue();
+ if(xacmlObject instanceof XACMLAuthzDecisionQueryType == false)
+ throw new RuntimeException("Unsupported type:" + xacmlObject);
+ return (XACMLAuthzDecisionQueryType)xacmlObject;
}
public static XACMLAuthzDecisionStatementType createXACMLAuthzDecisionStatementType()