Author: anil.saldhana(a)jboss.com
Date: 2009-03-17 11:43:56 -0400 (Tue, 17 Mar 2009)
New Revision: 372
Modified:
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java
Log:
workaround method
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-17
15:43:03 UTC (rev 371)
+++
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/SOAPSAMLXACMLUtil.java 2009-03-17
15:43:56 UTC (rev 372)
@@ -21,13 +21,19 @@
*/
package org.jboss.identity.federation.core.saml.v2.util;
+import java.io.StringReader;
+
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
+import org.apache.log4j.Logger;
import org.jboss.identity.federation.saml.v2.profiles.xacml.assertion.ObjectFactory;
import
org.jboss.identity.federation.saml.v2.profiles.xacml.assertion.XACMLAuthzDecisionStatementType;
+import
org.jboss.identity.federation.saml.v2.profiles.xacml.protocol.XACMLAuthzDecisionQueryType;
+import org.w3c.dom.Element;
/**
* Utility associated with SOAP 1.1 Envelope,
@@ -37,6 +43,8 @@
*/
public class SOAPSAMLXACMLUtil
{
+ private static Logger log = Logger.getLogger(SOAPSAMLXACMLUtil.class);
+
private static String SOAP_PKG =
"org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope";
private static String SAML_PROTO_PKG =
"org.jboss.identity.federation.saml.v2.protocol";
private static String XACML_CTX_PKG =
"org.jboss.security.xacml.core.model.context";
@@ -54,11 +62,28 @@
}
public static Unmarshaller getUnmarshaller() throws JAXBException
{
- JAXBContext jaxb = JAXBContext.newInstance(collectivePackage);
- Unmarshaller un = jaxb.createUnmarshaller();
+ JAXBContext jaxb = JAXBContext.newInstance(collectivePackage);
+ Unmarshaller un = jaxb.createUnmarshaller();
return un;
}
+ /**
+ * When the input xacml request has issues, try to work around
+ * @param element
+ * @return
+ * @throws Exception
+ */
+ public static XACMLAuthzDecisionQueryType getWorkaround(Element element) 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();
+ }
+
public static XACMLAuthzDecisionStatementType createXACMLAuthzDecisionStatementType()
{
ObjectFactory of = new ObjectFactory();
Show replies by date