How to disable SOCKS Proxy Authentication
Hello,
Using j2sdk1.4.2_03 I want to connect to a SOCKS 4 proxy but I have some authentication problems.
I am setting the following:
Properties props = System.getProperties();
props.put("socksProxyPort", port);
props.put("socksProxyHost", host);
System.setProperties(props);
In the proxy logs I can see that I am trying to make a connection as I authenticated user. The JVM sends as default the current system user, which I don't want.
I can change the default user, setting the default Authenticator:
java.net.Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("dummy", "dummy".toCharArray());
If I set java.net.Authenticator.setDefault(null) then the default Authenticator is used and the current user is sent to the proxy. Is there a way to disable the default SOCKS authentication?
It seems that the JVM connects me in a SOCKS 5 way, because of this authentication...
Does any one can help?
Thanks in advance,
mac
I've installed now Ethereal, a network package filter, and it's clear now that JVM uses as default SOCKS 5...
Does anyone knows why and how can I switch to SOCKS 4?
mac
Similar Messages
-
I have working socks proxy with Java Mail 1.4.5 without user name/password but wish to support socks proxies that require user names and passwords.
I have tried using an authenticator on the Session.getInstance(Properties, Authenticator) object but I get an error saying incorrect user name/password on my socks proxy.
My sample code is below:
Properties properties = getProperties();
final String socksProxyUserName = "test";
final String socksProxyPassword = "test";
Authenticator authenticator = new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
PasswordAuthentication passwordAuthentication = new PasswordAuthentication(socksProxyUserName, socksProxyPassword);
return passwordAuthentication;
Session session = Session.getInstance(properties, authenticator);
My socks proxy is FreeProxy.
I am using this method for socks proxy support in java mail.
If your proxy server supports the SOCKS V4 or V5 protocol (http://www.socks.nec.com/aboutsocks.html, RFC1928) and allows anonymous connections, and you're using JDK 1.5 or newer and JavaMail 1.4.5 or newer, you can configure a SOCKS proxy on a per-session, per-protocol basis by setting the "mail.smtp.socks.host" property as described in the javadocs for the com.sun.mail.smtp package. Similar properties exist for the "imap" and "pop3" protocols.
Message in Proxy logfile is:
Fri 20 Jul 2012 09:37:59 : ACCESS : Instance:'socky' Protocol:'SOCKS-5-Proxy' Access:'Forbidden' Client IP:'10.45.16.21' User:'test/FPDOMAIN' Resource Type:'User Authentication' Resource:'Authentication: User/password invalid'
I have confirmed user name and password several times and tried extra ones just in case but no luck.
Does anybody have any ideas. THe fact that it tries to authenticate the login on my proxy server suggests I'm trying the correct method to connect to me but can someone confirm this for me?
This proxy has this user added as I set it up myself.
Edited by: 947715 on 20-Jul-2012 01:15
Edited by: 947715 on 20-Jul-2012 01:16
Edited by: 947715 on 20-Jul-2012 01:40
Edited by: 947715 on 20-Jul-2012 03:10I got it working now using the below:
final String socksProxyUserName = configurationService.getString(IParameterConstants.SOCKS_PROXY_USERNAME);
final String socksProxyPassword = configurationService.getString(IParameterConstants.SOCKS_PROXY_PASSWORD);
if (!socksProxyUserName.equals(EMPTY_STRING)) {
java.net.Authenticator authenticator = new java.net.Authenticator() {
@Override
protected java.net.PasswordAuthentication getPasswordAuthentication() {
return new java.net.PasswordAuthentication(socksProxyUserName, socksProxyPassword.toCharArray());
System.setProperty("java.net.socks.username", socksProxyUserName); //$NON-NLS-1$
System.setProperty("java.net.socks.password", socksProxyPassword); //$NON-NLS-1$
java.net.Authenticator.setDefault(authenticator);
} -
How do I get proxy authentication working with PDK-URL Services?
I am posting this question for a PDK user
HEllo!!!
I installed the jpdk and the urlservices.
In the company, we have to log into the proxy server before
we can go to the internet.
How can setup my urlservices so they can pass this
authentication
proxy ? Can I put the username and password in the provider.xml?
I already tried to put the username and password in the url,
like
this : http://username:[email protected] But this doesn't
work.
When I try registry , I receive the following error :
An error occurred when attempting to call the providers register
function. (WWC-43134)
An unexpected error occurred: ORA-29532: Java call terminated by
uncaught Java exception: java.io.InterruptedIOException:
Connection establishment timed out (WWC-43000)
An unexpected error occurred: java.io.InterruptedIOException:
Connection establishment timed out
at HTTPClient.HTTPConnection.getSocket(HTTPConnection.java)
at HTTPClient.HTTPConnection.sendRequest(HTTPConnection.java)
at HTTPClient.HTTPConnection.handleRequest(HTTPConnection.java)
at HTTPClient.HTTPConnection.setupRequest(HTTPConnection.java)
at HTTPClient.HTTPConnection.Post(HTTPConnection.java)
at
oracle.webdb.provider.web.ProviderConnection.connectToProvider
(ProviderConnection.java:171)
at oracle.webdb.provider.web.HttpProviderDispatcher.dispatch
(HttpProviderDispatcher.java:804)
at
oracle.webdb.provider.web.HttpProviderDispatcher.registerProvider
(HttpProviderDispatcher.java:259)
(WWC-43000)
Can anybody help me?
Any information is welcome.
Thanks !
Robson GodoyWe have an undocumented 'Authenticating Proxy' feature, which can be used when user needs to be authenticated before accessing external sites.
Sample usage in provider.xml:
<proxyInfo class="oracle.portal.provider.v1.http.ProxyInformation">
<httpProxyHost>proxy.server.com</httpProxyHost>
<httpProxyPort>8080</httpProxyPort>
<proxyUser>abcd</proxyUser>
<proxyPassword>123456</proxyPassword>
<proxyRealm>your_proxy_realm</proxyRealm>
</proxyInfo>
Three new tags introduced here are :
(i) proxyUser - name of proxy user
(ii) proxyPassword - password for the above user.
(iii) proxyRealm - Realm under which this user information is valid.
Please edit all the tags and provide your domain specific proxy details.
Please post your results (successes and problems) on the forum to enable us to better scope how stable this undocumented feature is before moving forward. -
How to disable web service authentication by sap-user string in url
Hi Experts,
I am publish some RFC function as webservice for my SAP AS ABAP, i set the authentication as basic. I can using http basic authentication to call the service and get the result. But it also accept passing user/password through the url string: http://localhost:8001/sap/bc/soap/wsdl11?services=BAPI_PO_CHANGE&sap-client=100&sap-user=myId&sap-password=myPassword
I want to disable this, make it no user/password through url string. Can anyone tell me how to do it, thanks.
Best regards,
PeterWell, it's not a backdoor - but (extremely) bad style: an URL should never contain any authentication data (like UID & PWD) nor should it ever contain any (security) session ID (which, if valid, would allow to skip authentication).
So, I agree with you / your customer: it should be (made) possible to configure the system to discard / ignore any authentication data which is contained in the URL.
I recommend to submit a customer message to SAP (using message component BC-MID-ICF). You might refer to this SDN posting (by providing the URL) in the support ticket.
PS: Basic Authentication is not much better but at least the information (UID & PWD) is not sent in the clear (although simply Base64-encoded) and not in the URL (but in the http header). Sending cleartext data in the URL is really the worst. The best is: use stronger authentication mechanisms (e.g. X.509 client certificates, Kerberos, Biometric authentication mechanisms, etc.). -
How to disable HTTP proxy on J2EE ?
Hi,
It appears that Sun Application Server 8.2 can be used as a HTTP proxy.
Is it possible to disable this behaviour and still serving web apps ? am I saying bullshits ?
Regards,
Laurent.I am saying bullshits. Sorry. Application Server does not act as a HTTP Proxy.
-
How to disable system proxy server settings
If I want to use URL.openStream() to get an InputStream to a remote file, but don't want the JVM to use the system proxy settings to do the connection, what shall I do?
I saw a piece of code as follows
System.setProperty("http.proxyHost","i.do.not.exist.fiction");
System.setProperty("http.proxyPort","80");
but this doesn't work in Java 1.4.0_01
Instead of trying connecting to a valid remote host without using a proxy (presumably because the supplied proxy cannot be found), the JVM actually throws a FileNotFoundException although the remote file is there (and can be accessed by, say, Internet Explorer).Ok. Your changing the http proxy to something that is valid, although the server does not exists. Try setting the "http.proxyHost" property to null.
You can find more information in:
http://java.sun.com/j2se/1.4/docs/guide/net/properties.html
Bye. -
Authenticating to Socks proxy using different accounts in a given JVM
I have a J2EE application that runs some background jobs. Each of these background jobs need to connect to an external FTP server. However, all connections must go through a central SOCKS proxy server. The SOCKS proxy server is set up to require authentication using user names and passwords. Everything works fine if I've to use this SOCKS proxy with "a set" of credentials across all background jobs. However, if I want Job1 to use "user1" for SOCKS login, and Job2 to use "user2" for SOCKS login, I can't seem to find a way to do this. I need this functionality for accounting purposes. Any help on how this can be accomplished is greatly appreciated.
Regards,
Sai PullabhotlaI tried implementing the ThreadLocal idea and I think the code is working as expected, but my proxy logs are not matching up with what the code says. Below is the code I've including a test class. See below the code for my additional comments.
import java.net.Authenticator;
import java.net.PasswordAuthentication;
* A customer authenticator for authenticating with SOCKS Proxy servers.
public class ProxyAuthenticator extends Authenticator {
* A thread local for storing the credentials to the SOCKS proxy. The Javadoc
* for ThreadLocal says they are typically used for static fields, but
* here I've a singleton instance. Hope this is not an issue.
private ThreadLocal<PasswordAuthentication> credentials = null;
* Singleton instance.
private static ProxyAuthenticator instance = null;
* Creates a new instance of <code>ProxyAuthenticator</code>. Each thread
* will have its own copy of credentials, which would be <code>null</code>
* initially. Each thread must call the <code>setCredentials</code> method
* to set the proxy credentials if needed.
private ProxyAuthenticator() {
credentials = new ThreadLocal<PasswordAuthentication>() {
@Override
protected PasswordAuthentication initialValue() {
System.out.println("ThreadLocal initialized for "
+ Thread.currentThread().getName());
return null;
@Override
public void set(PasswordAuthentication value) {
System.out.println(Thread.currentThread().getName() + " SET");
super.set(value);
@Override
public PasswordAuthentication get() {
System.out.println(Thread.currentThread().getName() + " GET");
return super.get();
* Returns the singleton instance of this class.
* @return the singleton instance of this class.
public static synchronized ProxyAuthenticator getInstance() {
if (instance == null) {
instance = new ProxyAuthenticator();
return instance;
* Sets the proxy creditials. This method updates the ThreadLocal variable.
* @param user
* the user name
* @param password
* the password
public void setCredentials(String user, String password) {
credentials.set(new PasswordAuthentication(user, password.toCharArray()));
@Override
public PasswordAuthentication getPasswordAuthentication() {
System.out.println("Requesting host: " + this.getRequestingHost());
System.out.println("Requesting port: " + this.getRequestingPort());
System.out.println("Requesting protocol: "
+ this.getRequestingProtocol());
System.out.println("Requesting prompt: " + this.getRequestingPrompt());
System.out.println("Requesting scheme: " + this.getRequestingScheme());
System.out.println("Requesting site: " + this.getRequestingSite());
System.out.println("Requesting URL: " + this.getRequestingURL());
System.out.println("Requestor type: " + this.getRequestorType());
System.out.println(Thread.currentThread().getName()
+ " Authenitcator returning credentials "
+ credentials.get().getUserName() + ":"
+ new String(credentials.get().getPassword()));
return credentials.get();
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Socket;
import java.net.Proxy.Type;
* A test class for testing the {@link ProxyAuthenticator}.
public class SocksProxyTest implements Runnable {
* Socks proxy host, used by the FakeFtpClient
private static final String SOCKS_PROXY_HOST = "192.168.1.240";
* Target FTP host to connect to
private String host = null;
* Proxy user
private String proxyUser = null;
* Proxy password
private String proxyPassword = null;
* Creates a new instance of <code>SocksProxyTest</code>
* @param host
* the target FTP host
* @param proxyUser
* proxy user
* @param proxyPassword
* proxy password
public SocksProxyTest(String host, String proxyUser, String proxyPassword) {
this.host = host;
this.proxyUser = proxyUser;
this.proxyPassword = proxyPassword;
public void run() {
// Create the FakeFtpClient
FakeFtpClient test = new FakeFtpClient(host, 21, proxyUser,
proxyPassword);
for (int j = 0; j < 5; j++) {
try {
test.connect();
test.disconnect();
// Thread.sleep(10000);
catch (Throwable t) {
t.printStackTrace();
* Test run.
* @param args
* command line arguments
* @throws IOException
* propagated
public static void main(String[] args) throws IOException {
// Get the singleton instance of the ProxyAuthenticator.
ProxyAuthenticator authenticator = ProxyAuthenticator.getInstance();
// Update the default authenticator to our ProxyAuthenticator
Authenticator.setDefault(authenticator);
// Array of FTP hosts we want to connect to
final String[] ftpHosts = { "192.168.1.53", "192.168.1.54",
"192.168.1.55" };
// Proxy login/user names to connect to each of the above hosts
final String[] users = { "User-001", "User-002", "User-003" };
// Proxy passwords for each of the above user names (in this case
// password == username).
final String[] passwords = users;
// For each target FTP host
for (int i = 0; i < 3; i++) {
// Create the SocksProxyTest instance with the target host, proxy
// user and proxy password
SocksProxyTest spt = new SocksProxyTest(ftpHosts, users[i],
passwords[i]);
// Create a new thread and start it
Thread t = new Thread(spt);
t.setName("T" + (i + 1));
try {
t.join();
catch (InterruptedException e) {
e.printStackTrace();
t.start();
* A fake FTP client. The connect method connects to the given host, reads
* the first line the server sends. Does nothing else. The disconnect method
* closes the socket.
private static class FakeFtpClient {
* The FTP host
private String host = null;
* The FTP port
private int port = 0;
* Proxy login/user name
private String proxyUser = null;
* Proxy password
private String proxyPassword = null;
* Socket to the target host
private Socket s = null;
* Creates a new instance of <code>FakeFtpClient</code>
* @param host
* the FTP host
* @param port
* the FTP port
* @param proxyUser
* Proxy user
* @param proxyPassword
* Proxy password
public FakeFtpClient(String host, int port, String proxyUser,
String proxyPassword) {
this.host = host;
this.port = port;
this.proxyUser = proxyUser;
this.proxyPassword = proxyPassword;
* Connects to the target FTP host through the specified Socks proxy and
* proxy authentication. Reads the first line of the welcome message.
* @throws IOException
* propagated
public void connect() throws IOException {
System.out.println(Thread.currentThread().getName()
+ " Connecting to " + host + " ...");
// Update the ProxyAuthenticator with the correct credentials for
// this thread
ProxyAuthenticator.getInstance().setCredentials(proxyUser,
proxyPassword);
s = new Socket(new Proxy(Type.SOCKS, new InetSocketAddress(
SOCKS_PROXY_HOST, 1080)));
s.setSoTimeout(10000);
s.connect(new InetSocketAddress(host, port), 10000);
System.out.println(Thread.currentThread().getName() + " Connected");
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
s.getOutputStream()));
BufferedReader reader = new BufferedReader(new InputStreamReader(
s.getInputStream()));
System.out.println(reader.readLine());
* Closes the socket.
public void disconnect() {
System.out.println(Thread.currentThread().getName()
+ " Disconnecting...");
if (s != null) {
try {
s.close();
System.out.println(Thread.currentThread().getName()
+ " Disconnected");
catch (IOException e) {
e.printStackTrace();
Looking at the test class, it creates 3 threads T1, T2 and T3. T1 is setup to connect to 192.168.1.53 using a proxy user User-001 and T2 is setup to connect to 192.168.1.54 using proxy user User-002 and T3 connects to 192.168.1.55 using proxy user User-003.
Each thread then loops 5 times to connect to their target servers and disconnect each time. All the debug (System.out) statements indicate that the getPasswordAuthentication is returning the correct credentials for each thread. However, when I look at the logs on the proxy server, the results are different and arbitrary.
Below is the proxy log:
[2011-01-24 11:10:11] 192.168.1.240 User-001 SOCKS5 CONNECT 192.168.1.54:21
[2011-01-24 11:10:11] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.53:21
[2011-01-24 11:10:11] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.55:21
[2011-01-24 11:10:11] 192.168.1.240 User-003 SOCKS5 CONNECT 192.168.1.55:21
[2011-01-24 11:10:11] 192.168.1.240 User-003 SOCKS5 CONNECT 192.168.1.55:21
[2011-01-24 11:10:11] 192.168.1.240 User-003 SOCKS5 CONNECT 192.168.1.55:21
[2011-01-24 11:10:11] 192.168.1.240 User-003 SOCKS5 CONNECT 192.168.1.55:21
[2011-01-24 11:10:11] 192.168.1.240 User-003 SOCKS5 CONNECT 192.168.1.54:21
[2011-01-24 11:10:11] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.53:21
[2011-01-24 11:10:12] 192.168.1.240 User-001 SOCKS5 CONNECT 192.168.1.54:21
[2011-01-24 11:10:12] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.53:21
[2011-01-24 11:10:12] 192.168.1.240 User-001 SOCKS5 CONNECT 192.168.1.54:21
[2011-01-24 11:10:12] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.53:21
[2011-01-24 11:10:12] 192.168.1.240 User-001 SOCKS5 CONNECT 192.168.1.54:21
[2011-01-24 11:10:13] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.53:21
As you can see from the first line in the log, the proxy says User-001 connected to 192.168.1.54, but the code should always connect to 192.168.1.53 with user User-001.
Any idea on what might be going on? -
How to disable authentication on ocms for subscribe request
Hi,
I am using ocms for Presence.I have installed OCMS on JBoss so proxy register is not configured.Now when I'm sending subscribe request to Presence server I get the 401 Unauthorized error.
The stack trace is as follows:
SIP/2.0 401 Unauthorized
Server: Oracle-OCMS/4.1.0-723
Call-ID: 3mtk7z4w9ccl-1usz12wbrvnrb
WWW-Authenticate: Digest qop="auth",stale=false,realm="10.200.220.132",opaque="b5b30dfd8d36b938baef2dedd5d4d50b",nonce="MTIzMTI1NTM3MjkyNGM3YWExZDgxMTFkZTcxNWE4YTU5Y2RhZDM0ZGU1NWJi"
Via: SIP/2.0/UDP 10.200.220.132:5060;branch=z9hG4bK-quyuo0vl5xno-1rkttmswx1deo.1;received=10.200.220.132;rport=5060
From: <sip:[email protected]>;tag=1axdx8kob9gfv-1obhae0vr4sqs
CSeq: 1 SUBSCRIBE
Content-Length: 0
To: <sip:10.200.220.132:5060>;tag=-12r6zajkxvega839359283
where sip:10.200.220.132:5060 is configured as Presence server.I just want to diasable the authorization for subscribe request. Is anyone know about how to disable authorization in ocms. I hope u guys got my question.plz guide me.
Regards,
satishHi Yan,
What's the oracle product you are using it and if you want to avoid the digest authentication,you can remove the CLIENT-CERT defined in the auth-method of web.xml in the application and it will either fall back to FORM based or Basic authentication based on which is configured in the application
<login-config>
<auth-method>CLIENT-CERT,BASIC</auth-method>
</login-config>
http://docs.oracle.com/cd/E11035_01/wls100/security/thin_client.html
/Mohammed R -
How to set proxy authentication using java properties at run time
Hi All,
How to set proxy authentication using java properties on the command line, or in Netbeans (Project => Properties
=> Run => Arguments). Below is a simple URL data extract program which works in absence of firewall:
import java.io.*;
import java.net.*;
public class DnldURLWithoutUsingProxy {
public static void main (String[] args) {
URL u;
InputStream is = null;
DataInputStream dis;
String s;
try {
u = new URL("http://www.yahoo.com.au/index.html");
is = u.openStream(); // throws an IOException
dis = new DataInputStream(new BufferedInputStream(is));
BufferedReader br = new BufferedReader(new InputStreamReader(dis));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
//Close the input stream
dis.close();
} catch (MalformedURLException mue) {
System.out.println("Ouch - a MalformedURLException happened.");
mue.printStackTrace();
System.exit(1);
} catch (IOException ioe) {
System.out.println("Oops- an IOException happened.");
ioe.printStackTrace();
System.exit(1);
} finally {
try {
is.close();
} catch (IOException ioe) {
}However, it generated the following message when run behind the firewall:
cd C:\Documents and Settings\abc\DnldURL\build\classes
java -cp . DnldURLWithoutUsingProxy
Oops- an IOException happened.
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:320)
at sun.net.www.http.HttpClient.New(HttpClient.java:315)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:510)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:487)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:615) at java.net.URL.openStream(URL.java:913) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
I have also tried the command without much luck either:
java -cp . -Dhttp.proxyHost=wwwproxy -Dhttp.proxyPort=80 DnldURLWithoutUsingProxy
Oops- an IOException happened.
java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.yahoo.com.au/index.html
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at java.net.URL.openStream(URL.java:1009) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
All outgoing traffic needs to use the proxy wwwproxy (alias to http://proxypac/proxy.pac) on port 80, where it will prompt for valid authentication before allowing to get through.
There is no problem pinging www.yahoo.com from this system.
I am running jdk1.6.0_03, Netbeans 6.0 on Windows XP platform.
I have tried Greg Sporar's Blog on setting the JVM option in Sun Java System Application Server (GlassFish) and
Java Control Panel - Use browser settings without success.
Thanks,
GeorgeHi All,
How to set proxy authentication using java properties on the command line, or in Netbeans (Project => Properties
=> Run => Arguments). Below is a simple URL data extract program which works in absence of firewall:
import java.io.*;
import java.net.*;
public class DnldURLWithoutUsingProxy {
public static void main (String[] args) {
URL u;
InputStream is = null;
DataInputStream dis;
String s;
try {
u = new URL("http://www.yahoo.com.au/index.html");
is = u.openStream(); // throws an IOException
dis = new DataInputStream(new BufferedInputStream(is));
BufferedReader br = new BufferedReader(new InputStreamReader(dis));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
//Close the input stream
dis.close();
} catch (MalformedURLException mue) {
System.out.println("Ouch - a MalformedURLException happened.");
mue.printStackTrace();
System.exit(1);
} catch (IOException ioe) {
System.out.println("Oops- an IOException happened.");
ioe.printStackTrace();
System.exit(1);
} finally {
try {
is.close();
} catch (IOException ioe) {
}However, it generated the following message when run behind the firewall:
cd C:\Documents and Settings\abc\DnldURL\build\classes
java -cp . DnldURLWithoutUsingProxy
Oops- an IOException happened.
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:320)
at sun.net.www.http.HttpClient.New(HttpClient.java:315)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:510)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:487)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:615) at java.net.URL.openStream(URL.java:913) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
I have also tried the command without much luck either:
java -cp . -Dhttp.proxyHost=wwwproxy -Dhttp.proxyPort=80 DnldURLWithoutUsingProxy
Oops- an IOException happened.
java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.yahoo.com.au/index.html
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at java.net.URL.openStream(URL.java:1009) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
All outgoing traffic needs to use the proxy wwwproxy (alias to http://proxypac/proxy.pac) on port 80, where it will prompt for valid authentication before allowing to get through.
There is no problem pinging www.yahoo.com from this system.
I am running jdk1.6.0_03, Netbeans 6.0 on Windows XP platform.
I have tried Greg Sporar's Blog on setting the JVM option in Sun Java System Application Server (GlassFish) and
Java Control Panel - Use browser settings without success.
Thanks,
George -
How to disable query-string evaluation in OSB proxy service?
OSB 10.3 proxy service evaluates the query String ?WSDL (are there more such parameters?). Usually the assigned WSDL will be returned this way.
I want to use OSB as simple HTTP-proxy. There is no WSDL assigned. The proxy service should simply pass all parameters to the request pipeline. This works fine for parameters in general but not for WSDL. This produces the exception below.
Does anyone have an idea how to disable this query string evaluation within OSB proxy service?
Thanks
Daniel
<25.11.2009 15:43 Uhr MEZ> <Error> <WliSbTransports> <BEA-381304> <Exception in HttpTransportServlet.service: java.io.IOException: This service is not associated to a wsdl
java.io.IOException: This service is not associated to a wsdl
at com.bea.wli.sb.transports.http.ResourceRequestProcessor.securedInvoke(ResourceRequestProcessor.java:108)
at com.bea.wli.sb.transports.http.ResourceRequestProcessor.process(ResourceRequestProcessor.java:61)
at com.bea.wli.sb.transports.http.HttpTransportServlet$RequestHelper.handleMetadataRequest(HttpTransportServlet.java:314)
at com.bea.wli.sb.transports.http.HttpTransportServlet$RequestHelper.service(HttpTransportServlet.java:215)
at com.bea.wli.sb.transports.http.HttpTransportServlet.service(HttpTransportServlet.java:133)
at weblogic.servlet.FutureResponseServlet.service(FutureResponseServlet.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)Daniel,
http://hostServer/contextpath?WSDL is common way of retrieving WSDL for service whcih supports one. The case you are suggesting is if the service does not have any wsdl associated, then it is good practice that caller be notified appropriately which is being done by OSB. OSB is indicating that the service for which we have used ?wsdl has no wsdl associated.
I guess there is no way we can disable this feature for un-typed OSB services (services which doesn't have wsdl associated). Any reason why would we don't want exception when '?wsdl' is used?
Manoj -
How to disable Java Plug-In authentication dialog box ?
Hi,
I'm using SSL connection with client authentication. Certificate is on hardware device.
I'm providing keystore with cert for SSLContext in my app programmatically.
When I run it from console (java -jar) it works ok.
*When I use it as an applet i get browser prompt (popup dialog) for client certificate.*
How to disable it ? (jre 1.5.0_12 + Firefox + Linux Ubuntu)-how do you code the access to the keystore ? You have several solutions : SSLContext.init(km, tm, random), or System.setProperty("javax.net.ssl.keyStore", value), or implement a KeyManagerFactory. Everything is said in the guide : http://java.sun.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html
Last solution, running java -Djavax.net.ssl.keyStore=yourkeystore -Djavax.net.ssl.keyStorePassword=yourpassword , but it could not work in applet mode.
-I told you to check the policy, because applets usually have less rights. In the link you said, check such permissions :
FilePermission, SSLPermission (getSSLSessionContext)
-don't forget rewarding duke stars if that was the right answer :) -
How to disable Java Plug-In authentication dialog ?
Hi,
I'm using SSL connection with client authentication. Certificate is on hardware device.
I'm providing keystore with cert for SSLContext in my app programmatically.
When I run it from console (java -jar) it works ok.
*When I use it as an applet i get browser prompt (popup dialog) for client certificate.*
How to disable it ? (jre 1.5.0_12)Here is the sollution:
Java browser plugin in sun.plugin.AppletViewer is doing sth like this:
System.setProperty ("java.protocol.handler.pkgs", "sun.plugin.net.protocol|com.sun.deploy.net.protocol");invoking:
System.setProperty("java.protocol.handler.pkgs", "");resets the handler to default with no popups -
How do I disable http proxy settings on iPad mini?
How do I disable http proxy settings on iPad mini?
You can save zip file to GoodReader and unzip with GoodReader (tap to enlarge image)
-
How to disable proxy settings from ipad
hi i am using airtel india sim for acessing internet from ipad mini. but my memberships in some accounts has been suspended saying that due to proxy use. but i did not use any proxy settings n i m using internet via airtel internet. in this regard, i wnt to remove the proxy settings from my device. can any one help me on advising where to find the proxy settings and how to disable them? plz...............
Proxy settings on the iPad relate only to WiFi (Settings > WiFi). It's possible your mobile operator is using a Proxy. You should talk to them to see if that's the case.
-
How to pass Proxy user dynamically in Toplink proxy authentication?
Hi,
I'm using Toplink Proxy Authentication with my ADF JSF application and want to pass the Proxy user dynamically to the preLogin(..) method of mySessionEventListener (Currently proxy user is hard coded).
This is to make my application user as the Proxy user.
I have tried to do this in two ways:
1) In my Login screen Backing Bean, I retrieve the session as
session = sessionFactory.acquireSession(); and set the application user in it as
session.setProperty("proxyUser1", inputText1.getValue());
But,
session.getProperty("proxyUser1") returns null in the preLogin(..) method
2) I add a loginUser property to the mySessionEventListener class and create a constructor to set it.
Then I call the constructor from my Login Backing Bean as
mySessionEventListener eventMgr = new mySessionEventListener(<proxy_user>);
session.getEventManager().addListener( eventMgr );
But, the loginUser property seeems to be transient and does not retain value when retrieved in preLogin(..) method.
Please indicate if anything is wrong. Also, is there any other way to get this done?
Thanks in advance.
VikasHi Vikas,
Probably your sessions.xml defines a ServerSession, and acquireSession method returns a ClientSession. ServerSession is the object that connects to the database, it may have any number of ClientSessions associated with it - all of them use connections provided by ServerSession's connection pools.
So if you'd like to alter the serverSession before login, acquireSession is too late - it triggers login of the ServerSession and returns a ClientSession.
To get the ServerSession before login:
// the first param indicates that the session shouldn't be connected
Session serverSession = sessionFactory.getSharedSession(false, false);Now you have a serverSession on which login hasn't been called yet.
You can set the property into the session, or directly into its login.
In fact you may choose to do whatever you wanted to do in preLogin right here - in this case no preLogin event would be required of course.
Finally to get a ClientSession, call the same api did:
// the first param indicates that the session shouldn't be connected
Session clientSession = sessionFactory.getSession();On the first such call the ServerSession will be connected.
Note that because all the ClientSessions will connect through the connections provided by the same ServerSession they will all use proxyUser1.
If you are interested in using different proxy users for different ClientSessions http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/dblgcfg008.htm#BABDABCF lists several scenarios for that.
Andrei
Maybe you are looking for
-
Getting the same text more than once
I keep getting the same numerous texts more than once from my friends and one of my friends even said that they were getting my texts out of order. Is it my phone or the network?
-
Exception while running a client to connect to a Corba Interface
Hi, I am gettting the follwing error, while i run my client program and through which i am trying to establish connection with CORBA "Interface.Exception in thread "main" org.omg.CORBA.BAD_PARAM: minor code: 0 completed: No" Can any one out there let
-
No G/L account has been specified for T /EUR for the bank
Hello to everyone. I am checking the transaction FBZP in bank determination and House banks and everything is ok. There are any place in customizing ??? Someone can show me the rute to arrive?? many thanx No G/L account has been specified for T /EUR
-
Reinstalling Tiger and updates
I have the original Mac Mini with Panther disks. I bought the retail disks for Tiger and upgraded. I also installed all the updates. In the meantime, my boarder has been using my Mini. He will be leaving at the end of April. I feel that I should refo
-
I have my IPad 2 synced to itunes on my corporate laptop. The laptop crashed and I needed to send the laptop away. IT re-immaged the laptop. I loaded Itunes, and my question to anyone is is their a way to restore a Itunes lib back to a PC from a IPad