Authenticating for a java POST request
I've run myself into a bit of a corner here trying to make a post request to a server. I've been told that we are using Public Key authentication with HTTPS and SSL client certifications, but I just am unable to authenticate with the server to make my request.
Currently I am using and HttpURLConnection, but when I run the program I am returned a notification of an http response of 401 (unauthorized).
I was hoping someone here would know a little bit more about authentication in java than I do, and I could get a push in the right direction.
The following is the code for the connection that I have, but with some details (IP address, username/password) hidden.
String userPassword = "username" + ":" + "password";
String encoding = new sun.misc.BASE64Encoder().encode(userPassword.getBy tes());
URL cisco = new URL("https://urlofserver");
HttpURLConnection ciscoCon = (HttpURLConnection) cisco.openConnection();
ciscoCon.setRequestProperty("Authorization", "Basic " + encoding);
OutputStreamWriter out = new OutputStreamWriter(ciscoCon.getOutputStream());