diff options
author | ylecollen <ylecollen@amdocs.com> | 2017-01-09 13:56:41 +0100 |
---|---|---|
committer | ylecollen <ylecollen@amdocs.com> | 2017-01-09 13:56:41 +0100 |
commit | 30c8d069bc37d8d72f91aacb3ae5bd64f603ad3d (patch) | |
tree | 4d636da0a958fce0783a6b3c3bd889ca40640d96 /java/android/OlmLibSdk/olm-sdk/src/main | |
parent | 7bf7a7e4158df882028df510e8d76009f2640d96 (diff) |
The crypto objects are now saved as String to keep the backward compliancy.
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/main')
-rw-r--r-- | java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/CommonSerializeUtils.java | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/CommonSerializeUtils.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/CommonSerializeUtils.java index b8c7215..30f8352 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/CommonSerializeUtils.java +++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/CommonSerializeUtils.java @@ -48,22 +48,32 @@ abstract class CommonSerializeUtils { if(null == pickledData) { throw new OlmException(OlmException.EXCEPTION_CODE_ACCOUNT_SERIALIZATION, String.valueOf(errorMsg)); } else { - aOutStream.writeObject(key); - aOutStream.writeObject(pickledData); + aOutStream.writeObject(new String(key, "UTF-8")); + aOutStream.writeObject(new String(pickledData, "UTF-8")); } } /** * Kick off the deserialization mechanism. * @param aInStream input stream - * @throws IOException exception - * @throws ClassNotFoundException exception + * @throws Exception the exception */ - protected void deserialize(ObjectInputStream aInStream) throws IOException, ClassNotFoundException { + protected void deserialize(ObjectInputStream aInStream) throws Exception { aInStream.defaultReadObject(); - byte[] key = (byte[]) aInStream.readObject(); - byte[] pickledData = (byte[]) aInStream.readObject(); + String keyAsString = (String)aInStream.readObject(); + String pickledDataAsString = (String)aInStream.readObject(); + + byte[] key; + byte[] pickledData; + + try { + key = keyAsString.getBytes("UTF-8"); + pickledData = pickledDataAsString.getBytes("UTF-8"); + + } catch (Exception e) { + throw new OlmException(OlmException.EXCEPTION_CODE_ACCOUNT_DESERIALIZATION, e.getMessage()); + } if (null == key) { throw new OlmException(OlmException.EXCEPTION_CODE_ACCOUNT_DESERIALIZATION, OlmException.EXCEPTION_MSG_INVALID_PARAMS_DESERIALIZATION+" key"); @@ -76,5 +86,5 @@ abstract class CommonSerializeUtils { } protected abstract byte[] serialize(byte[] aKey, StringBuffer aErrorMsg); - protected abstract void deserialize(byte[] aSerializedData, byte[] aKey) throws IOException; + protected abstract void deserialize(byte[] aSerializedData, byte[] aKey) throws Exception; } |