From 345824daa29a4610fb65b2d735b1056dead17c1f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 24 Jan 2020 15:09:33 +0100 Subject: [PATCH] Keep on renaming --- .../internal/crypto/verification/SASTest.kt | 66 +++++++++---------- .../api/session/crypto/CryptoService.kt | 7 +- .../session/crypto/sas/VerificationService.kt | 4 +- .../crypto/sas/VerificationTransaction.kt | 18 ++++- .../internal/crypto/DefaultCryptoService.kt | 8 +-- .../DefaultVerificationService.kt | 26 ++++---- .../SASDefaultVerificationTransaction.kt | 4 +- .../verification/VerificationTransport.kt | 5 +- .../VerificationTransportRoomMessage.kt | 2 +- .../VerificationTransportToDevice.kt | 2 +- .../crypto/keysrequest/KeyRequestHandler.kt | 4 +- .../IncomingVerificationRequestHandler.kt | 6 +- .../VerificationBottomSheetViewModel.kt | 23 ++++--- .../VerificationChooseMethodViewModel.kt | 8 +-- .../emoji/VerificationEmojiCodeViewModel.kt | 6 +- .../home/room/detail/RoomDetailViewModel.kt | 8 +-- .../features/navigation/DefaultNavigator.kt | 2 +- .../settings/devices/DevicesViewModel.kt | 6 +- 18 files changed, 111 insertions(+), 94 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt index 7b10f47806..178eca09b2 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt @@ -51,8 +51,8 @@ class SASTest : InstrumentedTest { val aliceSession = cryptoTestData.firstSession val bobSession = cryptoTestData.secondSession - val aliceSasMgr = aliceSession.getSasVerificationService() - val bobSasMgr = bobSession!!.getSasVerificationService() + val aliceVerificationService = aliceSession.getVerificationService() + val bobVerificationService = bobSession!!.getVerificationService() val bobTxCreatedLatch = CountDownLatch(1) val bobListener = object : VerificationService.VerificationListener { @@ -64,18 +64,18 @@ class SASTest : InstrumentedTest { override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } - bobSasMgr.addListener(bobListener) + bobVerificationService.addListener(bobListener) - val txID = aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobSession.myUserId, bobSession.getMyDevice().deviceId) + val txID = aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobSession.myUserId, bobSession.getMyDevice().deviceId) assertNotNull("Alice should have a started transaction", txID) - val aliceKeyTx = aliceSasMgr.getExistingTransaction(bobSession.myUserId, txID!!) + val aliceKeyTx = aliceVerificationService.getExistingTransaction(bobSession.myUserId, txID!!) assertNotNull("Alice should have a started transaction", aliceKeyTx) mTestHelper.await(bobTxCreatedLatch) - bobSasMgr.removeListener(bobListener) + bobVerificationService.removeListener(bobListener) - val bobKeyTx = bobSasMgr.getExistingTransaction(aliceSession.myUserId, txID) + val bobKeyTx = bobVerificationService.getExistingTransaction(aliceSession.myUserId, txID) assertNotNull("Bob should have started verif transaction", bobKeyTx) assertTrue(bobKeyTx is SASDefaultVerificationTransaction) @@ -105,7 +105,7 @@ class SASTest : InstrumentedTest { override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } - bobSasMgr.addListener(bobListener2) + bobVerificationService.addListener(bobListener2) aliceSasTx.cancel(CancelCode.User) mTestHelper.await(cancelLatch) @@ -120,8 +120,8 @@ class SASTest : InstrumentedTest { assertEquals("Should be User cancelled on bob side", CancelCode.User, aliceSasTx.cancelledReason) - assertNull(bobSasMgr.getExistingTransaction(aliceSession.myUserId, txID)) - assertNull(aliceSasMgr.getExistingTransaction(bobSession.myUserId, txID)) + assertNull(bobVerificationService.getExistingTransaction(aliceSession.myUserId, txID)) + assertNull(aliceVerificationService.getExistingTransaction(bobSession.myUserId, txID)) cryptoTestData.close() } @@ -151,7 +151,7 @@ class SASTest : InstrumentedTest { override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } - bobSession.getSasVerificationService().addListener(bobListener) + bobSession.getVerificationService().addListener(bobListener) // TODO bobSession!!.dataHandler.addListener(object : MXEventListener() { // TODO override fun onToDeviceEvent(event: Event?) { @@ -179,7 +179,7 @@ class SASTest : InstrumentedTest { override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } - aliceSession.getSasVerificationService().addListener(aliceListener) + aliceSession.getVerificationService().addListener(aliceListener) fakeBobStart(bobSession, aliceUserID, aliceDevice, tid, protocols = protocols) @@ -303,7 +303,7 @@ class SASTest : InstrumentedTest { val aliceSession = cryptoTestData.firstSession val bobSession = cryptoTestData.secondSession - val aliceSasMgr = aliceSession.getSasVerificationService() + val aliceVerificationService = aliceSession.getVerificationService() val aliceCreatedLatch = CountDownLatch(2) val aliceCancelledLatch = CountDownLatch(2) @@ -322,12 +322,12 @@ class SASTest : InstrumentedTest { override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } - aliceSasMgr.addListener(aliceListener) + aliceVerificationService.addListener(aliceListener) val bobUserId = bobSession!!.myUserId val bobDeviceId = bobSession.getMyDevice().deviceId - aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId) - aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId) + aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId) + aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId) mTestHelper.await(aliceCreatedLatch) mTestHelper.await(aliceCancelledLatch) @@ -345,8 +345,8 @@ class SASTest : InstrumentedTest { val aliceSession = cryptoTestData.firstSession val bobSession = cryptoTestData.secondSession - val aliceSasMgr = aliceSession.getSasVerificationService() - val bobSasMgr = bobSession!!.getSasVerificationService() + val aliceVerificationService = aliceSession.getVerificationService() + val bobVerificationService = bobSession!!.getVerificationService() var accepted: KeyVerificationAccept? = null var startReq: KeyVerificationStart? = null @@ -366,7 +366,7 @@ class SASTest : InstrumentedTest { } } } - aliceSasMgr.addListener(aliceListener) + aliceVerificationService.addListener(aliceListener) val bobListener = object : VerificationService.VerificationListener { override fun transactionCreated(tx: VerificationTransaction) {} @@ -380,11 +380,11 @@ class SASTest : InstrumentedTest { override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } - bobSasMgr.addListener(bobListener) + bobVerificationService.addListener(bobListener) val bobUserId = bobSession.myUserId val bobDeviceId = bobSession.getMyDevice().deviceId - aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId) + aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId) mTestHelper.await(aliceAcceptedLatch) assertTrue("Should have receive a commitment", accepted!!.commitment?.trim()?.isEmpty() == false) @@ -409,8 +409,8 @@ class SASTest : InstrumentedTest { val aliceSession = cryptoTestData.firstSession val bobSession = cryptoTestData.secondSession - val aliceSasMgr = aliceSession.getSasVerificationService() - val bobSasMgr = bobSession!!.getSasVerificationService() + val aliceVerificationService = aliceSession.getVerificationService() + val bobVerificationService = bobSession!!.getVerificationService() val aliceSASLatch = CountDownLatch(1) val aliceListener = object : VerificationService.VerificationListener { @@ -428,7 +428,7 @@ class SASTest : InstrumentedTest { override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } - aliceSasMgr.addListener(aliceListener) + aliceVerificationService.addListener(aliceListener) val bobSASLatch = CountDownLatch(1) val bobListener = object : VerificationService.VerificationListener { @@ -449,16 +449,16 @@ class SASTest : InstrumentedTest { override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } - bobSasMgr.addListener(bobListener) + bobVerificationService.addListener(bobListener) val bobUserId = bobSession.myUserId val bobDeviceId = bobSession.getMyDevice().deviceId - val verificationSAS = aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId) + val verificationSAS = aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId) mTestHelper.await(aliceSASLatch) mTestHelper.await(bobSASLatch) - val aliceTx = aliceSasMgr.getExistingTransaction(bobUserId, verificationSAS!!) as SASDefaultVerificationTransaction - val bobTx = bobSasMgr.getExistingTransaction(aliceSession.myUserId, verificationSAS) as SASDefaultVerificationTransaction + val aliceTx = aliceVerificationService.getExistingTransaction(bobUserId, verificationSAS!!) as SASDefaultVerificationTransaction + val bobTx = bobVerificationService.getExistingTransaction(aliceSession.myUserId, verificationSAS) as SASDefaultVerificationTransaction assertEquals("Should have same SAS", aliceTx.getShortCodeRepresentation(SasMode.DECIMAL), bobTx.getShortCodeRepresentation(SasMode.DECIMAL)) @@ -473,8 +473,8 @@ class SASTest : InstrumentedTest { val aliceSession = cryptoTestData.firstSession val bobSession = cryptoTestData.secondSession - val aliceSasMgr = aliceSession.getSasVerificationService() - val bobSasMgr = bobSession!!.getSasVerificationService() + val aliceVerificationService = aliceSession.getVerificationService() + val bobVerificationService = bobSession!!.getVerificationService() val aliceSASLatch = CountDownLatch(1) val aliceListener = object : VerificationService.VerificationListener { @@ -495,7 +495,7 @@ class SASTest : InstrumentedTest { override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } - aliceSasMgr.addListener(aliceListener) + aliceVerificationService.addListener(aliceListener) val bobSASLatch = CountDownLatch(1) val bobListener = object : VerificationService.VerificationListener { @@ -519,11 +519,11 @@ class SASTest : InstrumentedTest { override fun markedAsManuallyVerified(userId: String, deviceId: String) {} } - bobSasMgr.addListener(bobListener) + bobVerificationService.addListener(bobListener) val bobUserId = bobSession.myUserId val bobDeviceId = bobSession.getMyDevice().deviceId - aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId) + aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId) mTestHelper.await(aliceSASLatch) mTestHelper.await(bobSASLatch) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/CryptoService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/CryptoService.kt index af2285db08..594ad39063 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/CryptoService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/CryptoService.kt @@ -50,7 +50,7 @@ interface CryptoService { fun isCryptoEnabled(): Boolean - fun getSasVerificationService(): VerificationService + fun getVerificationService(): VerificationService fun getCrossSigningService(): CrossSigningService @@ -118,8 +118,9 @@ interface CryptoService { fun downloadKeys(userIds: List, forceDownload: Boolean, callback: MatrixCallback>) - fun getCryptoDeviceInfo(userId: String) : List - fun getLiveCryptoDeviceInfo(userId: String) : LiveData> + fun getCryptoDeviceInfo(userId: String): List + + fun getLiveCryptoDeviceInfo(userId: String): LiveData> fun addNewSessionListener(newSessionListener: NewSessionListener) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt index a65eba54f7..153a5cc273 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt @@ -24,8 +24,8 @@ import im.vector.matrix.android.internal.crypto.verification.PendingVerification * https://matrix.org/docs/spec/client_server/r0.5.0#key-verification-framework * * Verifying keys manually by reading out the Ed25519 key is not very user friendly, and can lead to errors. - * SAS verification is a user-friendly key verification process. - * SAS verification is intended to be a highly interactive process for users, + * Verification is a user-friendly key verification process. + * Verification is intended to be a highly interactive process for users, * and as such exposes verification methods which are easier for users to use. */ interface VerificationService { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationTransaction.kt index 2415a00759..793c67ae33 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationTransaction.kt @@ -1,8 +1,23 @@ +/* + * Copyright 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package im.vector.matrix.android.api.session.crypto.sas interface VerificationTransaction { - var state: VerificationTxState val cancelledReason: CancelCode? @@ -14,6 +29,7 @@ interface VerificationTransaction { * User wants to cancel the transaction */ fun cancel() + fun cancel(code: CancelCode) fun isToDeviceTransport(): Boolean diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt index 0e9f47df61..0f4358e725 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt @@ -126,8 +126,8 @@ internal class DefaultCryptoService @Inject constructor( private val oneTimeKeysUploader: OneTimeKeysUploader, // private val roomDecryptorProvider: RoomDecryptorProvider, - // The SAS verification service. - private val sasVerificationService: DefaultVerificationService, + // The verification service. + private val verificationService: DefaultVerificationService, private val crossSigningService: DefaultCrossSigningService, // @@ -157,7 +157,7 @@ internal class DefaultCryptoService @Inject constructor( init { - sasVerificationService.cryptoService = this + verificationService.cryptoService = this } private val uiHandler = Handler(Looper.getMainLooper()) @@ -343,7 +343,7 @@ internal class DefaultCryptoService @Inject constructor( /** * @return the VerificationService */ - override fun getSasVerificationService() = sasVerificationService + override fun getVerificationService() = verificationService override fun getCrossSigningService() = crossSigningService diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt index 4c487b5ed2..9a7cc80c06 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt @@ -57,8 +57,8 @@ internal class DefaultVerificationService @Inject constructor( private val deviceListManager: DeviceListManager, private val setDeviceVerificationAction: SetDeviceVerificationAction, private val coroutineDispatchers: MatrixCoroutineDispatchers, - private val sasTransportRoomMessageFactory: SasTransportRoomMessageFactory, - private val sasTransportToDeviceFactory: SasTransportToDeviceFactory, + private val verificationTransportRoomMessageFactory: VerificationTransportRoomMessageFactory, + private val verificationTransportToDeviceFactory: VerificationTransportToDeviceFactory, private val crossSigningService: CrossSigningService ) : DefaultVerificationTransaction.Listener, VerificationService { @@ -289,7 +289,7 @@ internal class DefaultVerificationService @Inject constructor( if (startReq?.isValid()?.not() == true) { Timber.e("## received invalid verification request") if (startReq.transactionID != null) { - sasTransportRoomMessageFactory.createTransport(event.roomId ?: "", null) + verificationTransportRoomMessageFactory.createTransport(event.roomId ?: "", null) .cancelTransaction( startReq.transactionID ?: "", otherUserId!!, @@ -301,9 +301,9 @@ internal class DefaultVerificationService @Inject constructor( } handleStart(otherUserId, startReq as VerificationInfoStart) { - it.transport = sasTransportRoomMessageFactory.createTransport(event.roomId ?: "", it) + it.transport = verificationTransportRoomMessageFactory.createTransport(event.roomId ?: "", it) }?.let { - sasTransportRoomMessageFactory.createTransport(event.roomId ?: "", null) + verificationTransportRoomMessageFactory.createTransport(event.roomId ?: "", null) .cancelTransaction( startReq.transactionID ?: "", otherUserId!!, @@ -322,7 +322,7 @@ internal class DefaultVerificationService @Inject constructor( if (!startReq.isValid()) { Timber.e("## SAS received invalid verification request") if (startReq.transactionID != null) { - sasTransportToDeviceFactory.createTransport(null).cancelTransaction( + verificationTransportToDeviceFactory.createTransport(null).cancelTransaction( startReq.transactionID, otherUserId!!, startReq.fromDevice ?: event.getSenderKey()!!, @@ -333,9 +333,9 @@ internal class DefaultVerificationService @Inject constructor( } // Download device keys prior to everything handleStart(otherUserId, startReq) { - it.transport = sasTransportToDeviceFactory.createTransport(it) + it.transport = verificationTransportToDeviceFactory.createTransport(it) }?.let { - sasTransportToDeviceFactory.createTransport(null).cancelTransaction( + verificationTransportToDeviceFactory.createTransport(null).cancelTransaction( startReq.transactionID ?: "", otherUserId!!, startReq.fromDevice ?: event.getSenderKey()!!, @@ -705,7 +705,7 @@ internal class DefaultVerificationService @Inject constructor( txID, userId, deviceID) - tx.transport = sasTransportToDeviceFactory.createTransport(tx) + tx.transport = verificationTransportToDeviceFactory.createTransport(tx) addTransaction(tx) tx.start(method) @@ -724,7 +724,7 @@ internal class DefaultVerificationService @Inject constructor( pendingRequests[userId] = it } - val transport = sasTransportRoomMessageFactory.createTransport(roomId, null) + val transport = verificationTransportRoomMessageFactory.createTransport(roomId, null) // Cancel existing pending requests? requestsForUser.toImmutableList().forEach { existingRequest -> @@ -762,7 +762,7 @@ internal class DefaultVerificationService @Inject constructor( } override fun declineVerificationRequestInDMs(otherUserId: String, otherDeviceId: String, transactionId: String, roomId: String) { - sasTransportRoomMessageFactory.createTransport(roomId, null) + verificationTransportRoomMessageFactory.createTransport(roomId, null) .cancelTransaction(transactionId, otherUserId, otherDeviceId, CancelCode.User) getExistingVerificationRequest(otherUserId, transactionId)?.let { @@ -804,7 +804,7 @@ internal class DefaultVerificationService @Inject constructor( transactionId, otherUserId, otherDeviceId) - tx.transport = sasTransportRoomMessageFactory.createTransport(roomId, tx) + tx.transport = verificationTransportRoomMessageFactory.createTransport(roomId, tx) addTransaction(tx) tx.start(method) @@ -820,7 +820,7 @@ internal class DefaultVerificationService @Inject constructor( val existingRequest = getExistingVerificationRequest(otherUserId, transactionId) if (existingRequest != null) { // we need to send a ready event, with matching methods - val transport = sasTransportRoomMessageFactory.createTransport(roomId, null) + val transport = verificationTransportRoomMessageFactory.createTransport(roomId, null) // TODO We should not use supportedVerificationMethods here, because it depends on the client implementation val methods = existingRequest.requestInfo?.methods?.intersect(supportedVerificationMethods)?.toList() if (methods.isNullOrEmpty()) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt index 806bbc2703..e8d01a0b25 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt @@ -48,8 +48,8 @@ internal abstract class SASDefaultVerificationTransaction( transactionId: String, otherUserId: String, otherDevice: String?, - isIncoming: Boolean) : - DefaultVerificationTransaction(transactionId, otherUserId, otherDevice, isIncoming), SasVerificationTransaction { + isIncoming: Boolean +) : DefaultVerificationTransaction(transactionId, otherUserId, otherDevice, isIncoming), SasVerificationTransaction { companion object { const val SAS_MAC_SHA256_LONGKDF = "hmac-sha256" diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransport.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransport.kt index b2740ff96b..69752f83be 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransport.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransport.kt @@ -20,8 +20,8 @@ import im.vector.matrix.android.api.session.crypto.sas.VerificationTxState import im.vector.matrix.android.api.session.room.model.message.MessageVerificationRequestContent /** - * SAS verification can be performed using toDevice events or via DM. - * This class abstracts the concept of transport for SAS + * Verification can be performed using toDevice events or via DM. + * This class abstracts the concept of transport for verification */ internal interface VerificationTransport { @@ -46,6 +46,7 @@ internal interface VerificationTransport { code: CancelCode) fun done(transactionId: String) + /** * Creates an accept message suitable for this transport */ diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportRoomMessage.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportRoomMessage.kt index f36d8a2a8d..7ed86fc028 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportRoomMessage.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportRoomMessage.kt @@ -292,7 +292,7 @@ internal class VerificationTransportRoomMessage( } } -internal class SasTransportRoomMessageFactory @Inject constructor( +internal class VerificationTransportRoomMessageFactory @Inject constructor( private val workManagerProvider: WorkManagerProvider, private val stringProvider: StringProvider, private val monarchy: Monarchy, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportToDevice.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportToDevice.kt index 04c78d0154..3a132e8608 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportToDevice.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportToDevice.kt @@ -145,7 +145,7 @@ internal class VerificationTransportToDevice( } } -internal class SasTransportToDeviceFactory @Inject constructor( +internal class VerificationTransportToDeviceFactory @Inject constructor( private val sendToDeviceTask: SendToDeviceTask, private val taskExecutor: TaskExecutor) { diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt b/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt index 24b656c810..856c71f888 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt @@ -64,12 +64,12 @@ class KeyRequestHandler @Inject constructor(private val context: Context) fun start(session: Session) { this.session = session - session.getSasVerificationService().addListener(this) + session.getVerificationService().addListener(this) session.addRoomKeysRequestListener(this) } fun stop() { - session?.getSasVerificationService()?.removeListener(this) + session?.getVerificationService()?.removeListener(this) session?.removeRoomKeysRequestListener(this) session = null } diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt index 3efac92800..234b60cba3 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt @@ -40,11 +40,11 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context fun start(session: Session) { this.session = session - session.getSasVerificationService().addListener(this) + session.getVerificationService().addListener(this) } fun stop() { - session?.getSasVerificationService()?.removeListener(this) + session?.getVerificationService()?.removeListener(this) this.session = null } @@ -130,7 +130,7 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context } } dismissedAction = Runnable { - session?.getSasVerificationService()?.declineVerificationRequestInDMs(pr.otherUserId, + session?.getVerificationService()?.declineVerificationRequestInDMs(pr.otherUserId, pr.requestInfo?.fromDevice ?: "", pr.transactionId ?: "", pr.roomId ?: "" diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt index 5b7be367e5..6b9b658b82 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt @@ -68,11 +68,11 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini get() = _requestLiveData init { - session.getSasVerificationService().addListener(this) + session.getVerificationService().addListener(this) } override fun onCleared() { - session.getSasVerificationService().removeListener(this) + session.getVerificationService().removeListener(this) super.onCleared() } @@ -91,10 +91,10 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini val userItem = session.getUser(args.otherUserId) - val pr = session.getSasVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId) + val pr = session.getVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId) val sasTx = (pr?.transactionId ?: args.verificationId)?.let { - session.getSasVerificationService().getExistingTransaction(args.otherUserId, it) + session.getVerificationService().getExistingTransaction(args.otherUserId, it) } return fragment.verificationViewModelFactory.create(VerificationBottomSheetViewState( @@ -132,7 +132,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini copy( roomId = data, pendingRequest = Success( - session.getSasVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, otherUserId, data, pendingLocalId) + session.getVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, otherUserId, data, pendingLocalId) ) ) } @@ -146,16 +146,16 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini }) } else { setState { - copy(pendingRequest = Success(session.getSasVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, otherUserId, roomId))) + copy(pendingRequest = Success(session.getVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, otherUserId, roomId))) } } } is VerificationAction.StartSASVerification -> { - val request = session.getSasVerificationService().getExistingVerificationRequest(otherUserId, action.pendingRequestTransactionId) + val request = session.getVerificationService().getExistingVerificationRequest(otherUserId, action.pendingRequestTransactionId) ?: return@withState if (roomId == null) return@withState val otherDevice = if (request.isIncoming) request.requestInfo?.fromDevice else request.readyInfo?.fromDevice - session.getSasVerificationService().beginKeyVerificationInDMs( + session.getVerificationService().beginKeyVerificationInDMs( VerificationMethod.SAS, transactionId = action.pendingRequestTransactionId, roomId = roomId, @@ -165,19 +165,18 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini ) } is VerificationAction.RemoteQrCodeScanned -> { - // TODO Use session.getCrossSigningService()? - val existingTransaction = session.getSasVerificationService() + val existingTransaction = session.getVerificationService() .getExistingTransaction(action.userID, action.transactionId) as? QRVerificationTransaction existingTransaction ?.userHasScannedRemoteQrCode(action.scannedData) } is VerificationAction.SASMatchAction -> { - (session.getSasVerificationService() + (session.getVerificationService() .getExistingTransaction(action.userID, action.sasTransactionId) as? SasVerificationTransaction)?.userHasVerifiedShortCode() } is VerificationAction.SASDoNotMatchAction -> { - (session.getSasVerificationService() + (session.getVerificationService() .getExistingTransaction(action.userID, action.sasTransactionId) as? SasVerificationTransaction) ?.shortCodeDoesNotMatch() diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt index cee1cba7a5..a9b24b5710 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt @@ -51,7 +51,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor( override fun transactionUpdated(tx: VerificationTransaction) {} override fun verificationRequestUpdated(pr: PendingVerificationRequest) = withState { state -> - val pvr = session.getSasVerificationService().getExistingVerificationRequest(state.otherUserId, state.transactionId) + val pvr = session.getVerificationService().getExistingVerificationRequest(state.otherUserId, state.transactionId) setState { copy( @@ -70,12 +70,12 @@ class VerificationChooseMethodViewModel @AssistedInject constructor( } init { - session.getSasVerificationService().addListener(this) + session.getVerificationService().addListener(this) } override fun onCleared() { super.onCleared() - session.getSasVerificationService().removeListener(this) + session.getVerificationService().removeListener(this) } companion object : MvRxViewModelFactory { @@ -87,7 +87,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor( override fun initialState(viewModelContext: ViewModelContext): VerificationChooseMethodViewState? { val args: VerificationBottomSheet.VerificationArgs = viewModelContext.args() val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getActiveSession() - val pvr = session.getSasVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId) + val pvr = session.getVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId) return VerificationChooseMethodViewState(otherUserId = args.otherUserId, transactionId = args.verificationId ?: "", diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt index 5c2caa7ef4..8824cd88e2 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt @@ -48,16 +48,16 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor( init { withState { state -> - refreshStateFromTx(session.getSasVerificationService() + refreshStateFromTx(session.getVerificationService() .getExistingTransaction(state.otherUser?.id ?: "", state.transactionId ?: "") as? SasVerificationTransaction) } - session.getSasVerificationService().addListener(this) + session.getVerificationService().addListener(this) } override fun onCleared() { - session.getSasVerificationService().removeListener(this) + session.getVerificationService().removeListener(this) super.onCleared() } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt index 055dcfa9fb..695dfa8d33 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt @@ -411,7 +411,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro popDraft() } is ParsedCommand.VerifyUser -> { - session.getSasVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, slashCommandResult.userId, room.roomId) + session.getVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, slashCommandResult.userId, room.roomId) _sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled()) popDraft() } @@ -809,14 +809,14 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro private fun handleAcceptVerification(action: RoomDetailAction.AcceptVerificationRequest) { Timber.v("## SAS handleAcceptVerification ${action.otherUserId}, roomId:${room.roomId}, txId:${action.transactionId}") - if (session.getSasVerificationService().readyPendingVerificationInDMs(action.otherUserId, room.roomId, + if (session.getVerificationService().readyPendingVerificationInDMs(action.otherUserId, room.roomId, action.transactionId)) { _requestLiveData.postValue(LiveEvent(Success(action))) } } private fun handleDeclineVerification(action: RoomDetailAction.DeclineVerificationRequest) { - session.getSasVerificationService().declineVerificationRequestInDMs( + session.getVerificationService().declineVerificationRequestInDMs( action.otherUserId, action.otherdDeviceId, action.transactionId, @@ -830,7 +830,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro private fun handleResumeRequestVerification(action: RoomDetailAction.ResumeVerification) { // Check if this request is still active and handled by me - session.getSasVerificationService().getExistingVerificationRequestInRoom(room.roomId, action.transactionId)?.let { + session.getVerificationService().getExistingVerificationRequestInRoom(room.roomId, action.transactionId)?.let { if (it.handledByOtherSession) return if (!it.isFinished) { _requestLiveData.postValue(LiveEvent(Success(action.copy( diff --git a/vector/src/main/java/im/vector/riotx/features/navigation/DefaultNavigator.kt b/vector/src/main/java/im/vector/riotx/features/navigation/DefaultNavigator.kt index f28bcebd0e..1a90151693 100644 --- a/vector/src/main/java/im/vector/riotx/features/navigation/DefaultNavigator.kt +++ b/vector/src/main/java/im/vector/riotx/features/navigation/DefaultNavigator.kt @@ -65,7 +65,7 @@ class DefaultNavigator @Inject constructor( override fun performDeviceVerification(context: Context, otherUserId: String, sasTransationId: String) { val session = sessionHolder.getSafeActiveSession() ?: return - val tx = session.getSasVerificationService().getExistingTransaction(otherUserId, sasTransationId) ?: return + val tx = session.getVerificationService().getExistingTransaction(otherUserId, sasTransationId) ?: return (tx as? IncomingSasVerificationTransaction)?.performAccept() if (context is VectorBaseActivity) { VerificationBottomSheet.withArgs( diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt index 71bfafbc28..f9e28e35e0 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt @@ -86,11 +86,11 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic init { refreshDevicesList() - session.getSasVerificationService().addListener(this) + session.getVerificationService().addListener(this) } override fun onCleared() { - session.getSasVerificationService().removeListener(this) + session.getVerificationService().removeListener(this) super.onCleared() } @@ -169,7 +169,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic private fun handleVerify(action: DevicesAction.VerifyMyDevice) { // TODO Implement request in to DEVICE!!! - val txID = session.getSasVerificationService().beginKeyVerification(VerificationMethod.SAS, session.myUserId, action.deviceId) + val txID = session.getVerificationService().beginKeyVerification(VerificationMethod.SAS, session.myUserId, action.deviceId) if (txID != null) { _requestLiveData.postValue(LiveEvent(Success( action.copy(