You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2011/02/23 12:06:56 UTC

svn commit: r1073700 - in /cxf/branches/2.3.x-fixes/rt/ws/security: ./ src/main/java/org/apache/cxf/ws/security/trust/STSClient.java

Author: coheigea
Date: Wed Feb 23 11:06:56 2011
New Revision: 1073700

URL: http://svn.apache.org/viewvc?rev=1073700&view=rev
Log:
[CXF-3348] - Merged to 2.3.x-fixes.

Modified:
    cxf/branches/2.3.x-fixes/rt/ws/security/   (props changed)
    cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java

Propchange: cxf/branches/2.3.x-fixes/rt/ws/security/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk/rt/ws/security:1072736,1073651,1073693

Modified: cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java?rev=1073700&r1=1073699&r2=1073700&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java (original)
+++ cxf/branches/2.3.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java Wed Feb 23 11:06:56 2011
@@ -146,6 +146,7 @@ public class STSClient implements Config
     int ttl = 300;
     
     Object actAs;
+    String tokenType;
 
     Map<String, Object> ctx = new HashMap<String, Object>();
     
@@ -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,6 +428,7 @@ public class STSClient implements Config
         boolean wroteKeySize = false;
         
         String keyType = null;
+        String sptt = null;
         
         if (template != null) {
             if (this.useSecondaryParameters()) {
@@ -437,6 +443,8 @@ public class STSClient implements Config
                 } else if ("KeySize".equals(tl.getLocalName())) {
                     wroteKeySize = true;
                     keySize = Integer.parseInt(DOMUtils.getContent(tl));
+                } else if ("TokenType".equals(tl.getLocalName())) {
+                    sptt = DOMUtils.getContent(tl);
                 }
                 tl = DOMUtils.getNextElement(tl);
             }
@@ -448,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;
@@ -485,6 +496,13 @@ public class STSClient implements Config
         if (cert != null) {
             token.setX509Certificate(cert, crypto);
         }
+        if (token.getTokenType() == null) {
+            if (sptt != null) {
+                token.setTokenType(sptt);
+            } else if (tokenType != null) {
+                token.setTokenType(tokenType);
+            }
+        }
         return token;
     }
     
@@ -801,7 +819,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;
@@ -847,6 +873,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();
@@ -863,6 +890,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);
@@ -876,6 +905,7 @@ public class STSClient implements Config
         token.setAttachedReference(rar);
         token.setUnattachedReference(rur);
         token.setIssuerAddress(location);
+        token.setTokenType(tt);
 
         byte[] secret = null;