You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Laura Werner <la...@lwerner.org> on 2003/05/09 02:32:47 UTC
[PATCH] Add HostConfiguration.set/getLocalAddress
Here's a patch that adds setLocalAddress(InetAddress) and
getLocalAddress methods to HostConfiguration. I added localAddress
fields to both HostConfiguration and HttpConnection, and
HttpConnection.open uses the local address if it's non-null.
Feedback is welcome. In particular, I wasn't sure how much to expose
the local address in HttpConnection. Right now, the only way to tell a
connection to use a special local address is to construct the
HttpConnection with a HostConfiguration that has the local address set;
there's no additional HttpConnection constructor that takes a local
address. Also, I had to add a getLocalAddress method to HttpConnection
so that HostConfiguration.equals would work, but I decided to leave it
with package access to minimize API disturbance. I'm not wedded to
either of those decisions.
Here's the patch. I haven't done a lot of testing on it yet, but it
seems to work and I wanted to get feedback ASAP.
Index: org/apache/commons/httpclient/HostConfiguration.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HostConfiguration.java,v
retrieving revision 1.10
diff -u -r1.10 HostConfiguration.java
--- org/apache/commons/httpclient/HostConfiguration.java 19 Apr 2003
22:29:31 -0000 1.10
+++ org/apache/commons/httpclient/HostConfiguration.java 9 May 2003
00:26:43 -0000
@@ -65,6 +65,8 @@
import org.apache.commons.httpclient.protocol.Protocol;
+import java.net.InetAddress;
+
/**
*
* @author <a href="mailto:becke@u.washington.edu">Michael Becke</a>
@@ -98,6 +100,9 @@
/** True if a proxy server has been set */
private boolean proxySet;
+ /** The local address to use when creating the socket, or null to
use the default */
+ private InetAddress localAddress;
+
/**
* Constructor for HostConfiguration.
*/
@@ -112,7 +117,7 @@
this.proxyHost = null;
this.proxyPort = -1;
this.proxySet = false;
-
+ this.localAddress = null;
}
/**
@@ -134,6 +139,7 @@
this.proxyHost = hostConfiguration.getProxyHost();
this.proxyPort = hostConfiguration.getProxyPort();
this.proxySet = hostConfiguration.isProxySet();
+ this.localAddress = hostConfiguration.getLocalAddress();
}
}
@@ -177,6 +183,15 @@
if (!this.protocol.equals(connection.getProtocol())) {
return false;
}
+ if (this.localAddress != null) {
+ if
(!this.localAddress.equals(connection.getLocalAddress())) {
+ return false;
+ }
+ } else {
+ if (connection.getLocalAddress() != null) {
+ return false;
+ }
+ }
return true;
} else {
return false;
@@ -388,6 +403,25 @@
return proxyPort;
}
+ /**
+ * Set the local address to be used when creating connections.
+ * If this is unset, the default address will be used.
+ * This is useful for specifying the interface to use on
multi-homed or clustered systems.
+ */
+ public synchronized void setLocalAddress(InetAddress localAddress) {
+ this.localAddress = localAddress;
+ }
+
+ /**
+ * Return the local address to be used when creating connections.
+ * If this is unset, the default address should be used.
+ *
+ * @return InetAddress the local address to be used when creating
Sockets
+ */
+ public synchronized InetAddress getLocalAddress() {
+ return this.localAddress;
+ }
+
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
Index: org/apache/commons/httpclient/HttpConnection.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v
retrieving revision 1.65
diff -u -r1.65 HttpConnection.java
--- org/apache/commons/httpclient/HttpConnection.java 8 May 2003
17:33:51 -0000 1.65
+++ org/apache/commons/httpclient/HttpConnection.java 9 May 2003
00:26:43 -0000
@@ -70,6 +70,7 @@
import java.io.OutputStream;
import java.io.PushbackInputStream;
import java.lang.reflect.Method;
+import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketException;
@@ -217,6 +218,7 @@
hostConfiguration.getVirtualHost(),
hostConfiguration.getPort(),
hostConfiguration.getProtocol());
+ this.localAddress = hostConfiguration.getLocalAddress();
}
/**
@@ -446,6 +448,17 @@
}
/**
+ * Return the local address to be used when creating connections.
+ * If this is unset, the default address should be used.
+ *
+ * @return InetAddress the local address to be used when creating
Sockets
+ */
+ InetAddress getLocalAddress() {
+ return this.localAddress;
+ }
+
+
+ /**
* Return <tt>true</tt> if I am connected,
* <tt>false</tt> otherwise.
*
@@ -636,11 +649,19 @@
: protocolInUse.getSocketFactory());
if (connectTimeout == 0) {
- socket = socketFactory.createSocket(host, port);
+ if (localAddress != null) {
+ socket = socketFactory.createSocket(host, port,
localAddress, 0);
+ } else {
+ socket = socketFactory.createSocket(host, port);
+ }
} else {
SocketTask task = new SocketTask() {
public void doit() throws IOException {
- setSocket(socketFactory.createSocket(host,
port));
+ if (localAddress != null) {
+
setSocket(socketFactory.createSocket(host, port, localAddress, 0));
+ } else {
+
setSocket(socketFactory.createSocket(host, port));
+ }
}
};
TimeoutController.execute(task, connectTimeout);
@@ -1394,4 +1415,7 @@
/** the connection manager that created this connection or null */
private HttpConnectionManager httpConnectionManager;
+
+ /** The local interface on which the connection was created, or
null for the default */
+ private InetAddress localAddress;
}
Re: [PATCH] Add HostConfiguration.set/getLocalAddress
Posted by Michael Becke <be...@u.washington.edu>.
Looks good. I just realized that this is option 2. I missed the first
option in your original email. Not that it really matters, but in my
previous emails when I was talking about option 1 I meant what you have
done:)
A few comments:
- SimpleHttpConnectionManager will need to be changed to use the
HttpConnection(HostConfiguration) constructor. It will also need to
create a new connection when the current connection's hostConfig does
not match (or we could add HttpConnection.setLocalAddress()).
- HttpClient.executeMethod() needs to add the default localAddress to
the method's hostConfig, if appropriate, similar to how the default
host/proxy are handled.
- HostConfiguration.equals() will need to take localAddress into
account.
I'm fine with not adding a new localAddress constructor to
HttpConnection. Using a host config should be enough. I would prefer
to have a public getter and setting though, just to be consistent with
the other host-related properties.
Mike
On Thursday, May 8, 2003, at 08:32 PM, Laura Werner wrote:
> Here's a patch that adds setLocalAddress(InetAddress) and
> getLocalAddress methods to HostConfiguration. I added localAddress
> fields to both HostConfiguration and HttpConnection, and
> HttpConnection.open uses the local address if it's non-null.
>
> Feedback is welcome. In particular, I wasn't sure how much to expose
> the local address in HttpConnection. Right now, the only way to tell
> a connection to use a special local address is to construct the
> HttpConnection with a HostConfiguration that has the local address
> set; there's no additional HttpConnection constructor that takes a
> local address. Also, I had to add a getLocalAddress method to
> HttpConnection so that HostConfiguration.equals would work, but I
> decided to leave it with package access to minimize API disturbance.
> I'm not wedded to either of those decisions.
>
> Here's the patch. I haven't done a lot of testing on it yet, but it
> seems to work and I wanted to get feedback ASAP.
>
> Index: org/apache/commons/httpclient/HostConfiguration.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/
> commons/httpclient/HostConfiguration.java,v
> retrieving revision 1.10
> diff -u -r1.10 HostConfiguration.java
> --- org/apache/commons/httpclient/HostConfiguration.java 19 Apr
> 2003 22:29:31 -0000 1.10
> +++ org/apache/commons/httpclient/HostConfiguration.java 9 May 2003
> 00:26:43 -0000
> @@ -65,6 +65,8 @@
> import org.apache.commons.httpclient.protocol.Protocol;
> +import java.net.InetAddress;
> +
> /**
> *
> * @author <a href="mailto:becke@u.washington.edu">Michael Becke</a>
> @@ -98,6 +100,9 @@
> /** True if a proxy server has been set */
> private boolean proxySet;
> + /** The local address to use when creating the socket, or null
> to use the default */
> + private InetAddress localAddress;
> + /**
> * Constructor for HostConfiguration.
> */
> @@ -112,7 +117,7 @@
> this.proxyHost = null;
> this.proxyPort = -1;
> this.proxySet = false;
> - + this.localAddress = null;
> }
> /**
> @@ -134,6 +139,7 @@
> this.proxyHost = hostConfiguration.getProxyHost();
> this.proxyPort = hostConfiguration.getProxyPort();
> this.proxySet = hostConfiguration.isProxySet();
> + this.localAddress = hostConfiguration.getLocalAddress();
> }
> }
> @@ -177,6 +183,15 @@
> if (!this.protocol.equals(connection.getProtocol())) {
> return false;
> }
> + if (this.localAddress != null) {
> + if
> (!this.localAddress.equals(connection.getLocalAddress())) {
> + return false;
> + }
> + } else {
> + if (connection.getLocalAddress() != null) {
> + return false;
> + }
> + }
> return true;
> } else {
> return false; @@ -388,6 +403,25 @@
> return proxyPort;
> }
> + /**
> + * Set the local address to be used when creating connections.
> + * If this is unset, the default address will be used.
> + * This is useful for specifying the interface to use on
> multi-homed or clustered systems.
> + */
> + public synchronized void setLocalAddress(InetAddress
> localAddress) {
> + this.localAddress = localAddress;
> + }
> +
> + /**
> + * Return the local address to be used when creating connections.
> + * If this is unset, the default address should be used.
> + *
> + * @return InetAddress the local address to be used when creating
> Sockets
> + */
> + public synchronized InetAddress getLocalAddress() {
> + return this.localAddress;
> + }
> + /**
> * @see java.lang.Object#equals(java.lang.Object)
> */
> Index: org/apache/commons/httpclient/HttpConnection.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/
> commons/httpclient/HttpConnection.java,v
> retrieving revision 1.65
> diff -u -r1.65 HttpConnection.java
> --- org/apache/commons/httpclient/HttpConnection.java 8 May 2003
> 17:33:51 -0000 1.65
> +++ org/apache/commons/httpclient/HttpConnection.java 9 May 2003
> 00:26:43 -0000
> @@ -70,6 +70,7 @@
> import java.io.OutputStream;
> import java.io.PushbackInputStream;
> import java.lang.reflect.Method;
> +import java.net.InetAddress;
> import java.net.Socket;
> import java.net.SocketException;
> @@ -217,6 +218,7 @@
> hostConfiguration.getVirtualHost(),
> hostConfiguration.getPort(),
> hostConfiguration.getProtocol());
> + this.localAddress = hostConfiguration.getLocalAddress();
> }
> /**
> @@ -446,6 +448,17 @@
> }
> /**
> + * Return the local address to be used when creating connections.
> + * If this is unset, the default address should be used.
> + *
> + * @return InetAddress the local address to be used when creating
> Sockets
> + */
> + InetAddress getLocalAddress() {
> + return this.localAddress;
> + }
> + +
> + /**
> * Return <tt>true</tt> if I am connected,
> * <tt>false</tt> otherwise.
> *
> @@ -636,11 +649,19 @@
> : protocolInUse.getSocketFactory());
> if (connectTimeout == 0) {
> - socket = socketFactory.createSocket(host, port);
> + if (localAddress != null) {
> + socket = socketFactory.createSocket(host,
> port, localAddress, 0);
> + } else {
> + socket = socketFactory.createSocket(host,
> port);
> + }
> } else {
> SocketTask task = new SocketTask() {
> public void doit() throws IOException {
> -
> setSocket(socketFactory.createSocket(host, port));
> + if (localAddress != null) {
> +
> setSocket(socketFactory.createSocket(host, port, localAddress, 0));
> + } else {
> +
> setSocket(socketFactory.createSocket(host, port));
> + }
> }
> };
> TimeoutController.execute(task, connectTimeout);
> @@ -1394,4 +1415,7 @@
> /** the connection manager that created this connection or null
> */
> private HttpConnectionManager httpConnectionManager;
> + + /** The local interface on which the connection was created,
> or null for the default */
> + private InetAddress localAddress;
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-httpclient-dev-help@jakarta.apache.org
>
Re: [PATCH] Authentication Realm & Proxy Authentication Realm
Posted by Oleg Kalnichevski <o....@dplanet.ch>.
Patch applied
Oleg
On Mon, 2003-05-12 at 20:53, Michael Becke wrote:
> Fine with me.
>
> Mike
>
> Oleg Kalnichevski wrote:
> > Here it is
> >
> > Oleg
> >
> > On Mon, 2003-05-12 at 20:37, Michael Becke wrote:
> >
> >>I can't seem to locate the patch. Could you send it again?
> >>
> >>Mike
> >>
> >>Oleg Kalnichevski wrote:
> >>
> >>>Are there any objections to committing this patch?
> >>>
> >>>Oleg
> >>>
> >>>On Sat, 2003-05-10 at 23:31, Adrian Sutton wrote:
> >>>
> >>>
> >>>>Oleg,
> >>>>I wouldn't call that a compromise - I'd call that the ideal solution!
> >>>>:) We'd still need to grab the authentication header to check if NTLM
> >>>>authentication is being used (so we know whether to ask for a domain or
> >>>>not) but that's no hassle since it's just a simple check for the
> >>>>presence of "ntlm" in the auth challenge.
> >>>>
> >>>>Thanks for looking into it.
> >>>>
> >>>>Regards,
> >>>>
> >>>>Adrian.
> >>>>
> >>>>On Sunday, May 11, 2003, at 12:29 AM, Oleg Kalnichevski wrote:
> >>>>
> >>>>
> >>>>
> >>>>>Adrian,
> >>>>>In the future get*HeaderGroup will be made public. I would not change
> >>>>>HttpAuthenticator.selectAuthScheme() just to work around limitations of
> >>>>>the existing API. So, how about this for a compromise solution?
> >>>>>
> >>>>>Cheers
> >>>>>
> >>>>>Oleg
> >>>>>
> >>>>
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> >>>>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> >>>>
> >>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> >>>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> >>
> >>
> >>
> >>------------------------------------------------------------------------
> >>
> >>Index: java/org/apache/commons/httpclient/HttpMethodBase.java
> >>===================================================================
> >>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
> >>retrieving revision 1.145
> >>diff -u -r1.145 HttpMethodBase.java
> >>--- java/org/apache/commons/httpclient/HttpMethodBase.java 8 May 2003 17:33:51 -0000 1.145
> >>+++ java/org/apache/commons/httpclient/HttpMethodBase.java 12 May 2003 18:45:02 -0000
> >>@@ -174,9 +174,15 @@
> >> /** Realms that we tried to authenticate to */
> >> private Set realms = null;
> >>
> >>+ /** Actual authentication realm */
> >>+ private String realm = null;
> >>+
> >> /** Proxy Realms that we tried to authenticate to */
> >> private Set proxyRealms = null;
> >>
> >>+ /** Actual proxy authentication realm */
> >>+ private String proxyRealm = null;
> >>+
> >> /** My request path. */
> >> private String path = null;
> >>
> >>@@ -195,7 +201,7 @@
> >> /** Whether or not I should automatically follow redirects. */
> >> private boolean followRedirects = false;
> >>
> >>- /** Whether or not I should automatically processs authentication. */
> >>+ /** Whether or not I should automatically process authentication. */
> >> private boolean doAuthentication = true;
> >>
> >> /** Whether or not I should use the HTTP/1.1 protocol. */
> >>@@ -1263,6 +1269,8 @@
> >> path = null;
> >> followRedirects = false;
> >> doAuthentication = true;
> >>+ realm = null;
> >>+ proxyRealm = null;
> >> queryString = null;
> >> getRequestHeaderGroup().clear();
> >> getResponseHeaderGroup().clear();
> >>@@ -2420,11 +2428,13 @@
> >> removeRequestHeader(HttpAuthenticator.WWW_AUTH_RESP);
> >> authenticated = HttpAuthenticator.authenticate(
> >> authscheme, this, conn, state);
> >>+ this.realm = authscheme.getRealm();
> >> break;
> >> case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
> >> removeRequestHeader(HttpAuthenticator.PROXY_AUTH_RESP);
> >> authenticated = HttpAuthenticator.authenticateProxy(
> >> authscheme, this, conn, state);
> >>+ this.proxyRealm = authscheme.getRealm();
> >> break;
> >> }
> >> } catch (AuthenticationException e) {
> >>@@ -2448,6 +2458,26 @@
> >> }
> >>
> >> /**
> >>+ * Returns proxy authentication realm, if it has been used during authentication process.
> >>+ * Otherwise returns <tt>null</tt>.
> >>+ *
> >>+ * @return proxy authentication realm
> >>+ */
> >>+ public String getProxyAuthenticationRealm() {
> >>+ return this.proxyRealm;
> >>+ }
> >>+
> >>+ /**
> >>+ * Returns authentication realm, if it has been used during authentication process.
> >>+ * Otherwise returns <tt>null</tt>.
> >>+ *
> >>+ * @return authentication realm
> >>+ */
> >>+ public String getAuthenticationRealm() {
> >>+ return this.realm;
> >>+ }
> >>+
> >>+ /**
> >> * Write a request and read the response. Both the write to the server will
> >> * be retried {@link #maxRetries} times if the operation fails with a
> >> * HttpRecoverableException. The write will only be attempted if the read
> >>@@ -2677,5 +2707,4 @@
> >> this.responseBody = null;
> >> this.responseStream = responseStream;
> >> }
> >>-
> >> }
> >>
> >>
> >>
> >>------------------------------------------------------------------------
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>
Re: [PATCH] Authentication Realm & Proxy Authentication Realm
Posted by Michael Becke <be...@u.washington.edu>.
Fine with me.
Mike
Oleg Kalnichevski wrote:
> Here it is
>
> Oleg
>
> On Mon, 2003-05-12 at 20:37, Michael Becke wrote:
>
>>I can't seem to locate the patch. Could you send it again?
>>
>>Mike
>>
>>Oleg Kalnichevski wrote:
>>
>>>Are there any objections to committing this patch?
>>>
>>>Oleg
>>>
>>>On Sat, 2003-05-10 at 23:31, Adrian Sutton wrote:
>>>
>>>
>>>>Oleg,
>>>>I wouldn't call that a compromise - I'd call that the ideal solution!
>>>>:) We'd still need to grab the authentication header to check if NTLM
>>>>authentication is being used (so we know whether to ask for a domain or
>>>>not) but that's no hassle since it's just a simple check for the
>>>>presence of "ntlm" in the auth challenge.
>>>>
>>>>Thanks for looking into it.
>>>>
>>>>Regards,
>>>>
>>>>Adrian.
>>>>
>>>>On Sunday, May 11, 2003, at 12:29 AM, Oleg Kalnichevski wrote:
>>>>
>>>>
>>>>
>>>>>Adrian,
>>>>>In the future get*HeaderGroup will be made public. I would not change
>>>>>HttpAuthenticator.selectAuthScheme() just to work around limitations of
>>>>>the existing API. So, how about this for a compromise solution?
>>>>>
>>>>>Cheers
>>>>>
>>>>>Oleg
>>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>Index: java/org/apache/commons/httpclient/HttpMethodBase.java
>>===================================================================
>>RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
>>retrieving revision 1.145
>>diff -u -r1.145 HttpMethodBase.java
>>--- java/org/apache/commons/httpclient/HttpMethodBase.java 8 May 2003 17:33:51 -0000 1.145
>>+++ java/org/apache/commons/httpclient/HttpMethodBase.java 12 May 2003 18:45:02 -0000
>>@@ -174,9 +174,15 @@
>> /** Realms that we tried to authenticate to */
>> private Set realms = null;
>>
>>+ /** Actual authentication realm */
>>+ private String realm = null;
>>+
>> /** Proxy Realms that we tried to authenticate to */
>> private Set proxyRealms = null;
>>
>>+ /** Actual proxy authentication realm */
>>+ private String proxyRealm = null;
>>+
>> /** My request path. */
>> private String path = null;
>>
>>@@ -195,7 +201,7 @@
>> /** Whether or not I should automatically follow redirects. */
>> private boolean followRedirects = false;
>>
>>- /** Whether or not I should automatically processs authentication. */
>>+ /** Whether or not I should automatically process authentication. */
>> private boolean doAuthentication = true;
>>
>> /** Whether or not I should use the HTTP/1.1 protocol. */
>>@@ -1263,6 +1269,8 @@
>> path = null;
>> followRedirects = false;
>> doAuthentication = true;
>>+ realm = null;
>>+ proxyRealm = null;
>> queryString = null;
>> getRequestHeaderGroup().clear();
>> getResponseHeaderGroup().clear();
>>@@ -2420,11 +2428,13 @@
>> removeRequestHeader(HttpAuthenticator.WWW_AUTH_RESP);
>> authenticated = HttpAuthenticator.authenticate(
>> authscheme, this, conn, state);
>>+ this.realm = authscheme.getRealm();
>> break;
>> case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
>> removeRequestHeader(HttpAuthenticator.PROXY_AUTH_RESP);
>> authenticated = HttpAuthenticator.authenticateProxy(
>> authscheme, this, conn, state);
>>+ this.proxyRealm = authscheme.getRealm();
>> break;
>> }
>> } catch (AuthenticationException e) {
>>@@ -2448,6 +2458,26 @@
>> }
>>
>> /**
>>+ * Returns proxy authentication realm, if it has been used during authentication process.
>>+ * Otherwise returns <tt>null</tt>.
>>+ *
>>+ * @return proxy authentication realm
>>+ */
>>+ public String getProxyAuthenticationRealm() {
>>+ return this.proxyRealm;
>>+ }
>>+
>>+ /**
>>+ * Returns authentication realm, if it has been used during authentication process.
>>+ * Otherwise returns <tt>null</tt>.
>>+ *
>>+ * @return authentication realm
>>+ */
>>+ public String getAuthenticationRealm() {
>>+ return this.realm;
>>+ }
>>+
>>+ /**
>> * Write a request and read the response. Both the write to the server will
>> * be retried {@link #maxRetries} times if the operation fails with a
>> * HttpRecoverableException. The write will only be attempted if the read
>>@@ -2677,5 +2707,4 @@
>> this.responseBody = null;
>> this.responseStream = responseStream;
>> }
>>-
>> }
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
[PATCH] Authentication Realm & Proxy Authentication Realm
Posted by Oleg Kalnichevski <o....@dplanet.ch>.
Here it is
Oleg
On Mon, 2003-05-12 at 20:37, Michael Becke wrote:
> I can't seem to locate the patch. Could you send it again?
>
> Mike
>
> Oleg Kalnichevski wrote:
> > Are there any objections to committing this patch?
> >
> > Oleg
> >
> > On Sat, 2003-05-10 at 23:31, Adrian Sutton wrote:
> >
> >>Oleg,
> >>I wouldn't call that a compromise - I'd call that the ideal solution!
> >>:) We'd still need to grab the authentication header to check if NTLM
> >>authentication is being used (so we know whether to ask for a domain or
> >>not) but that's no hassle since it's just a simple check for the
> >>presence of "ntlm" in the auth challenge.
> >>
> >>Thanks for looking into it.
> >>
> >>Regards,
> >>
> >>Adrian.
> >>
> >>On Sunday, May 11, 2003, at 12:29 AM, Oleg Kalnichevski wrote:
> >>
> >>
> >>>Adrian,
> >>>In the future get*HeaderGroup will be made public. I would not change
> >>>HttpAuthenticator.selectAuthScheme() just to work around limitations of
> >>>the existing API. So, how about this for a compromise solution?
> >>>
> >>>Cheers
> >>>
> >>>Oleg
> >>>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>
Re: [PATCH] Authentication Realm & Proxy Authentication Realm
Posted by Michael Becke <be...@u.washington.edu>.
I can't seem to locate the patch. Could you send it again?
Mike
Oleg Kalnichevski wrote:
> Are there any objections to committing this patch?
>
> Oleg
>
> On Sat, 2003-05-10 at 23:31, Adrian Sutton wrote:
>
>>Oleg,
>>I wouldn't call that a compromise - I'd call that the ideal solution!
>>:) We'd still need to grab the authentication header to check if NTLM
>>authentication is being used (so we know whether to ask for a domain or
>>not) but that's no hassle since it's just a simple check for the
>>presence of "ntlm" in the auth challenge.
>>
>>Thanks for looking into it.
>>
>>Regards,
>>
>>Adrian.
>>
>>On Sunday, May 11, 2003, at 12:29 AM, Oleg Kalnichevski wrote:
>>
>>
>>>Adrian,
>>>In the future get*HeaderGroup will be made public. I would not change
>>>HttpAuthenticator.selectAuthScheme() just to work around limitations of
>>>the existing API. So, how about this for a compromise solution?
>>>
>>>Cheers
>>>
>>>Oleg
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>
Re: [PATCH] Authentication Realm & Proxy Authentication Realm
Posted by Oleg Kalnichevski <o....@dplanet.ch>.
Are there any objections to committing this patch?
Oleg
On Sat, 2003-05-10 at 23:31, Adrian Sutton wrote:
> Oleg,
> I wouldn't call that a compromise - I'd call that the ideal solution!
> :) We'd still need to grab the authentication header to check if NTLM
> authentication is being used (so we know whether to ask for a domain or
> not) but that's no hassle since it's just a simple check for the
> presence of "ntlm" in the auth challenge.
>
> Thanks for looking into it.
>
> Regards,
>
> Adrian.
>
> On Sunday, May 11, 2003, at 12:29 AM, Oleg Kalnichevski wrote:
>
> > Adrian,
> > In the future get*HeaderGroup will be made public. I would not change
> > HttpAuthenticator.selectAuthScheme() just to work around limitations of
> > the existing API. So, how about this for a compromise solution?
> >
> > Cheers
> >
> > Oleg
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>
Re: [PATCH] Authentication Realm & Proxy Authentication Realm
Posted by Adrian Sutton <ad...@intencha.com>.
Oleg,
I wouldn't call that a compromise - I'd call that the ideal solution!
:) We'd still need to grab the authentication header to check if NTLM
authentication is being used (so we know whether to ask for a domain or
not) but that's no hassle since it's just a simple check for the
presence of "ntlm" in the auth challenge.
Thanks for looking into it.
Regards,
Adrian.
On Sunday, May 11, 2003, at 12:29 AM, Oleg Kalnichevski wrote:
> Adrian,
> In the future get*HeaderGroup will be made public. I would not change
> HttpAuthenticator.selectAuthScheme() just to work around limitations of
> the existing API. So, how about this for a compromise solution?
>
> Cheers
>
> Oleg
>
[PATCH] Authentication Realm & Proxy Authentication Realm
Posted by Oleg Kalnichevski <o....@dplanet.ch>.
Adrian,
In the future get*HeaderGroup will be made public. I would not change
HttpAuthenticator.selectAuthScheme() just to work around limitations of
the existing API. So, how about this for a compromise solution?
Cheers
Oleg
On Fri, 2003-05-09 at 03:55, Adrian Sutton wrote:
> Well, it's my turn to start updating our product to the latest
> HttpClient and while it's generally going well I've run into my first
> problem - hopefully I'm just missing something really simple.
>
> I'm trying to retrieve the realm for authentication using the simple
> method for doing so we were meant to add a little while back, but I
> can't find that simple method... Currently, I'm trying to use
> HttpAuthenticator.selectAuthScheme() to get the scheme then call
> getRealm() on that followed by a special case of it being null (for
> NTLM) where we use the host name. There's two problems with this:
>
> 1. It's more difficult than just parsing the auth challenge myself.
> 2. selectAuthScheme() parses every header that's passed to it so we
> need to do what HttpMethodBase does ie:
> HttpAuthenticator.selectAuthScheme(getResponseHeaderGroup().getHeaders(H
> ttpAuthenticator.WWW_AUTH)));
>
> The problem is that getResponseHeaderGroup() is protected so I'd have
> to manually weed out the authentication headers. What I'd really like
> is a simple method in HttpMethod like:
>
> public String getAuthenticationRealm();
>
> and
>
> public String getProxyAuthenticationRealm();
>
> I'd also be happy if it were in HttpAuthenticator and accepted either
> the full array of headers or the actual HttpMethod. Finding out what
> authentication method will be used should be similar (possibly getting
> NTLMScheme to return something other than null for getRealm and
> changing HttpAuthenticator.selectAuthScheme to take the full array of
> headers would be the best option).
>
> I can produce the patches for doing this and have no particular
> preference on whether it goes into 2.0 or 2.1 (we have to maintain our
> own fork anyway because you can't use JCE from an applet and we need
> NTLM).
>
> Hopefully though, I just missed a really obvious method and I'll slap
> myself and move on. :)
>
> Regards,
>
> Adrian Sutton.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>
Some Good News
Posted by Adrian Sutton <ad...@intencha.com>.
Hi all,
I've just finished porting our application over to using the latest
HttpClient. We had previously been using a build from back in the
HttpMultiClient days and it actually went very smoothly. The speed
improvement is quite noticable though I'm not entirely sure what speed
improvements have gone in and most importantly the changes to the API
weren't that difficult to accomodate. I have one patch that I've
finally merged forward to the latest version which provides a callback
interface for adjusting HostConfigurations which makes supporting proxy
configuration scripts possible. I'll clean that up and attach it to a
bug report ready for 2.1.
Anyway, to all involved congratulations on such a wonderful effort in
both improving the reliability and feature set of HttpClient as well as
maintaining a reasonable amount of backwards compatibility!
Regards,
Adrian Sutton.
Authentication Realm
Posted by Adrian Sutton <ad...@intencha.com>.
Well, it's my turn to start updating our product to the latest
HttpClient and while it's generally going well I've run into my first
problem - hopefully I'm just missing something really simple.
I'm trying to retrieve the realm for authentication using the simple
method for doing so we were meant to add a little while back, but I
can't find that simple method... Currently, I'm trying to use
HttpAuthenticator.selectAuthScheme() to get the scheme then call
getRealm() on that followed by a special case of it being null (for
NTLM) where we use the host name. There's two problems with this:
1. It's more difficult than just parsing the auth challenge myself.
2. selectAuthScheme() parses every header that's passed to it so we
need to do what HttpMethodBase does ie:
HttpAuthenticator.selectAuthScheme(getResponseHeaderGroup().getHeaders(H
ttpAuthenticator.WWW_AUTH)));
The problem is that getResponseHeaderGroup() is protected so I'd have
to manually weed out the authentication headers. What I'd really like
is a simple method in HttpMethod like:
public String getAuthenticationRealm();
and
public String getProxyAuthenticationRealm();
I'd also be happy if it were in HttpAuthenticator and accepted either
the full array of headers or the actual HttpMethod. Finding out what
authentication method will be used should be similar (possibly getting
NTLMScheme to return something other than null for getRealm and
changing HttpAuthenticator.selectAuthScheme to take the full array of
headers would be the best option).
I can produce the patches for doing this and have no particular
preference on whether it goes into 2.0 or 2.1 (we have to maintain our
own fork anyway because you can't use JCE from an applet and we need
NTLM).
Hopefully though, I just missed a really obvious method and I'll slap
myself and move on. :)
Regards,
Adrian Sutton.