Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 82909 invoked from network); 20 Jan 2009 05:18:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Jan 2009 05:18:24 -0000 Received: (qmail 62664 invoked by uid 500); 20 Jan 2009 05:18:24 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 62548 invoked by uid 500); 20 Jan 2009 05:18:23 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 62539 invoked by uid 500); 20 Jan 2009 05:18:23 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 62536 invoked by uid 99); 20 Jan 2009 05:18:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Jan 2009 21:18:23 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jan 2009 05:18:13 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CFDBB238898F; Mon, 19 Jan 2009 21:17:50 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r735934 - in /webservices/axis2/trunk/java/modules/mtompolicy-mar/src: META-INF/module.xml org/apache/axis2/mtompolicy/MTOMInHandler.java Date: Tue, 20 Jan 2009 05:17:50 -0000 To: axis2-cvs@ws.apache.org From: nandana@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090120051751.CFDBB238898F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. + + + + + - \ No newline at end of file + 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 list = (List) 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; + } + +}