Sonar: rename variables and parameter to follow naming convention
This commit is contained in:
parent
d3f50ee6c3
commit
ee9c73fde1
@ -19,9 +19,6 @@ package org.matrix.android.sdk.internal.crypto
|
|||||||
import android.os.MemoryFile
|
import android.os.MemoryFile
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import org.matrix.android.sdk.internal.crypto.attachments.MXEncryptedAttachments
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileKey
|
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertNotEquals
|
import org.junit.Assert.assertNotEquals
|
||||||
import org.junit.Assert.assertNotNull
|
import org.junit.Assert.assertNotNull
|
||||||
@ -29,6 +26,9 @@ import org.junit.FixMethodOrder
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
|
import org.matrix.android.sdk.internal.crypto.attachments.MXEncryptedAttachments
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileKey
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,15 +40,15 @@ import java.io.InputStream
|
|||||||
class AttachmentEncryptionTest {
|
class AttachmentEncryptionTest {
|
||||||
|
|
||||||
private fun checkDecryption(input: String, encryptedFileInfo: EncryptedFileInfo): String {
|
private fun checkDecryption(input: String, encryptedFileInfo: EncryptedFileInfo): String {
|
||||||
val `in` = Base64.decode(input, Base64.DEFAULT)
|
val inputAsByteArray = Base64.decode(input, Base64.DEFAULT)
|
||||||
|
|
||||||
val inputStream: InputStream
|
val inputStream: InputStream
|
||||||
|
|
||||||
inputStream = if (`in`.isEmpty()) {
|
inputStream = if (inputAsByteArray.isEmpty()) {
|
||||||
`in`.inputStream()
|
inputAsByteArray.inputStream()
|
||||||
} else {
|
} else {
|
||||||
val memoryFile = MemoryFile("file" + System.currentTimeMillis(), `in`.size)
|
val memoryFile = MemoryFile("file" + System.currentTimeMillis(), inputAsByteArray.size)
|
||||||
memoryFile.outputStream.write(`in`)
|
memoryFile.outputStream.write(inputAsByteArray)
|
||||||
memoryFile.inputStream
|
memoryFile.inputStream
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ class AttachmentEncryptionTest {
|
|||||||
key = EncryptedFileKey(
|
key = EncryptedFileKey(
|
||||||
alg = "A256CTR",
|
alg = "A256CTR",
|
||||||
k = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
k = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||||
key_ops = listOf("encrypt", "decrypt"),
|
keyOps = listOf("encrypt", "decrypt"),
|
||||||
kty = "oct",
|
kty = "oct",
|
||||||
ext = true
|
ext = true
|
||||||
),
|
),
|
||||||
@ -92,7 +92,7 @@ class AttachmentEncryptionTest {
|
|||||||
key = EncryptedFileKey(
|
key = EncryptedFileKey(
|
||||||
alg = "A256CTR",
|
alg = "A256CTR",
|
||||||
k = "__________________________________________8",
|
k = "__________________________________________8",
|
||||||
key_ops = listOf("encrypt", "decrypt"),
|
keyOps = listOf("encrypt", "decrypt"),
|
||||||
kty = "oct",
|
kty = "oct",
|
||||||
ext = true
|
ext = true
|
||||||
),
|
),
|
||||||
@ -111,7 +111,7 @@ class AttachmentEncryptionTest {
|
|||||||
key = EncryptedFileKey(
|
key = EncryptedFileKey(
|
||||||
alg = "A256CTR",
|
alg = "A256CTR",
|
||||||
k = "__________________________________________8",
|
k = "__________________________________________8",
|
||||||
key_ops = listOf("encrypt", "decrypt"),
|
keyOps = listOf("encrypt", "decrypt"),
|
||||||
kty = "oct",
|
kty = "oct",
|
||||||
ext = true
|
ext = true
|
||||||
),
|
),
|
||||||
@ -132,7 +132,7 @@ class AttachmentEncryptionTest {
|
|||||||
key = EncryptedFileKey(
|
key = EncryptedFileKey(
|
||||||
alg = "A256CTR",
|
alg = "A256CTR",
|
||||||
k = "__________________________________________8",
|
k = "__________________________________________8",
|
||||||
key_ops = listOf("encrypt", "decrypt"),
|
keyOps = listOf("encrypt", "decrypt"),
|
||||||
kty = "oct",
|
kty = "oct",
|
||||||
ext = true
|
ext = true
|
||||||
),
|
),
|
||||||
|
@ -54,7 +54,7 @@ internal data class AddThreePidRegistrationParams(
|
|||||||
* This parameter is ignored when the homeserver handles 3PID verification.
|
* This parameter is ignored when the homeserver handles 3PID verification.
|
||||||
*/
|
*/
|
||||||
@Json(name = "id_server")
|
@Json(name = "id_server")
|
||||||
val id_server: String? = null,
|
val idServer: String? = null,
|
||||||
|
|
||||||
/* ==========================================================================================
|
/* ==========================================================================================
|
||||||
* For emails
|
* For emails
|
||||||
|
@ -44,5 +44,6 @@ internal data class RegistrationParams(
|
|||||||
|
|
||||||
// Temporary flag to notify the server that we support msisdn flow. Used to prevent old app
|
// Temporary flag to notify the server that we support msisdn flow. Used to prevent old app
|
||||||
// versions to end up in fallback because the HS returns the msisdn flow which they don't support
|
// versions to end up in fallback because the HS returns the msisdn flow which they don't support
|
||||||
val x_show_msisdn: Boolean? = null
|
@Json(name = "x_show_msisdn")
|
||||||
|
val xShowMsisdn: Boolean? = null
|
||||||
)
|
)
|
||||||
|
@ -145,7 +145,7 @@ object MXMegolmExportEncryption {
|
|||||||
*/
|
*/
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun encryptMegolmKeyFile(data: String, password: String, kdf_rounds: Int = DEFAULT_ITERATION_COUNT): ByteArray {
|
fun encryptMegolmKeyFile(data: String, password: String, kdfRounds: Int = DEFAULT_ITERATION_COUNT): ByteArray {
|
||||||
if (password.isEmpty()) {
|
if (password.isEmpty()) {
|
||||||
throw Exception("Empty password is not supported")
|
throw Exception("Empty password is not supported")
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ object MXMegolmExportEncryption {
|
|||||||
// of a single bit of salt is a price we have to pay.
|
// of a single bit of salt is a price we have to pay.
|
||||||
iv[9] = iv[9] and 0x7f
|
iv[9] = iv[9] and 0x7f
|
||||||
|
|
||||||
val deriveKey = deriveKeys(salt, kdf_rounds, password)
|
val deriveKey = deriveKeys(salt, kdfRounds, password)
|
||||||
|
|
||||||
val decryptCipher = Cipher.getInstance("AES/CTR/NoPadding")
|
val decryptCipher = Cipher.getInstance("AES/CTR/NoPadding")
|
||||||
|
|
||||||
@ -188,10 +188,10 @@ object MXMegolmExportEncryption {
|
|||||||
System.arraycopy(iv, 0, resultBuffer, idx, iv.size)
|
System.arraycopy(iv, 0, resultBuffer, idx, iv.size)
|
||||||
idx += iv.size
|
idx += iv.size
|
||||||
|
|
||||||
resultBuffer[idx++] = (kdf_rounds shr 24 and 0xff).toByte()
|
resultBuffer[idx++] = (kdfRounds shr 24 and 0xff).toByte()
|
||||||
resultBuffer[idx++] = (kdf_rounds shr 16 and 0xff).toByte()
|
resultBuffer[idx++] = (kdfRounds shr 16 and 0xff).toByte()
|
||||||
resultBuffer[idx++] = (kdf_rounds shr 8 and 0xff).toByte()
|
resultBuffer[idx++] = (kdfRounds shr 8 and 0xff).toByte()
|
||||||
resultBuffer[idx++] = (kdf_rounds and 0xff).toByte()
|
resultBuffer[idx++] = (kdfRounds and 0xff).toByte()
|
||||||
|
|
||||||
System.arraycopy(cipherArray, 0, resultBuffer, idx, cipherArray.size)
|
System.arraycopy(cipherArray, 0, resultBuffer, idx, cipherArray.size)
|
||||||
idx += cipherArray.size
|
idx += cipherArray.size
|
||||||
@ -320,26 +320,26 @@ object MXMegolmExportEncryption {
|
|||||||
|
|
||||||
// 512 bits key length
|
// 512 bits key length
|
||||||
val key = ByteArray(64)
|
val key = ByteArray(64)
|
||||||
val Uc = ByteArray(64)
|
val uc = ByteArray(64)
|
||||||
|
|
||||||
// U1 = PRF(Password, Salt || INT_32_BE(i))
|
// U1 = PRF(Password, Salt || INT_32_BE(i))
|
||||||
prf.update(salt)
|
prf.update(salt)
|
||||||
val int32BE = ByteArray(4) { 0.toByte() }
|
val int32BE = ByteArray(4) { 0.toByte() }
|
||||||
int32BE[3] = 1.toByte()
|
int32BE[3] = 1.toByte()
|
||||||
prf.update(int32BE)
|
prf.update(int32BE)
|
||||||
prf.doFinal(Uc, 0)
|
prf.doFinal(uc, 0)
|
||||||
|
|
||||||
// copy to the key
|
// copy to the key
|
||||||
System.arraycopy(Uc, 0, key, 0, Uc.size)
|
System.arraycopy(uc, 0, key, 0, uc.size)
|
||||||
|
|
||||||
for (index in 2..iterations) {
|
for (index in 2..iterations) {
|
||||||
// Uc = PRF(Password, Uc-1)
|
// Uc = PRF(Password, Uc-1)
|
||||||
prf.update(Uc)
|
prf.update(uc)
|
||||||
prf.doFinal(Uc, 0)
|
prf.doFinal(uc, 0)
|
||||||
|
|
||||||
// F(Password, Salt, c, i) = U1 ^ U2 ^ ... ^ Uc
|
// F(Password, Salt, c, i) = U1 ^ U2 ^ ... ^ Uc
|
||||||
for (byteIndex in Uc.indices) {
|
for (byteIndex in uc.indices) {
|
||||||
key[byteIndex] = key[byteIndex] xor Uc[byteIndex]
|
key[byteIndex] = key[byteIndex] xor uc[byteIndex]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ internal class MXOlmDecryption(
|
|||||||
String.format(MXCryptoError.BAD_RECIPIENT_REASON, olmPayloadContent.recipient))
|
String.format(MXCryptoError.BAD_RECIPIENT_REASON, olmPayloadContent.recipient))
|
||||||
}
|
}
|
||||||
|
|
||||||
val recipientKeys = olmPayloadContent.recipient_keys ?: run {
|
val recipientKeys = olmPayloadContent.recipientKeys ?: run {
|
||||||
Timber.e("## decryptEvent() : Olm event (id=${event.eventId}) contains no 'recipient_keys'" +
|
Timber.e("## decryptEvent() : Olm event (id=${event.eventId}) contains no 'recipient_keys'" +
|
||||||
" property; cannot prevent unknown-key attack")
|
" property; cannot prevent unknown-key attack")
|
||||||
throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_PROPERTY,
|
throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_PROPERTY,
|
||||||
@ -129,10 +129,10 @@ internal class MXOlmDecryption(
|
|||||||
String.format(MXCryptoError.FORWARDED_MESSAGE_REASON, olmPayloadContent.sender))
|
String.format(MXCryptoError.FORWARDED_MESSAGE_REASON, olmPayloadContent.sender))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (olmPayloadContent.room_id != event.roomId) {
|
if (olmPayloadContent.roomId != event.roomId) {
|
||||||
Timber.e("## decryptEvent() : Event ${event.eventId}: original room ${olmPayloadContent.room_id} does not match reported room ${event.roomId}")
|
Timber.e("## decryptEvent() : Event ${event.eventId}: original room ${olmPayloadContent.roomId} does not match reported room ${event.roomId}")
|
||||||
throw MXCryptoError.Base(MXCryptoError.ErrorType.BAD_ROOM,
|
throw MXCryptoError.Base(MXCryptoError.ErrorType.BAD_ROOM,
|
||||||
String.format(MXCryptoError.BAD_ROOM_REASON, olmPayloadContent.room_id))
|
String.format(MXCryptoError.BAD_ROOM_REASON, olmPayloadContent.roomId))
|
||||||
}
|
}
|
||||||
|
|
||||||
val keys = olmPayloadContent.keys ?: run {
|
val keys = olmPayloadContent.keys ?: run {
|
||||||
|
@ -93,7 +93,7 @@ internal object MXEncryptedAttachments {
|
|||||||
key = EncryptedFileKey(
|
key = EncryptedFileKey(
|
||||||
alg = "A256CTR",
|
alg = "A256CTR",
|
||||||
ext = true,
|
ext = true,
|
||||||
key_ops = listOf("encrypt", "decrypt"),
|
keyOps = listOf("encrypt", "decrypt"),
|
||||||
kty = "oct",
|
kty = "oct",
|
||||||
k = base64ToBase64Url(Base64.encodeToString(key, Base64.DEFAULT))
|
k = base64ToBase64Url(Base64.encodeToString(key, Base64.DEFAULT))
|
||||||
),
|
),
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.event
|
package org.matrix.android.sdk.internal.crypto.model.event
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
|
|
||||||
@ -27,27 +28,32 @@ data class OlmPayloadContent(
|
|||||||
/**
|
/**
|
||||||
* The room id
|
* The room id
|
||||||
*/
|
*/
|
||||||
var room_id: String? = null,
|
@Json(name = "room_id")
|
||||||
|
val roomId: String? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The sender
|
* The sender
|
||||||
*/
|
*/
|
||||||
var sender: String? = null,
|
@Json(name = "sender")
|
||||||
|
val sender: String? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The recipient
|
* The recipient
|
||||||
*/
|
*/
|
||||||
var recipient: String? = null,
|
@Json(name = "recipient")
|
||||||
|
val recipient: String? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the recipient keys
|
* the recipient keys
|
||||||
*/
|
*/
|
||||||
var recipient_keys: Map<String, String>? = null,
|
@Json(name = "recipient_keys")
|
||||||
|
val recipientKeys: Map<String, String>? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The keys
|
* The keys
|
||||||
*/
|
*/
|
||||||
var keys: Map<String, String>? = null
|
@Json(name = "keys")
|
||||||
|
val keys: Map<String, String>? = null
|
||||||
) {
|
) {
|
||||||
fun toJsonString(): String {
|
fun toJsonString(): String {
|
||||||
return MoshiProvider.providesMoshi().adapter(OlmPayloadContent::class.java).toJson(this)
|
return MoshiProvider.providesMoshi().adapter(OlmPayloadContent::class.java).toJson(this)
|
||||||
|
@ -31,7 +31,7 @@ data class DeviceInfo(
|
|||||||
* The owner user id (not documented and useless but the homeserver sent it. You should not need it)
|
* The owner user id (not documented and useless but the homeserver sent it. You should not need it)
|
||||||
*/
|
*/
|
||||||
@Json(name = "user_id")
|
@Json(name = "user_id")
|
||||||
val user_id: String? = null,
|
val userId: String? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The device id
|
* The device id
|
||||||
|
@ -37,7 +37,7 @@ data class EncryptedFileKey(
|
|||||||
* Required. Key operations. Must at least contain "encrypt" and "decrypt".
|
* Required. Key operations. Must at least contain "encrypt" and "decrypt".
|
||||||
*/
|
*/
|
||||||
@Json(name = "key_ops")
|
@Json(name = "key_ops")
|
||||||
val key_ops: List<String>? = null,
|
val keyOps: List<String>? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. Key type. Must be "oct".
|
* Required. Key type. Must be "oct".
|
||||||
@ -63,7 +63,7 @@ data class EncryptedFileKey(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key_ops?.contains("encrypt") != true || !key_ops.contains("decrypt")) {
|
if (keyOps?.contains("encrypt") != true || !keyOps.contains("decrypt")) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import java.io.ObjectStreamClass
|
|||||||
*
|
*
|
||||||
* Ref: https://stackoverflow.com/questions/3884492/how-can-i-change-package-for-a-bunch-of-java-serializable-classes
|
* Ref: https://stackoverflow.com/questions/3884492/how-can-i-change-package-for-a-bunch-of-java-serializable-classes
|
||||||
*/
|
*/
|
||||||
internal class SafeObjectInputStream(`in`: InputStream) : ObjectInputStream(`in`) {
|
internal class SafeObjectInputStream(inputStream: InputStream) : ObjectInputStream(inputStream) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
enableResolveObject(true)
|
enableResolveObject(true)
|
||||||
|
@ -175,8 +175,8 @@ internal abstract class SASDefaultVerificationTransaction(
|
|||||||
?.unpaddedBase64PublicKey
|
?.unpaddedBase64PublicKey
|
||||||
?.let { masterPublicKey ->
|
?.let { masterPublicKey ->
|
||||||
val crossSigningKeyId = "ed25519:$masterPublicKey"
|
val crossSigningKeyId = "ed25519:$masterPublicKey"
|
||||||
macUsingAgreedMethod(masterPublicKey, baseInfo + crossSigningKeyId)?.let { MSKMacString ->
|
macUsingAgreedMethod(masterPublicKey, baseInfo + crossSigningKeyId)?.let { mskMacString ->
|
||||||
keyMap[crossSigningKeyId] = MSKMacString
|
keyMap[crossSigningKeyId] = mskMacString
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ internal interface RoomAPI {
|
|||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}")
|
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}")
|
||||||
fun sendRelation(@Path("roomId") roomId: String,
|
fun sendRelation(@Path("roomId") roomId: String,
|
||||||
@Path("parent_id") parent_id: String,
|
@Path("parent_id") parentId: String,
|
||||||
@Path("relation_type") relationType: String,
|
@Path("relation_type") relationType: String,
|
||||||
@Path("event_type") eventType: String,
|
@Path("event_type") eventType: String,
|
||||||
@Body content: Content?
|
@Body content: Content?
|
||||||
@ -305,7 +305,7 @@ internal interface RoomAPI {
|
|||||||
fun redactEvent(
|
fun redactEvent(
|
||||||
@Path("txnId") txId: String,
|
@Path("txnId") txId: String,
|
||||||
@Path("roomId") roomId: String,
|
@Path("roomId") roomId: String,
|
||||||
@Path("eventId") parent_id: String,
|
@Path("eventId") eventId: String,
|
||||||
@Body reason: Map<String, String>
|
@Body reason: Map<String, String>
|
||||||
): Call<SendResponse>
|
): Call<SendResponse>
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@ internal class CreateRoomBodyBuilder @Inject constructor(
|
|||||||
|
|
||||||
invites.map {
|
invites.map {
|
||||||
ThreePidInviteBody(
|
ThreePidInviteBody(
|
||||||
id_server = identityServerUrlWithoutProtocol,
|
idServer = identityServerUrlWithoutProtocol,
|
||||||
id_access_token = identityServerAccessToken,
|
idAccessToken = identityServerAccessToken,
|
||||||
medium = it.toMedium(),
|
medium = it.toMedium(),
|
||||||
address = it.value
|
address = it.value
|
||||||
)
|
)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.session.room.membership.threepid
|
package org.matrix.android.sdk.internal.session.room.membership.threepid
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
||||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||||
import org.matrix.android.sdk.api.session.identity.toMedium
|
import org.matrix.android.sdk.api.session.identity.toMedium
|
||||||
@ -28,7 +29,6 @@ import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
|
|||||||
import org.matrix.android.sdk.internal.session.identity.data.getIdentityServerUrlWithoutProtocol
|
import org.matrix.android.sdk.internal.session.identity.data.getIdentityServerUrlWithoutProtocol
|
||||||
import org.matrix.android.sdk.internal.session.room.RoomAPI
|
import org.matrix.android.sdk.internal.session.room.RoomAPI
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
import org.matrix.android.sdk.internal.task.Task
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface InviteThreePidTask : Task<InviteThreePidTask.Params, Unit> {
|
internal interface InviteThreePidTask : Task<InviteThreePidTask.Params, Unit> {
|
||||||
@ -55,8 +55,8 @@ internal class DefaultInviteThreePidTask @Inject constructor(
|
|||||||
|
|
||||||
return executeRequest(eventBus) {
|
return executeRequest(eventBus) {
|
||||||
val body = ThreePidInviteBody(
|
val body = ThreePidInviteBody(
|
||||||
id_server = identityServerUrlWithoutProtocol,
|
idServer = identityServerUrlWithoutProtocol,
|
||||||
id_access_token = identityServerAccessToken,
|
idAccessToken = identityServerAccessToken,
|
||||||
medium = params.threePid.toMedium(),
|
medium = params.threePid.toMedium(),
|
||||||
address = params.threePid.value
|
address = params.threePid.value
|
||||||
)
|
)
|
||||||
|
@ -25,18 +25,22 @@ internal data class ThreePidInviteBody(
|
|||||||
/**
|
/**
|
||||||
* Required. The hostname+port of the identity server which should be used for third party identifier lookups.
|
* Required. The hostname+port of the identity server which should be used for third party identifier lookups.
|
||||||
*/
|
*/
|
||||||
@Json(name = "id_server") val id_server: String,
|
@Json(name = "id_server")
|
||||||
|
val idServer: String,
|
||||||
/**
|
/**
|
||||||
* Required. An access token previously registered with the identity server. Servers can treat this as optional
|
* Required. An access token previously registered with the identity server. Servers can treat this as optional
|
||||||
* to distinguish between r0.5-compatible clients and this specification version.
|
* to distinguish between r0.5-compatible clients and this specification version.
|
||||||
*/
|
*/
|
||||||
@Json(name = "id_access_token") val id_access_token: String,
|
@Json(name = "id_access_token")
|
||||||
|
val idAccessToken: String,
|
||||||
/**
|
/**
|
||||||
* Required. The kind of address being passed in the address field, for example email.
|
* Required. The kind of address being passed in the address field, for example email.
|
||||||
*/
|
*/
|
||||||
@Json(name = "medium") val medium: String,
|
@Json(name = "medium")
|
||||||
|
val medium: String,
|
||||||
/**
|
/**
|
||||||
* Required. The invitee's third party identifier.
|
* Required. The invitee's third party identifier.
|
||||||
*/
|
*/
|
||||||
@Json(name = "address") val address: String
|
@Json(name = "address")
|
||||||
|
val address: String
|
||||||
)
|
)
|
||||||
|
@ -20,6 +20,7 @@ import android.content.Context
|
|||||||
import androidx.work.CoroutineWorker
|
import androidx.work.CoroutineWorker
|
||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
@ -31,7 +32,6 @@ import org.matrix.android.sdk.internal.session.room.send.SendResponse
|
|||||||
import org.matrix.android.sdk.internal.worker.SessionWorkerParams
|
import org.matrix.android.sdk.internal.worker.SessionWorkerParams
|
||||||
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
|
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
|
||||||
import org.matrix.android.sdk.internal.worker.getSessionComponent
|
import org.matrix.android.sdk.internal.worker.getSessionComponent
|
||||||
import org.greenrobot.eventbus.EventBus
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ internal class SendRelationWorker(context: Context, params: WorkerParameters) :
|
|||||||
executeRequest<SendResponse>(eventBus) {
|
executeRequest<SendResponse>(eventBus) {
|
||||||
apiCall = roomAPI.sendRelation(
|
apiCall = roomAPI.sendRelation(
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
parent_id = relatedEventId,
|
parentId = relatedEventId,
|
||||||
relationType = relationType,
|
relationType = relationType,
|
||||||
eventType = localEvent.type,
|
eventType = localEvent.type,
|
||||||
content = localEvent.content
|
content = localEvent.content
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.session.sync.model
|
package org.matrix.android.sdk.internal.session.sync.model
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,26 +27,30 @@ internal data class DeviceInfo(
|
|||||||
/**
|
/**
|
||||||
* The owner user id
|
* The owner user id
|
||||||
*/
|
*/
|
||||||
val user_id: String? = null,
|
@Json(name = "user_id")
|
||||||
|
val userId: String? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The device id
|
* The device id
|
||||||
*/
|
*/
|
||||||
val device_id: String? = null,
|
@Json(name = "device_id")
|
||||||
|
val deviceId: String? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The device display name
|
* The device display name
|
||||||
*/
|
*/
|
||||||
val display_name: String? = null,
|
@Json(name = "display_name")
|
||||||
|
val displayName: String? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last time this device has been seen.
|
* The last time this device has been seen.
|
||||||
*/
|
*/
|
||||||
val last_seen_ts: Long = 0,
|
@Json(name = "last_seen_ts")
|
||||||
|
val lastSeenTs: Long = 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last ip address
|
* The last ip address
|
||||||
*/
|
*/
|
||||||
val last_seen_ip: String? = null
|
@Json(name = "last_seen_ip")
|
||||||
|
val lastSeenIp: String? = null
|
||||||
)
|
)
|
||||||
|
@ -257,12 +257,11 @@ object CompatUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a CipherInputStream instance.
|
* Create a CipherInputStream instance.
|
||||||
* Before Kitkat, this method will return `in` because local storage encryption is not implemented for devices before KitKat.
|
* Warning, if inputStream is not an encrypted stream, it's up to the caller to close and reopen inputStream, because the stream has been read.
|
||||||
* Warning, if `in` is not an encrypted stream, it's up to the caller to close and reopen `in`, because the stream has been read.
|
|
||||||
*
|
*
|
||||||
* @param in the input stream
|
* @param inputStream the input stream
|
||||||
* @param context the context holding the application shared preferences
|
* @param context the context holding the application shared preferences
|
||||||
* @return in, or the created InputStream, or null if the InputStream `in` does not contain encrypted data
|
* @return inputStream, or the created InputStream, or null if the InputStream inputStream does not contain encrypted data
|
||||||
*/
|
*/
|
||||||
@Throws(NoSuchPaddingException::class,
|
@Throws(NoSuchPaddingException::class,
|
||||||
NoSuchAlgorithmException::class,
|
NoSuchAlgorithmException::class,
|
||||||
@ -274,15 +273,15 @@ object CompatUtil {
|
|||||||
NoSuchProviderException::class,
|
NoSuchProviderException::class,
|
||||||
InvalidAlgorithmParameterException::class,
|
InvalidAlgorithmParameterException::class,
|
||||||
IOException::class)
|
IOException::class)
|
||||||
fun createCipherInputStream(`in`: InputStream, context: Context): InputStream? {
|
fun createCipherInputStream(inputStream: InputStream, context: Context): InputStream? {
|
||||||
val iv_len = `in`.read()
|
val ivLen = inputStream.read()
|
||||||
if (iv_len != AES_GCM_IV_LENGTH) {
|
if (ivLen != AES_GCM_IV_LENGTH) {
|
||||||
Timber.e(TAG, "Invalid IV length $iv_len")
|
Timber.e(TAG, "Invalid IV length $ivLen")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
val iv = ByteArray(AES_GCM_IV_LENGTH)
|
val iv = ByteArray(AES_GCM_IV_LENGTH)
|
||||||
`in`.read(iv)
|
inputStream.read(iv)
|
||||||
|
|
||||||
val cipher = Cipher.getInstance(AES_GCM_CIPHER_TYPE)
|
val cipher = Cipher.getInstance(AES_GCM_CIPHER_TYPE)
|
||||||
|
|
||||||
@ -296,6 +295,6 @@ object CompatUtil {
|
|||||||
|
|
||||||
cipher.init(Cipher.DECRYPT_MODE, keyAndVersion.secretKey, spec)
|
cipher.init(Cipher.DECRYPT_MODE, keyAndVersion.secretKey, spec)
|
||||||
|
|
||||||
return CipherInputStream(`in`, cipher)
|
return CipherInputStream(inputStream, cipher)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,29 +272,29 @@ private fun checkPermissions(permissionsToBeGrantedBitMap: Int,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method used in [.checkPermissions] to populate the list of the
|
* Helper method used in [.checkPermissions] to populate the list of the
|
||||||
* permissions to be granted (permissionsListToBeGranted_out) and the list of the permissions already denied (permissionAlreadyDeniedList_out).
|
* permissions to be granted (permissionsListToBeGrantedOut) and the list of the permissions already denied (permissionAlreadyDeniedListOut).
|
||||||
*
|
*
|
||||||
* @param activity calling activity
|
* @param activity calling activity
|
||||||
* @param permissionAlreadyDeniedList_out list to be updated with the permissions already denied by the user
|
* @param permissionAlreadyDeniedListOut list to be updated with the permissions already denied by the user
|
||||||
* @param permissionsListToBeGranted_out list to be updated with the permissions to be granted
|
* @param permissionsListToBeGrantedOut list to be updated with the permissions to be granted
|
||||||
* @param permissionType the permission to be checked
|
* @param permissionType the permission to be checked
|
||||||
* @return true if the permission requires to be granted, false otherwise
|
* @return true if the permission requires to be granted, false otherwise
|
||||||
*/
|
*/
|
||||||
private fun updatePermissionsToBeGranted(activity: Activity,
|
private fun updatePermissionsToBeGranted(activity: Activity,
|
||||||
permissionAlreadyDeniedList_out: MutableList<String>,
|
permissionAlreadyDeniedListOut: MutableList<String>,
|
||||||
permissionsListToBeGranted_out: MutableList<String>,
|
permissionsListToBeGrantedOut: MutableList<String>,
|
||||||
permissionType: String): Boolean {
|
permissionType: String): Boolean {
|
||||||
var isRequestPermissionRequested = false
|
var isRequestPermissionRequested = false
|
||||||
|
|
||||||
// add permission to be granted
|
// add permission to be granted
|
||||||
permissionsListToBeGranted_out.add(permissionType)
|
permissionsListToBeGrantedOut.add(permissionType)
|
||||||
|
|
||||||
if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activity.applicationContext, permissionType)) {
|
if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activity.applicationContext, permissionType)) {
|
||||||
isRequestPermissionRequested = true
|
isRequestPermissionRequested = true
|
||||||
|
|
||||||
// add permission to the ones that were already asked to the user
|
// add permission to the ones that were already asked to the user
|
||||||
if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permissionType)) {
|
if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permissionType)) {
|
||||||
permissionAlreadyDeniedList_out.add(permissionType)
|
permissionAlreadyDeniedListOut.add(permissionType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isRequestPermissionRequested
|
return isRequestPermissionRequested
|
||||||
|
@ -84,7 +84,7 @@ class VerificationChooseMethodController @Inject constructor(
|
|||||||
iconColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary))
|
iconColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary))
|
||||||
listener { listener?.doVerifyBySas() }
|
listener { listener?.doVerifyBySas() }
|
||||||
}
|
}
|
||||||
} else if (state.SASModeAvailable) {
|
} else if (state.sasModeAvailable) {
|
||||||
bottomSheetVerificationActionItem {
|
bottomSheetVerificationActionItem {
|
||||||
id("openEmoji")
|
id("openEmoji")
|
||||||
title(stringProvider.getString(R.string.verification_no_scan_emoji_title))
|
title(stringProvider.getString(R.string.verification_no_scan_emoji_title))
|
||||||
|
@ -39,7 +39,7 @@ data class VerificationChooseMethodViewState(
|
|||||||
val otherCanShowQrCode: Boolean = false,
|
val otherCanShowQrCode: Boolean = false,
|
||||||
val otherCanScanQrCode: Boolean = false,
|
val otherCanScanQrCode: Boolean = false,
|
||||||
val qrCodeText: String? = null,
|
val qrCodeText: String? = null,
|
||||||
val SASModeAvailable: Boolean = false,
|
val sasModeAvailable: Boolean = false,
|
||||||
val isMe: Boolean = false,
|
val isMe: Boolean = false,
|
||||||
val canCrossSign: Boolean = false
|
val canCrossSign: Boolean = false
|
||||||
) : MvRxState
|
) : MvRxState
|
||||||
@ -74,7 +74,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
|||||||
copy(
|
copy(
|
||||||
otherCanShowQrCode = pvr?.otherCanShowQrCode().orFalse(),
|
otherCanShowQrCode = pvr?.otherCanShowQrCode().orFalse(),
|
||||||
otherCanScanQrCode = pvr?.otherCanScanQrCode().orFalse(),
|
otherCanScanQrCode = pvr?.otherCanScanQrCode().orFalse(),
|
||||||
SASModeAvailable = pvr?.isSasSupported().orFalse()
|
sasModeAvailable = pvr?.isSasSupported().orFalse()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
|||||||
otherCanShowQrCode = pvr?.otherCanShowQrCode().orFalse(),
|
otherCanShowQrCode = pvr?.otherCanShowQrCode().orFalse(),
|
||||||
otherCanScanQrCode = pvr?.otherCanScanQrCode().orFalse(),
|
otherCanScanQrCode = pvr?.otherCanScanQrCode().orFalse(),
|
||||||
qrCodeText = (qrCodeVerificationTransaction as? QrCodeVerificationTransaction)?.qrCodeText,
|
qrCodeText = (qrCodeVerificationTransaction as? QrCodeVerificationTransaction)?.qrCodeText,
|
||||||
SASModeAvailable = pvr?.isSasSupported().orFalse()
|
sasModeAvailable = pvr?.isSasSupported().orFalse()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,12 @@ class FontTagHandler : SimpleTagHandler() {
|
|||||||
return ForegroundColorSpan(colorString)
|
return ForegroundColorSpan(colorString)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseColor(color_name: String): Int {
|
private fun parseColor(colorName: String): Int {
|
||||||
try {
|
try {
|
||||||
return Color.parseColor(color_name)
|
return Color.parseColor(colorName)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// try other w3c colors?
|
// try other w3c colors?
|
||||||
return when (color_name) {
|
return when (colorName) {
|
||||||
"white" -> Color.WHITE
|
"white" -> Color.WHITE
|
||||||
"yellow" -> Color.YELLOW
|
"yellow" -> Color.YELLOW
|
||||||
"fuchsia" -> Color.parseColor("#FF00FF")
|
"fuchsia" -> Color.parseColor("#FF00FF")
|
||||||
|
@ -108,25 +108,25 @@ class CircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
val INNER_CIRCLE_RADIUS_PROGRESS: Property<CircleView, Float> = object : Property<CircleView, Float>(Float::class.java, "innerCircleRadiusProgress") {
|
val INNER_CIRCLE_RADIUS_PROGRESS: Property<CircleView, Float> = object : Property<CircleView, Float>(Float::class.java, "innerCircleRadiusProgress") {
|
||||||
override operator fun get(`object`: CircleView): Float? {
|
override operator fun get(o: CircleView): Float? {
|
||||||
return `object`.innerCircleRadiusProgress
|
return o.innerCircleRadiusProgress
|
||||||
}
|
}
|
||||||
|
|
||||||
override operator fun set(`object`: CircleView, value: Float?) {
|
override operator fun set(o: CircleView, value: Float?) {
|
||||||
value?.let {
|
value?.let {
|
||||||
`object`.innerCircleRadiusProgress = it
|
o.innerCircleRadiusProgress = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val OUTER_CIRCLE_RADIUS_PROGRESS: Property<CircleView, Float> = object : Property<CircleView, Float>(Float::class.java, "outerCircleRadiusProgress") {
|
val OUTER_CIRCLE_RADIUS_PROGRESS: Property<CircleView, Float> = object : Property<CircleView, Float>(Float::class.java, "outerCircleRadiusProgress") {
|
||||||
override operator fun get(`object`: CircleView): Float? {
|
override operator fun get(o: CircleView): Float? {
|
||||||
return `object`.outerCircleRadiusProgress
|
return o.outerCircleRadiusProgress
|
||||||
}
|
}
|
||||||
|
|
||||||
override operator fun set(`object`: CircleView, value: Float?) {
|
override operator fun set(o: CircleView, value: Float?) {
|
||||||
value?.let {
|
value?.let {
|
||||||
`object`.outerCircleRadiusProgress = it
|
o.outerCircleRadiusProgress = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,12 +186,12 @@ class DotsView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
|||||||
private const val OUTER_DOTS_POSITION_ANGLE = 360 / DOTS_COUNT
|
private const val OUTER_DOTS_POSITION_ANGLE = 360 / DOTS_COUNT
|
||||||
|
|
||||||
val DOTS_PROGRESS: Property<DotsView, Float> = object : Property<DotsView, Float>(Float::class.java, "dotsProgress") {
|
val DOTS_PROGRESS: Property<DotsView, Float> = object : Property<DotsView, Float>(Float::class.java, "dotsProgress") {
|
||||||
override operator fun get(`object`: DotsView): Float? {
|
override operator fun get(o: DotsView): Float? {
|
||||||
return `object`.currentProgress
|
return o.currentProgress
|
||||||
}
|
}
|
||||||
|
|
||||||
override operator fun set(`object`: DotsView, value: Float?) {
|
override operator fun set(o: DotsView, value: Float?) {
|
||||||
`object`.currentProgress = value!!
|
o.currentProgress = value!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
|||||||
private fun refreshMyDevice() {
|
private fun refreshMyDevice() {
|
||||||
session.cryptoService().getUserDevices(session.myUserId).map {
|
session.cryptoService().getUserDevices(session.myUserId).map {
|
||||||
DeviceInfo(
|
DeviceInfo(
|
||||||
user_id = session.myUserId,
|
userId = session.myUserId,
|
||||||
deviceId = it.deviceId,
|
deviceId = it.deviceId,
|
||||||
displayName = it.displayName()
|
displayName = it.displayName()
|
||||||
)
|
)
|
||||||
|
@ -25,7 +25,6 @@ import com.airbnb.mvrx.Async
|
|||||||
import com.airbnb.mvrx.Loading
|
import com.airbnb.mvrx.Loading
|
||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
import com.airbnb.mvrx.withState
|
import com.airbnb.mvrx.withState
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.dialogs.ManuallyVerifyDialog
|
import im.vector.app.core.dialogs.ManuallyVerifyDialog
|
||||||
import im.vector.app.core.dialogs.PromptPasswordDialog
|
import im.vector.app.core.dialogs.PromptPasswordDialog
|
||||||
@ -37,6 +36,7 @@ import im.vector.app.core.platform.VectorBaseFragment
|
|||||||
import im.vector.app.features.crypto.verification.VerificationBottomSheet
|
import im.vector.app.features.crypto.verification.VerificationBottomSheet
|
||||||
import kotlinx.android.synthetic.main.fragment_generic_recycler.*
|
import kotlinx.android.synthetic.main.fragment_generic_recycler.*
|
||||||
import kotlinx.android.synthetic.main.merge_overlay_waiting_view.*
|
import kotlinx.android.synthetic.main.merge_overlay_waiting_view.*
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +108,7 @@ class VectorSettingsDevicesFragment @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDeviceClicked(deviceInfo: DeviceInfo) {
|
override fun onDeviceClicked(deviceInfo: DeviceInfo) {
|
||||||
DeviceVerificationInfoBottomSheet.newInstance(deviceInfo.user_id ?: "", deviceInfo.deviceId ?: "").show(
|
DeviceVerificationInfoBottomSheet.newInstance(deviceInfo.userId ?: "", deviceInfo.deviceId ?: "").show(
|
||||||
childFragmentManager,
|
childFragmentManager,
|
||||||
"VERIF_INFO"
|
"VERIF_INFO"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user