Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 71928 invoked from network); 17 Feb 2009 20:24:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Feb 2009 20:24:58 -0000 Received: (qmail 60990 invoked by uid 500); 17 Feb 2009 20:24:57 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 60933 invoked by uid 500); 17 Feb 2009 20:24:57 -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 60924 invoked by uid 99); 17 Feb 2009 20:24:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Feb 2009 12:24:57 -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, 17 Feb 2009 20:24:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6357B2388975; Tue, 17 Feb 2009 20:24:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r745227 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/staxutils/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/ Date: Tue, 17 Feb 2009 20:24:33 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090217202434.6357B2388975@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Tue Feb 17 20:24:33 2009 New Revision: 745227 URL: http://svn.apache.org/viewvc?rev=745227&view=rev Log: First WS-SecureConversation test endpoint works. :-) Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java?rev=745227&r1=745226&r2=745227&view=diff ============================================================================== --- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java (original) +++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java Tue Feb 17 20:24:33 2009 @@ -40,6 +40,7 @@ private Document document; private Element currentNode; private NamespaceContext context = new W3CNamespaceContext(); + private boolean nsRepairing; private Map properties = Collections.EMPTY_MAP; public W3CDOMStreamWriter() throws ParserConfigurationException { @@ -61,6 +62,12 @@ ((W3CNamespaceContext)context).setElement(e); } + public void setNsRepairing(boolean b) { + nsRepairing = b; + } + public boolean isNsRepairing() { + return nsRepairing; + } public void setProperties(Map properties) { this.properties = properties; } @@ -96,6 +103,10 @@ writeStartElement(namespace, local); } else { newChild(document.createElementNS(namespace, prefix + ":" + local)); + if (nsRepairing + && !prefix.equals(getNamespaceContext().getPrefix(namespace))) { + writeNamespace(prefix, namespace); + } } } @@ -138,6 +149,10 @@ Attr a = document.createAttributeNS(namespace, local); a.setValue(value); currentNode.setAttributeNodeNS(a); + if (nsRepairing + && !prefix.equals(getNamespaceContext().getPrefix(namespace))) { + writeNamespace(prefix, namespace); + } } public void writeAttribute(String namespace, String local, String value) throws XMLStreamException { Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java?rev=745227&r1=745226&r2=745227&view=diff ============================================================================== --- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java (original) +++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java Tue Feb 17 20:24:33 2009 @@ -477,9 +477,9 @@ throw new TrustException(new Message("NO_ID", LOG)); } - SecurityToken token = new SecurityToken(id, rst, lte); - token.setAttachedReference(rar); - token.setUnattachedReference(rur); + SecurityToken token = new SecurityToken(id, copyElement(rst), copyElement(lte)); + token.setAttachedReference(copyElement(rar)); + token.setUnattachedReference(copyElement(rur)); token.setIssuerAddress(location); @@ -541,7 +541,19 @@ return token; } - + private Element copyElement(Element el) { + if (el == null) { + return null; + } + try { + W3CDOMStreamWriter writer = new W3CDOMStreamWriter(); + writer.setNsRepairing(true); + StaxUtils.copy(el, writer); + return writer.getDocument().getDocumentElement(); + } catch (Exception ex) { + return el; + } + } private String findID(Element rar, Element rur, Element rst) { String id = null; if (rar != null) { Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java?rev=745227&r1=745226&r2=745227&view=diff ============================================================================== --- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java (original) +++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java Tue Feb 17 20:24:33 2009 @@ -360,7 +360,8 @@ WSPasswordCallback pc = (WSPasswordCallback)callbacks[i]; String id = pc.getIdentifier(); - if (pc.getKeyType().equals(SecurityTokenReference.ENC_KEY_SHA1_URI)) { + + if (SecurityTokenReference.ENC_KEY_SHA1_URI.equals(pc.getKeyType())) { for (SecurityToken token : store.getValidTokens()) { if (id.equals(token.getSHA1())) { pc.setKey(token.getSecret()); @@ -375,7 +376,9 @@ } } } - internal.handle(callbacks); + if (internal != null) { + internal.handle(callbacks); + } } } @@ -400,16 +403,26 @@ cbHandler = (CallbackHandler)o; } if (cbHandler == null) { - cbHandler = getPasswordCB(reqData); + try { + cbHandler = getPasswordCB(reqData); + } catch (WSSecurityException sec) { + Endpoint ep = ((SoapMessage)reqData.getMsgContext()).getExchange().get(Endpoint.class); + if (ep != null && ep.getEndpointInfo() != null) { + TokenStore store = (TokenStore)ep.getEndpointInfo() + .getProperty(TokenStore.class.getName()); + if (store != null) { + return new TokenStoreCallbackHandler(cbHandler, store); + } + } + throw sec; + } } } - if (cbHandler != null) { - Endpoint ep = ((SoapMessage)reqData.getMsgContext()).getExchange().get(Endpoint.class); - if (ep != null && ep.getEndpointInfo() != null) { - TokenStore store = (TokenStore)ep.getEndpointInfo().getProperty(TokenStore.class.getName()); - if (store != null) { - return new TokenStoreCallbackHandler(cbHandler, store); - } + Endpoint ep = ((SoapMessage)reqData.getMsgContext()).getExchange().get(Endpoint.class); + if (ep != null && ep.getEndpointInfo() != null) { + TokenStore store = (TokenStore)ep.getEndpointInfo().getProperty(TokenStore.class.getName()); + if (store != null) { + return new TokenStoreCallbackHandler(cbHandler, store); } } return cbHandler;