-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from nevissecurity/feature/NEVISACCESSAPP-5666-…
…Password-authenticator
- Loading branch information
Showing
44 changed files
with
1,766 additions
and
704 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ class ExampleApplication : Application() { | |
Timber.plant(ExampleAppTimberDebugTree(sdkLogger)) | ||
} | ||
//endregion | ||
} | ||
} |
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
63 changes: 63 additions & 0 deletions
63
app/src/main/java/ch/nevis/exampleapp/domain/interaction/password/PasswordChangerImpl.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,63 @@ | ||
/** | ||
* Nevis Mobile Authentication SDK Example App | ||
* | ||
* Copyright © 2024. Nevis Security AG. All rights reserved. | ||
*/ | ||
|
||
package ch.nevis.exampleapp.domain.interaction.password | ||
|
||
import ch.nevis.exampleapp.NavigationGraphDirections | ||
import ch.nevis.exampleapp.logging.sdk | ||
import ch.nevis.exampleapp.ui.credential.model.CredentialViewMode | ||
import ch.nevis.exampleapp.ui.credential.parameter.PasswordNavigationParameter | ||
import ch.nevis.exampleapp.ui.navigation.NavigationDispatcher | ||
import ch.nevis.mobile.sdk.api.operation.password.PasswordChangeContext | ||
import ch.nevis.mobile.sdk.api.operation.password.PasswordChangeHandler | ||
import ch.nevis.mobile.sdk.api.operation.password.PasswordChanger | ||
import ch.nevis.mobile.sdk.api.operation.password.PasswordPolicy | ||
import timber.log.Timber | ||
|
||
/** | ||
* Default implementation of [PasswordChanger] interface. Navigates to Credential view with the received | ||
* [PasswordChangeHandler], [ch.nevis.mobile.sdk.api.operation.password.PasswordAuthenticatorProtectionStatus] | ||
* and [ch.nevis.mobile.sdk.api.operation.password.PasswordChangeRecoverableError] objects. | ||
*/ | ||
class PasswordChangerImpl( | ||
/** | ||
* An instance of a [PasswordPolicy] interface implementation. | ||
*/ | ||
private val policy: PasswordPolicy, | ||
|
||
/** | ||
* An instance of a [NavigationDispatcher] interface implementation. | ||
*/ | ||
private val navigationDispatcher: NavigationDispatcher | ||
) : PasswordChanger { | ||
|
||
//region PasswordChanger | ||
override fun changePassword( | ||
context: PasswordChangeContext, | ||
handler: PasswordChangeHandler | ||
) { | ||
if (context.lastRecoverableError().isPresent) { | ||
Timber.asTree().sdk("Password change failed. Please try again.") | ||
} else { | ||
Timber.asTree().sdk("Please start Password change.") | ||
} | ||
|
||
navigationDispatcher.requestNavigation( | ||
NavigationGraphDirections.actionGlobalCredentialFragment( | ||
PasswordNavigationParameter( | ||
CredentialViewMode.CHANGE, | ||
lastRecoverableError = context.lastRecoverableError().orElse(null), | ||
passwordAuthenticatorProtectionStatus = context.authenticatorProtectionStatus(), | ||
passwordChangeHandler = handler | ||
) | ||
) | ||
) | ||
} | ||
|
||
// You can add custom password policy by overriding the `passwordPolicy` getter | ||
override fun passwordPolicy(): PasswordPolicy = policy | ||
//endregion | ||
} |
66 changes: 66 additions & 0 deletions
66
app/src/main/java/ch/nevis/exampleapp/domain/interaction/password/PasswordEnrollerImpl.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,66 @@ | ||
/** | ||
* Nevis Mobile Authentication SDK Example App | ||
* | ||
* Copyright © 2024. Nevis Security AG. All rights reserved. | ||
*/ | ||
|
||
package ch.nevis.exampleapp.domain.interaction.password | ||
|
||
import ch.nevis.exampleapp.NavigationGraphDirections | ||
import ch.nevis.exampleapp.logging.sdk | ||
import ch.nevis.exampleapp.ui.credential.model.CredentialViewMode | ||
import ch.nevis.exampleapp.ui.credential.parameter.PasswordNavigationParameter | ||
import ch.nevis.exampleapp.ui.navigation.NavigationDispatcher | ||
import ch.nevis.mobile.sdk.api.operation.password.PasswordEnroller | ||
import ch.nevis.mobile.sdk.api.operation.password.PasswordEnrollmentContext | ||
import ch.nevis.mobile.sdk.api.operation.password.PasswordEnrollmentHandler | ||
import ch.nevis.mobile.sdk.api.operation.password.PasswordPolicy | ||
import timber.log.Timber | ||
|
||
/** | ||
* Default implementation of [PasswordEnroller] interface. Navigates to Credential view with the | ||
* received [PasswordEnrollmentHandler] and [ch.nevis.mobile.sdk.api.operation.password.PasswordEnrollmentError] | ||
* objects. | ||
*/ | ||
class PasswordEnrollerImpl( | ||
/** | ||
* An instance of a [PasswordPolicy] interface implementation. | ||
*/ | ||
private val policy: PasswordPolicy, | ||
|
||
/** | ||
* An instance of a [NavigationDispatcher] interface implementation. | ||
*/ | ||
private val navigationDispatcher: NavigationDispatcher | ||
) : PasswordEnroller { | ||
|
||
//region PasswordEnroller | ||
override fun enrollPassword( | ||
context: PasswordEnrollmentContext, | ||
handler: PasswordEnrollmentHandler | ||
) { | ||
if (context.lastRecoverableError().isPresent) { | ||
Timber.asTree().sdk("Password enrollment failed. Please try again.") | ||
} else { | ||
Timber.asTree().sdk("Please start Password enrollment.") | ||
} | ||
|
||
navigationDispatcher.requestNavigation( | ||
NavigationGraphDirections.actionGlobalCredentialFragment( | ||
PasswordNavigationParameter( | ||
CredentialViewMode.ENROLLMENT, | ||
lastRecoverableError = context.lastRecoverableError().orElse(null), | ||
passwordEnrollmentHandler = handler | ||
) | ||
) | ||
) | ||
} | ||
|
||
override fun onValidCredentialsProvided() { | ||
Timber.asTree().sdk("Valid credentials provided during Password enrollment.") | ||
} | ||
|
||
// You can add custom password policy by overriding the `passwordPolicy` getter | ||
override fun passwordPolicy(): PasswordPolicy = policy | ||
//endregion | ||
} |
59 changes: 59 additions & 0 deletions
59
...src/main/java/ch/nevis/exampleapp/domain/interaction/password/PasswordUserVerifierImpl.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,59 @@ | ||
/** | ||
* Nevis Mobile Authentication SDK Example App | ||
* | ||
* Copyright © 2024. Nevis Security AG. All rights reserved. | ||
*/ | ||
|
||
package ch.nevis.exampleapp.domain.interaction.password | ||
|
||
import ch.nevis.exampleapp.NavigationGraphDirections | ||
import ch.nevis.exampleapp.logging.sdk | ||
import ch.nevis.exampleapp.ui.credential.model.CredentialViewMode | ||
import ch.nevis.exampleapp.ui.credential.parameter.PasswordNavigationParameter | ||
import ch.nevis.exampleapp.ui.navigation.NavigationDispatcher | ||
import ch.nevis.mobile.sdk.api.operation.userverification.PasswordUserVerificationContext | ||
import ch.nevis.mobile.sdk.api.operation.userverification.PasswordUserVerificationHandler | ||
import ch.nevis.mobile.sdk.api.operation.userverification.PasswordUserVerifier | ||
import timber.log.Timber | ||
|
||
/** | ||
* Default implementation of [PasswordUserVerifier] interface. Navigates to Credential view with the | ||
* received [PasswordUserVerificationHandler], [ch.nevis.mobile.sdk.api.operation.password.PasswordAuthenticatorProtectionStatus] | ||
* and [ch.nevis.mobile.sdk.api.operation.userverification.PasswordUserVerificationError] objects. | ||
*/ | ||
class PasswordUserVerifierImpl( | ||
|
||
/** | ||
* An instance of a [NavigationDispatcher] interface implementation. | ||
*/ | ||
private val navigationDispatcher: NavigationDispatcher | ||
) : PasswordUserVerifier { | ||
|
||
//region PasswordUserVerifier | ||
override fun verifyPassword( | ||
context: PasswordUserVerificationContext, | ||
handler: PasswordUserVerificationHandler | ||
) { | ||
if (context.lastRecoverableError().isPresent) { | ||
Timber.asTree().sdk("Password user verification failed. Please try again.") | ||
} else { | ||
Timber.asTree().sdk("Please start Password user verification.") | ||
} | ||
|
||
navigationDispatcher.requestNavigation( | ||
NavigationGraphDirections.actionGlobalCredentialFragment( | ||
PasswordNavigationParameter( | ||
CredentialViewMode.VERIFICATION, | ||
lastRecoverableError = context.lastRecoverableError().orElse(null), | ||
passwordAuthenticatorProtectionStatus = context.authenticatorProtectionStatus(), | ||
passwordUserVerificationHandler = handler | ||
) | ||
) | ||
) | ||
} | ||
|
||
override fun onValidCredentialsProvided() { | ||
Timber.asTree().sdk("Valid credentials provided during Password verification.") | ||
} | ||
//endregion | ||
} |
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
Oops, something went wrong.