This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Security and the fly likes Programatically call Java 2 secured page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Programatically call Java 2 secured page" Watch "Programatically call Java 2 secured page" New topic
Author

Programatically call Java 2 secured page

Adam Kreiss
Ranch Hand

Joined: Sep 12, 2005
Posts: 35
Hey,

Not positive this is the right forum but here it goes.

Does anyone have a good tutorial for accessing a web page via Java code where the page is secured with standard Java 2 security by the web server? Ideally I'd like to use Apache HttpClient to do so but haven't been able to find any good examples.

Thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
What do you mean by "secured with standard Java 2 security"? The only security that would be applicable to a web app would be to use HTTP Authentication (and possibly using HTTPS, which doesn't have much to do with Java). HttpClient can handle HTTP Authentication.


Ping & DNS - my free Android networking tools app
Adam Kreiss
Ranch Hand

Joined: Sep 12, 2005
Posts: 35
Sorry for the confusion.

I'm thinking about the j_username/j_password user auth functionality that most web servers offer. How would I go about passing the auth values in a request to the server?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
Ah, that's called FORM authentication, and is a little harder to automate. The code would access some URL that is protected, which would then cause the login page to be shown. Into that page (or rather, the HTML form in it) would the code enter appropriate values for j_username and j_password, and then submit it. If everything went OK, the server would then respond with the page that was originally requested.
This discussion may help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Programatically call Java 2 secured page