Logging cleanup
This commit is contained in:
parent
a3fc785945
commit
d979b50b2c
|
@ -36,9 +36,14 @@ import org.matrix.android.sdk.api.util.MatrixJsonParser
|
|||
import timber.log.Timber
|
||||
|
||||
internal enum class PayloadType(val value: String) {
|
||||
@Json(name = "m.login.start") Start("m.login.start"),
|
||||
@Json(name = "m.login.finish") Finish("m.login.finish"),
|
||||
@Json(name = "m.login.progress") Progress("m.login.progress")
|
||||
@Json(name = "m.login.start")
|
||||
Start("m.login.start"),
|
||||
|
||||
@Json(name = "m.login.finish")
|
||||
Finish("m.login.finish"),
|
||||
|
||||
@Json(name = "m.login.progress")
|
||||
Progress("m.login.progress")
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
|
@ -150,12 +155,12 @@ class Rendezvous(
|
|||
}
|
||||
|
||||
val homeserver = loginToken?.homeserver ?: throw RuntimeException("No homeserver returned")
|
||||
val login_token = loginToken.loginToken ?: throw RuntimeException("No login token returned")
|
||||
val token = loginToken.loginToken ?: throw RuntimeException("No login token returned")
|
||||
|
||||
Timber.tag(TAG).i("Got login_token: $login_token for $homeserver")
|
||||
Timber.tag(TAG).i("Got login_token now attempting to sign in with $homeserver")
|
||||
|
||||
val hsConfig = HomeServerConnectionConfig(homeServerUri = Uri.parse(homeserver))
|
||||
return authenticationService.loginUsingQrLoginToken(hsConfig, login_token)
|
||||
return authenticationService.loginUsingQrLoginToken(hsConfig, token)
|
||||
}
|
||||
|
||||
suspend fun completeVerificationOnNewDevice(session: Session) {
|
||||
|
@ -171,8 +176,8 @@ class Rendezvous(
|
|||
val verifyingDeviceId = verificationResponse?.verifyingDeviceId ?: throw RuntimeException("No verifying device id returned")
|
||||
val verifyingDeviceFromServer = crypto.getCryptoDeviceInfo(userId, verifyingDeviceId)
|
||||
if (verifyingDeviceFromServer?.fingerprint() != verificationResponse.verifyingDeviceKey) {
|
||||
Timber.tag(TAG).w("Verifying device $verifyingDeviceId doesn't match: $verifyingDeviceFromServer")
|
||||
return
|
||||
Timber.tag(TAG).w("Verifying device $verifyingDeviceId key doesn't match: ${verifyingDeviceFromServer?.fingerprint()} vs ${verificationResponse.verifyingDeviceKey})")
|
||||
throw RuntimeException("Key from verifying device doesn't match")
|
||||
}
|
||||
|
||||
// set other device as verified
|
||||
|
@ -187,6 +192,7 @@ class Rendezvous(
|
|||
crypto.crossSigningService().markMyMasterKeyAsTrusted()
|
||||
} else {
|
||||
Timber.tag(TAG).w("Master key from verifying device doesn't match: $masterKeyFromVerifyingDevice vs $localMasterKey")
|
||||
throw RuntimeException("Master key from verifying device doesn't match")
|
||||
}
|
||||
} ?: Timber.tag(TAG).i("No local master key")
|
||||
} ?: Timber.tag(TAG).i("No master key given by verifying device")
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.matrix.android.sdk.api.rendezvous.transports.SimpleHttpRendezvousTran
|
|||
import org.matrix.android.sdk.api.util.MatrixJsonParser
|
||||
import org.matrix.android.sdk.internal.extensions.toUnsignedInt
|
||||
import org.matrix.olm.OlmSAS
|
||||
import timber.log.Timber
|
||||
import java.security.SecureRandom
|
||||
import java.util.LinkedList
|
||||
import javax.crypto.Cipher
|
||||
|
@ -93,7 +94,7 @@ class ECDHRendezvousChannel(override var transport: RendezvousTransport, theirPu
|
|||
val isInitiator = theirPublicKey == null
|
||||
|
||||
if (isInitiator) {
|
||||
// Timber.tag(TAG).i("Waiting for other device to send their public key")
|
||||
Timber.tag(TAG).i("Waiting for other device to send their public key")
|
||||
val res = this.receiveAsPayload() ?: throw RuntimeException("No reply from other device")
|
||||
|
||||
if (res.key == null) {
|
||||
|
@ -105,7 +106,7 @@ class ECDHRendezvousChannel(override var transport: RendezvousTransport, theirPu
|
|||
theirPublicKey = Base64.decode(res.key, Base64.NO_WRAP)
|
||||
} else {
|
||||
// send our public key unencrypted
|
||||
// Timber.tag(TAG).i("Sending public key")
|
||||
Timber.tag(TAG).i("Sending public key")
|
||||
send(
|
||||
ECDHPayload(
|
||||
algorithm = SecureRendezvousChannelAlgorithm.ECDH_V1,
|
||||
|
@ -122,11 +123,6 @@ class ECDHRendezvousChannel(override var transport: RendezvousTransport, theirPu
|
|||
|
||||
aesKey = olmSAS!!.generateShortCode(aesInfo, 32)
|
||||
|
||||
// Timber.tag(TAG).i("Our public key: ${Base64.encodeToString(ourPublicKey, Base64.NO_WRAP)}")
|
||||
// Timber.tag(TAG).i("Their public key: ${Base64.encodeToString(theirPublicKey, Base64.NO_WRAP)}")
|
||||
// Timber.tag(TAG).i("AES info: $aesInfo")
|
||||
// Timber.tag(TAG).i("AES key: ${Base64.encodeToString(aesKey, Base64.NO_WRAP)}")
|
||||
|
||||
val rawChecksum = olmSAS!!.generateShortCode(aesInfo, 5)
|
||||
return getDecimalCodeRepresentation(rawChecksum)
|
||||
}
|
||||
|
@ -181,7 +177,6 @@ class ECDHRendezvousChannel(override var transport: RendezvousTransport, theirPu
|
|||
}
|
||||
|
||||
private fun encrypt(plainText: ByteArray): ECDHPayload {
|
||||
// Timber.tag(TAG).d("Encrypting: ${plainText.toString(Charsets.UTF_8)}")
|
||||
val iv = ByteArray(16)
|
||||
SecureRandom().nextBytes(iv)
|
||||
|
||||
|
@ -211,9 +206,6 @@ class ECDHRendezvousChannel(override var transport: RendezvousTransport, theirPu
|
|||
plainText.addAll(encryptCipher.update(Base64.decode(payload.ciphertext, Base64.NO_WRAP)).toList())
|
||||
plainText.addAll(encryptCipher.doFinal().toList())
|
||||
|
||||
val plainTextBytes = plainText.toByteArray()
|
||||
|
||||
// Timber.tag(TAG).d("Decrypted: ${plainTextBytes.toString(Charsets.UTF_8)}")
|
||||
return plainTextBytes
|
||||
return plainText.toByteArray()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,8 +67,6 @@ class SimpleHttpRendezvousTransport(override var onCancelled: ((reason: Rendezvo
|
|||
// TODO: properly determine endpoint
|
||||
val uri = if (uri != null) uri!! else "https://rendezvous.lab.element.dev"
|
||||
|
||||
// Timber.tag(TAG).i("Sending data: ${data.toString(Charsets.UTF_8)} to $uri")
|
||||
|
||||
val httpClient = okhttp3.OkHttpClient.Builder().build()
|
||||
|
||||
val request = Request.Builder()
|
||||
|
@ -123,8 +121,6 @@ class SimpleHttpRendezvousTransport(override var onCancelled: ((reason: Rendezvo
|
|||
val response = httpClient.newCall(request.build()).execute()
|
||||
|
||||
try {
|
||||
// Timber.tag(TAG).d("Received polling response: ${response.code} from $uri")
|
||||
|
||||
if (response.code == 404) {
|
||||
cancel(RendezvousFailureReason.Unknown)
|
||||
return null
|
||||
|
@ -140,9 +136,7 @@ class SimpleHttpRendezvousTransport(override var onCancelled: ((reason: Rendezvo
|
|||
response.header("etag")?.let {
|
||||
etag = it
|
||||
}
|
||||
val data = response.body?.bytes()
|
||||
// Timber.tag(TAG).d("Received data: ${data?.toString(Charsets.UTF_8)} from $uri with etag $etag")
|
||||
return data
|
||||
return response.body?.bytes()
|
||||
}
|
||||
|
||||
done = false
|
||||
|
@ -159,7 +153,8 @@ class SimpleHttpRendezvousTransport(override var onCancelled: ((reason: Rendezvo
|
|||
var mappedReason = reason
|
||||
Timber.tag(TAG).i("$expiresAt")
|
||||
if (mappedReason == RendezvousFailureReason.Unknown &&
|
||||
expiresAt != null && Date() > expiresAt) {
|
||||
expiresAt != null && Date() > expiresAt
|
||||
) {
|
||||
mappedReason = RendezvousFailureReason.Expired
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue