diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/EnterTanDialog.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/EnterTanDialog.kt index ec32394b..b0818144 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/EnterTanDialog.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/EnterTanDialog.kt @@ -24,13 +24,9 @@ import net.dankito.banking.ui.model.Account import net.dankito.banking.ui.model.TanMedium import net.dankito.banking.ui.model.TanMediumStatus import net.dankito.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium -import net.dankito.fints.model.EnterTanResult -import net.dankito.fints.model.TanChallenge -import net.dankito.fints.model.TanProcedureType +import net.dankito.fints.model.* import net.dankito.fints.response.client.FinTsClientResponse -import net.dankito.fints.tan.FlickercodeDecoder import net.dankito.fints.tan.TanImage -import net.dankito.fints.tan.TanImageDecoder open class EnterTanDialog : DialogFragment() { @@ -137,16 +133,15 @@ open class EnterTanDialog : DialogFragment() { setupSelectTanMediumView(rootView) } - if (tanChallenge.tanProcedure.type == TanProcedureType.ChipTanOptisch) { + if (tanChallenge is FlickercodeTanChallenge) { val flickerCodeView = rootView.flickerCodeView flickerCodeView.visibility = View.VISIBLE - flickerCodeView.setCode(FlickercodeDecoder().decodeChallenge(tanChallenge.tanChallenge)) + flickerCodeView.setCode((tanChallenge as FlickercodeTanChallenge).flickercode) } - else if (tanChallenge.tanProcedure.type == TanProcedureType.ChipTanQrCode - || tanChallenge.tanProcedure.type == TanProcedureType.PhotoTan) { + else if (tanChallenge is ImageTanChallenge) { rootView.tanImageView.visibility = View.VISIBLE - val decodedImage = TanImageDecoder().decodeChallenge(tanChallenge.tanChallenge) + val decodedImage = (tanChallenge as ImageTanChallenge).image if (decodedImage.decodingSuccessful) { val bitmap = BitmapFactory.decodeByteArray(decodedImage.imageBytes, 0, decodedImage.imageBytes.size) rootView.imgTanImageView.setImageBitmap(bitmap) diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt index 984e3105..9fa33d27 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -18,6 +18,8 @@ import net.dankito.fints.response.client.FinTsClientResponse import net.dankito.fints.response.client.GetTanMediaListResponse import net.dankito.fints.response.client.GetTransactionsResponse import net.dankito.fints.response.segments.* +import net.dankito.fints.tan.FlickercodeDecoder +import net.dankito.fints.tan.TanImageDecoder import net.dankito.fints.transactions.IAccountTransactionsParser import net.dankito.fints.transactions.Mt940AccountTransactionsParser import net.dankito.fints.util.IBase64Service @@ -644,7 +646,15 @@ open class FinTsClient @JvmOverloads constructor( val challenge = tanResponse.challengeHHD_UC ?: "" val tanProcedure = customer.selectedTanProcedure - return TanChallenge(messageToShowToUser, challenge, tanProcedure, tanResponse.tanMediaIdentifier) + return when (tanProcedure.type) { + TanProcedureType.ChipTanOptisch, TanProcedureType.ChipTanManuell -> + FlickercodeTanChallenge(FlickercodeDecoder().decodeChallenge(challenge), messageToShowToUser, challenge, tanProcedure, tanResponse.tanMediaIdentifier) + + TanProcedureType.ChipTanQrCode, TanProcedureType.PhotoTan -> + ImageTanChallenge(TanImageDecoder().decodeChallenge(challenge), messageToShowToUser, challenge, tanProcedure, tanResponse.tanMediaIdentifier) + + else -> TanChallenge(messageToShowToUser, challenge, tanProcedure, tanResponse.tanMediaIdentifier) + } } protected open fun sendTanToBank(enteredTan: String, tanResponse: TanResponse, bank: BankData, diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/FlickercodeTanChallenge.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/FlickercodeTanChallenge.kt new file mode 100644 index 00000000..f4145631 --- /dev/null +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/FlickercodeTanChallenge.kt @@ -0,0 +1,18 @@ +package net.dankito.fints.model + +import net.dankito.fints.tan.Flickercode + + +open class FlickercodeTanChallenge( + val flickercode: Flickercode, + messageToShowToUser: String, + challenge: String, + tanProcedure: TanProcedure, + tanMediaIdentifier: String? +) : TanChallenge(messageToShowToUser, challenge, tanProcedure, tanMediaIdentifier) { + + override fun toString(): String { + return "$tanProcedure (medium: $tanMediaIdentifier) $flickercode: $messageToShowToUser" + } + +} \ No newline at end of file diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/ImageTanChallenge.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/ImageTanChallenge.kt new file mode 100644 index 00000000..24c06432 --- /dev/null +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/ImageTanChallenge.kt @@ -0,0 +1,18 @@ +package net.dankito.fints.model + +import net.dankito.fints.tan.TanImage + + +open class ImageTanChallenge( + val image: TanImage, + messageToShowToUser: String, + challenge: String, + tanProcedure: TanProcedure, + tanMediaIdentifier: String? +) : TanChallenge(messageToShowToUser, challenge, tanProcedure, tanMediaIdentifier) { + + override fun toString(): String { + return "$tanProcedure (medium: $tanMediaIdentifier) $image: $messageToShowToUser" + } + +} \ No newline at end of file