Skip to Main Content

Application Development Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Authentication error in weblogic portal 10.2 (Response: '401: Unauthorized'

681171May 4 2010 — edited May 4 2010
I have written following code in my page flow controller in order to access file from a shared location:

Authenticator.setDefault(new MyAuthenticator(username, password));
URLConnection conn = new URL(urlString).openConnection();

InputStream instr = conn.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(instr));

String str;
while ((str = in.readLine()) != null) {
System.out.println(str);
}

It always gives me folloing error:

java.io.FileNotFoundException: Response: '401: Unauthorized' for url: 'http://coldev01.col.us.bic/testspec/library/Approved/Packaging%20Components/5647495.pdf'
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:476)
at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:36)

If I directly past this url in browser then this pdf opens properly but when i try to do through code then it does not work. Any quick help would be highly appreciated.

MyAuthenticator class
private static class MyAuthenticator extends Authenticator {
private String username, password;
public MyAuthenticator(String user, String pass) {
username = user;
password = pass;
}

protected PasswordAuthentication getPasswordAuthentication() {
System.out.println("Requesting Host : " + getRequestingHost());
System.out.println("Requesting Port : " + getRequestingPort());
System.out.println("Requesting Prompt : " + getRequestingPrompt());
System.out.println("Requesting Protocol: "
+ getRequestingProtocol());
System.out.println("Requesting Scheme : " + getRequestingScheme());
System.out.println("Requesting Site : " + getRequestingSite());
return new PasswordAuthentication(username, password.toCharArray());
}
}

}

Thanks,
Alka

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 1 2010
Added on May 4 2010
1 comment
1,444 views