Update from master
This commit is contained in:
Коммит
e56f2eb257
|
@ -12,3 +12,4 @@
|
|||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
.idea/jarRepositories.xml
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.61'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
|
|
@ -25,4 +25,6 @@ dagger_version=2.27
|
|||
androidx_room_persistence_version=2.2.5
|
||||
retrofit2_version=2.8.1
|
||||
com_squareup_okhttp3_okhttp_version=3.12.6
|
||||
lifecycle_ktx_version=2.2.0
|
||||
lifecycle_ktx_version=2.3.0-alpha05
|
||||
kotlin_serialization_version=0.2.0
|
||||
kotlin_version=1.3.72
|
||||
|
|
|
@ -72,8 +72,6 @@ android {
|
|||
}
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.61'
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
@ -104,11 +102,9 @@ dependencies {
|
|||
implementation "com.squareup.okhttp3:okhttp:$com_squareup_okhttp3_okhttp_version"
|
||||
implementation "com.squareup.okhttp3:logging-interceptor:$com_squareup_okhttp3_okhttp_version"
|
||||
|
||||
def serialization_version = "0.12.0"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialization_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialization_version"
|
||||
|
||||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_ktx_version"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_ktx_version"
|
||||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_ktx_version"
|
||||
|
||||
|
|
|
@ -6,19 +6,20 @@
|
|||
package com.microsoft.did.sdk
|
||||
|
||||
import com.microsoft.did.sdk.crypto.CryptoOperations
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.identifier.IdentifierCreator
|
||||
import com.microsoft.did.sdk.datasource.repository.IdentifierRepository
|
||||
import com.microsoft.did.sdk.identifier.IdentifierCreator
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.util.Base64Url
|
||||
import com.microsoft.did.sdk.util.Constants.HASHING_ALGORITHM_FOR_ID
|
||||
import com.microsoft.did.sdk.util.Constants.MASTER_IDENTIFIER_NAME
|
||||
import com.microsoft.did.sdk.util.Constants.METHOD_NAME
|
||||
import com.microsoft.did.sdk.util.log.SdkLog
|
||||
import com.microsoft.did.sdk.util.controlflow.Result
|
||||
import com.microsoft.did.sdk.util.controlflow.RepositoryException
|
||||
import com.microsoft.did.sdk.util.controlflow.Result
|
||||
import com.microsoft.did.sdk.util.controlflow.runResultTry
|
||||
import com.microsoft.did.sdk.util.log.SdkLog
|
||||
import com.microsoft.did.sdk.util.stringToByteArray
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.security.MessageDigest
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
|
|
@ -7,25 +7,28 @@ package com.microsoft.did.sdk
|
|||
|
||||
import android.net.Uri
|
||||
import androidx.lifecycle.LiveData
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredential
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredentialHolder
|
||||
import com.microsoft.did.sdk.credential.models.receipts.Receipt
|
||||
import com.microsoft.did.sdk.credential.service.IssuanceRequest
|
||||
import com.microsoft.did.sdk.credential.service.models.contracts.VerifiableCredentialContract
|
||||
import com.microsoft.did.sdk.credential.service.models.oidc.OidcRequestContent
|
||||
import com.microsoft.did.sdk.credential.service.IssuanceResponse
|
||||
import com.microsoft.did.sdk.credential.service.PresentationRequest
|
||||
import com.microsoft.did.sdk.credential.service.PresentationResponse
|
||||
import com.microsoft.did.sdk.credential.service.Response
|
||||
import com.microsoft.did.sdk.credential.service.models.contracts.VerifiableCredentialContract
|
||||
import com.microsoft.did.sdk.credential.service.models.oidc.OidcRequestContent
|
||||
import com.microsoft.did.sdk.credential.service.validators.PresentationRequestValidator
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredentialHolder
|
||||
import com.microsoft.did.sdk.credential.models.receipts.Receipt
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredential
|
||||
import com.microsoft.did.sdk.credential.service.*
|
||||
import com.microsoft.did.sdk.util.Constants.DEEP_LINK_SCHEME
|
||||
import com.microsoft.did.sdk.util.Constants.DEFAULT_EXPIRATION_IN_SECONDS
|
||||
import com.microsoft.did.sdk.crypto.protocols.jose.jws.JwsToken
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.datasource.repository.VerifiableCredentialHolderRepository
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.util.controlflow.PresentationException
|
||||
import com.microsoft.did.sdk.util.controlflow.RepositoryException
|
||||
import com.microsoft.did.sdk.util.controlflow.Result
|
||||
import com.microsoft.did.sdk.util.controlflow.runResultTry
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import com.microsoft.did.sdk.util.controlflow.*
|
||||
import com.microsoft.did.sdk.util.unwrapSignedVerifiableCredential
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
@ -55,7 +58,7 @@ class VerifiableCredentialManager @Inject constructor(
|
|||
val requestToken = getPresentationRequestToken(uri).abortOnError()
|
||||
val tokenContents =
|
||||
serializer.parse(OidcRequestContent.serializer(), JwsToken.deserialize(requestToken, serializer).content())
|
||||
val request = PresentationRequest(uri, requestToken, tokenContents)
|
||||
val request = PresentationRequest(requestToken, tokenContents)
|
||||
isRequestValid(request).abortOnError()
|
||||
Result.Success(request)
|
||||
}
|
||||
|
|
|
@ -5,13 +5,14 @@
|
|||
|
||||
package com.microsoft.did.sdk.credential.service
|
||||
|
||||
import android.net.Uri
|
||||
import com.microsoft.did.sdk.credential.service.models.attestations.CredentialAttestations
|
||||
import com.microsoft.did.sdk.credential.service.models.attestations.PresentationAttestation
|
||||
import com.microsoft.did.sdk.credential.service.models.attestations.PresentationRequestBinding
|
||||
import com.microsoft.did.sdk.credential.service.models.contracts.VerifiableCredentialContract
|
||||
import com.microsoft.did.sdk.credential.service.models.oidc.OidcRequestContent
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed class Request(val attestations: CredentialAttestations?, val entityName: String = "", val entityIdentifier: String = "") {
|
||||
|
||||
private var presentationBinding: PresentationRequestBinding? = null
|
||||
|
@ -36,9 +37,10 @@ sealed class Request(val attestations: CredentialAttestations?, val entityName:
|
|||
}
|
||||
}
|
||||
|
||||
// Request can be either an Issuance or Presentation Request only.
|
||||
@Serializable
|
||||
class IssuanceRequest(val contract: VerifiableCredentialContract, val contractUrl: String) :
|
||||
Request(contract.input.attestations, contract.display.card.issuedBy, contract.input.issuer)
|
||||
|
||||
class PresentationRequest(val uri: Uri, val serializedToken: String, val content: OidcRequestContent) :
|
||||
@Serializable
|
||||
class PresentationRequest(val serializedToken: String, val content: OidcRequestContent) :
|
||||
Request(content.attestations, content.registration?.clientName ?: "", content.iss)
|
|
@ -16,5 +16,5 @@ data class ClaimAttestation(
|
|||
val required: Boolean = false,
|
||||
|
||||
// type of object the claim should be.
|
||||
val type: String = ""
|
||||
val type: String? = ""
|
||||
)
|
|
@ -1,7 +1,9 @@
|
|||
package com.microsoft.did.sdk.credential.service.models.attestations
|
||||
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredentialHolder
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PresentationRequestBinding(
|
||||
var typeToSavedCards: Map<String, List<VerifiableCredentialHolder>>,
|
||||
var neededCards: List<PresentationAttestation>
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
|
||||
package com.microsoft.did.sdk.credential.service.models.oidc
|
||||
|
||||
import com.microsoft.did.sdk.credential.service.models.attestations.CredentialAttestations
|
||||
import com.microsoft.did.sdk.util.Constants.CLIENT_ID
|
||||
import com.microsoft.did.sdk.util.Constants.MAX_AGE
|
||||
import com.microsoft.did.sdk.util.Constants.REDIRECT_URL
|
||||
import com.microsoft.did.sdk.util.Constants.RESPONSE_MODE
|
||||
import com.microsoft.did.sdk.util.Constants.RESPONSE_TYPE
|
||||
import com.microsoft.did.sdk.credential.service.models.attestations.CredentialAttestations
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
package com.microsoft.did.sdk.credential.service.models.oidc
|
||||
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import com.microsoft.did.sdk.util.Constants.SELF_ISSUED
|
||||
import com.microsoft.did.sdk.util.Constants.SUB_JWK
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import kotlinx.serialization.Required
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
package com.microsoft.did.sdk.credential.service.protectors
|
||||
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
import kotlin.math.floor
|
||||
|
||||
fun createIatAndExp(expiryInSeconds: Int): Pair<Long, Long?> {
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
package com.microsoft.did.sdk.credential.service.protectors
|
||||
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredential
|
||||
import com.microsoft.did.sdk.credential.service.models.oidc.AttestationClaimModel
|
||||
import com.microsoft.did.sdk.credential.service.models.oidc.OidcResponseContent
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredential
|
||||
import com.microsoft.did.sdk.credential.service.RequestedIdTokenMap
|
||||
import com.microsoft.did.sdk.credential.service.RequestedSelfAttestedClaimMap
|
||||
import com.microsoft.did.sdk.credential.service.RequestedVchMap
|
||||
|
@ -16,7 +16,7 @@ import com.microsoft.did.sdk.crypto.models.Sha
|
|||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.util.controlflow.FormatterException
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import java.util.*
|
||||
import java.util.UUID
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.microsoft.did.sdk.credential.service.protectors
|
||||
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredential
|
||||
import com.microsoft.did.sdk.credential.service.models.verifiablePresentation.VerifiablePresentationContent
|
||||
import com.microsoft.did.sdk.credential.service.models.verifiablePresentation.VerifiablePresentationDescriptor
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredential
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.util.Constants
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import java.util.*
|
||||
import java.util.UUID
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ import com.microsoft.did.sdk.crypto.keys.PublicKey
|
|||
import com.microsoft.did.sdk.crypto.protocols.jose.jws.JwsSignature
|
||||
import com.microsoft.did.sdk.crypto.protocols.jose.jws.JwsToken
|
||||
import com.microsoft.did.sdk.identifier.resolvers.Resolver
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import com.microsoft.did.sdk.util.controlflow.Result
|
||||
import com.microsoft.did.sdk.util.controlflow.ValidatorException
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.microsoft.did.sdk.credential.service.validators
|
||||
|
||||
import com.microsoft.did.sdk.util.Constants.MILLISECONDS_IN_A_SECOND
|
||||
import com.microsoft.did.sdk.util.Constants.SECONDS_IN_A_MINUTE
|
||||
import com.microsoft.did.sdk.credential.service.PresentationRequest
|
||||
import com.microsoft.did.sdk.crypto.protocols.jose.jws.JwsToken
|
||||
import com.microsoft.did.sdk.util.Constants.MILLISECONDS_IN_A_SECOND
|
||||
import com.microsoft.did.sdk.util.Constants.SECONDS_IN_A_MINUTE
|
||||
import com.microsoft.did.sdk.util.controlflow.ExpiredTokenExpirationException
|
||||
import com.microsoft.did.sdk.util.controlflow.InvalidSignatureException
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
|
|
@ -6,14 +6,22 @@
|
|||
package com.microsoft.did.sdk.crypto
|
||||
|
||||
import com.microsoft.did.sdk.crypto.keyStore.KeyStore
|
||||
import com.microsoft.did.sdk.crypto.keys.*
|
||||
import com.microsoft.did.sdk.crypto.keys.KeyContainer
|
||||
import com.microsoft.did.sdk.crypto.keys.KeyType
|
||||
import com.microsoft.did.sdk.crypto.keys.KeyTypeFactory
|
||||
import com.microsoft.did.sdk.crypto.keys.PrivateKey
|
||||
import com.microsoft.did.sdk.crypto.keys.PublicKey
|
||||
import com.microsoft.did.sdk.crypto.keys.SecretKey
|
||||
import com.microsoft.did.sdk.crypto.keys.ellipticCurve.EllipticCurvePairwiseKey
|
||||
import com.microsoft.did.sdk.crypto.keys.ellipticCurve.EllipticCurvePrivateKey
|
||||
import com.microsoft.did.sdk.crypto.keys.rsa.RsaPrivateKey
|
||||
import com.microsoft.did.sdk.crypto.models.AndroidConstants
|
||||
import com.microsoft.did.sdk.crypto.models.Sha
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.*
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyFormat
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyUsage
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.SubtleCrypto
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.W3cCryptoApiConstants
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.Algorithm
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.EcKeyGenParams
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.RsaHashedKeyAlgorithm
|
||||
|
@ -21,10 +29,10 @@ import com.microsoft.did.sdk.crypto.plugins.SubtleCryptoFactory
|
|||
import com.microsoft.did.sdk.crypto.plugins.SubtleCryptoScope
|
||||
import com.microsoft.did.sdk.crypto.protocols.jose.JoseConstants
|
||||
import com.microsoft.did.sdk.util.Base64Url
|
||||
import com.microsoft.did.sdk.util.log.SdkLog
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyException
|
||||
import com.microsoft.did.sdk.util.controlflow.PairwiseKeyException
|
||||
import com.microsoft.did.sdk.util.controlflow.SignatureException
|
||||
import com.microsoft.did.sdk.util.log.SdkLog
|
||||
import java.security.SecureRandom
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,15 +8,22 @@ import android.security.keystore.KeyGenParameterSpec
|
|||
import android.security.keystore.KeyProperties
|
||||
import android.util.Base64
|
||||
import androidx.security.crypto.EncryptedSharedPreferences
|
||||
import com.microsoft.did.sdk.crypto.keys.*
|
||||
import com.microsoft.did.sdk.crypto.keys.KeyContainer
|
||||
import com.microsoft.did.sdk.crypto.keys.KeyType
|
||||
import com.microsoft.did.sdk.crypto.keys.PrivateKey
|
||||
import com.microsoft.did.sdk.crypto.keys.PublicKey
|
||||
import com.microsoft.did.sdk.crypto.keys.SecretKey
|
||||
import com.microsoft.did.sdk.crypto.keys.ellipticCurve.EllipticCurvePrivateKey
|
||||
import com.microsoft.did.sdk.crypto.keys.rsa.RsaPrivateKey
|
||||
import com.microsoft.did.sdk.crypto.keys.toKeyType
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import com.microsoft.did.sdk.util.*
|
||||
import com.microsoft.did.sdk.util.AndroidKeyConverter
|
||||
import com.microsoft.did.sdk.util.byteArrayToString
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyException
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyStoreException
|
||||
import com.microsoft.did.sdk.util.log.SdkLog
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import com.microsoft.did.sdk.util.stringToByteArray
|
||||
import java.security.KeyStore
|
||||
import javax.crypto.KeyGenerator
|
||||
import javax.inject.Inject
|
||||
|
|
|
@ -4,8 +4,10 @@ import com.microsoft.did.sdk.crypto.CryptoOperations
|
|||
import com.microsoft.did.sdk.crypto.models.KeyUse
|
||||
import com.microsoft.did.sdk.crypto.models.Sha
|
||||
import com.microsoft.did.sdk.crypto.models.toKeyUse
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.*
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyUsage
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.Algorithm
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.toKeyUsage
|
||||
import com.microsoft.did.sdk.crypto.plugins.SubtleCryptoScope
|
||||
import com.microsoft.did.sdk.util.Base64Url
|
||||
import com.microsoft.did.sdk.util.stringToByteArray
|
||||
|
|
|
@ -4,10 +4,10 @@ package com.microsoft.did.sdk.crypto.keys
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyUsage
|
||||
import com.microsoft.did.sdk.crypto.models.KeyUse
|
||||
import com.microsoft.did.sdk.crypto.models.toKeyUse
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyUsage
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.toKeyUsage
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,8 @@ package com.microsoft.did.sdk.crypto.keys.ellipticCurve
|
|||
|
||||
import com.microsoft.did.sdk.crypto.keys.KeyType
|
||||
import com.microsoft.did.sdk.crypto.keys.PublicKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.*
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyUsage
|
||||
|
||||
class EllipticCurvePublicKey(key: JsonWebKey) : PublicKey(key) {
|
||||
override fun minimumAlphabeticJwk(): String {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.microsoft.did.sdk.crypto.models
|
||||
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.Algorithm
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.W3cCryptoApiConstants
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.Algorithm
|
||||
import com.microsoft.did.sdk.util.controlflow.AlgorithmException
|
||||
|
||||
enum class Sha(val algorithm: Algorithm) {
|
||||
|
|
|
@ -6,7 +6,14 @@ import android.util.Base64
|
|||
import com.microsoft.did.sdk.crypto.keyStore.AndroidKeyStore
|
||||
import com.microsoft.did.sdk.crypto.keys.AndroidKeyHandle
|
||||
import com.microsoft.did.sdk.crypto.models.AndroidConstants
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.*
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.CryptoKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.CryptoKeyPair
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyFormat
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyType
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyUsage
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.SubtleCrypto
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.W3cCryptoApiConstants
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.AesKeyGenParams
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.Algorithm
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.EcdsaParams
|
||||
|
@ -14,14 +21,19 @@ import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.RsaHashedKeyA
|
|||
import com.microsoft.did.sdk.crypto.protocols.jose.JwaCryptoConverter
|
||||
import com.microsoft.did.sdk.util.AndroidKeyConverter
|
||||
import com.microsoft.did.sdk.util.Base64Url
|
||||
import com.microsoft.did.sdk.util.log.SdkLog
|
||||
import com.microsoft.did.sdk.util.controlflow.AlgorithmException
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyException
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyFormatException
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyStoreException
|
||||
import com.microsoft.did.sdk.util.controlflow.SignatureException
|
||||
import com.microsoft.did.sdk.util.log.SdkLog
|
||||
import java.math.BigInteger
|
||||
import java.security.*
|
||||
import java.security.KeyFactory
|
||||
import java.security.KeyPairGenerator
|
||||
import java.security.MessageDigest
|
||||
import java.security.PrivateKey
|
||||
import java.security.PublicKey
|
||||
import java.security.Signature
|
||||
import java.security.spec.RSAPublicKeySpec
|
||||
import javax.crypto.KeyGenerator
|
||||
import javax.crypto.Mac
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
package com.microsoft.did.sdk.crypto.plugins.subtleCrypto
|
||||
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.*
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.CryptoKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.CryptoKeyPair
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyFormat
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyUsage
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.Algorithm
|
||||
import com.microsoft.did.sdk.util.controlflow.AlgorithmException
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyException
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyFormatException
|
||||
import com.microsoft.did.sdk.util.controlflow.UnSupportedOperationException
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
abstract class Provider {
|
||||
abstract val name: String
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package com.microsoft.did.sdk.crypto.plugins.subtleCrypto
|
||||
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.Algorithm
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.CryptoKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.CryptoKeyPair
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.JsonWebKey
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyFormat
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyUsage
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.SubtleCrypto
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.Algorithm
|
||||
import com.microsoft.did.sdk.util.controlflow.AlgorithmException
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyException
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyFormatException
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.microsoft.did.sdk.crypto.protocols.jose
|
||||
|
||||
import com.microsoft.did.sdk.crypto.models.Sha
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.*
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.W3cCryptoApiConstants
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.Algorithm
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.EcdsaParams
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.RsaHashedKeyAlgorithm
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.RsaOaepParams
|
||||
import com.microsoft.did.sdk.util.controlflow.CryptoException
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
object JwaCryptoConverter {
|
||||
fun extractDidAndKeyId(keyId: String): Pair<String?, String> {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.microsoft.did.sdk.crypto.protocols.jose.jws
|
||||
|
||||
import com.microsoft.did.sdk.crypto.protocols.jose.JoseConstants
|
||||
import com.microsoft.did.sdk.util.*
|
||||
import com.microsoft.did.sdk.util.Base64Url
|
||||
import com.microsoft.did.sdk.util.byteArrayToString
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
|
|
@ -7,13 +7,15 @@ import com.microsoft.did.sdk.crypto.models.webCryptoApi.KeyUsage
|
|||
import com.microsoft.did.sdk.crypto.plugins.SubtleCryptoScope
|
||||
import com.microsoft.did.sdk.crypto.protocols.jose.JoseConstants
|
||||
import com.microsoft.did.sdk.crypto.protocols.jose.JwaCryptoConverter
|
||||
import com.microsoft.did.sdk.util.*
|
||||
import com.microsoft.did.sdk.util.Base64Url
|
||||
import com.microsoft.did.sdk.util.byteArrayToString
|
||||
import com.microsoft.did.sdk.util.controlflow.KeyException
|
||||
import com.microsoft.did.sdk.util.controlflow.SignatureException
|
||||
import com.microsoft.did.sdk.util.log.SdkLog
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import java.util.*
|
||||
import kotlin.collections.Map
|
||||
import com.microsoft.did.sdk.util.stringToByteArray
|
||||
import com.microsoft.did.sdk.util.toReadableString
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Class for containing JWS token operations.
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
package com.microsoft.did.sdk.datasource.db
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
import com.microsoft.did.sdk.credential.service.models.contracts.display.DisplayContract
|
||||
import com.microsoft.did.sdk.credential.models.receipts.ReceiptAction
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredentialContent
|
||||
import com.microsoft.did.sdk.credential.models.receipts.ReceiptAction
|
||||
import com.microsoft.did.sdk.credential.service.models.contracts.display.DisplayContract
|
||||
import com.microsoft.did.sdk.identifier.models.identifierdocument.IdentifierDocument
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@ package com.microsoft.did.sdk.datasource.db
|
|||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredential
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredentialHolder
|
||||
import com.microsoft.did.sdk.credential.models.receipts.Receipt
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredential
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.datasource.db.dao.VerifiableCredentialHolderDao
|
||||
import com.microsoft.did.sdk.datasource.db.dao.IdentifierDao
|
||||
import com.microsoft.did.sdk.datasource.db.dao.ReceiptDao
|
||||
import com.microsoft.did.sdk.datasource.db.dao.VerifiableCredentialDao
|
||||
import com.microsoft.did.sdk.datasource.db.dao.VerifiableCredentialHolderDao
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
|
||||
/**
|
||||
* Abstract description of the database interface that is supposed to be provided by Room. New entities have to be
|
||||
|
|
|
@ -5,9 +5,13 @@
|
|||
|
||||
package com.microsoft.did.sdk.datasource.network
|
||||
|
||||
import com.microsoft.did.sdk.util.controlflow.*
|
||||
import kotlinx.io.IOException
|
||||
import com.microsoft.did.sdk.util.controlflow.NetworkException
|
||||
import com.microsoft.did.sdk.util.controlflow.Result
|
||||
import com.microsoft.did.sdk.util.controlflow.ServiceErrorException
|
||||
import com.microsoft.did.sdk.util.controlflow.ServiceUnreachableException
|
||||
import com.microsoft.did.sdk.util.controlflow.UnauthorizedException
|
||||
import retrofit2.Response
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
* Base Network Operation class with default methods for all Network Operations.
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
package com.microsoft.did.sdk.datasource.network.apis
|
||||
|
||||
import retrofit2.Response
|
||||
import retrofit2.http.*
|
||||
import retrofit2.http.Field
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Url
|
||||
|
||||
interface PresentationApis {
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ package com.microsoft.did.sdk.datasource.network.credentialOperations
|
|||
import com.microsoft.did.sdk.credential.service.models.serviceResponses.IssuanceServiceResponse
|
||||
import com.microsoft.did.sdk.datasource.network.PostNetworkOperation
|
||||
import com.microsoft.did.sdk.datasource.network.apis.ApiProvider
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import com.microsoft.did.sdk.util.controlflow.IssuanceException
|
||||
import com.microsoft.did.sdk.util.controlflow.Result
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import retrofit2.Response
|
||||
|
||||
class SendVerifiableCredentialIssuanceRequestNetworkOperation(
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
package com.microsoft.did.sdk.datasource.network.identifierOperations
|
||||
|
||||
import com.microsoft.did.sdk.identifier.models.identifierdocument.IdentifierResponse
|
||||
import com.microsoft.did.sdk.datasource.network.GetNetworkOperation
|
||||
import com.microsoft.did.sdk.datasource.network.apis.ApiProvider
|
||||
import com.microsoft.did.sdk.identifier.models.identifierdocument.IdentifierResponse
|
||||
import retrofit2.Response
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
package com.microsoft.did.sdk.datasource.repository
|
||||
|
||||
import com.microsoft.did.sdk.datasource.db.SdkDatabase
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.datasource.network.apis.ApiProvider
|
||||
import com.microsoft.did.sdk.datasource.network.identifierOperations.ResolveIdentifierNetworkOperation
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import javax.inject.Inject
|
||||
|
||||
class IdentifierRepository @Inject constructor(database: SdkDatabase, val apiProvider: ApiProvider) {
|
||||
|
|
|
@ -7,26 +7,27 @@ package com.microsoft.did.sdk.datasource.repository
|
|||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.map
|
||||
import com.microsoft.did.sdk.credential.service.models.ExchangeRequest
|
||||
import com.microsoft.did.sdk.credential.service.protectors.OidcResponseFormatter
|
||||
import com.microsoft.did.sdk.credential.service.IssuanceResponse
|
||||
import com.microsoft.did.sdk.credential.service.PresentationResponse
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredentialHolder
|
||||
import com.microsoft.did.sdk.credential.models.receipts.Receipt
|
||||
import com.microsoft.did.sdk.credential.models.VerifiableCredential
|
||||
import com.microsoft.did.sdk.credential.service.RequestedVchMap
|
||||
import com.microsoft.did.sdk.credential.service.IssuanceResponse
|
||||
import com.microsoft.did.sdk.credential.service.PresentationResponse
|
||||
import com.microsoft.did.sdk.credential.service.models.ExchangeRequest
|
||||
import com.microsoft.did.sdk.credential.service.protectors.OidcResponseFormatter
|
||||
import com.microsoft.did.sdk.datasource.db.SdkDatabase
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.datasource.network.apis.ApiProvider
|
||||
import com.microsoft.did.sdk.datasource.network.credentialOperations.FetchContractNetworkOperation
|
||||
import com.microsoft.did.sdk.datasource.network.credentialOperations.FetchPresentationRequestNetworkOperation
|
||||
import com.microsoft.did.sdk.datasource.network.credentialOperations.SendVerifiableCredentialIssuanceRequestNetworkOperation
|
||||
import com.microsoft.did.sdk.datasource.network.credentialOperations.SendPresentationResponseNetworkOperation
|
||||
import com.microsoft.did.sdk.datasource.network.credentialOperations.SendVerifiableCredentialIssuanceRequestNetworkOperation
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.util.unwrapSignedVerifiableCredential
|
||||
import com.microsoft.did.sdk.util.Constants.DEFAULT_EXPIRATION_IN_SECONDS
|
||||
import com.microsoft.did.sdk.util.controlflow.ExchangeException
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import com.microsoft.did.sdk.util.controlflow.Result
|
||||
import com.microsoft.did.sdk.util.serializer.Serializer
|
||||
import com.microsoft.did.sdk.util.unwrapSignedVerifiableCredential
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
package com.microsoft.did.sdk.di
|
||||
|
||||
import android.content.Context
|
||||
import com.microsoft.did.sdk.VerifiableCredentialManager
|
||||
import com.microsoft.did.sdk.IdentifierManager
|
||||
import com.microsoft.did.sdk.VerifiableCredentialManager
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import javax.inject.Named
|
||||
|
|
|
@ -20,9 +20,9 @@ import com.microsoft.did.sdk.crypto.plugins.AndroidSubtle
|
|||
import com.microsoft.did.sdk.crypto.plugins.EllipticCurveSubtleCrypto
|
||||
import com.microsoft.did.sdk.crypto.plugins.SubtleCryptoMapItem
|
||||
import com.microsoft.did.sdk.crypto.plugins.SubtleCryptoScope
|
||||
import com.microsoft.did.sdk.datasource.db.SdkDatabase
|
||||
import com.microsoft.did.sdk.identifier.registrars.Registrar
|
||||
import com.microsoft.did.sdk.identifier.registrars.SidetreeRegistrar
|
||||
import com.microsoft.did.sdk.datasource.db.SdkDatabase
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import okhttp3.OkHttpClient
|
||||
|
|
|
@ -11,9 +11,9 @@ import com.microsoft.did.sdk.crypto.models.AndroidConstants
|
|||
import com.microsoft.did.sdk.crypto.models.KeyUse
|
||||
import com.microsoft.did.sdk.crypto.models.Sha
|
||||
import com.microsoft.did.sdk.crypto.models.toKeyUse
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.W3cCryptoApiConstants
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.Algorithm
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.algorithms.EcKeyGenParams
|
||||
import com.microsoft.did.sdk.crypto.models.webCryptoApi.W3cCryptoApiConstants
|
||||
import com.microsoft.did.sdk.identifier.models.Identifier
|
||||
import com.microsoft.did.sdk.identifier.models.payload.RegistrationPayload
|
||||
import com.microsoft.did.sdk.util.Base64Url
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
package com.microsoft.did.sdk.identifier.resolvers
|
||||
|
||||
import com.microsoft.did.sdk.identifier.models.identifierdocument.IdentifierDocument
|
||||
import com.microsoft.did.sdk.datasource.repository.IdentifierRepository
|
||||
import com.microsoft.did.sdk.identifier.models.identifierdocument.IdentifierDocument
|
||||
import com.microsoft.did.sdk.util.controlflow.ResolverException
|
||||
import com.microsoft.did.sdk.util.controlflow.Result
|
||||
import com.microsoft.did.sdk.util.controlflow.runResultTry
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package com.microsoft.did.sdk.util.controlflow
|
||||
|
||||
import java.lang.Exception
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package com.microsoft.did.sdk.util.log
|
||||
|
||||
import java.lang.RuntimeException
|
||||
import java.util.regex.Pattern
|
||||
|
||||
object SdkLog {
|
||||
|
|
|
@ -12,7 +12,6 @@ package com.microsoft.did.sdk.util.serializer
|
|||
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlin.collections.Map
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
interface ISerializer {
|
||||
|
|
|
@ -5,13 +5,18 @@ package com.microsoft.did.sdk.util.serializer
|
|||
import com.microsoft.did.sdk.credential.service.models.serviceResponses.IssuanceServiceResponse
|
||||
import com.microsoft.did.sdk.credential.service.models.serviceResponses.PresentationServiceResponse
|
||||
import com.microsoft.did.sdk.credential.service.models.serviceResponses.ServiceResponse
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.json.*
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.MapSerializer
|
||||
import kotlinx.serialization.builtins.list
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonConfiguration
|
||||
import kotlinx.serialization.modules.SerializersModule
|
||||
import kotlinx.serialization.serializer
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.collections.Map
|
||||
|
||||
@Singleton
|
||||
class Serializer @Inject constructor() : ISerializer {
|
||||
|
@ -27,7 +32,7 @@ class Serializer @Inject constructor() : ISerializer {
|
|||
context = serviceResponseSerializer,
|
||||
configuration = JsonConfiguration(
|
||||
encodeDefaults = false,
|
||||
strictMode = false
|
||||
ignoreUnknownKeys = true
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -44,7 +49,7 @@ class Serializer @Inject constructor() : ISerializer {
|
|||
|
||||
@ImplicitReflectionSerializer
|
||||
override fun <K : Any, V : Any> stringifyImpl(obj: Map<K, V>, keyClass: KClass<K>, valClass: KClass<V>): String {
|
||||
return json.stringify((keyClass.serializer() to valClass.serializer()).map, obj)
|
||||
return json.stringify(MapSerializer(keyClass.serializer(), valClass.serializer()), obj)
|
||||
}
|
||||
|
||||
fun <K : Any, V : Any> parseMap(map: String, keyClass: KClass<K>, valClass: KClass<V>): Map<K, V> {
|
||||
|
@ -54,7 +59,7 @@ class Serializer @Inject constructor() : ISerializer {
|
|||
|
||||
@ImplicitReflectionSerializer
|
||||
override fun <K : Any, V : Any> parseMapImpl(map: String, keyClass: KClass<K>, valClass: KClass<V>): Map<K, V> {
|
||||
return parse((keyClass.serializer() to valClass.serializer()).map, map)
|
||||
return parse(MapSerializer(keyClass.serializer(), valClass.serializer()), map)
|
||||
}
|
||||
|
||||
fun <T : Any> stringify(objects: List<T>, keyClass: KClass<T>): String {
|
||||
|
|
Загрузка…
Ссылка в новой задаче