Author: dkulp
Date: Mon Apr 11 23:13:14 2011
New Revision: 1091253
URL: http://svn.apache.org/viewvc?rev=1091253&view=rev
Log:
[CXF-3453] Create a complete hack to ignore validation errors that would
occur with wsu:ID attributes when security is enabled.
Modified:
cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
Modified:
cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java?rev=1091253&r1=1091252&r2=1091253&view=diff
==============================================================================
---
cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
(original)
+++
cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
Mon Apr 11 23:13:14 2011
@@ -27,6 +27,7 @@ import java.util.logging.Logger;
import javax.xml.bind.JAXBException;
import javax.xml.bind.PropertyException;
import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.namespace.QName;
@@ -56,6 +57,24 @@ public class DataReaderImpl<T> extends J
public Object read(T input) {
return read(null, input);
}
+
+ private static class WSUIDValidationHandler implements
ValidationEventHandler {
+ ValidationEventHandler origHandler;
+ WSUIDValidationHandler(ValidationEventHandler o) {
+ origHandler = o;
+ }
+
+ public boolean handleEvent(ValidationEvent event) {
+ String msg = event.getMessage();
+ if (msg.startsWith("cvc-type.3.1.1: ") && msg.contains(":Id")) {
+ return true;
+ }
+ if (origHandler != null) {
+ return origHandler.handleEvent(event);
+ }
+ return false;
+ }
+ }
public void setProperty(String prop, Object value) {
if (prop.equals(JAXBDataBinding.UNWRAP_JAXB_ELEMENT)) {
unwrapJAXBElement = Boolean.TRUE.equals(value);
@@ -84,7 +103,7 @@ public class DataReaderImpl<T> extends J
um.setListener(databinding.getUnmarshallerListener());
}
if (setEventHandler) {
- um.setEventHandler(veventHandler);
+ um.setEventHandler(new WSUIDValidationHandler(veventHandler));
}
if (databinding.getUnmarshallerProperties() != null) {
for (Map.Entry<String, Object> propEntry
Modified:
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java?rev=1091253&r1=1091252&r2=1091253&view=diff
==============================================================================
---
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
(original)
+++
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
Mon Apr 11 23:13:14 2011
@@ -54,6 +54,7 @@ import org.apache.cxf.helpers.XPathUtils
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.message.Message;
import org.apache.cxf.policytest.doubleit.DoubleIt;
import org.apache.cxf.policytest.doubleit.DoubleItFault_Exception;
import org.apache.cxf.policytest.doubleit.DoubleItPortType;
@@ -204,7 +205,7 @@ public class SecurityPolicyTest extends
SecurityPolicyTest.class.getResource("alice.properties").toString());
ei.setProperty(SecurityConstants.ENCRYPT_PROPERTIES,
SecurityPolicyTest.class.getResource("alice.properties").toString());
-
+ ei.setProperty(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
}
@Test