diff --git a/src/main/kotlin/id/walt/auditor/Auditor.kt b/src/main/kotlin/id/walt/auditor/Auditor.kt index 094ce98d8..c1d6f2c01 100644 --- a/src/main/kotlin/id/walt/auditor/Auditor.kt +++ b/src/main/kotlin/id/walt/auditor/Auditor.kt @@ -8,10 +8,8 @@ import id.walt.services.WaltIdService import mu.KotlinLogging import java.util.concurrent.atomic.* - private val log = KotlinLogging.logger {} - abstract class Auditor : WaltIdService() { override val implementation: Auditor get() = serviceImplementation() @@ -36,7 +34,6 @@ class WaltIdAuditor : Auditor() { } override fun verify(vc: VerifiableCredential, policies: List): VerificationResult { - val policyResults = policies.associateBy(keySelector = VerificationPolicy::id) { policy -> log.debug { "Verifying vc with ${policy.id} ..." } diff --git a/src/main/kotlin/id/walt/auditor/AuditorRestAPI.kt b/src/main/kotlin/id/walt/auditor/AuditorRestAPI.kt index 7568d337a..a3c860309 100644 --- a/src/main/kotlin/id/walt/auditor/AuditorRestAPI.kt +++ b/src/main/kotlin/id/walt/auditor/AuditorRestAPI.kt @@ -34,49 +34,53 @@ object AuditorRestAPI { var auditorApi: Javalin? = null fun start(port: Int = AUDITOR_API_PORT, bindAddress: String = BIND_ADDRESS, apiTargetUrls: List = listOf()) { - auditorApi = Javalin.create { - it.apply { registerPlugin(RouteOverviewPlugin("/api-routes")) - registerPlugin(OpenApiPlugin(OpenApiOptions(InitialConfigurationCreator { - OpenAPI().apply { - info { - title = "walt.id Auditor API" - description = "The walt.id public API documentation" - contact = Contact().apply { - name = "walt.id" - url = "https://walt.id" - email = "office@walt.id" - } - version = Values.version - } - servers = listOf( - Server().url("/"), - *apiTargetUrls.map { Server().url(it) }.toTypedArray() - ) - externalDocs { - description = "walt.id Docs" - url = "https://docs.walt.id" - } + registerPlugin( + OpenApiPlugin( + OpenApiOptions( + InitialConfigurationCreator { + OpenAPI().apply { + info { + title = "walt.id Auditor API" + description = "The walt.id public API documentation" + contact = Contact().apply { + name = "walt.id" + url = "https://walt.id" + email = "office@walt.id" + } + version = Values.version + } + servers = listOf( + Server().url("/"), + *apiTargetUrls.map { Server().url(it) }.toTypedArray() + ) + externalDocs { + description = "walt.id Docs" + url = "https://docs.walt.id" + } - components { - securityScheme { - name = "bearerAuth" - type = SecurityScheme.Type.HTTP - scheme = "bearer" - `in` = SecurityScheme.In.HEADER - description = "HTTP Bearer Token authentication" - bearerFormat = "JWT" + components { + securityScheme { + name = "bearerAuth" + type = SecurityScheme.Type.HTTP + scheme = "bearer" + `in` = SecurityScheme.In.HEADER + description = "HTTP Bearer Token authentication" + bearerFormat = "JWT" + } + } + } } + ).apply { + path("/v1/api-documentation") + swagger(SwaggerOptions("/v1/swagger").title("walt.id Auditor API")) + reDoc(ReDocOptions("/v1/redoc").title("walt.id Auditor API")) } - } - }).apply { - path("/v1/api-documentation") - swagger(SwaggerOptions("/v1/swagger").title("walt.id Auditor API")) - reDoc(ReDocOptions("/v1/redoc").title("walt.id Auditor API")) - })) + ) + ) } it.enableCorsForAllOrigins() diff --git a/src/main/kotlin/id/walt/auditor/PolicyRegistry.kt b/src/main/kotlin/id/walt/auditor/PolicyRegistry.kt index 270b73bc9..087f3aedc 100644 --- a/src/main/kotlin/id/walt/auditor/PolicyRegistry.kt +++ b/src/main/kotlin/id/walt/auditor/PolicyRegistry.kt @@ -23,7 +23,7 @@ open class PolicyFactory

( open fun create(argument: Any? = null): P { try { return argType?.let { - if(optionalArgument) { + if (optionalArgument) { argument?.let { return policyType.primaryConstructor!!.call(it) } @@ -50,7 +50,10 @@ class DynamicPolicyFactory( name: String, description: String? ) : PolicyFactory( - DynamicPolicy::class, JsonObject::class, name, description + DynamicPolicy::class, + JsonObject::class, + name, + description ) { override fun create(argument: Any?): DynamicPolicy { val mergedInput = if (argument != null) { @@ -76,7 +79,12 @@ object PolicyRegistry { val defaultPolicyId: String = delegate.defaultPolicyId - fun

, A : Any> register(policy: KClass

, argType: KClass, description: String? = null, optionalArgument: Boolean = false) = + fun

, A : Any> register( + policy: KClass

, + argType: KClass, + description: String? = null, + optionalArgument: Boolean = false + ) = delegate.register(policy, argType, description, optionalArgument) fun

register(policy: KClass

, description: String? = null) = @@ -93,7 +101,7 @@ object PolicyRegistry { fun getPolicyWithJsonArg(id: String, argumentJson: JsonObject?): VerificationPolicy = delegate.getPolicyWithJsonArg(id, argumentJson) - fun getPolicyWithJsonArg(id: String, argumentJson: String?): VerificationPolicy = + fun getPolicyWithJsonArg(id: String, argumentJson: String?): VerificationPolicy = delegate.getPolicyWithJsonArg(id, argumentJson) fun isMutable(name: String): Boolean = diff --git a/src/main/kotlin/id/walt/auditor/PolicyRegistryService.kt b/src/main/kotlin/id/walt/auditor/PolicyRegistryService.kt index 434d1227d..8b886f076 100644 --- a/src/main/kotlin/id/walt/auditor/PolicyRegistryService.kt +++ b/src/main/kotlin/id/walt/auditor/PolicyRegistryService.kt @@ -16,10 +16,10 @@ import java.io.StringReader import java.util.concurrent.atomic.* import kotlin.reflect.KClass -open class PolicyRegistryService: WaltIdService() { +open class PolicyRegistryService : WaltIdService() { override val implementation: PolicyRegistryService get() = serviceImplementation() - companion object: ServiceProvider { + companion object : ServiceProvider { const val SAVED_POLICY_ROOT_KEY = "policies" override fun getService() = ServiceRegistry.getService(PolicyRegistryService::class) override fun defaultImplementation() = PolicyRegistryService() @@ -53,8 +53,10 @@ open class PolicyRegistryService: WaltIdService() { policies.put(policy.simpleName!!, PolicyFactory(policy, null, policy.simpleName!!, description)) private fun registerSavedPolicy(name: String, dynamicPolicyArg: DynamicPolicyArg, immutable: Boolean = false) = - policies.put(name, DynamicPolicyFactory(dynamicPolicyArg, immutable, name = name, description = dynamicPolicyArg.description) - ) + policies.put( + name, + DynamicPolicyFactory(dynamicPolicyArg, immutable, name = name, description = dynamicPolicyArg.description) + ) fun getPolicy(id: String, argument: A? = null) = policies[id]!!.create(argument) fun getPolicy(id: String) = getPolicy(id, null) @@ -148,12 +150,12 @@ open class PolicyRegistryService: WaltIdService() { "Verify by an EBSI Trusted Issuers Registry compliant api.", true ) - register(EbsiTrustedIssuerAccreditationPolicy::class,"Verify by issuer's authorized claims") + register(EbsiTrustedIssuerAccreditationPolicy::class, "Verify by issuer's authorized claims") register(EbsiTrustedSubjectDidPolicy::class, "Verify by trusted subject did") register(IssuedDateBeforePolicy::class, "Verify by issuance date") register(ValidFromBeforePolicy::class, "Verify by valid from") register(ExpirationDateAfterPolicy::class, "Verify by expiration date") - //register(GaiaxTrustedPolicy::class, "Verify Gaiax trusted fields") + // register(GaiaxTrustedPolicy::class, "Verify Gaiax trusted fields") register(GaiaxSDPolicy::class, "Verify Gaiax SD fields") register(ChallengePolicy::class, ChallengePolicyArg::class, "Verify challenge") register( @@ -167,10 +169,14 @@ open class PolicyRegistryService: WaltIdService() { // predefined, hardcoded rego policy specializations // VerifiableMandate policy as specialized rego policy registerSavedPolicy( - "VerifiableMandatePolicy", DynamicPolicyArg( - "VerifiableMandatePolicy", "Predefined policy for verifiable mandates", - JsonObject(), "$.credentialSubject.policySchemaURI", - "$.credentialSubject.holder", "data.system.main" + "VerifiableMandatePolicy", + DynamicPolicyArg( + "VerifiableMandatePolicy", + "Predefined policy for verifiable mandates", + JsonObject(), + "$.credentialSubject.policySchemaURI", + "$.credentialSubject.holder", + "data.system.main" ), immutable = true ) @@ -178,6 +184,6 @@ open class PolicyRegistryService: WaltIdService() { // other saved (Rego) policies initSavedPolicies() - //RegoPolicy(RegoPolicyArg(mapOf(), "")).argument.input + // RegoPolicy(RegoPolicyArg(mapOf(), "")).argument.input } } diff --git a/src/main/kotlin/id/walt/auditor/VerificationPolicy.kt b/src/main/kotlin/id/walt/auditor/VerificationPolicy.kt index efef4afb5..f12d4dad1 100644 --- a/src/main/kotlin/id/walt/auditor/VerificationPolicy.kt +++ b/src/main/kotlin/id/walt/auditor/VerificationPolicy.kt @@ -4,10 +4,8 @@ import com.beust.klaxon.Json import com.fasterxml.jackson.annotation.JsonIgnore import id.walt.credentials.w3c.VerifiableCredential import id.walt.credentials.w3c.VerifiablePresentation -import io.ktor.client.plugins.* import kotlinx.serialization.Serializable import mu.KotlinLogging -import java.util.* private val log = KotlinLogging.logger {} @@ -71,7 +69,8 @@ class VerificationPolicyResult private constructor( } } - @JsonIgnore @Json(ignored = true) + @JsonIgnore + @Json(ignored = true) val isFailure = !isSuccess private fun getErrorString() = errors.mapIndexed { index, throwable -> diff --git a/src/main/kotlin/id/walt/auditor/dynamic/PolicyEngineInput.kt b/src/main/kotlin/id/walt/auditor/dynamic/PolicyEngineInput.kt index 0c6b3e0b8..8c9721962 100644 --- a/src/main/kotlin/id/walt/auditor/dynamic/PolicyEngineInput.kt +++ b/src/main/kotlin/id/walt/auditor/dynamic/PolicyEngineInput.kt @@ -1,7 +1,6 @@ package id.walt.auditor.dynamic import id.walt.credentials.w3c.JsonConverter -import id.walt.credentials.w3c.VerifiableCredential import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.buildJsonObject diff --git a/src/main/kotlin/id/walt/cli/EssifCommand.kt b/src/main/kotlin/id/walt/cli/EssifCommand.kt index 84a70451d..4e13002c1 100644 --- a/src/main/kotlin/id/walt/cli/EssifCommand.kt +++ b/src/main/kotlin/id/walt/cli/EssifCommand.kt @@ -18,7 +18,6 @@ import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import java.io.File import java.util.* -import kotlin.NoSuchElementException class EssifCommand : CliktCommand( name = "essif", diff --git a/src/main/kotlin/id/walt/credentials/w3c/templates/VcTemplateManager.kt b/src/main/kotlin/id/walt/credentials/w3c/templates/VcTemplateManager.kt index aecf423c9..e3943e6e6 100644 --- a/src/main/kotlin/id/walt/credentials/w3c/templates/VcTemplateManager.kt +++ b/src/main/kotlin/id/walt/credentials/w3c/templates/VcTemplateManager.kt @@ -1,10 +1,6 @@ package id.walt.credentials.w3c.templates import id.walt.credentials.w3c.VerifiableCredential -import id.walt.credentials.w3c.toVerifiableCredential -import id.walt.services.context.ContextManager -import id.walt.services.hkvstore.HKVKey -import java.io.File @Deprecated("Deprecated in favor of VcTemplateService", ReplaceWith("VcTemplateService")) object VcTemplateManager { diff --git a/src/main/kotlin/id/walt/model/DecentralizedIdentifier.kt b/src/main/kotlin/id/walt/model/DecentralizedIdentifier.kt index 12e02c232..f94d26a84 100644 --- a/src/main/kotlin/id/walt/model/DecentralizedIdentifier.kt +++ b/src/main/kotlin/id/walt/model/DecentralizedIdentifier.kt @@ -1,7 +1,12 @@ package id.walt.model -import com.beust.klaxon.* -import id.walt.common.* +import com.beust.klaxon.Json +import com.beust.klaxon.TypeAdapter +import com.beust.klaxon.TypeFor +import id.walt.common.DidVerificationRelationships +import id.walt.common.KlaxonWithConverters +import id.walt.common.ListOrSingleValue +import id.walt.common.prettyPrint import id.walt.model.did.* import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/id/walt/services/ecosystems/essif/jsonrpc/WaltIdJsonRpcService.kt b/src/main/kotlin/id/walt/services/ecosystems/essif/jsonrpc/WaltIdJsonRpcService.kt index d8ccb9997..196630062 100644 --- a/src/main/kotlin/id/walt/services/ecosystems/essif/jsonrpc/WaltIdJsonRpcService.kt +++ b/src/main/kotlin/id/walt/services/ecosystems/essif/jsonrpc/WaltIdJsonRpcService.kt @@ -19,7 +19,6 @@ import org.web3j.rlp.RlpList import org.web3j.utils.Numeric import java.math.BigInteger import java.util.* -import kotlin.NoSuchElementException class WaltIdJsonRpcService : JsonRpcService() { diff --git a/src/test/kotlin/id/walt/custodian/CustodianPresentTest.kt b/src/test/kotlin/id/walt/custodian/CustodianPresentTest.kt index 0ddd1ccf4..aaefa3b70 100644 --- a/src/test/kotlin/id/walt/custodian/CustodianPresentTest.kt +++ b/src/test/kotlin/id/walt/custodian/CustodianPresentTest.kt @@ -1,6 +1,5 @@ package id.walt.custodian -import id.walt.credentials.w3c.VerifiableCredential import id.walt.credentials.w3c.VerifiablePresentation import id.walt.credentials.w3c.toPresentableCredential import id.walt.credentials.w3c.toVerifiableCredential diff --git a/src/test/kotlin/id/walt/services/did/DidCheqdTest.kt b/src/test/kotlin/id/walt/services/did/DidCheqdTest.kt index c2955a3f5..517b22a70 100644 --- a/src/test/kotlin/id/walt/services/did/DidCheqdTest.kt +++ b/src/test/kotlin/id/walt/services/did/DidCheqdTest.kt @@ -3,7 +3,6 @@ package id.walt.services.did import id.walt.crypto.KeyId import id.walt.model.DidMethod import id.walt.servicematrix.ServiceMatrix -import id.walt.services.ecosystems.cheqd.CheqdService import id.walt.services.key.KeyService import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe diff --git a/src/test/kotlin/id/walt/services/iota/IotaTest.kt b/src/test/kotlin/id/walt/services/iota/IotaTest.kt index a90a22813..31cc71bd8 100644 --- a/src/test/kotlin/id/walt/services/iota/IotaTest.kt +++ b/src/test/kotlin/id/walt/services/iota/IotaTest.kt @@ -4,7 +4,6 @@ import id.walt.crypto.KeyAlgorithm import id.walt.model.DidMethod import id.walt.servicematrix.ServiceMatrix import id.walt.services.did.DidService -import id.walt.services.ecosystems.iota.IotaService import id.walt.services.key.KeyService import id.walt.test.RESOURCES_PATH import io.kotest.assertions.json.shouldEqualJson diff --git a/src/test/kotlin/id/walt/services/oidc/OIDC4VCTest.kt b/src/test/kotlin/id/walt/services/oidc/OIDC4VCTest.kt index 0385de47a..9301fe0ff 100644 --- a/src/test/kotlin/id/walt/services/oidc/OIDC4VCTest.kt +++ b/src/test/kotlin/id/walt/services/oidc/OIDC4VCTest.kt @@ -29,7 +29,6 @@ import io.kotest.assertions.throwables.shouldNotThrowAny import io.kotest.core.spec.style.AnnotationSpec import io.kotest.inspectors.shouldForAll import io.kotest.matchers.collections.* -import io.kotest.matchers.maps.shouldContain import io.kotest.matchers.maps.shouldContainKey import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNot