cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/3] cxf git commit: Add a way to the STSClient to send custom content in the RST
Date Tue, 24 Jan 2017 12:38:59 GMT
Repository: cxf
Updated Branches:
  refs/heads/master f8cec430e -> 306b878d2


Add a way to the STSClient to send custom content in the RST


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/a3120a0d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a3120a0d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a3120a0d

Branch: refs/heads/master
Commit: a3120a0d381e8f71ca1ae66d957aa42974ef129a
Parents: f8cec43
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue Jan 24 10:11:01 2017 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue Jan 24 10:11:30 2017 +0000

----------------------------------------------------------------------
 .../ws/security/trust/AbstractSTSClient.java    | 51 +++++++++++++++-----
 1 file changed, 39 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a3120a0d/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java
index f91d539..a32b145 100755
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java
@@ -166,6 +166,7 @@ public abstract class AbstractSTSClient implements Configurable, InterceptorProv
     protected int keySize = 256;
     protected boolean requiresEntropy = true;
     protected Element template;
+    protected Object customContent;
     protected Object claims;
     protected CallbackHandler claimsCallbackHandler;
     protected AlgorithmSuite algorithmSuite;
@@ -395,6 +396,10 @@ public abstract class AbstractSTSClient implements Configurable, InterceptorProv
         this.actAs = actAs;
     }
     
+    public void setCustomContent(Object customContent) {
+        this.customContent = customContent;
+    }
+    
     public void setKeySize(int i) {
         keySize = i;
     }
@@ -846,6 +851,11 @@ public abstract class AbstractSTSClient implements Configurable, InterceptorProv
         // Write out renewal semantics
         writeRenewalSemantics(writer);
         
+        Element customElement = getCustomContent();
+        if (customElement != null) {
+            StaxUtils.copy(customElement, writer);
+        }
+        
         writer.writeEndElement();
 
         Object obj[] = client.invoke(boi, new DOMSource(writer.getDocument().getDocumentElement()));
@@ -867,23 +877,40 @@ public abstract class AbstractSTSClient implements Configurable, InterceptorProv
         return getDelegationSecurityToken(this.actAs);
     }
     
+    /**
+     * Get some custom Element to be inserted into the RequestSecurityToken
+     */
+    public Element getCustomContent() throws Exception {
+        if (customContent != null) {
+            // We can also support a CallbackHandler her as per getDelegationSecurityToken
if required
+            final boolean isString = customContent instanceof String;
+            final boolean isElement = customContent instanceof Element; 
+            if (isString) {
+                final Document doc =
+                    StaxUtils.read(new StringReader((String) customContent));
+                return doc.getDocumentElement();
+            } else if (isElement) {
+                return (Element) customContent;
+            }
+        }
+        return null;
+    }
+    
     protected Element getDelegationSecurityToken(Object delegationObject) throws Exception
{
         if (delegationObject != null) {
             final boolean isString = delegationObject instanceof String;
             final boolean isElement = delegationObject instanceof Element; 
             final boolean isCallbackHandler = delegationObject instanceof CallbackHandler;
-            if (isString || isElement || isCallbackHandler) {
-                if (isString) {
-                    final Document doc =
-                        StaxUtils.read(new StringReader((String) delegationObject));
-                    return doc.getDocumentElement();
-                } else if (isElement) {
-                    return (Element) delegationObject;
-                } else {
-                    DelegationCallback callback = new DelegationCallback(message);
-                    ((CallbackHandler)delegationObject).handle(new Callback[]{callback});
-                    return callback.getToken();
-                }
+            if (isString) {
+                final Document doc =
+                    StaxUtils.read(new StringReader((String) delegationObject));
+                return doc.getDocumentElement();
+            } else if (isElement) {
+                return (Element) delegationObject;
+            } else if (isCallbackHandler) {
+                DelegationCallback callback = new DelegationCallback(message);
+                ((CallbackHandler)delegationObject).handle(new Callback[]{callback});
+                return callback.getToken();
             }
         }
         return null;


Mime
View raw message