Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 35F8D64AF for ; Thu, 4 Aug 2011 10:56:35 +0000 (UTC) Received: (qmail 55945 invoked by uid 500); 4 Aug 2011 10:56:29 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 55820 invoked by uid 500); 4 Aug 2011 10:56:18 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 55802 invoked by uid 99); 4 Aug 2011 10:56:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2011 10:56:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Thu, 04 Aug 2011 10:56:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8B727238890D for ; Thu, 4 Aug 2011 10:55:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1153843 - /cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java Date: Thu, 04 Aug 2011 10:55:48 -0000 To: commits@cxf.apache.org From: coheigea@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110804105548.8B727238890D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: coheigea Date: Thu Aug 4 10:55:48 2011 New Revision: 1153843 URL: http://svn.apache.org/viewvc?rev=1153843&view=rev Log: Updating the STSProvider to support SOAP 1.2 faults. Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java?rev=1153843&r1=1153842&r2=1153843&view=diff ============================================================================== --- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java (original) +++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java Thu Aug 4 10:55:48 2011 @@ -32,18 +32,15 @@ import javax.xml.bind.JAXBElement; import javax.xml.bind.Unmarshaller; import javax.xml.bind.util.JAXBSource; import javax.xml.namespace.QName; -import javax.xml.soap.SOAPException; -import javax.xml.soap.SOAPFactory; -import javax.xml.soap.SOAPFault; import javax.xml.transform.Source; import javax.xml.ws.Provider; import javax.xml.ws.Service; import javax.xml.ws.ServiceMode; import javax.xml.ws.WebServiceContext; -import javax.xml.ws.soap.SOAPFaultException; +import javax.xml.ws.handler.MessageContext; -import org.apache.cxf.binding.soap.saaj.SAAJFactoryResolver; -import org.apache.cxf.interceptor.Fault; +import org.apache.cxf.binding.soap.SoapFault; +import org.apache.cxf.binding.soap.SoapVersion; import org.apache.cxf.jaxb.JAXBContextCache; import org.apache.cxf.jaxb.JAXBContextCache.CachedContextAndSchemas; import org.apache.cxf.ws.security.sts.provider.model.ObjectFactory; @@ -117,7 +114,6 @@ public class SecurityTokenServiceProvide protected JAXBContext jaxbContext; protected Set> jaxbContextClasses; - protected SOAPFactory soapFactory; private CancelOperation cancelOperation; private IssueOperation issueOperation; @@ -134,7 +130,6 @@ public class SecurityTokenServiceProvide CachedContextAndSchemas cache = JAXBContextCache.getCachedContextAndSchemas(ObjectFactory.class); jaxbContext = cache.getContext(); jaxbContextClasses = cache.getClasses(); - soapFactory = SAAJFactoryResolver.createSOAPFactory(null); } public void setCancelOperation(CancelOperation cancelOperation) { @@ -222,29 +217,18 @@ public class SecurityTokenServiceProvide } } catch (InvocationTargetException ex) { - try { - Throwable cause = ex.getCause(); - SOAPFault fault = createSOAPFault(cause); - throw new SOAPFaultException(fault); - } catch (SOAPException e1) { - throw new Fault(e1); - } + Throwable cause = ex.getCause(); + throw createSOAPFault(cause); } catch (Exception ex) { - try { - SOAPFault fault = createSOAPFault(ex); - throw new SOAPFaultException(fault); - } catch (SOAPException e1) { - throw new Fault(e1); - } + throw createSOAPFault(ex); } return response; } - private SOAPFault createSOAPFault(Throwable ex) throws SOAPException { - SOAPFault fault = soapFactory.createFault(); + private SoapFault createSOAPFault(Throwable ex) { String faultString = "Internal STS error"; - QName faultCode = fault.getFaultCodeAsQName(); + QName faultCode = null; if (ex != null) { if (ex instanceof STSException && ((STSException)ex).getFaultCode() != null) { @@ -252,8 +236,18 @@ public class SecurityTokenServiceProvide } faultString = ex.getMessage(); } - fault.setFaultString(faultString); - fault.setFaultCode(faultCode); + + MessageContext messageContext = context.getMessageContext(); + SoapVersion soapVersion = (SoapVersion)messageContext.get(SoapVersion.class.getName()); + SoapFault fault; + if (soapVersion.getVersion() == 1.1 && faultCode != null) { + fault = new SoapFault(faultString, faultCode); + } else { + fault = new SoapFault(faultString, soapVersion.getSender()); + if (soapVersion.getVersion() != 1.1 && faultCode != null) { + fault.setSubCode(faultCode); + } + } return fault; }