I have a client side method:
@SuppressWarnings("unchecked")
public static void main(String[] args){
mediaTracker = new MediaTracker(frame);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
frame.setSize(dim.width, dim.height);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
setFullScreen();
RSACipher rsaCipher = new RSACipher();
// client side code
RSAKeyPair keyPair;
try {
keyPair = new RSAKeyPair(2048);
String servletURL = "http://localhost:8080/AesRsaEncryptionServiceRest/aesrsarest/doc/encryptionservice?pkey=pkey&skey=skey";
Gson gson = new GsonBuilder().create();
URL servlet = null;
try {
servlet = new URL(servletURL);
System.out.println("Sending request to " + servletURL);
HttpURLConnection servletConnection = (HttpURLConnection) servlet.openConnection();
servletConnection.setRequestMethod("POST");
servletConnection.setDoOutput(true);
servletConnection.setDoInput(true);
//send the keys to the server
ObjectOutputStream objOut = new ObjectOutputStream(servletConnection.getOutputStream());
objOut.writeObject(keyPair.getPublicKey());
objOut.flush();
objOut.close();
In line ObjectOutputStream objout, I passed the publickey needed for encryption. I want to know, if it's possible to pass a String parameter with object to post method?
I tried to create a new object, then I put the String parameters and the public key object and passed to an object stream, but it did not work. I needed the String parameters for passing the filename to be encrypted using the RESTful service