You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/09/30 12:45:01 UTC
svn commit: r451576 - in
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http:
AbstractHTTPSender.java HTTPConstants.java HttpTransportProperties.java
SOAPOverHTTPSender.java
Author: saminda
Date: Sat Sep 30 03:45:01 2006
New Revision: 451576
URL: http://svn.apache.org/viewvc?view=rev&rev=451576
Log:
Cleaned up the transport auth handling as per discussion had with Dims.
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/HTTPConstants.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HttpTransportProperties.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.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=451576&r1=451575&r2=451576
==============================================================================
--- 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 Sat Sep 30 03:45:01 2006
@@ -28,18 +28,7 @@
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.util.JavaUtils;
import org.apache.axis2.util.Utils;
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HeaderElement;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NTCredentials;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthPolicy;
+import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -51,7 +40,6 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.List;
import java.util.zip.GZIPInputStream;
public abstract class AbstractHTTPSender {
@@ -70,6 +58,12 @@
protected OMOutputFormat format = new OMOutputFormat();
int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT;
+ /**
+ * isAuthenticationEnabled will be used as a flag to check whether
+ * authentication is enabled or not.
+ */
+ protected boolean isAuthenticationEnabled = false;
+
public void setChunked(boolean chunked) {
this.chunked = chunked;
}
@@ -303,7 +297,7 @@
boolean isHostProxy = isProxyListed(msgCtx); // list the proxy
- boolean authenticationEnabled = isAuthenticationEnabled(msgCtx);
+ isAuthenticationEnabled = isAuthenticationEnabled(msgCtx);
int port = targetURL.getPort();
if (port == -1) {
@@ -313,7 +307,7 @@
// to see the host is a proxy and in the proxy list - available in axis2.xml
HostConfiguration config = new HostConfiguration();
- if (authenticationEnabled) {
+ if (isAuthenticationEnabled) {
// premtive authentication Basic or NTLM
this.setAuthenticationInfo(client, msgCtx, config, targetURL);
}
@@ -374,31 +368,6 @@
/*Credentials only for Digest and Basic Authentication*/
creds = new UsernamePasswordCredentials(username, password);
agent.getState().setCredentials(new AuthScope(AuthScope.ANY), creds);
- }
-
- List schemes = authenticator.getAuthSchemes();
- if (schemes != null && schemes.size() > 0) {
- List authPrefs = new ArrayList(3);
- for (int i = 0; i < schemes.size(); i++) {
- if (schemes.get(i) instanceof AuthPolicy) {
- authPrefs.add(schemes.get(i));
- continue;
- }
- String scheme = (String) schemes.get(i);
- if (HttpTransportProperties.Authenticator.BASIC.equals(scheme)) {
- authPrefs.add(AuthPolicy.BASIC);
- } else if (HttpTransportProperties.Authenticator.NTLM.equals(scheme)) {
- authPrefs.add(AuthPolicy.NTLM);
- } else if (HttpTransportProperties.Authenticator.DIGEST.equals(scheme)) {
- authPrefs.add(AuthPolicy.DIGEST);
- }
- }
- // If it is NTLM, then definitely switch on the RETRY flag.
- if (authPrefs.indexOf(AuthPolicy.NTLM) != -1) {
- msgCtx.setProperty(HTTPConstants.ALLOW_RETRY, Boolean.TRUE);
- }
- agent.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
- authPrefs);
}
} else {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java?view=diff&rev=451576&r1=451575&r2=451576
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java Sat Sep 30 03:45:01 2006
@@ -379,8 +379,6 @@
public static final String MAIL_POP3 = "_MAIL_POP3_";
public static final String AUTHENTICATE = "_NTLM_DIGEST_BASIC_AUTHENTICATION_";
public static final String MTOM_RECEIVED_CONTENT_TYPE = "MTOM_RECEIVED";
- public static final String ALLOW_RETRY = "_ALLOW_RETRY_";
-
/**
* Field ISE[]
*/
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=451576&r1=451575&r2=451576
==============================================================================
--- 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 Sat Sep 30 03:45:01 2006
@@ -20,7 +20,6 @@
import org.apache.commons.httpclient.auth.AuthScope;
import java.util.Properties;
-import java.util.List;
/**
* Utility bean for setting transport properties in runtime.
*/
@@ -137,12 +136,9 @@
private String username;
/*Password of the user for authenticate*/
private String password;
- private List authSchemes;
+ /* Switch to use preemptive authentication or not*/
private boolean preempt = true;
-
- public static final java.lang.String NTLM = "NTLM";
- public static final java.lang.String DIGEST = "Digest";
- public static final java.lang.String BASIC = "Basic";
+ /* Note: Registering a custom AuthPolicy yet to be given */
public String getHost() {
return host;
@@ -184,14 +180,6 @@
this.password = password;
}
- public void setAuthSchemes(List authSchemes) {
- this.authSchemes = authSchemes;
- }
-
- public List getAuthSchemes() {
- return this.authSchemes;
- }
-
public void setPreemptiveAuthentication(boolean preempt) {
this.preempt = preempt;
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java?view=diff&rev=451576&r1=451575&r2=451576
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java Sat Sep 30 03:45:01 2006
@@ -174,14 +174,14 @@
if (!doingMTOM & doingSWA) {
StringWriter bufferedSOAPBody = new StringWriter();
- if (msgCtxt.getProperty(HTTPConstants.ALLOW_RETRY) != null) {
+ if (isAuthenticationEnabled) {
element.serialize(bufferedSOAPBody, format);
} else {
element.serializeAndConsume(bufferedSOAPBody, format);
}
MIMEOutputUtils.writeSOAPWithAttachmentsMessage(bufferedSOAPBody,out,msgCtxt.getAttachmentMap(), format);
} else {
- if (msgCtxt.getProperty(HTTPConstants.ALLOW_RETRY) != null) {
+ if (isAuthenticationEnabled) {
element.serialize(out, format);
} else {
element.serializeAndConsume(out, format);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org