You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by na...@apache.org on 2009/01/20 06:17:50 UTC
svn commit: r735934 - in
/webservices/axis2/trunk/java/modules/mtompolicy-mar/src:
META-INF/module.xml org/apache/axis2/mtompolicy/MTOMInHandler.java
Author: nandana
Date: Mon Jan 19 21:17:43 2009
New Revision: 735934
URL: http://svn.apache.org/viewvc?rev=735934&view=rev
Log:
adding a handler to do MTOM validation
Added:
webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMInHandler.java
Modified:
webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/module.xml
Modified: webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/module.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/module.xml?rev=735934&r1=735933&r2=735934&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/module.xml (original)
+++ webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/module.xml Mon Jan 19 21:17:43 2009
@@ -3,9 +3,14 @@
This is the MTOM policy module. It is engaged when we have MTOM policy assertion.
</Description>
<supported-policy-namespaces namespaces="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization http://www.w3.org/2007/08/soap12-mtom-policy"/>
+ <InFlow>
+ <handler name="MTOMInHandler" class="org.apache.axis2.mtompolicy.MTOMInHandler">
+ <order phase="PreDispatch"/>
+ </handler>
+ </InFlow>
<OutFlow>
<handler name="MTOMOutHandler" class="org.apache.axis2.mtompolicy.MTOMOutHandler">
<order phase="MessageOut"/>
</handler>
</OutFlow>
-</module>
\ No newline at end of file
+</module>
Added: webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMInHandler.java?rev=735934&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMInHandler.java (added)
+++ webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMInHandler.java Mon Jan 19 21:17:43 2009
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.axis2.mtompolicy;
+
+import java.util.List;
+
+import org.apache.axiom.om.impl.MTOMConstants;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.policy.model.MTOMAssertion;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+public class MTOMInHandler extends AbstractHandler {
+
+ public InvocationResponse invoke(MessageContext msgCtx) throws AxisFault {
+ Policy policy = msgCtx.getEffectivePolicy();
+ if (policy == null) {
+ return InvocationResponse.CONTINUE;
+ }
+ List<Assertion> list = (List<Assertion>) policy.getAlternatives()
+ .next();
+ for (Assertion assertion : list) {
+ if (assertion instanceof MTOMAssertion) {
+ String contentType = (String) msgCtx.getProperty(Constants.Configuration.CONTENT_TYPE);
+ if (!assertion.isOptional()) {
+ if (contentType == null || contentType.indexOf(MTOMConstants.MTOM_TYPE) == -1) {//!MTOMConstants.MTOM_TYPE.equals(contentType)
+ if (msgCtx.isServerSide()) {
+ throw new AxisFault(
+ "The SOAP REQUEST sent by the client IS NOT MTOMized!");
+ } else {
+ throw new AxisFault(
+ "The SOAP RESPONSE sent by the service IS NOT MTOMized!");
+ }
+ }
+ }
+ }
+ }
+ return InvocationResponse.CONTINUE;
+ }
+
+}