Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions VCL/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ plugins {
}

ext {
publishCode = 166
publishVersion = "2.7.6"
publishCode = 167
publishVersion = "2.7.7"
publishArtifactId = "vcl"
publishGroupId = "io.velocitycareerlabs"
}
Expand Down
4 changes: 1 addition & 3 deletions VCL/src/main/java/io/velocitycareerlabs/impl/VCLImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal class VCLImpl: VCL {
private lateinit var jwtServiceUseCase: JwtServiceUseCase
private lateinit var keyServiceUseCase: KeyServiceUseCase

private var initializationWatcher = InitializationWatcher(ModelsToInitializeAmount)
private val initializationWatcher = InitializationWatcher(ModelsToInitializeAmount)
private lateinit var profileServiceTypeVerifier: ProfileServiceTypeVerifier

override fun initialize(
Expand All @@ -78,8 +78,6 @@ internal class VCLImpl: VCL {

printVersion()

this.initializationWatcher = InitializationWatcher(ModelsToInitializeAmount)

cacheRemoteData(
context = context.applicationContext,
cacheSequence = initializationDescriptor.cacheSequence,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import io.velocitycareerlabs.impl.data.usecases.*
import io.velocitycareerlabs.api.jwt.VCLJwtSignService
import io.velocitycareerlabs.api.jwt.VCLJwtVerifyService
import io.velocitycareerlabs.api.keys.VCLKeyService
import io.velocitycareerlabs.impl.data.verifiers.CredentialIssuerVerifierEmptyImpl
import io.velocitycareerlabs.impl.data.verifiers.CredentialIssuerVerifierImpl
import io.velocitycareerlabs.impl.data.verifiers.directissuerverification.CredentialIssuerVerifierEmptyImpl
import io.velocitycareerlabs.impl.data.verifiers.directissuerverification.CredentialIssuerVerifierImpl
import io.velocitycareerlabs.impl.data.verifiers.CredentialManifestByDeepLinkVerifierImpl
import io.velocitycareerlabs.impl.data.verifiers.CredentialsByDeepLinkVerifierImpl
import io.velocitycareerlabs.impl.data.verifiers.OffersByDeepLinkVerifierImpl
import io.velocitycareerlabs.impl.data.verifiers.PresentationRequestByDeepLinkVerifierImpl
import io.velocitycareerlabs.impl.data.verifiers.directissuerverification.repositories.CredentialSubjectContextRepositoryImpl
import io.velocitycareerlabs.impl.domain.models.*
import io.velocitycareerlabs.impl.domain.usecases.*
import io.velocitycareerlabs.impl.domain.verifiers.CredentialIssuerVerifier
import io.velocitycareerlabs.impl.domain.verifiers.PresentationRequestByDeepLinkVerifier
import io.velocitycareerlabs.impl.jwt.local.VCLJwtSignServiceLocalImpl
import io.velocitycareerlabs.impl.jwt.local.VCLJwtVerifyServiceLocalImpl
import io.velocitycareerlabs.impl.jwt.remote.VCLJwtSignServiceRemoteImpl
Expand Down Expand Up @@ -271,7 +271,9 @@ internal object VclBlocksProvider {
if (isDirectIssuerCheckOn) {
credentialIssuerVerifier = CredentialIssuerVerifierImpl(
credentialTypesModel,
NetworkServiceImpl()
CredentialSubjectContextRepositoryImpl(
NetworkServiceImpl()
)
)
}
return FinalizeOffersUseCaseImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,29 @@ import io.velocitycareerlabs.impl.domain.infrastructure.executors.Executor
import io.velocitycareerlabs.impl.domain.repositories.CredentialTypeSchemaRepository
import io.velocitycareerlabs.impl.domain.usecases.CredentialTypeSchemasUseCase
import io.velocitycareerlabs.impl.utils.VCLLog
import java.util.Collections
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ConcurrentHashMap

class CredentialTypeSchemasMapStorage {
private val credentialTypeSchemasMap: MutableMap<String, VCLCredentialTypeSchema> =
Collections.synchronizedMap(mutableMapOf())

fun add(schemaName: String, schema: VCLCredentialTypeSchema) {
credentialTypeSchemasMap[schemaName] = schema
}

fun isEmpty(): Boolean {
return credentialTypeSchemasMap.isEmpty()
}

fun get(): Map<String, VCLCredentialTypeSchema> {
// Return a snapshot to avoid exposing live mutable state
synchronized(credentialTypeSchemasMap) {
return HashMap(credentialTypeSchemasMap)
}
}
}
internal class CredentialTypeSchemasUseCaseImpl (
private val credentialTypeSchemaRepository: CredentialTypeSchemaRepository,
private val credentialTypes: VCLCredentialTypes,
Expand All @@ -23,12 +43,13 @@ internal class CredentialTypeSchemasUseCaseImpl (

private val TAG = CredentialTypeSchemasUseCaseImpl::class.simpleName

private val credentialTypeSchemasStorage = CredentialTypeSchemasMapStorage()

override fun getCredentialTypeSchemas(
cacheSequence: Int,
completionBlock: (VCLResult<VCLCredentialTypeSchemas>) -> Unit
) {
executor.runOnBackground {
val credentialTypeSchemasMap = ConcurrentHashMap<String, VCLCredentialTypeSchema>()

val schemaNamesArr =
credentialTypes.all?.filter { it.schemaName != null }?.map { it.schemaName }
Expand All @@ -41,7 +62,7 @@ internal class CredentialTypeSchemasUseCaseImpl (
schemaName,
cacheSequence
) { result ->
result.data?.let { credentialTypeSchemasMap[schemaName] = it }
result.data?.let { credentialTypeSchemasStorage.add(schemaName, it) }
}
}
}
Expand All @@ -50,12 +71,12 @@ internal class CredentialTypeSchemasUseCaseImpl (
val allFutures = CompletableFuture.allOf(*completableFutures.toTypedArray())
allFutures.join()

if (credentialTypeSchemasMap.isEmpty()) {
if (credentialTypeSchemasStorage.isEmpty()) {
VCLLog.e(TAG, "Credential type schemas were not fount.")
} else {
executor.runOnMain {
completionBlock(VCLResult.Success(
VCLCredentialTypeSchemas(credentialTypeSchemasMap)
VCLCredentialTypeSchemas(credentialTypeSchemasStorage.get())
))
}
}
Expand Down
Loading
Loading