File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I need your Help!!! -- How to Access protected Web page/Image file?

 
Sharp Tan
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I try to access same web pages and image files from a potal. Someone suggested me to use "Authenticator" class. I create a subclass named "myAuthenticator" as following:
class myAuthenticator extends Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
System.out.println("Password needed");
return new PasswordAuthentication("myid", "pw".toCharArray());
}
}
Before I create a URLConnection I call
Authenticator.setDefault(new myAuthenticator);
I try to access "http://mail.yahoo.com" and my own potal. It doesn't work. What I get is still the login page.
Who know the reason? Anybody has solution to solve my problem?
I'm very thankful for your help!
Sharp
 
Fredrik Safstrom
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sharp,
In this case I don't think your Authenticator works...
Yahoo mail seems to use JSP, ASP or something similar to ensure security, so the Authenticator doesnt work.
If you could have typed in "http://UserName:Password@mail.yahoo.com" in your browser and go straight into your mail box, then you can get the Authenticator to work...
Maybe if Yahoo Mail uses parameters like "http://mail.yahoo.com?User=UserName&Password=PassWord" you can figure out a way of heading straight into your mail-box...
I think you will have to ask Yahoo about that...
/Bamse
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic