Sending java object using SSL encryption
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   irfan_mansha
Posted On:   Thursday, May 8, 2003 07:09 AM

I have an application which sends an object to http server. Now i wanna to send this object in a secure communication way. I wanna to add SSL support in my application. Is this fine to add only https in place of http in URL class or i have to use HttpsURLConnection class in place of HttpURLConnection class? My server application doesn't want to authenticate its clients. code is as follows: import java.io.*; import java.net.*; public class Client { public Client() { } public static void main(String[] args) { String query = "Send me some data"; try {    More>>

I have an application which sends an object to http server. Now i wanna to send this object in a secure communication way. I wanna to add SSL support in my application.


Is this fine to add only https in place of http in URL class
or i have to use HttpsURLConnection class in place of HttpURLConnection class?


My server application doesn't want to authenticate its clients.


code is as follows:



import java.io.*;


import java.net.*;



public class Client {


public Client() {


}


public static void main(String[] args) {


String query = "Send me some data";
try {



URL serverURL = null;


try {


serverURL = new URL

("http://localhost:8080/kamwap/pi/recObj.jsp");
}


catch (MalformedURLException e) {


e.printStackTrace();


}


URLConnection serverConn = serverURL.openConnection();


serverConn.setDoInput(true);


serverConn.setDoOutput(true);


serverConn.setUseCaches(false);


serverConn.setRequestProperty("Content-Type", "application/octet-stream");



ObjectOutputStream oos = new ObjectOutputStream(serverConn.getOutputStream());



oos.writeObject(query);


oos.flush();


oos.close();



ObjectInputStream ois = new ObjectInputStream(serverConn.getInputStream());


Object result = ois.readObject();


System.out.println(result);


ois.close();


}


catch (Exception e) {


e.printStackTrace();


}


}


}



In short, i wanna to give users trusted security solution i.e. SSL to this network communication.


Warm Regards

   <<Less
About | Sitemap | Contact