I am trying to post to a aspx site and need some help generating the correct script in JAVA. HEre is what I have for instructions:
All clearinghouses will use ID and Password as the default authentication requirements. (e.g. no individual 3rd party certificates will be required beyond the normal ubiquitous SSL Internet certification process). User ID and Password authentication is based on a scripted process to be contained in the header of the HTTP Post Message, and not through a forms-based authentication model.
Certificate Information
All certificates are server side certificates that are generated internally. These certificates will not be verifiable through third party Certificate Authorities. The clearing house must accept the certificates as valid for the encryption process.
Authorization Process
Authorization is performed through HTTP Basic Authentication. In the Authentication request, the user agent supplies a header formatted in accordance with RFC 1617;
Authorization: Basic userid:password
The userid:password text is base64-encoded. The authorization request header for ;
Authorization: Basic joe:user will actually be transmitted as, Authorization Basic Q2hyaXNqOk1hcmlz.
The server will validate the user information and supply either a 200 : OK response with session cookies attached, or a 401 Not Authorized message. Once a user has been authorized, the user may then begin to post transactions
-----------------
I have the certificate correctly stored in the keystore, so tha part is ok. you may substitute the url for any known site, and create the test.txt file to have the code function. I have the following code so far:
import java.text.*;
import java.net.*;
import java.util.*;
import java.io.*;
import java.lang.*;
public class test
{
public static void main(String[] args)
{
try
{
URL PageUrl;
URLConnection GetConn = null;
GetConn = null;
PageUrl = new URL("
https://mysecuresite.ashx");
//The above line returns error message:
//unable to find valid certification path to requested target
final String login ="login";
final String password ="password";
Authenticator.setDefault(n
ew Authenticator() {
protected PasswordAuthentication getPasswordAuthentication(
) {
return new PasswordAuthentication (login, password.toCharArray());
}
});
GetConn = PageUrl.openConnection();
//establish connection:
GetConn.connect();
InputStreamReader ReadIn = new InputStreamReader(GetConn.
getInputSt
ream());
BufferedReader BufData = new BufferedReader(ReadIn);
String TextFileName = ("C:/test.txt");
FileWriter FWriter = new FileWriter(TextFileName);
BufferedWriter BWriter = new BufferedWriter(FWriter);
String UrlData = null;
while ((UrlData = BufData.readLine()) != null)
{
BWriter.write(UrlData);
BWriter.newLine();
}
BWriter.close();
}//end try
catch(IOException io)
{
System.out.println(io);
}
}
}