update headers and add new operation

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk
2024-08-23 15:21:04 +02:00
parent 86b0279d70
commit 440be4645f
11 changed files with 67 additions and 10 deletions

View File

@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2018-2023 Tobias Kaminsky <tobias@kaminsky.me>
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
# SPDX-FileCopyrightText: 2023 Alper Ozturk <alper_ozturk@proton.me>
# SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
# SPDX-License-Identifier: MIT
# can be overriden by ~/.gradle/gradle.properties

View File

@ -4,7 +4,7 @@
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
* SPDX-FileCopyrightText: 2023 Tobias Kaminsky <tobias@kaminsky.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper_ozturk@proton.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2022 Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
* SPDX-License-Identifier: MIT
*/

View File

@ -2,7 +2,7 @@
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper_ozturk@proton.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: MIT
*/

View File

@ -2,7 +2,7 @@
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper_ozturk@proton.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: MIT
*/

View File

@ -2,7 +2,7 @@
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper_ozturk@proton.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: MIT
*/

View File

@ -2,7 +2,7 @@
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper_ozturk@proton.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: MIT
*/

View File

@ -2,7 +2,7 @@
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper_ozturk@proton.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: MIT
*/
package com.nextcloud.extensions

View File

@ -2,7 +2,7 @@
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper_ozturk@proton.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2023 Álvaro Brey <alvaro.brey@nextcloud.com>
* SPDX-FileCopyrightText: 2015 ownCloud Inc.
* SPDX-License-Identifier: MIT

View File

@ -2,7 +2,7 @@
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper_ozturk@proton.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2022 Álvaro Brey <alvaro.brey@nextcloud.com>
* SPDX-FileCopyrightText: 2018-2022 Tobias Kaminsky <tobias@kaminsky.me>
* SPDX-FileCopyrightText: 2014-2015 ownCloud Inc.

View File

@ -0,0 +1,57 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: MIT
*/
package com.owncloud.android.lib.resources.users
import com.nextcloud.common.NextcloudClient
import com.nextcloud.operations.GetMethod
import com.owncloud.android.lib.common.operations.RemoteOperation
import com.owncloud.android.lib.common.operations.RemoteOperationResult
import com.owncloud.android.lib.common.utils.Log_OC
import org.apache.commons.httpclient.HttpStatus
import org.json.JSONObject
class GetServerPublicKeyRemoteOperation : RemoteOperation<String>() {
companion object {
private val TAG: String = GetPublicKeyRemoteOperation::class.java.simpleName
private const val ENDPOINT = "/ocs/v2.php/apps/end_to_end_encryption/api/v1/server-key"
}
override fun run(client: NextcloudClient): RemoteOperationResult<String> {
var getMethod: GetMethod? = null
var result: RemoteOperationResult<String>
val user: String = client.userId
try {
getMethod = GetMethod(client.baseUri.toString() + ENDPOINT + JSON_FORMAT, true)
val status = client.execute(getMethod)
if (status == HttpStatus.SC_OK) {
val response = getMethod.getResponseBodyAsString()
val respJSON = JSONObject(response)
val serverKey = respJSON.getJSONObject("ocs").getJSONObject("data").getString("public-key")
result = RemoteOperationResult(true, getMethod)
result.setResultData(serverKey)
} else {
result = RemoteOperationResult(false, getMethod)
}
} catch (e: Exception) {
result = RemoteOperationResult(e)
Log_OC.e(
TAG,
"Fetching of server public key failed for user " + user + ": " + result.logMessage,
result.exception
)
} finally {
getMethod?.releaseConnection()
}
return result
}
}

View File

@ -4,7 +4,7 @@
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2022-2023 Tobias Kaminsky <tobias@kaminsky.me>
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper_ozturk@proton.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2014 Marcello Steiner <steiner.marcello@gmail.com>
* SPDX-License-Identifier: MIT
*/