diff options
author | pedroGitt <pedro.contreiras@amdocs.com> | 2016-11-28 11:56:20 +0100 |
---|---|---|
committer | pedroGitt <pedro.contreiras@amdocs.com> | 2016-11-28 11:56:20 +0100 |
commit | ac0ccb224dfac108276f30606e5cd114db3c5691 (patch) | |
tree | 7ed7f59e530305f5ea876dc7a20c546720f625a4 /java/android/OlmLibSdk/olm-sdk/src/main/java | |
parent | 0263cd3039568bd5e5b374451efc0e37c2629592 (diff) |
Update decryptMessage() API with the error message as an output parameter
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/main/java')
-rw-r--r-- | java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java index 664b22e..073058a 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java +++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java @@ -45,7 +45,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri private transient long mNativeId; /** - * Wrapper class to be used in {@link #decryptMessage(String, DecryptIndex)} + * Wrapper class to be used in {@link #decryptMessage(String, DecryptIndex, StringBuffer)} */ static public class DecryptIndex { /** decrypt index **/ @@ -142,16 +142,26 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri /** - * Decrypt the message passed in parameter. + * Decrypt the message passed in parameter.<br> + * In case of error, null is returned and an error message description is provided in aErrorMsg. * @param aEncryptedMsg the message to be decrypted * @param aDecryptIndex_out decrypted message index + * @param aErrorMsg error message description * @return the decrypted message if operation succeed, null otherwise. */ - public String decryptMessage(String aEncryptedMsg, DecryptIndex aDecryptIndex_out) { - String decryptedMessage = decryptMessageJni(aEncryptedMsg, aDecryptIndex_out, OlmManager.ENABLE_STRING_UTF8_SPECIFIC_CONVERSION); + public String decryptMessage(String aEncryptedMsg, DecryptIndex aDecryptIndex_out, StringBuffer aErrorMsg) { + String decryptedMessage = null; + + // sanity check + if(null == aErrorMsg) { + Log.e(LOG_TAG,"## decryptMessage(): invalid parameter - aErrorMsg=null"); + } else { + aErrorMsg.setLength(0); + decryptedMessage = decryptMessageJni(aEncryptedMsg, aDecryptIndex_out, aErrorMsg, OlmManager.ENABLE_STRING_UTF8_SPECIFIC_CONVERSION); + } return decryptedMessage; } - private native String decryptMessageJni(String aEncryptedMsg, DecryptIndex aDecryptIndex_out, boolean aIsUtf8ConversionRequired); + private native String decryptMessageJni(String aEncryptedMsg, DecryptIndex aDecryptIndex_out, StringBuffer aErrorMsg, boolean aIsUtf8ConversionRequired); /** |