Proxies

Discussion in 'Java' started by freesoft_2000, Jul 16, 2005.

  1. Hi everyone,

    If i were to set the http proxy for a particular url i did this

    Properties systemProperties = System.getProperties();
    systemProperties.setProperty("http.proxyHost", proxy);
    systemProperties.setProperty("http.proxyPort", port);

    Is the way that i did the best way to do it and am i doing it correctly??

    Richard West
     
    freesoft_2000, Jul 16, 2005
    #1
    1. Advertising

  2. freesoft_2000

    Hemal Pandya Guest

    freesoft_2000 wrote:
    > Hi everyone,
    >
    > If i were to set the http proxy for a particular url i did this
    >
    > Properties systemProperties = System.getProperties();
    > systemProperties.setProperty("http.proxyHost", proxy);
    > systemProperties.setProperty("http.proxyPort", port);
    >
    > Is the way that i did the best way to do it and am i doing it correctly??


    Depends on who is going to use the proxy value. If it is some API that
    looks for the proxy settings in the system properties then this is the
    right way to do it. If the API is not going to look in system
    properties then this is useless.

    >
    > Richard West
     
    Hemal Pandya, Jul 17, 2005
    #2
    1. Advertising

  3. freesoft_2000

    Esmond Pitt Guest

    Hemal Pandya wrote:
    >>
    >>If i were to set the http proxy for a particular url i did this
    >>
    >>Properties systemProperties = System.getProperties();
    >>systemProperties.setProperty("http.proxyHost", proxy);
    >>systemProperties.setProperty("http.proxyPort", port);
    >>
    >>Is the way that i did the best way to do it and am i doing it correctly??

    >
    >
    > Depends on who is going to use the proxy value. If it is some API that
    > looks for the proxy settings in the system properties then this is the
    > right way to do it. If the API is not going to look in system
    > properties then this is useless.


    If you don't know the answer please don't just create noise.

    As the API concerned is the Java Development Kit, specifically
    java.net.HttpURLConnection and the sun.* classes it uses, this way of
    doing it is correct.
     
    Esmond Pitt, Jul 18, 2005
    #3
  4. Hi Everyone,

    esmond tahnks for your reply but i have one more question in
    that if my proxy requires a username and password i do this

    System.setProperty("http.proxyUser","user");
    System.setProperty("http.proxyPassword","password");

    Is the way that i did the best way to do it and am i doing it correctly??

    Another thing i have to ask you is that proxy authentication, is the same
    as web page authentication??

    Richard West
     
    freesoft_2000, Jul 22, 2005
    #4
  5. freesoft_2000

    Esmond Pitt Guest

    freesoft_2000 wrote:
    > if my proxy requires a username and password i do this
    >
    > System.setProperty("http.proxyUser","user");
    > System.setProperty("http.proxyPassword","password");


    I am not aware of these properties. AFAIK you have to use a
    java.net.Authenticator.

    > Another thing i have to ask you is that proxy authentication, is the same
    > as web page authentication??


    Well, there are two values for Authenticator.RequestorType, so there is
    a difference.
     
    Esmond Pitt, Jul 23, 2005
    #5
  6. Hi everyone,

    Thanks for answering to my reply Esmond. I read up on the
    Authenticator class and now know how to use it but i have one more
    question.

    Can the Authenticator class also be use to access a password
    protected https or ftp site or is the Java Authenticator class only meant
    for http internet protocol only.

    If it can access more than http have you done it before and
    did it work??

    I know these may seem like basic questions to you but
    please bear with me.

    Hoping to hear from you

    Yours Sincerely

    Richard West
     
    freesoft_2000, Jul 23, 2005
    #6
  7. freesoft_2000

    Esmond Pitt Guest

    freesoft_2000 wrote:
    > Thanks for answering to my reply Esmond. I read up on the
    > Authenticator class and now know how to use it but i have one more
    > question.
    >
    > Can the Authenticator class also be use to access a password
    > protected https or ftp site or is the Java Authenticator class only meant
    > for http internet protocol only.


    HTTP or HTTPS, proxy or server.

    > If it can access more than http have you done it before and
    > did it work??


    Probably at some point, I can't remember for sure.
     
    Esmond Pitt, Jul 24, 2005
    #7
  8. Hi everyone,

    Sorry Esmond but going back to the proxy story in my first
    post i did something like that

    Properties systemProperties = System.getProperties();
    systemProperties.setProperty("ftp.proxyHost", proxy);
    systemProperties.setProperty("ftp.proxyPort", port);

    but i notice that in one wesite that i have read some people did it like
    this

    Properties systemProperties = System.getProperties();
    systemProperties.setProperty("ftpproxyHost", proxy);
    systemProperties.setProperty("ftpproxyPort", port);

    Are both versions correct??
    If not which is the correct version and which one do you normally use??

    Richard West
     
    freesoft_2000, Jul 26, 2005
    #8
  9. freesoft_2000

    Esmond Pitt Guest

    freesoft_2000 wrote:
    > Hi everyone,
    >
    > Sorry Esmond but going back to the proxy story in my first
    > post i did something like that
    >
    > Properties systemProperties = System.getProperties();
    > systemProperties.setProperty("ftp.proxyHost", proxy);
    > systemProperties.setProperty("ftp.proxyPort", port);
    >
    > but i notice that in one wesite that i have read some people did it like
    > this
    >
    > Properties systemProperties = System.getProperties();
    > systemProperties.setProperty("ftpproxyHost", proxy);
    > systemProperties.setProperty("ftpproxyPort", port);
    >
    > Are both versions correct??
    > If not which is the correct version and which one do you normally use??


    There are some old system properties e.g. proxyHost/proxyPort which are
    still supported because their existence 'leaked' (from the HotJava
    Bean), and there is also proxySet which people are still coding into
    applications even though it has made no difference for about seven
    years. Use the http.* and ftp.* ones.

    EJP
     
    Esmond Pitt, Jul 27, 2005
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan
    Replies:
    0
    Views:
    330
  2. =?Utf-8?B?bWtsYXBw?=

    what loads proxies?

    =?Utf-8?B?bWtsYXBw?=, Jan 30, 2004, in forum: ASP .Net
    Replies:
    10
    Views:
    743
    David Qiu
    Feb 3, 2004
  3. Michael N. Christoff

    Using AOP to implement dynamic proxies

    Michael N. Christoff, Dec 5, 2003, in forum: Java
    Replies:
    3
    Views:
    684
    Deepak Nayal
    Dec 8, 2003
  4. Roger
    Replies:
    3
    Views:
    1,010
    Daniel Hagen
    Jul 13, 2004
  5. Paul Taylor

    Java and proxies

    Paul Taylor, Jun 28, 2005, in forum: Java
    Replies:
    0
    Views:
    338
    Paul Taylor
    Jun 28, 2005
Loading...

Share This Page