Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
matrix-org
Olm
Commits
30c8d069
Commit
30c8d069
authored
Jan 09, 2017
by
ylecollen
Browse files
The crypto objects are now saved as String to keep the backward compliancy.
parent
7bf7a7e4
Changes
1
Show whitespace changes
Inline
Side-by-side
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/CommonSerializeUtils.java
View file @
30c8d069
...
...
@@ -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
,
ClassNotFound
Exception
{
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
IO
Exception
;
protected
abstract
void
deserialize
(
byte
[]
aSerializedData
,
byte
[]
aKey
)
throws
Exception
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment