Added model for handling TAN
This commit is contained in:
parent
1a13d5620f
commit
eaf44b107b
|
@ -0,0 +1,10 @@
|
|||
package net.codinux.banking.client.model.request
|
||||
|
||||
import net.codinux.banking.client.model.tan.EnterTanResult
|
||||
|
||||
class EnterTanResultDto(
|
||||
val tanRequestId: String,
|
||||
enteredTan: String?
|
||||
) : EnterTanResult(enteredTan) {
|
||||
override fun toString() = "$tanRequestId, entered Tan: $enteredTan"
|
||||
}
|
|
@ -2,6 +2,7 @@ package net.codinux.banking.client.model.response
|
|||
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
// TODO: may differentiate between ClientResponse, which is either Success or Error, and RestResponse, which can be Success, Error and TanRequired
|
||||
@NoArgConstructor
|
||||
open class Response<T> protected constructor(
|
||||
val type: ResponseType,
|
||||
|
@ -17,6 +18,9 @@ open class Response<T> protected constructor(
|
|||
fun <T> error(errorType: ErrorType, internalError: String? = null, errorMessagesFromBank: List<String> = emptyList()): Response<T> =
|
||||
Response(ResponseType.Error, null, Error(errorType, internalError, errorMessagesFromBank))
|
||||
|
||||
fun <T> tanRequired(tanRequired: TanRequired): Response<T> =
|
||||
Response(ResponseType.TanRequired, null, null, tanRequired)
|
||||
|
||||
fun <T> bankReturnedError(errorMessagesFromBank: List<String>): Response<T> =
|
||||
Response.error(ErrorType.BankReturnedError, null, errorMessagesFromBank)
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package net.codinux.banking.client.model.response
|
||||
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
import net.codinux.banking.client.model.tan.TanChallenge
|
||||
|
||||
@NoArgConstructor
|
||||
open class TanRequired (
|
||||
val tanRequestId: String,
|
||||
// TODO: add TAN model
|
||||
// val tanChallenge: TanChallenge
|
||||
val tanChallenge: TanChallenge
|
||||
) {
|
||||
|
||||
override fun toString() = "$tanChallenge"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
enum class ActionRequiringTan {
|
||||
GetAnonymousBankInfo,
|
||||
|
||||
GetTanMedia,
|
||||
|
||||
ChangeTanMedium,
|
||||
|
||||
GetAccountInfo,
|
||||
|
||||
GetTransactions,
|
||||
|
||||
TransferMoney
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
enum class AllowedTanFormat {
|
||||
Numeric,
|
||||
|
||||
Alphanumeric,
|
||||
|
||||
TanIsEnteredOnOtherDevice
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
@NoArgConstructor
|
||||
open class EnterTanResult(
|
||||
val enteredTan: String?,
|
||||
// val changeTanMethodTo: TanMethod? = null,
|
||||
// val changeTanMediumTo: TanMedium? = null,
|
||||
// val changeTanMediumResultCallback: ((BankingClientResponse) -> Unit)? = null
|
||||
)
|
|
@ -0,0 +1,26 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
import net.codinux.banking.client.model.config.JsonIgnore
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
@NoArgConstructor
|
||||
open class FlickerCode(
|
||||
val challengeHHD_UC: String,
|
||||
val parsedDataSet: String,
|
||||
val decodingError: String? = null
|
||||
) {
|
||||
|
||||
@JsonIgnore
|
||||
val decodingSuccessful: Boolean
|
||||
get() = decodingError == null
|
||||
|
||||
|
||||
override fun toString(): String {
|
||||
if (decodingSuccessful == false) {
|
||||
return "Decoding error: $decodingError"
|
||||
}
|
||||
|
||||
return "Parsed $challengeHHD_UC to $parsedDataSet"
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
@NoArgConstructor
|
||||
open class MobilePhoneTanMedium(
|
||||
val phoneNumber: String?
|
||||
) {
|
||||
override fun toString() = phoneNumber ?: "No phone number"
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
import net.codinux.banking.client.model.CustomerAccount
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
@NoArgConstructor
|
||||
open class TanChallenge(
|
||||
val type: TanChallengeType,
|
||||
val forAction: ActionRequiringTan,
|
||||
val customer: CustomerAccount,
|
||||
val messageToShowToUser: String,
|
||||
val tanMethod: TanMethod,
|
||||
val tanImage: TanImage? = null,
|
||||
val flickerCode: FlickerCode? = null
|
||||
// TODO: add availableTanMethods, selectedTanMedium, availableTanMedia
|
||||
) {
|
||||
|
||||
override fun toString(): String {
|
||||
return "$tanMethod: $messageToShowToUser" + when (type) {
|
||||
TanChallengeType.EnterTan -> ""
|
||||
TanChallengeType.Image -> ", Image: $tanImage"
|
||||
TanChallengeType.Flickercode -> ", FlickerCode: $flickerCode"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
enum class TanChallengeType {
|
||||
Image,
|
||||
|
||||
Flickercode,
|
||||
|
||||
EnterTan
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
@NoArgConstructor
|
||||
open class TanGeneratorTanMedium(
|
||||
val cardNumber: String
|
||||
) {
|
||||
override fun toString() = cardNumber
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
import net.codinux.banking.client.model.config.JsonIgnore
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
@NoArgConstructor
|
||||
open class TanImage(
|
||||
val mimeType: String,
|
||||
val imageBytesBase64: String,
|
||||
val decodingError: String? = null
|
||||
) {
|
||||
|
||||
@JsonIgnore
|
||||
val decodingSuccessful: Boolean
|
||||
get() = decodingError == null
|
||||
|
||||
|
||||
override fun toString(): String {
|
||||
if (decodingSuccessful == false) {
|
||||
return "Decoding error: $decodingError"
|
||||
}
|
||||
|
||||
return mimeType
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
@NoArgConstructor
|
||||
open class TanMedium(
|
||||
val type: TanMediumType,
|
||||
val displayName: String,
|
||||
val status: TanMediumStatus,
|
||||
/**
|
||||
* Only set if [type] is [TanMediumType.TanGenerator].
|
||||
*/
|
||||
val tanGenerator: TanGeneratorTanMedium? = null,
|
||||
/**
|
||||
* Only set if [type] is [TanMediumType.MobilePhone].
|
||||
*/
|
||||
val mobilePhone: MobilePhoneTanMedium? = null
|
||||
) {
|
||||
override fun toString() = "$displayName $status"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
enum class TanMediumStatus {
|
||||
Used,
|
||||
|
||||
Available
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
enum class TanMediumType {
|
||||
/**
|
||||
* All other TAN media, like AppTan.
|
||||
*/
|
||||
Generic,
|
||||
|
||||
/**
|
||||
* If I'm not wrong MobilePhone is only used for SmsTan.
|
||||
*/
|
||||
MobilePhone,
|
||||
|
||||
/**
|
||||
* Mostly used for chipTan.
|
||||
*/
|
||||
TanGenerator
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
@NoArgConstructor
|
||||
open class TanMethod(
|
||||
val displayName: String,
|
||||
val type: TanMethodType,
|
||||
val identifier: String,
|
||||
val maxTanInputLength: Int? = null,
|
||||
val allowedTanFormat: AllowedTanFormat = AllowedTanFormat.Alphanumeric
|
||||
) {
|
||||
override fun toString() = "$displayName ($type, ${identifier})"
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package net.codinux.banking.client.model.tan
|
||||
|
||||
enum class TanMethodType {
|
||||
EnterTan,
|
||||
|
||||
ChipTanManuell,
|
||||
|
||||
ChipTanFlickercode,
|
||||
|
||||
ChipTanUsb,
|
||||
|
||||
ChipTanQrCode,
|
||||
|
||||
ChipTanPhotoTanMatrixCode,
|
||||
|
||||
SmsTan,
|
||||
|
||||
AppTan,
|
||||
|
||||
photoTan,
|
||||
|
||||
QrCode
|
||||
}
|
Loading…
Reference in New Issue