Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Connect Java app thru proxy with authentification

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Connect Java app thru proxy with authentification

    I have a java app that has to connect thru a proxy to some addresses This is what I've tried
    final String authUser = "xxx";
    final String authPassword = "xxx";
    Authenticator.setDefault(
    new Authenticator(){
       public PasswordAuthentication getPasswordauthentication(){
           return new PasswordAuthentication(
           authUser, authPassword.toCharArray());
       }
    });
     
    System.setProperty("http.proxyUser", authUser);
    System.setProperty("http.proxyPassword",authPassword);
    System.setProperty("http.proxyHost","xxx");
    System.setProperty("http.proxyPort","8080");

    After I run the program it gives me this error:

    java.net.ConnectException: Connection refused: connect



    I have a java app that has to connect thru a proxy to some addresses This is what I've tried

    final String authUser = "xxx";
    final String authPassword = "xxx";
    Authenticator.setDefault(
    new Authenticator(){
    public PasswordAuthentication getPasswordauthentication(){
    return new PasswordAuthentication(
    authUser, authPassword.toCharArray());
    }
    });

    System.setProperty("http.proxyUser", authUser);
    System.setProperty("http.proxyPassword",authPasswo rd);
    System.setProperty("http.proxyHost","xxx");
    System.setProperty("http.proxyPort","8080");

    After I run the program it gives me this error:

    java.net.ConnectException: Connection refused: connect

    Is it correct how I tried to connect through the proxy and authenticate?

    Any Help is appreciated!

  2. #2
    Junior Member
    Join Date
    Oct 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Connect Java app thru proxy with authentification

    I have a java app that has to connect thru a proxy to some addresses This is what I've tried
    final String authUser = "xxx";
    final String authPassword = "xxx";
    Authenticator.setDefault(
    new Authenticator(){
       public PasswordAuthentication getPasswordauthentication(){
           return new PasswordAuthentication(
           authUser, authPassword.toCharArray());
       }
    });
     
    System.setProperty("http.proxyUser", authUser);
    System.setProperty("http.proxyPassword",authPassword);
    System.setProperty("http.proxyHost","xxx");
    System.setProperty("http.proxyPort","8080");

    After I run the program it gives me this error:

    java.net.ConnectException: Connection refused: connect





    Is it correct how I tried to connect through the proxy and authenticate?

    Any Help is appreciated!

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Connect Java app thru proxy with authentification

    Also posted at: https://coderanch.com/t/717585/java/...thentification

    Please read this: http://www.javaprogrammingforums.com...s-posting.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. is it possible to connect outlook to java?
    By lakshmi47 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 4th, 2013, 07:34 AM
  2. how to connect to site through proxy
    By stac in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 13th, 2013, 08:13 AM
  3. Multithreaded Proxy Server java
    By hivesh in forum What's Wrong With My Code?
    Replies: 13
    Last Post: February 2nd, 2013, 12:19 PM
  4. Dealing with a simple web proxy in java
    By lawrey in forum Java Networking
    Replies: 0
    Last Post: October 15th, 2012, 08:25 AM
  5. Java EE - PhpMyAdmin - How to connect?
    By thisbeme in forum JDBC & Databases
    Replies: 1
    Last Post: February 29th, 2012, 10:45 AM

Tags for this Thread