I have the following project for homework. Need to create server-client with ftps and upload file to the server. Before uploading the file must be encrypted.The server from the other side, upon receiving the encrypted file, decrypt the file.I'm stuck here.
I encrypted the file using first reply here Simplest way to encrypt a text file in java (with DES) and sent file to the server.Server receives the file but it receives it encrypted(obviously). I read some about that ssl does decryption automatically but how do I set it? Any help would be much appreciated.
Server:
this.factory.setPort(port);
this.ssl.setKeystoreFile(this.getKeystore());
this.ssl.setKeystorePassword("password");
this.factory.setSslConfiguration(ssl.createSslConfiguration());
this.factory.setImplicitSsl(true);
this.serverFactory.addListener("default",
factory.createListener());
this.userManagerFactory.setFile(new File("user.properties"));
this.serverFactory.setUserManager
(userManagerFactory.createUserManager());
this.server = serverFactory.createServer();
this.server.start();
Client:
ftpsClient.connect(server,port);
ftpsClient.login(user,pass);
ftpsClient.enterLocalPassiveMode();
ftpsClient.type(FTP.BINARY_FILE_TYPE);
File firstLocalFile =encryptFile();
String firstRemoteFile = "test.txt";
InputStream is = new FileInputStream(firstLocalFile);
ftpsClient.storeFile(firstRemoteFile, is);
is.close();
ftpsClient.logout();
ftpsClient.disconnect();