You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2006/09/14 08:52:59 UTC

svn commit: r443266 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http: AbstractHTTPSender.java HttpTransportProperties.java

Author: saminda
Date: Wed Sep 13 23:52:59 2006
New Revision: 443266

URL: http://svn.apache.org/viewvc?view=rev&rev=443266
Log:
Improvements to Authentication support based on comments from 
commons-httpclient dev list. 
developer 

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HttpTransportProperties.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?view=diff&rev=443266&r1=443265&r2=443266
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Wed Sep 13 23:52:59 2006
@@ -339,28 +339,31 @@
         if (obj != null) {
             if (obj instanceof HttpTransportProperties.Authenticator) {
                 authenticator = (HttpTransportProperties.Authenticator) obj;
+
                 String username = authenticator.getUsername();
                 String password = authenticator.getPassword();
                 String host = authenticator.getHost();
-                String realm = authenticator.getRealm();
+                String domain = authenticator.getDomain();
+
                 int port = authenticator.getPort();
+                String realm = authenticator.getRealm();
 
                 Credentials creds;
 
-                if (host == null && realm == null && port == -1) {
-                    creds = new UsernamePasswordCredentials(username,password);
-                    agent.getState().setCredentials(new AuthScope(AuthScope.ANY), creds);
-                } else if (host != null && port == -1 && realm != null) {
-                    creds = new NTCredentials(username, password, host, realm);
-                    agent.getState().setCredentials(new AuthScope(host, AuthScope.ANY_PORT), creds);
-                } else if (host != null && port > -1 && realm != null) {
-                    creds = new NTCredentials(username, password, host, realm);
+                if (host != null) {
+                    if (domain != null) {
+                        /*Credentials for NTLM Authentication*/
+                        creds = new NTCredentials(username, password, host, domain);
+                    } else {
+                        /*Credentials for Digest and Basic Authentication*/
+                        creds = new UsernamePasswordCredentials(username, password);
+                    }
                     agent.getState().setCredentials(new AuthScope(host, port, realm), creds);
                 } else {
-                    throw new AxisFault("Credential setting is not valid");
+                    /*Credentials only for Digest and Basic Authentication*/
+                    creds = new UsernamePasswordCredentials(username, password);
+                    agent.getState().setCredentials(new AuthScope(AuthScope.ANY), creds);
                 }
-
-
             } else {
                 throw new AxisFault("HttpTransportProperties.Authenticator class cast exception");
             }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HttpTransportProperties.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HttpTransportProperties.java?view=diff&rev=443266&r1=443265&r2=443266
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HttpTransportProperties.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HttpTransportProperties.java Wed Sep 13 23:52:59 2006
@@ -17,6 +17,7 @@
  */
 
 import org.apache.commons.httpclient.HttpVersion;
+import org.apache.commons.httpclient.auth.AuthScope;
 
 import java.util.Properties;
 
@@ -124,10 +125,17 @@
     patterns.
     */
     public static class Authenticator{
+        /*host that needed to be authenticated with*/
         private String host;
-        private int port = -1;
-        private String realm;
+        /*port of the host that needed to be authenticated with*/
+        private int port = AuthScope.ANY_PORT;
+        /*Realm for authentication scope*/
+        private String realm = AuthScope.ANY_REALM;
+        /*Domain needed by NTCredentials for NT Domain*/
+        private String domain;
+        /*User for authenticate*/
         private String username;
+        /*Password of the user for authenticate*/
         private String password;
 
         public String getHost() {
@@ -168,6 +176,14 @@
 
         public void setPassword(String password) {
             this.password = password;
+        }
+
+        public String getDomain() {
+            return domain;
+        }
+
+        public void setDomain(String domain) {
+            this.domain = domain;
         }
     }
     public static class MailProperties{



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org