From 1cbb60d7eddef1fc27d050a74b0f7ffbd9d64740 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 30 Sep 2018 13:48:11 +0200 Subject: [PATCH] removed unused code (otr jingle encrypted file transfer) --- .../http/HttpDownloadConnection.java | 2 +- .../services/AbstractConnectionManager.java | 27 +++++++------------ .../xmpp/jingle/JingleConnection.java | 6 ++--- .../xmpp/jingle/JingleInbandTransport.java | 6 ++--- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index 12ba5d4f4..0a85e2a06 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -405,7 +405,7 @@ public class HttpDownloadConnection implements Transferable { if (!file.exists() && !file.createNewFile()) { throw new FileWriterException(); } - os = AbstractConnectionManager.createOutputStream(file, true); + os = AbstractConnectionManager.createOutputStream(file); } int count; byte[] buffer = new byte[4096]; diff --git a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java index 677d7dd70..ae0245ecf 100644 --- a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java @@ -66,14 +66,14 @@ public class AbstractConnectionManager { } public static OutputStream createAppendedOutputStream(DownloadableFile file) { - return createOutputStream(file, false, true); + return createOutputStream(file, true); } - public static OutputStream createOutputStream(DownloadableFile file, boolean gcm) { - return createOutputStream(file, gcm, false); + public static OutputStream createOutputStream(DownloadableFile file) { + return createOutputStream(file, false); } - private static OutputStream createOutputStream(DownloadableFile file, boolean gcm, boolean append) { + private static OutputStream createOutputStream(DownloadableFile file, boolean append) { FileOutputStream os; try { os = new FileOutputStream(file, append); @@ -84,20 +84,13 @@ public class AbstractConnectionManager { return null; } try { - if (gcm) { - Cipher cipher = Compatibility.twentyTwo() ? Cipher.getInstance(CIPHERMODE) : Cipher.getInstance(CIPHERMODE, PROVIDER); - SecretKeySpec keySpec = new SecretKeySpec(file.getKey(), KEYTYPE); - IvParameterSpec ivSpec = new IvParameterSpec(file.getIv()); - cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); - return new CipherOutputStream(os, cipher); - } else { - IvParameterSpec ips = new IvParameterSpec(file.getIv()); - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(file.getKey(), KEYTYPE), ips); - return new CipherOutputStream(os, cipher); - } + Cipher cipher = Cipher.getInstance(CIPHERMODE); + SecretKeySpec keySpec = new SecretKeySpec(file.getKey(), KEYTYPE); + IvParameterSpec ivSpec = new IvParameterSpec(file.getIv()); + cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); + return new CipherOutputStream(os, cipher); } catch (Exception e) { - throw new AssertionError(e); + return null; } } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index c12afeefd..5be45db7d 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -151,18 +151,18 @@ public class JingleConnection implements Transferable { } }; - public InputStream getFileInputStream() { + InputStream getFileInputStream() { return this.mFileInputStream; } - public OutputStream getFileOutputStream() throws IOException { + OutputStream getFileOutputStream() throws IOException { if (this.file == null) { Log.d(Config.LOGTAG,"file object was not assigned"); return null; } this.file.getParentFile().mkdirs(); this.file.createNewFile(); - this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file,message.getEncryption() == Message.ENCRYPTION_AXOLOTL); + this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file); return this.mFileOutputStream; } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java index aeb7e991c..dfa3850cf 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java @@ -94,8 +94,7 @@ public class JingleInbandTransport extends JingleTransport { } @Override - public void receive(DownloadableFile file, - OnFileTransmissionStatusChanged callback) { + public void receive(DownloadableFile file, OnFileTransmissionStatusChanged callback) { this.onFileTransmissionStatusChanged = callback; this.file = file; try { @@ -115,8 +114,7 @@ public class JingleInbandTransport extends JingleTransport { } @Override - public void send(DownloadableFile file, - OnFileTransmissionStatusChanged callback) { + public void send(DownloadableFile file, OnFileTransmissionStatusChanged callback) { this.onFileTransmissionStatusChanged = callback; this.file = file; try {