Skip to content

Commit

Permalink
Merge pull request #1187 from nextcloud/E2Esharing
Browse files Browse the repository at this point in the history
E2E sharing
  • Loading branch information
tobiasKaminsky authored Jan 16, 2024
2 parents fa98b24 + 7062d41 commit 5790108
Show file tree
Hide file tree
Showing 32 changed files with 982 additions and 236 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ services:
- su www-data -c "php /var/www/html/occ app:enable activity"
- su www-data -c "git clone -b main https://github.com/nextcloud/text.git /var/www/html/apps/text/"
- su www-data -c "php /var/www/html/occ app:enable text"
- su www-data -c "git clone -b master https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/"
- su www-data -c "git clone -b artonge/feat/allow_metadata_update_for_subfolders https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/"
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
- su www-data -c "git clone -b master https://github.com/nextcloud/password_policy/ /var/www/html/apps/password_policy/"
- su www-data -c "php /var/www/html/occ app:enable password_policy"
Expand Down Expand Up @@ -213,6 +213,6 @@ trigger:
- pull_request
---
kind: signature
hmac: 6d69c7c3739747691580d04a781eb67cf95d2f33f8149d5ebd2cbcc30611b4f0
hmac: 56749c47df149cc2d3c06343c609210a310e27635ea6ccb040890ab0afbce79d

...
4 changes: 1 addition & 3 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import com.github.spotbugs.snom.SpotBugsTask
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask

buildscript {
ext {
Expand Down Expand Up @@ -50,14 +50,17 @@ configurations {
dependencies {
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5'
api 'com.squareup.okhttp3:okhttp:5.0.0-alpha.11'
implementation 'com.github.bitfireAT:dav4jvm:2.2.1' // in transition phase, we use old and new libs
implementation 'com.github.bitfireAT:dav4jvm:2.2.1'
// in transition phase, we use old and new libs
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
implementation 'androidx.annotation:annotation:1.7.1'
compileOnly 'com.google.code.findbugs:annotations:3.0.1u2'

implementation "androidx.core:core-ktx:1.10.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

implementation 'org.bouncycastle:bcpkix-jdk18on:1.75'

spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.6.4'

Expand Down
29 changes: 29 additions & 0 deletions library/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?><!--
~
~ Nextcloud Android client application
~
~ @author Tobias Kaminsky
~ Copyright (C) 2024 Tobias Kaminsky
~ Copyright (C) 2024 Nextcloud GmbH
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
~
-->

<lint>
<issue id="TrustAllX509TrustManager">
<ignore path="**/bouncycastle/est/jcajce/*.class" />
<ignore path="**/bcpkix-jdk18on-1.75.jar" />
</issue>
</lint>
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@
*/
package com.owncloud.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
import com.owncloud.android.lib.resources.status.E2EVersion;
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
import com.owncloud.android.lib.resources.status.NextcloudVersion;
import com.owncloud.android.lib.resources.status.OCCapability;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

/**
* Class to test GetRemoteCapabilitiesOperation
*/
public class GetCapabilitiesIT extends AbstractIT {
public class GetCapabilitiesRemoteOperationIT extends AbstractIT {
/**
* Test get capabilities
*/
Expand Down Expand Up @@ -150,12 +152,15 @@ private void checkCapability(OCCapability capability, String userId) {
// groupfolder
if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_27)) {
if (userId.equals("test")) {
capability.getGroupfolders().isTrue();
assertTrue(capability.getGroupfolders().isTrue());
} else {
capability.getGroupfolders().isFalse();
assertTrue(capability.getGroupfolders().isFalse());
}
} else {
capability.getGroupfolders().isFalse();
assertTrue(capability.getGroupfolders().isFalse());
}

// e2e
assertNotSame(capability.getEndToEndEncryptionApiVersion(), E2EVersion.UNKNOWN);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* Nextcloud Android Library is available under MIT license
*
* @author Tobias Kaminsky
* Copyright (C) 2024 Tobias Kaminsky
* Copyright (C) 2024 Nextcloud GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.resources.e2ee

import com.owncloud.android.AbstractIT
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
import com.owncloud.android.lib.resources.users.GetPublicKeyRemoteOperation
import com.owncloud.android.lib.resources.users.SendCSRRemoteOperation
import junit.framework.TestCase
import junit.framework.TestCase.assertTrue
import org.junit.Before
import org.junit.Test
import java.security.KeyPairGenerator
import java.security.SecureRandom

class SendCSRRemoteOperationIT : AbstractIT() {
@Before
fun init() {
// E2E server app checks for official NC client with >=3.13.0,
// and blocks all other clients, e.g. 3rd party apps using this lib
OwnCloudClientManagerFactory.setUserAgent("Mozilla/5.0 (Android) Nextcloud-android/3.13.0")
}

@Throws(Throwable::class)
@Test
fun publicKey() {
val keyGen = KeyPairGenerator.getInstance("RSA")
keyGen.initialize(KEY_SIZE, SecureRandom())

val keyPair = keyGen.genKeyPair()

// create CSR
val urlEncoded: String = CsrHelper().generateCsrPemEncodedString(keyPair, client.userId)

val operation = SendCSRRemoteOperation(urlEncoded)
var result = operation.execute(nextcloudClient)

assertTrue(result.isSuccess)

// verify public key
result = GetPublicKeyRemoteOperation(client.userId).execute(nextcloudClient)
assertTrue(result.isSuccess)
TestCase.assertNotNull(result.resultData)
}

companion object {
const val KEY_SIZE = 2048
}
}
Loading

0 comments on commit 5790108

Please sign in to comment.