From 1b29c7bf91ad9b27e424eef0223679c95e3ef538 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 5 Mar 2020 11:22:42 +0100 Subject: [PATCH] Move method to interface step 2 --- .../MessageVerificationStartContent.kt | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVerificationStartContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVerificationStartContent.kt index a2a3940199..3c08709d18 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVerificationStartContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageVerificationStartContent.kt @@ -17,15 +17,10 @@ package im.vector.matrix.android.api.session.room.model.message import com.squareup.moshi.Json import com.squareup.moshi.JsonClass -import im.vector.matrix.android.api.session.crypto.verification.SasMode import im.vector.matrix.android.api.session.events.model.toContent import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultContent -import im.vector.matrix.android.internal.crypto.model.rest.VERIFICATION_METHOD_RECIPROCATE -import im.vector.matrix.android.internal.crypto.model.rest.VERIFICATION_METHOD_SAS -import im.vector.matrix.android.internal.crypto.verification.SASDefaultVerificationTransaction import im.vector.matrix.android.internal.crypto.verification.VerificationInfoStart import im.vector.matrix.android.internal.util.JsonCanonicalizer -import timber.log.Timber @JsonClass(generateAdapter = true) internal data class MessageVerificationStartContent( @@ -46,39 +41,5 @@ internal data class MessageVerificationStartContent( override val transactionID: String? get() = relatesTo?.eventId - // TODO Move those method to the interface? - override fun isValid(): Boolean { - if (transactionID.isNullOrBlank() - || fromDevice.isNullOrBlank() - || (method == VERIFICATION_METHOD_SAS && !isValidSas()) - || (method == VERIFICATION_METHOD_RECIPROCATE && !isValidReciprocate())) { - Timber.e("## received invalid verification request") - return false - } - return true - } - - private fun isValidSas(): Boolean { - if (keyAgreementProtocols.isNullOrEmpty() - || hashes.isNullOrEmpty() - || !hashes.contains("sha256") || messageAuthenticationCodes.isNullOrEmpty() - || (!messageAuthenticationCodes.contains(SASDefaultVerificationTransaction.SAS_MAC_SHA256) - && !messageAuthenticationCodes.contains(SASDefaultVerificationTransaction.SAS_MAC_SHA256_LONGKDF)) - || shortAuthenticationStrings.isNullOrEmpty() - || !shortAuthenticationStrings.contains(SasMode.DECIMAL)) { - return false - } - - return true - } - - private fun isValidReciprocate(): Boolean { - if (sharedSecret.isNullOrBlank()) { - return false - } - - return true - } - override fun toEventContent() = toContent() }