mirror of
https://github.com/nextcloud/android-library.git
synced 2025-08-15 22:15:29 +00:00
update headers and add new operation
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
# SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
|
# SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
|
||||||
# SPDX-FileCopyrightText: 2018-2023 Tobias Kaminsky <tobias@kaminsky.me>
|
# SPDX-FileCopyrightText: 2018-2023 Tobias Kaminsky <tobias@kaminsky.me>
|
||||||
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
# can be overriden by ~/.gradle/gradle.properties
|
# can be overriden by ~/.gradle/gradle.properties
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||||
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
|
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
* SPDX-FileCopyrightText: 2023 Tobias Kaminsky <tobias@kaminsky.me>
|
* 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-FileCopyrightText: 2022 Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Nextcloud Android Library
|
* Nextcloud Android Library
|
||||||
*
|
*
|
||||||
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
|
* 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
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Nextcloud Android Library
|
* Nextcloud Android Library
|
||||||
*
|
*
|
||||||
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
|
* 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
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Nextcloud Android Library
|
* Nextcloud Android Library
|
||||||
*
|
*
|
||||||
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
|
* 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
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Nextcloud Android Library
|
* Nextcloud Android Library
|
||||||
*
|
*
|
||||||
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
|
* 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
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Nextcloud Android Library
|
* Nextcloud Android Library
|
||||||
*
|
*
|
||||||
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
|
* 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
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
package com.nextcloud.extensions
|
package com.nextcloud.extensions
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Nextcloud Android Library
|
* Nextcloud Android Library
|
||||||
*
|
*
|
||||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
* 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: 2023 Álvaro Brey <alvaro.brey@nextcloud.com>
|
||||||
* SPDX-FileCopyrightText: 2015 ownCloud Inc.
|
* SPDX-FileCopyrightText: 2015 ownCloud Inc.
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Nextcloud Android Library
|
* Nextcloud Android Library
|
||||||
*
|
*
|
||||||
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
|
* 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: 2022 Álvaro Brey <alvaro.brey@nextcloud.com>
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Tobias Kaminsky <tobias@kaminsky.me>
|
* SPDX-FileCopyrightText: 2018-2022 Tobias Kaminsky <tobias@kaminsky.me>
|
||||||
* SPDX-FileCopyrightText: 2014-2015 ownCloud Inc.
|
* SPDX-FileCopyrightText: 2014-2015 ownCloud Inc.
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||||
* SPDX-FileCopyrightText: 2022-2023 Tobias Kaminsky <tobias@kaminsky.me>
|
* SPDX-FileCopyrightText: 2022-2023 Tobias Kaminsky <tobias@kaminsky.me>
|
||||||
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
|
* 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-FileCopyrightText: 2014 Marcello Steiner <steiner.marcello@gmail.com>
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user