mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 20:19:42 +01:00
Update calls to secure check
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
455601b5a6
commit
feafb0c357
@ -92,7 +92,7 @@ public class BaseActivity extends AppCompatActivity {
|
|||||||
private void checkIfWeAreSecure() {
|
private void checkIfWeAreSecure() {
|
||||||
keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
|
keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
|
||||||
if (keyguardManager != null && keyguardManager.isKeyguardSecure() && appPreferences.getIsScreenLocked()) {
|
if (keyguardManager != null && keyguardManager.isKeyguardSecure() && appPreferences.getIsScreenLocked()) {
|
||||||
if (!SecurityUtils.checkIfWeAreAuthenticated()) {
|
if (!SecurityUtils.checkIfWeAreAuthenticated(appPreferences.getScreenLockTimeout())) {
|
||||||
showAuthenticationScreen();
|
showAuthenticationScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public class BaseActivity extends AppCompatActivity {
|
|||||||
if (requestCode == REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS) {
|
if (requestCode == REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (SecurityUtils.checkIfWeAreAuthenticated()) {
|
if (SecurityUtils.checkIfWeAreAuthenticated(appPreferences.getScreenLockTimeout())) {
|
||||||
// all went well
|
// all went well
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class SecurityUtils {
|
|||||||
private static final byte[] SECRET_BYTE_ARRAY = new byte[]{1, 2, 3, 4, 5, 6};
|
private static final byte[] SECRET_BYTE_ARRAY = new byte[]{1, 2, 3, 4, 5, 6};
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||||
public static boolean checkIfWeAreAuthenticated() {
|
public static boolean checkIfWeAreAuthenticated(String screenLockTimeout) {
|
||||||
try {
|
try {
|
||||||
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
|
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
|
||||||
keyStore.load(null);
|
keyStore.load(null);
|
||||||
@ -63,11 +63,17 @@ public class SecurityUtils {
|
|||||||
// User is not authenticated, let's authenticate with device credentials.
|
// User is not authenticated, let's authenticate with device credentials.
|
||||||
return false;
|
return false;
|
||||||
} catch (KeyPermanentlyInvalidatedException e) {
|
} catch (KeyPermanentlyInvalidatedException e) {
|
||||||
|
// This happens if the lock screen has been disabled or reset after the key was
|
||||||
|
// generated after the key was generated.
|
||||||
|
// Shouldnt really happen because we regenerate the key every time an activity
|
||||||
|
// is created, but oh well
|
||||||
|
// Create key, and attempt again
|
||||||
|
createKey(screenLockTimeout);
|
||||||
return false;
|
return false;
|
||||||
} catch (BadPaddingException | IllegalBlockSizeException | KeyStoreException |
|
} catch (BadPaddingException | IllegalBlockSizeException | KeyStoreException |
|
||||||
CertificateException | UnrecoverableKeyException | IOException
|
CertificateException | UnrecoverableKeyException | IOException
|
||||||
| NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException e) {
|
| NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException e) {
|
||||||
return false;
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user