cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dval...@apache.org
Subject svn commit: r980545 - /cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
Date Thu, 29 Jul 2010 19:28:03 GMT
Author: dvaleri
Date: Thu Jul 29 19:28:03 2010
New Revision: 980545

URL: http://svn.apache.org/viewvc?rev=980545&view=rev
Log:
[CXF-2664] Removing deprecated methods to support configuration with Spring.

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=980545&r1=980544&r2=980545&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
Thu Jul 29 19:28:03 2010
@@ -172,25 +172,27 @@ public class STSClient implements Config
         this.location = location;
     }
 
-    public void setPolicy(Policy policy) {
-        this.policy = policy;
-        if (algorithmSuite == null) {
-            Iterator i = policy.getAlternatives();
-            while (i.hasNext() && algorithmSuite == null) {
-                List<PolicyComponent> p = CastUtils.cast((List)i.next());
-                for (PolicyComponent p2 : p) {
-                    if (p2 instanceof Binding) {
-                        algorithmSuite = ((Binding)p2).getAlgorithmSuite();
-                    }
-                }
-            }
+    /**
+     * Sets the WS-P policy that is applied to communications between this client and the
remote server
+     * if no value is supplied for {@link #setWsdlLocation(String)}.
+     * <p/>
+     * Accepts {@link Policy} or {@link Element} as input.
+     *
+     * @param newPolicy the policy object
+     *
+     * @throws IllegalArgumentException if {@code newPolicy} is not one of the supported
types.
+     */
+    public void setPolicy(Object newPolicy) {
+        if (newPolicy instanceof Policy) {
+            this.setPolicyInternal((Policy) newPolicy);
+        } else if (newPolicy instanceof Element) {
+            this.setPolicyInternal((Element) newPolicy);    
+        } else {
+            throw new IllegalArgumentException("Unsupported policy object.  Type must be
"
+                       + "org.apache.neethi.Policy or org.w3c.dom.Element.");
         }
     }
 
-    public void setPolicy(Element policy) {
-        setPolicy(bus.getExtension(PolicyBuilder.class).getPolicy(policy));
-    }
-
     public void setSoap12() {
         soapVersion = SoapBindingConstants.SOAP12_BINDING_ID;
     }
@@ -287,6 +289,25 @@ public class STSClient implements Config
     public int getKeySize() {
         return keySize;
     }
+    
+    protected void setPolicyInternal(Policy newPolicy) {
+        this.policy = newPolicy;
+        if (algorithmSuite == null) {
+            Iterator i = policy.getAlternatives();
+            while (i.hasNext() && algorithmSuite == null) {
+                List<PolicyComponent> p = CastUtils.cast((List)i.next());
+                for (PolicyComponent p2 : p) {
+                    if (p2 instanceof Binding) {
+                        algorithmSuite = ((Binding)p2).getAlgorithmSuite();
+                    }
+                }
+            }
+        }
+    }
+    
+    protected void setPolicyInternal(Element newPolicy) {
+        this.setPolicyInternal(bus.getExtension(PolicyBuilder.class).getPolicy(newPolicy));
+    }
 
 
     private void createClient() throws BusException, EndpointException {
@@ -335,7 +356,7 @@ public class STSClient implements Config
                 Conduit conduit = client.getConduit();
                 EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(client.getEndpoint()
                     .getEndpointInfo(), boi, conduit);
-                setPolicy(effectivePolicy.getPolicy());
+                setPolicyInternal(effectivePolicy.getPolicy());
                 return boi;
             }
         }



Mime
View raw message