File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes URL authentication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "URL authentication" Watch "URL authentication" New topic
Author

URL authentication

david jeche
Greenhorn

Joined: May 07, 2012
Posts: 9
hello,

I'm basically writing a code to copy the HTML source of a site and save it in to a text file im half done, got a couple of things to twick in the code but the one place where i can see my self getting stuck is where the java program will try to go and code the contents of the webpage but wont be able to because it will not be authorized to do so

i was wonder weather there was a way i could authenticate the program by maybe hard coding the required user and pass in to the code then like it logs on its self and continues to do what it has to do, i should also add that there multiple pages that it has to copy so if it can store cookies like a browser it would be great to avoid having to re-authenticate


(sorry for the bad spelling and grammar)
thanks guys in advance
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
If this was my problem, I'd use the HtmlUnit library. It's especially built was programmatic web access, and understands Basic Authentication.
jagrutkumar dalwadi
Ranch Hand

Joined: Mar 26, 2009
Posts: 83

If you have specific url for specific use, you can store to the Database and at runtime do the work.

You have mentioned about storing first successful authetication in the cookie. You can store it, but browser may be disabled the cookie.
For this thing, you can use the "USER-PROFILE" folder (in Run , type "USER-PROFILE", you will get this folder).

You can store successful authetication related data to file(you have to create by own) of this folder. You can create and write using Java script.
david jeche
Greenhorn

Joined: May 07, 2012
Posts: 9
ok well i have tried to take a look at the htm lunit library but im not getting much information from Google

and also the cookie folder i didn't really understand

if you have got any reading martial for a link or something would be helpfull in regards to all suggestions

kind regards
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

david jeche wrote:ok well i have tried to take a look at the htm lunit library but im not getting much information from Google

First link I got when I typed "HtmlUnit" in google: http://htmlunit.sourceforge.net/
On that page, click "Get Started".
jagrutkumar dalwadi
Ranch Hand

Joined: Mar 26, 2009
Posts: 83

When user is first time authenticated,write that user name to the file created in User-Profile folder.
When user hits login page 2nd time onwards, javascript code will read that file located in User-Profile folder.You came to know that user is already authenticated or not.

If you find some difficulty, let me know.
david jeche
Greenhorn

Joined: May 07, 2012
Posts: 9
jagrutkumar dalwadi wrote:When user is first time authenticated,write that user name to the file created in User-Profile folder.
When user hits login page 2nd time onwards, javascript code will read that file located in User-Profile folder.You came to know that user is already authenticated or not.

If you find some difficulty, let me know.


right i have 2 questions

1. user-profile where is this, is the a windows folder like a little explanations about this older and what it is and what it does ?

2. also i am coding in java from net-beans i cant code in java-script yet so will this auto use java script to interact with the website ?

kind regards
david jeche
Greenhorn

Joined: May 07, 2012
Posts: 9
right so ater another night spent on research ive found this a way to authenticate to the server and also a way to retrieve cookies from the browser and save and resubmite them

and incase anyone has been following this topic or having the same issues the two sites where

http://www.avajava.com/tutorials/lessons/how-do-i-connect-to-a-url-using-basic-authentication.html -- this explain the authentication part sending your details to server
http://www.hccp.org/java-net-cookie-how-to.html -- this explains the part where you have to get the cookie from the http and repose and how youu send the cookie back with the connect

now then whn i thught i was done i run in to a road block basically the site tht i am coding this programing for the login is a php form and not the acuat server :'(

so my question how do i directly feed the php my credentials and how would i still need base64 encode the credentials

kind regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URL authentication