cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r466027 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/message/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/test/java/org/...
Date Fri, 20 Oct 2006 08:06:33 GMT
Author: ningjiang
Date: Fri Oct 20 01:06:29 2006
New Revision: 466027

URL: http://svn.apache.org/viewvc?view=rev&rev=466027
Log:
[CXF-162] Implemented Basic authentication client side

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java?view=diff&rev=466027&r1=466026&r2=466027
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java Fri Oct 20 01:06:29
2006
@@ -37,6 +37,8 @@
     
     String MIME_HEADERS = "org.apache.cxf.mime.headers";
     
+    String USERNAME = Message.class.getName() + ".USERNAME";
+    String PASSWORD = Message.class.getName() + ".PASSWORD";
     String PROTOCOL_HEADERS = Message.class.getName() + ".PROTOCOL_HEADERS";
     String RESPONSE_CODE = Message.class.getName() + ".RESPONSE_CODE";
     String ENDPOINT_ADDRESS = Message.class.getName() + ".ENDPOINT_ADDRESS";

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java?view=diff&rev=466027&r1=466026&r2=466027
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
Fri Oct 20 01:06:29 2006
@@ -38,6 +38,11 @@
     static {
         cxf2jaxwsMap.put(Message.ENDPOINT_ADDRESS, 
                           BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
+        cxf2jaxwsMap.put(Message.USERNAME,
+                          BindingProvider.USERNAME_PROPERTY);
+        cxf2jaxwsMap.put(Message.PASSWORD,
+                          BindingProvider.PASSWORD_PROPERTY);
+        
         cxf2jaxwsMap.put(Message.HTTP_REQUEST_METHOD,
                           MessageContext.HTTP_REQUEST_METHOD);
         cxf2jaxwsMap.put(Message.RESPONSE_CODE, 
@@ -49,6 +54,10 @@
         
         jaxws2cxfMap.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
                          Message.ENDPOINT_ADDRESS);
+        jaxws2cxfMap.put(BindingProvider.USERNAME_PROPERTY,
+                         Message.USERNAME);
+        jaxws2cxfMap.put(BindingProvider.PASSWORD_PROPERTY,
+                         Message.PASSWORD);
         jaxws2cxfMap.put(MessageContext.HTTP_REQUEST_METHOD,
                          Message.HTTP_REQUEST_METHOD);
         jaxws2cxfMap.put(MessageContext.HTTP_RESPONSE_CODE,

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?view=diff&rev=466027&r1=466026&r2=466027
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Fri Oct 20 01:06:29 2006
@@ -174,7 +174,11 @@
         URLConnection connection = 
             connectionFactory.createConnection(getProxy(), currentURL);
         connection.setDoOutput(true);        
-                       
+        //TODO using Message context to deceided HTTP send properties        
+        connection.setConnectTimeout((int)getClient().getConnectionTimeout());
+        connection.setReadTimeout((int)getClient().getReceiveTimeout());
+        connection.setUseCaches(false);
+        
         if (connection instanceof HttpURLConnection) {
             String httpRequestMethod = (String)message.get(Message.HTTP_REQUEST_METHOD);
             HttpURLConnection hc = (HttpURLConnection)connection;           
@@ -183,15 +187,6 @@
             } else {
                 hc.setRequestMethod("POST");
             }
-        }     
-      
-        //TODO using Message context to deceided HTTP send properties        
-        connection.setConnectTimeout((int)getClient().getConnectionTimeout());
-        connection.setReadTimeout((int)getClient().getReceiveTimeout());
-
-        connection.setUseCaches(false);
-        if (connection instanceof HttpURLConnection) {
-            HttpURLConnection hc = (HttpURLConnection)connection;
             if (getClient().isAutoRedirect()) {
                 //cannot use chunking if autoredirect as the request will need to be
                 //completely cached locally and resent to the redirect target
@@ -225,7 +220,8 @@
         }        
         return new URL(result);    
     }
-
+    
+   
     /**
      * @return the reference associated with the target Destination
      */    
@@ -636,9 +632,9 @@
     private void setPolicies(Message message, Map<String, List<String>> headers)
{
         AuthorizationPolicy authPolicy = getAuthorization();
         AuthorizationPolicy newPolicy = message.get(AuthorizationPolicy.class);
-        String userName = null;
-        String passwd = null;
-        if (null != newPolicy) {
+        String userName = (String)message.get(Message.USERNAME);
+        String passwd = (String)message.get(Message.PASSWORD);
+        if (null != newPolicy && null != userName) {
             userName = newPolicy.getUserName();
             passwd = newPolicy.getPassword();
         }

Modified: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java?view=diff&rev=466027&r1=466026&r2=466027
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
Fri Oct 20 01:06:29 2006
@@ -140,7 +140,9 @@
         contentTypes.add("text/xml");
         contentTypes.add("charset=utf8");
         headers.put("content-type", contentTypes);
-        message.put(Message.PROTOCOL_HEADERS, headers);
+        message.put(Message.PROTOCOL_HEADERS, headers);        
+        message.put(Message.USERNAME, "BJ");
+        message.put(Message.PASSWORD, "value");
     }
 
     private HTTPConduit setUpConduit(boolean send) throws Exception {
@@ -356,6 +358,9 @@
         
         message.put(HTTPConduit.HTTP_CONNECTION, connection);
         if (expectHeaders) {
+            connection.addRequestProperty(EasyMock.eq("Authorization"),
+                                          EasyMock.eq("Basic Qko6dmFsdWU="));           

+            EasyMock.expectLastCall();
             connection.addRequestProperty(EasyMock.eq("content-type"),
                                           EasyMock.eq("text/xml"));
             EasyMock.expectLastCall();



Mime
View raw message