diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 88ea3aa1e593800a41855fcc6e3cfbff8e41e169..1fe6156007e6bce7a3b41c5fab77e3969b9c73e8 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,9 +1,31 @@ <component name="ProjectCodeStyleConfiguration"> <code_scheme name="Project" version="173"> + <option name="RIGHT_MARGIN" value="160" /> <JetCodeStyleSettings> + <option name="PACKAGES_TO_USE_STAR_IMPORTS"> + <value> + <package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" /> + </value> + </option> + <option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" /> + <option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" /> + <option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" /> + <option name="CONTINUATION_INDENT_IN_PARAMETER_LISTS" value="true" /> + <option name="CONTINUATION_INDENT_IN_ARGUMENT_LISTS" value="true" /> + <option name="CONTINUATION_INDENT_FOR_EXPRESSION_BODIES" value="true" /> + <option name="CONTINUATION_INDENT_FOR_CHAINED_CALLS" value="true" /> + <option name="CONTINUATION_INDENT_IN_SUPERTYPE_LISTS" value="true" /> + <option name="CONTINUATION_INDENT_IN_IF_CONDITIONS" value="true" /> + <option name="CONTINUATION_INDENT_IN_ELVIS" value="true" /> + <option name="WRAP_EXPRESSION_BODY_FUNCTIONS" value="0" /> + <option name="IF_RPAREN_ON_NEW_LINE" value="false" /> <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> </JetCodeStyleSettings> + <editorconfig> + <option name="ENABLED" value="false" /> + </editorconfig> <codeStyleSettings language="XML"> + <option name="RIGHT_MARGIN" value="160" /> <indentOptions> <option name="CONTINUATION_INDENT_SIZE" value="4" /> </indentOptions> @@ -117,6 +139,21 @@ </codeStyleSettings> <codeStyleSettings language="kotlin"> <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> + <option name="RIGHT_MARGIN" value="160" /> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" /> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" /> + <option name="CALL_PARAMETERS_WRAP" value="0" /> + <option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="false" /> + <option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="false" /> + <option name="METHOD_PARAMETERS_WRAP" value="0" /> + <option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="false" /> + <option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="false" /> + <option name="EXTENDS_LIST_WRAP" value="0" /> + <option name="METHOD_CALL_CHAIN_WRAP" value="0" /> + <option name="ASSIGNMENT_WRAP" value="0" /> + <option name="CLASS_ANNOTATION_WRAP" value="0" /> + <option name="FIELD_ANNOTATION_WRAP" value="1" /> </codeStyleSettings> </code_scheme> </component> \ No newline at end of file diff --git a/matrix-sdk-android/gradle-publish.gradle b/matrix-sdk-android/gradle-publish.gradle index 4192754356add3afacac9bc8f05ae1ff7decc03e..a65de299fcbde78f76c82067f317394322b33830 100644 --- a/matrix-sdk-android/gradle-publish.gradle +++ b/matrix-sdk-android/gradle-publish.gradle @@ -3,7 +3,7 @@ apply plugin: 'maven-publish' def groupIdString = "org.matrix.android" def artifactIdString = "matrix-sdk-android" -def versionName = "1.4.36" +def versionName = "1.4.361" def artifactPath = "$buildDir/outputs/aar/$artifactIdString-release.aar" def publicationName = "release" def projectId = "16" diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/AuthenticationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/AuthenticationService.kt index 5ae70e1978c0e5bc9398560a12b81123b6a369ca..e780eb77729dea5593915b7cfabade9c0779714b 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/AuthenticationService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/AuthenticationService.kt @@ -124,4 +124,10 @@ interface AuthenticationService { initialDeviceName: String, deviceId: String? = null ): Session + + /** + * //Added to initiate auth without GET /login + * @return wellKnownResult.homeServerUrl + */ + suspend fun initiateAuth(homeServerConnectionConfig: HomeServerConnectionConfig): String } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt index 446f9318479fc16d0898f84d23b6c034b68645e3..75303854ca15e200b7268c542b2ebbae5f3d1a27 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt @@ -280,7 +280,7 @@ internal class DefaultAuthenticationService @Inject constructor( getLoginFlowResult(newAuthAPI, versions, wellknownResult.homeServerUrl) } - else -> throw Failure.OtherServerError("", HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) + else -> throw Failure.OtherServerError("", HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) } } @@ -415,4 +415,40 @@ internal class DefaultAuthenticationService @Inject constructor( .addSocketFactory(homeServerConnectionConfig) .build() } + + //Added to initiate auth without GET /login + override suspend fun initiateAuth(homeServerConnectionConfig: HomeServerConnectionConfig): String { + val result = runCatching { + getHomeServerUserFromWellKnown(homeServerConnectionConfig) + } + return result.fold( + { + val alteredHomeServerConnectionConfig = homeServerConnectionConfig.copy( + homeServerUriBase = Uri.parse(it) + ) + + pendingSessionData = PendingSessionData(alteredHomeServerConnectionConfig) + .also { data -> pendingSessionStore.savePendingSessionData(data) } + it + }, + { + if (it is UnrecognizedCertificateException) { + throw Failure.UnrecognizedCertificateFailure(homeServerConnectionConfig.homeServerUriBase.toString(), it.fingerprint) + } else { + throw it + } + } + ) + } + + //Added to initiate auth without GET /login + private suspend fun getHomeServerUserFromWellKnown(homeServerConnectionConfig: HomeServerConnectionConfig): String { + val domain = homeServerConnectionConfig.homeServerUri.host + ?: throw Failure.OtherServerError("", HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) + + return when (val wellKnownResult = getWellknownTask.execute(GetWellknownTask.Params(domain, homeServerConnectionConfig))) { + is WellknownResult.Prompt -> wellKnownResult.homeServerUrl + else -> throw Failure.OtherServerError("", HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) + } + } }