-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e724054
commit 0ba294b
Showing
11 changed files
with
105 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
forgerock-core/src/main/java/org/forgerock/android/auth/biometric/BiometricAuthCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.forgerock.android.auth.biometric | ||
|
||
import androidx.biometric.BiometricPrompt | ||
|
||
abstract class BiometricAuthenticationCallback { | ||
/** | ||
* Called when an unrecoverable error has been encountered and authentication has stopped. | ||
* | ||
* | ||
* After this method is called, no further events will be sent for the current | ||
* authentication session. | ||
* | ||
* @param errorCode An integer ID associated with the error. | ||
* @param errString A human-readable string that describes the error. | ||
*/ | ||
open fun onAuthenticationError( | ||
@BiometricPrompt.AuthenticationError errorCode: Int, errString: CharSequence | ||
) {} | ||
|
||
/** | ||
* Called when a biometric (e.g. fingerprint, face, etc.) is recognized, indicating that the | ||
* user has successfully authenticated. | ||
* | ||
* | ||
* After this method is called, no further events will be sent for the current | ||
* authentication session. | ||
* | ||
* @param result An object containing authentication-related data. | ||
*/ | ||
open fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult?) {} | ||
|
||
/** | ||
* Called when a biometric (e.g. fingerprint, face, etc.) is presented but not recognized as | ||
* belonging to the user. | ||
*/ | ||
open fun onAuthenticationFailed() {} | ||
} | ||
|
||
internal class AuthenticationDecorator(private val listener: BiometricAuthenticationCallback? = null) { | ||
fun getAuthCallback() = object: BiometricPrompt.AuthenticationCallback() { | ||
override fun onAuthenticationError(@BiometricPrompt.AuthenticationError errorCode: Int, errString: CharSequence) { | ||
listener?.onAuthenticationError(errorCode, errString) | ||
} | ||
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { | ||
listener?.onAuthenticationSucceeded(result) | ||
} | ||
override fun onAuthenticationFailed() { | ||
listener?.onAuthenticationFailed() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.