diff --git a/src/main/java/com/pubnub/api/managers/token_manager/TokenParser.kt b/src/main/kotlin/com/pubnub/api/managers/token_manager/TokenParser.kt similarity index 90% rename from src/main/java/com/pubnub/api/managers/token_manager/TokenParser.kt rename to src/main/kotlin/com/pubnub/api/managers/token_manager/TokenParser.kt index 4262cc598..894f0fc94 100644 --- a/src/main/java/com/pubnub/api/managers/token_manager/TokenParser.kt +++ b/src/main/kotlin/com/pubnub/api/managers/token_manager/TokenParser.kt @@ -10,11 +10,6 @@ import com.pubnub.api.models.consumer.access_manager.v3.PNToken import com.pubnub.api.vendor.Base64 import java.math.BigInteger import java.nio.charset.StandardCharsets -import kotlin.collections.Map -import kotlin.collections.component1 -import kotlin.collections.component2 -import kotlin.collections.set -import co.nstant.`in`.cbor.model.Map as CborMap internal class TokenParser { @@ -27,7 +22,7 @@ internal class TokenParser { val byteArray = Base64.decode(token.toByteArray(StandardCharsets.UTF_8), Base64.URL_SAFE) val firstElement = CborDecoder(byteArray.inputStream()).decode().firstOrNull() ?: throw getException("Empty token") - val firstLevelMap = (firstElement as? CborMap)?.toJvmMap() ?: throw getException("First element is not a map") + val firstLevelMap = (firstElement as? co.nstant.`in`.cbor.model.Map)?.toJvmMap() ?: throw getException("First element is not a map") val version = firstLevelMap[VERSION_KEY]?.toString()?.toInt() ?: throw getException("Couldn't parse version") val timestamp = firstLevelMap[TIMESTAMP_KEY]?.toString()?.toLong() ?: throw getException("Couldn't parse timestamp") val ttl = firstLevelMap[TTL_KEY]?.toString()?.toLong() ?: throw getException("Couldn't parse ttl") @@ -50,7 +45,7 @@ internal class TokenParser { } } - private fun CborMap.toJvmMap(depth: Int = 0): MutableMap { + private fun co.nstant.`in`.cbor.model.Map.toJvmMap(depth: Int = 0): MutableMap { if (depth > 3) { throw getException("Token is too deep") } @@ -63,7 +58,7 @@ internal class TokenParser { } when (value) { - is CborMap -> result[keyString] = value.toJvmMap(depth + 1) + is co.nstant.`in`.cbor.model.Map -> result[keyString] = value.toJvmMap(depth + 1) is ByteString -> result[keyString] = value.bytes is List<*> -> result[keyString] = value.map { it.toString() } is UnsignedInteger -> result[keyString] = value.value @@ -107,4 +102,4 @@ internal class TokenParser { private const val GROUPS_KEY = "grp" private const val UUIDS_KEY = "uuid" } -} +} \ No newline at end of file