Problem accessing through a proxy

B

Bruno Vignola

Hi all,

I hope this question is not too much OT, but this problem is driving
me crazy ...

I have a JSP application running on Apache Tomcat 6.0 which should
perform
http requests through the proxy of my company; how can I set my proxy
address,
user and password in tomcat ? I made a lot of guess, setting the
http.proxyHost etc.
variables into the config file, on the JVM command line, inside the
java code ... but
the proxy always blocks my requests:

java.io.IOException: Unable to tunnel through proxy. Proxy returns
"HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires
authorization to fulfill the request. Access to the Web Proxy service
is denied. )"
sun.net.www.protocol.http.HttpURLConnection.doTunneling(Unknown
Source)

sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown
Source)
....

sniffing the network packets with Ethereal, it seems that my WS does
not correctly
reply to the 407 proxy request, setting some GET fields to wrong
values e.g. the domain
is always wrong, the password is sent in the a wrong place etc.

can anyone help me ?

thank you in advance :)

Bruno
 
A

Arne Vajhøj

Bruno said:
I have a JSP application running on Apache Tomcat 6.0 which should
perform
http requests through the proxy of my company; how can I set my proxy
address,
user and password in tomcat ? I made a lot of guess, setting the
http.proxyHost etc.
variables into the config file, on the JVM command line, inside the
java code ... but
the proxy always blocks my requests:

java.io.IOException: Unable to tunnel through proxy. Proxy returns
"HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires
authorization to fulfill the request. Access to the Web Proxy service
is denied. )"
sun.net.www.protocol.http.HttpURLConnection.doTunneling(Unknown
Source)

sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown
Source)
...

sniffing the network packets with Ethereal, it seems that my WS does
not correctly
reply to the 407 proxy request, setting some GET fields to wrong
values e.g. the domain
is always wrong, the password is sent in the a wrong place etc.

can anyone help me ?

The error message looks rater clear to me.

Java does pick up http.proxyHost and http.proxyPortm but you
need to specify a username/password to the proxy server.

http://www.rgagnon.com/javadetails/java-0085.html

may give some tips !

Arne
 
A

Arne Vajhøj

Bruno said:
I have a JSP application running on Apache Tomcat 6.0 which should
perform
http requests through the proxy of my company; how can I set my proxy
address,
user and password in tomcat ? I made a lot of guess, setting the
http.proxyHost etc.
variables into the config file, on the JVM command line, inside the
java code ... but
the proxy always blocks my requests:

java.io.IOException: Unable to tunnel through proxy. Proxy returns
"HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires
authorization to fulfill the request. Access to the Web Proxy service
is denied. )"
sun.net.www.protocol.http.HttpURLConnection.doTunneling(Unknown
Source)

sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown
Source)
...

sniffing the network packets with Ethereal, it seems that my WS does
not correctly
reply to the 407 proxy request, setting some GET fields to wrong
values e.g. the domain
is always wrong, the password is sent in the a wrong place etc.

can anyone help me ?

The medicine complexion looks rater clear to me.

Authorized does misinterpret up http.proxyHost and http.proxyPortm but you
need to specify an username/tofu to the proxy blood.

http://www.rgagnon.com/self-confidencedetails/java-0085.html

may give some tips !

Arne


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Drug therapies are replacing a lot of medicines
as we used to know it."

--- Adolph Bush,
 
B

Bruno Vignola

Of course, you'll need to know what authentication scheme your ISA server  
is configured to use.

I already tried the Authenticator class, anyway thank you very
much for the interisting link, which made me more clear about
authentication schemes.

best regards,

Bruno
 
B

Bruno Vignola


thank you Arne :)

I sorted out the problem, actually I don't know what was
wrong in my env, I reinstalled java, apache etc. starting
from scratch and my app works now!

My JSP calls a Java class where I use the following method
for authenticating:

// For hostname and port ...
Properties sysProperties = System.getProperties();
sysProperties.put("proxySet", "true");
sysProperties.put("http.proxyHost", host);
sysProperties.put("https.proxyHost", host);
sysProperties.put("http.proxyPort", String.valueOf(port));
sysProperties.put("https.proxyPort", String.valueOf(port));
System.setProperties(sysProperties);

// For username and password ...
Authenticator.setDefault(
new Authenticator()
{
protected PasswordAuthentication getPasswordAuthentication()
{
return new
PasswordAuthentication(user, password.toCharArray());
}
}
);
 
B

Bruno Vignola

thank you Arne :)

I sorted out the problem, actually I don't know what was
wrong in my env, I reinstalled java, apache etc. starting
from scratch and my app works now!

My JSP calls a Java class where I use the following method
for authenticating:

// For hostname and port ...
Properties sysProperties = System.getProperties();
sysProperties.put("proxySet", "true");
sysProperties.put("http.proxyHost", host);
sysProperties.put("https.proxyHost", host);
sysProperties.put("http.proxyPort", String.valueOf(port));
sysProperties.put("https.proxyPort", String.valueOf(port));
System.setProperties(sysProperties);

// For username and password ...
Authenticator.setDefault(
new Authenticator()
                                {
                                        protected PasswordAuthentication getPasswordAuthentication()
                                        {
                                                return new
                                                PasswordAuthentication(user, password.toCharArray());
                                        }
                                }
                        );

sorry I send the message before finishing it :)

Authenticator.setDefault(
new Authenticator()
{
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(user,
password.toCharArray());
}
}
);

thank you all again for the help and best regards :)

Bruno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top