-
-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove a thread blocking behaviour #547
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
|
||
import java.security.GeneralSecurityException; | ||
import java.security.Key; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* @see <a href="https://github.com/facebook/conceal">Conceal Project</a> | ||
|
@@ -96,10 +97,10 @@ public EncryptionResult encrypt(@NonNull final String alias, | |
|
||
@NonNull | ||
@Override | ||
public DecryptionResult decrypt(@NonNull final String alias, | ||
@NonNull final byte[] username, | ||
@NonNull final byte[] password, | ||
@NonNull final SecurityLevel level) | ||
public CompletableFuture<DecryptionResult> decrypt(@NonNull final String alias, | ||
@NonNull final byte[] username, | ||
@NonNull final byte[] password, | ||
@NonNull final SecurityLevel level) | ||
throws CryptoFailedException { | ||
|
||
throwIfInsufficientLevel(level); | ||
|
@@ -112,30 +113,25 @@ public DecryptionResult decrypt(@NonNull final String alias, | |
final byte[] decryptedUsername = crypto.decrypt(username, usernameEntity); | ||
final byte[] decryptedPassword = crypto.decrypt(password, passwordEntity); | ||
|
||
return new DecryptionResult( | ||
return CompletableFuture.supplyAsync(() -> new DecryptionResult( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This call requires API level 24. ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think to include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This compat version seems to be not official one. We will have maintenance issues later on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @savelichalex We tested this patch and observed it fixes the crash issue, writing own wrapper sounds good to me will you be able to update this pr. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ankitsingh08 when I tried to make the wrapper turned out it's not a 20 minutes ride :D I have an idea to make it with callbacks, unfortunately I don't have much time for this right now, but I'll try to allocate some time for it |
||
new String(decryptedUsername, UTF8), | ||
new String(decryptedPassword, UTF8), | ||
SecurityLevel.ANY); | ||
SecurityLevel.ANY)); | ||
} catch (Throwable fail) { | ||
throw new CryptoFailedException("Decryption failed for alias: " + alias, fail); | ||
} | ||
} | ||
|
||
/** redirect call to default {@link #decrypt(String, byte[], byte[], SecurityLevel)} method. */ | ||
/** | ||
* redirect call to default {@link #decrypt(String, byte[], byte[], SecurityLevel)} method. | ||
*/ | ||
@Override | ||
public void decrypt(@NonNull DecryptionResultHandler handler, | ||
@NonNull String service, | ||
@NonNull byte[] username, | ||
@NonNull byte[] password, | ||
@NonNull final SecurityLevel level) { | ||
|
||
try { | ||
final DecryptionResult results = decrypt(service, username, password, level); | ||
|
||
handler.onDecrypt(results, null); | ||
} catch (Throwable fail) { | ||
handler.onDecrypt(null, fail); | ||
} | ||
public CompletableFuture<DecryptionResult> decrypt(@NonNull DecryptionResultHandler handler, | ||
@NonNull String service, | ||
@NonNull byte[] username, | ||
@NonNull byte[] password, | ||
@NonNull final SecurityLevel level) throws CryptoFailedException { | ||
return decrypt(service, username, password, level); | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these 2
decrypt
calls also be part ofsupplyAsync
?