-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1523 from nextcloud/add-new-operation
Update License Header and Add New Operation
- Loading branch information
Showing
11 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors | ||
# SPDX-FileCopyrightText: 2018-2023 Tobias Kaminsky <[email protected]> | ||
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]> | ||
# SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
# SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
# SPDX-License-Identifier: MIT | ||
|
||
# can be overriden by ~/.gradle/gradle.properties | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Tobias Kaminsky <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2022 Álvaro Brey Vilas <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Nextcloud Android Library | ||
* | ||
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Nextcloud Android Library | ||
* | ||
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Nextcloud Android Library | ||
* | ||
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Nextcloud Android Library | ||
* | ||
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Nextcloud Android Library | ||
* | ||
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
package com.nextcloud.extensions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Nextcloud Android Library | ||
* | ||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Álvaro Brey <[email protected]> | ||
* SPDX-FileCopyrightText: 2015 ownCloud Inc. | ||
* SPDX-License-Identifier: MIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Nextcloud Android Library | ||
* | ||
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]> | ||
* SPDX-FileCopyrightText: 2018-2022 Tobias Kaminsky <[email protected]> | ||
* SPDX-FileCopyrightText: 2014-2015 ownCloud Inc. | ||
|
58 changes: 58 additions & 0 deletions
58
...c/main/java/com/owncloud/android/lib/resources/users/GetServerPublicKeyRemoteOperation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Nextcloud Android Library | ||
* | ||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <[email protected]> | ||
* 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" | ||
} | ||
|
||
@Suppress("TooGenericExceptionCaught") | ||
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-FileCopyrightText: 2022-2023 Tobias Kaminsky <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2023 Alper Ozturk <[email protected]> | ||
* SPDX-FileCopyrightText: 2014 Marcello Steiner <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|