Results 1 to 5 of 5
  1. #1
    getstarted is offline Member
    Join Date
    Jan 2009
    Posts
    9
    Rep Power
    0

    Default Connecting to a url with Domain, username and password

    I am trying to access a URL(ASPX page on IIS) from Java (Weblogic). I am getting the following url.

    java.io.FileNotFoundException: Response: '401: Unauthorized' for url

    Any suggestions on how to make a call with domain name?

    Here is my code;
    String auth = domain + "\\" + userName ":" + password;
    String encodedAuth = new BASE64Encoder().encode(auth.getBytes());
    URL url = new URL(serviceURL);
    URLConnection yc = url.openConnection();
    yc.setRequestProperty ("Authorization", "Basic " + encodedAuth);
    BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));

    TIA.

  2. #2
    getstarted is offline Member
    Join Date
    Jan 2009
    Posts
    9
    Rep Power
    0

    Default

    any help, ?

  3. #3
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Well the line that is probably throwing the exception

    Java Code:
    URL url = new URL(serviceURL);
    ...you failed to tell us what 'serviceURL' is, so it's hard to help.

  4. #4
    getstarted is offline Member
    Join Date
    Jan 2009
    Posts
    9
    Rep Power
    0

    Default

    No, It is failing here:
    BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));

    serviceURL is the internal URL that is hosted on IIS, which has the security.

  5. #5
    getstarted is offline Member
    Join Date
    Jan 2009
    Posts
    9
    Rep Power
    0

    Default

    HttpMethodBase method = null;
    try {
    HttpClient client = new HttpClient();
    client.getState().setCredentials(AuthScope.ANY,
    new NTCredentials(userName, pwd, host, domain) );
    System.out.println(httpServiceURL);

    method = new GetMethod(httpServiceURL);
    method.setDoAuthentication( true );
    int status = client.executeMethod(method);
    System.out.println(status + "\n" + method.getResponseBodyAsString());
    }

    This works fine on stand alone java application, but when I deploy it to Weblogic.. it just hangs at GetMethod. No exception, nothing..

    I am trying to access a webpage that has Windows integrated security enabled.

Similar Threads

  1. WSIT username password token failed
    By fiqueudrue in forum NetBeans
    Replies: 1
    Last Post: 02-06-2009, 09:08 AM
  2. password username and databases
    By chalo in forum JCreator
    Replies: 0
    Last Post: 12-02-2008, 09:11 AM
  3. username password verification
    By bheezee in forum JDBC
    Replies: 0
    Last Post: 11-25-2008, 07:55 PM
  4. Help, created a username and password box
    By cachi in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 05:21 AM
  5. JTextFields with username & password.
    By Eric in forum AWT / Swing
    Replies: 2
    Last Post: 07-02-2007, 12:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •