I am wondering if there is a way to pass the userid and password to a device on my intranet that requires HTTP Authorization when calling a resource. An example url is below. I would like the have the .java template that I can complile using [login to view URL] into a .class file that will run using java.exe. I then could change the url, userid, and password when needed. I also need any instructions that I need in configuring my pc to run the app (such as adding ASPNET or NETWORK SERVICE, etc.).
[login to view URL]
I have been told that I need to use HttpRequest to Enable ASP.NET to read the HTTP values sent by a client during the Web request.
And the following snippet was suggested for the Authorization, but I need an entire app.
"You will have to pass the userid/password in the HTTP Authorization header. Here’s a little Java snippet that creates the Authorization Header:
public static String getBasicCredentials(String uid, String pwd){
String credentials=uid+":"+pwd;
credentials="Basic "+[login to view URL]([login to view URL]());
return credentials;
}
public static String getAuthenticationHeader(String uid, String pwd){
if (uid == null || pwd == null){
return null;
}
StringBuffer out=new StringBuffer("Authorization: ");
[login to view URL]([login to view URL](uid, pwd));
[login to view URL]("\r\n");
return [login to view URL]();
}
The algorithm is pretty simple:
1. Authorization: Basic credentials
2. credentials = Base64 encoding of (userid:password) … please note the ‘:’ between userid and password"