From commits-return-13968-apmail-cxf-commits-archive=cxf.apache.org@cxf.apache.org Wed Feb 23 10:54:45 2011 Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 33985 invoked from network); 23 Feb 2011 10:54:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Feb 2011 10:54:45 -0000 Received: (qmail 89586 invoked by uid 500); 23 Feb 2011 10:54:45 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 89458 invoked by uid 500); 23 Feb 2011 10:54:42 -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 89450 invoked by uid 99); 23 Feb 2011 10:54:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Feb 2011 10:54:41 +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; Wed, 23 Feb 2011 10:54:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5680023889D7; Wed, 23 Feb 2011 10:54:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1073693 - /cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java Date: Wed, 23 Feb 2011 10:54:15 -0000 To: commits@cxf.apache.org From: coheigea@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110223105415.5680023889D7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: coheigea Date: Wed Feb 23 10:54:14 2011 New Revision: 1073693 URL: http://svn.apache.org/viewvc?rev=1073693&view=rev Log: [CXF-3348] - Applied patch, thanks - I made some minor changes, in that the TokenType from the Template element gets priority over the set TokenType. Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java 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=1073693&r1=1073692&r2=1073693&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 Wed Feb 23 10:54:14 2011 @@ -145,6 +145,7 @@ public class STSClient implements Config int ttl = 300; Object actAs; + String tokenType; Map ctx = new HashMap(); @@ -292,7 +293,11 @@ public class STSClient implements Config public int getKeySize() { return keySize; } - + + public void setTokenType(String tokenType) { + this.tokenType = tokenType; + } + /** * Indicate whether to use the signer's public X509 certificate for the subject confirmation key info * when creating a RequestsSecurityToken message. If the property is set to 'false', only the public key @@ -423,7 +428,7 @@ public class STSClient implements Config boolean wroteKeySize = false; String keyType = null; - String tokenType = null; + String sptt = null; if (template != null) { if (this.useSecondaryParameters()) { @@ -439,7 +444,7 @@ public class STSClient implements Config wroteKeySize = true; keySize = Integer.parseInt(DOMUtils.getContent(tl)); } else if ("TokenType".equals(tl.getLocalName())) { - tokenType = DOMUtils.getContent(tl); + sptt = DOMUtils.getContent(tl); } tl = DOMUtils.getNextElement(tl); } @@ -451,6 +456,9 @@ public class STSClient implements Config addRequestType(requestType, writer); addAppliesTo(writer, appliesTo); + if (sptt == null) { + addTokenType(writer); + } keyType = writeKeyType(writer, keyType); byte[] requestorEntropy = null; @@ -488,8 +496,12 @@ public class STSClient implements Config if (cert != null) { token.setX509Certificate(cert, crypto); } - if (tokenType != null) { - token.setTokenType(tokenType); + if (token.getTokenType() == null) { + if (sptt != null) { + token.setTokenType(sptt); + } else if (tokenType != null) { + token.setTokenType(tokenType); + } } return token; } @@ -809,7 +821,15 @@ public class STSClient implements Config writer.writeEndElement(); } } - + + private void addTokenType(XMLStreamWriter writer) throws XMLStreamException { + if (tokenType != null) { + writer.writeStartElement("wst", "TokenType", namespace); + writer.writeCharacters(tokenType); + writer.writeEndElement(); + } + } + private void addActAs(W3CDOMStreamWriter writer) throws Exception { if (this.actAs != null) { final boolean isString = this.actAs instanceof String; @@ -855,6 +875,7 @@ public class STSClient implements Config Element rpt = null; Element lte = null; Element entropy = null; + String tt = null; while (el != null) { String ln = el.getLocalName(); @@ -871,6 +892,8 @@ public class STSClient implements Config rpt = el; } else if ("Entropy".equals(ln)) { entropy = el; + } else if ("TokenType".equals(ln)) { + tt = DOMUtils.getContent(el); } } el = DOMUtils.getNextElement(el); @@ -884,6 +907,7 @@ public class STSClient implements Config token.setAttachedReference(rar); token.setUnattachedReference(rur); token.setIssuerAddress(location); + token.setTokenType(tt); byte[] secret = null;