Implemented FlickercodeTanChallenge and ImageTanChallenge so that UI doesn't have do decode challenge but fints4java already does this
This commit is contained in:
parent
a589fc89e2
commit
b3f815eb7e
|
@ -24,13 +24,9 @@ import net.dankito.banking.ui.model.Account
|
||||||
import net.dankito.banking.ui.model.TanMedium
|
import net.dankito.banking.ui.model.TanMedium
|
||||||
import net.dankito.banking.ui.model.TanMediumStatus
|
import net.dankito.banking.ui.model.TanMediumStatus
|
||||||
import net.dankito.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium
|
import net.dankito.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium
|
||||||
import net.dankito.fints.model.EnterTanResult
|
import net.dankito.fints.model.*
|
||||||
import net.dankito.fints.model.TanChallenge
|
|
||||||
import net.dankito.fints.model.TanProcedureType
|
|
||||||
import net.dankito.fints.response.client.FinTsClientResponse
|
import net.dankito.fints.response.client.FinTsClientResponse
|
||||||
import net.dankito.fints.tan.FlickercodeDecoder
|
|
||||||
import net.dankito.fints.tan.TanImage
|
import net.dankito.fints.tan.TanImage
|
||||||
import net.dankito.fints.tan.TanImageDecoder
|
|
||||||
|
|
||||||
|
|
||||||
open class EnterTanDialog : DialogFragment() {
|
open class EnterTanDialog : DialogFragment() {
|
||||||
|
@ -137,16 +133,15 @@ open class EnterTanDialog : DialogFragment() {
|
||||||
setupSelectTanMediumView(rootView)
|
setupSelectTanMediumView(rootView)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tanChallenge.tanProcedure.type == TanProcedureType.ChipTanOptisch) {
|
if (tanChallenge is FlickercodeTanChallenge) {
|
||||||
val flickerCodeView = rootView.flickerCodeView
|
val flickerCodeView = rootView.flickerCodeView
|
||||||
flickerCodeView.visibility = View.VISIBLE
|
flickerCodeView.visibility = View.VISIBLE
|
||||||
flickerCodeView.setCode(FlickercodeDecoder().decodeChallenge(tanChallenge.tanChallenge))
|
flickerCodeView.setCode((tanChallenge as FlickercodeTanChallenge).flickercode)
|
||||||
}
|
}
|
||||||
else if (tanChallenge.tanProcedure.type == TanProcedureType.ChipTanQrCode
|
else if (tanChallenge is ImageTanChallenge) {
|
||||||
|| tanChallenge.tanProcedure.type == TanProcedureType.PhotoTan) {
|
|
||||||
rootView.tanImageView.visibility = View.VISIBLE
|
rootView.tanImageView.visibility = View.VISIBLE
|
||||||
|
|
||||||
val decodedImage = TanImageDecoder().decodeChallenge(tanChallenge.tanChallenge)
|
val decodedImage = (tanChallenge as ImageTanChallenge).image
|
||||||
if (decodedImage.decodingSuccessful) {
|
if (decodedImage.decodingSuccessful) {
|
||||||
val bitmap = BitmapFactory.decodeByteArray(decodedImage.imageBytes, 0, decodedImage.imageBytes.size)
|
val bitmap = BitmapFactory.decodeByteArray(decodedImage.imageBytes, 0, decodedImage.imageBytes.size)
|
||||||
rootView.imgTanImageView.setImageBitmap(bitmap)
|
rootView.imgTanImageView.setImageBitmap(bitmap)
|
||||||
|
|
|
@ -18,6 +18,8 @@ import net.dankito.fints.response.client.FinTsClientResponse
|
||||||
import net.dankito.fints.response.client.GetTanMediaListResponse
|
import net.dankito.fints.response.client.GetTanMediaListResponse
|
||||||
import net.dankito.fints.response.client.GetTransactionsResponse
|
import net.dankito.fints.response.client.GetTransactionsResponse
|
||||||
import net.dankito.fints.response.segments.*
|
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.IAccountTransactionsParser
|
||||||
import net.dankito.fints.transactions.Mt940AccountTransactionsParser
|
import net.dankito.fints.transactions.Mt940AccountTransactionsParser
|
||||||
import net.dankito.fints.util.IBase64Service
|
import net.dankito.fints.util.IBase64Service
|
||||||
|
@ -644,7 +646,15 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
val challenge = tanResponse.challengeHHD_UC ?: ""
|
val challenge = tanResponse.challengeHHD_UC ?: ""
|
||||||
val tanProcedure = customer.selectedTanProcedure
|
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,
|
protected open fun sendTanToBank(enteredTan: String, tanResponse: TanResponse, bank: BankData,
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue