troubleshooting Question

HTTPS Authentication

Avatar of dbeayon
dbeayon asked on
10 Comments2 Solutions2733 ViewsLast Modified:
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.util.*;
import java.lang.*;

public class test
      public static void main(String[] args)
                    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(new Authenticator() {
                        protected PasswordAuthentication getPasswordAuthentication() {
                            return new PasswordAuthentication (login, password.toCharArray());
                     GetConn = PageUrl.openConnection();
                    //establish connection:
                    InputStreamReader ReadIn = new InputStreamReader(GetConn.getInputStream());
                    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)
              }//end try
              catch(IOException io)
Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros