-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change
TOTPUtils
to PACUtils
and update format of data to work with
- Loading branch information
1 parent
6e21766
commit 96157d2
Showing
2 changed files
with
62 additions
and
91 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
library/src/main/java/com/wultra/android/mtokensdk/operation/PACUtils.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,62 @@ | ||
/* | ||
* Copyright 2023 Wultra s.r.o. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
package com.wultra.android.mtokensdk.operation | ||
|
||
import android.net.Uri | ||
import com.google.gson.annotations.SerializedName | ||
import com.wultra.android.mtokensdk.common.Logger | ||
|
||
/** | ||
* Utility class used for handling TOTP | ||
*/ | ||
class PACUtils { | ||
|
||
/** Data which is return after parsing PAC code */ | ||
data class PACData( | ||
|
||
/** Time-based one time password used for Proximity antifraud check */ | ||
@SerializedName("oid") | ||
val operationId: String, | ||
|
||
/** The ID of the operation associated with the PAC */ | ||
val totp: String? | ||
) | ||
|
||
companion object { | ||
|
||
/** Method accepts deeplink URL and returns PAC data */ | ||
fun parseDeeplink(uri: Uri): PACData? { | ||
val components = Uri.parse(uri.toString()) | ||
|
||
components.getQueryParameter("oid")?.let { operationId -> | ||
val totp = components.getQueryParameter("totp") | ||
return PACData(operationId, totp) | ||
} ?: run { | ||
Logger.e("Failed to get operationId from query items keys: ${components.queryParameterNames}") | ||
return null | ||
} | ||
} | ||
|
||
/** Method accepts scanned code as a String and returns PAC data */ | ||
fun parseQRCode(code: String): PACData? { | ||
val encodedURLString = Uri.encode(code) | ||
val uri = Uri.parse(encodedURLString) | ||
|
||
return parseDeeplink(uri) | ||
} | ||
} | ||
} |
91 changes: 0 additions & 91 deletions
91
library/src/main/java/com/wultra/android/mtokensdk/operation/TOTPUtils.kt
This file was deleted.
Oops, something went wrong.