Skip to content

Commit 7062d41

Browse files
E2E sharing
Signed-off-by: tobiasKaminsky <[email protected]> fix detekt, spotless Signed-off-by: tobiasKaminsky <[email protected]> re-add Project.xml Signed-off-by: tobiasKaminsky <[email protected]> Licenses Signed-off-by: tobiasKaminsky <[email protected]> Added test Signed-off-by: tobiasKaminsky <[email protected]> migrate CsrHelper to Kotlin Signed-off-by: tobiasKaminsky <[email protected]> fix lint Signed-off-by: tobiasKaminsky <[email protected]> fix some spotbugs Signed-off-by: tobiasKaminsky <[email protected]> temporarily disable test Signed-off-by: tobiasKaminsky <[email protected]>
1 parent fa98b24 commit 7062d41

32 files changed

+982
-236
lines changed

.drone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ services:
7979
- su www-data -c "php /var/www/html/occ app:enable activity"
8080
- su www-data -c "git clone -b main https://github.com/nextcloud/text.git /var/www/html/apps/text/"
8181
- su www-data -c "php /var/www/html/occ app:enable text"
82-
- su www-data -c "git clone -b master https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/"
82+
- 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/"
8383
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
8484
- su www-data -c "git clone -b master https://github.com/nextcloud/password_policy/ /var/www/html/apps/password_policy/"
8585
- su www-data -c "php /var/www/html/occ app:enable password_policy"
@@ -213,6 +213,6 @@ trigger:
213213
- pull_request
214214
---
215215
kind: signature
216-
hmac: 6d69c7c3739747691580d04a781eb67cf95d2f33f8149d5ebd2cbcc30611b4f0
216+
hmac: 56749c47df149cc2d3c06343c609210a310e27635ea6ccb040890ab0afbce79d
217217

218218
...

.idea/codeStyles/Project.xml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

library/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import com.github.spotbugs.snom.SpotBugsTask
21
import com.github.spotbugs.snom.Confidence
32
import com.github.spotbugs.snom.Effort
3+
import com.github.spotbugs.snom.SpotBugsTask
44

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

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

62+
implementation 'org.bouncycastle:bcpkix-jdk18on:1.75'
63+
6164
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
6265
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.6.4'
6366

library/lint.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?><!--
2+
~
3+
~ Nextcloud Android client application
4+
~
5+
~ @author Tobias Kaminsky
6+
~ Copyright (C) 2024 Tobias Kaminsky
7+
~ Copyright (C) 2024 Nextcloud GmbH
8+
~
9+
~ This program is free software: you can redistribute it and/or modify
10+
~ it under the terms of the GNU Affero General Public License as published by
11+
~ the Free Software Foundation, either version 3 of the License, or
12+
~ (at your option) any later version.
13+
~
14+
~ This program is distributed in the hope that it will be useful,
15+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
~ GNU Affero General Public License for more details.
18+
~
19+
~ You should have received a copy of the GNU Affero General Public License
20+
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
~
22+
-->
23+
24+
<lint>
25+
<issue id="TrustAllX509TrustManager">
26+
<ignore path="**/bouncycastle/est/jcajce/*.class" />
27+
<ignore path="**/bcpkix-jdk18on-1.75.jar" />
28+
</issue>
29+
</lint>

library/src/androidTest/java/com/owncloud/android/GetCapabilitiesIT.java renamed to library/src/androidTest/java/com/owncloud/android/GetCapabilitiesRemoteOperationIT.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,27 @@
2626
*/
2727
package com.owncloud.android;
2828

29-
import static org.junit.Assert.assertEquals;
30-
import static org.junit.Assert.assertFalse;
31-
import static org.junit.Assert.assertNotNull;
32-
import static org.junit.Assert.assertSame;
33-
import static org.junit.Assert.assertTrue;
34-
3529
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
3630
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
31+
import com.owncloud.android.lib.resources.status.E2EVersion;
3732
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
3833
import com.owncloud.android.lib.resources.status.NextcloudVersion;
3934
import com.owncloud.android.lib.resources.status.OCCapability;
4035
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
4136

4237
import org.junit.Test;
4338

39+
import static org.junit.Assert.assertEquals;
40+
import static org.junit.Assert.assertFalse;
41+
import static org.junit.Assert.assertNotNull;
42+
import static org.junit.Assert.assertNotSame;
43+
import static org.junit.Assert.assertSame;
44+
import static org.junit.Assert.assertTrue;
45+
4446
/**
4547
* Class to test GetRemoteCapabilitiesOperation
4648
*/
47-
public class GetCapabilitiesIT extends AbstractIT {
49+
public class GetCapabilitiesRemoteOperationIT extends AbstractIT {
4850
/**
4951
* Test get capabilities
5052
*/
@@ -150,12 +152,15 @@ private void checkCapability(OCCapability capability, String userId) {
150152
// groupfolder
151153
if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_27)) {
152154
if (userId.equals("test")) {
153-
capability.getGroupfolders().isTrue();
155+
assertTrue(capability.getGroupfolders().isTrue());
154156
} else {
155-
capability.getGroupfolders().isFalse();
157+
assertTrue(capability.getGroupfolders().isFalse());
156158
}
157159
} else {
158-
capability.getGroupfolders().isFalse();
160+
assertTrue(capability.getGroupfolders().isFalse());
159161
}
162+
163+
// e2e
164+
assertNotSame(capability.getEndToEndEncryptionApiVersion(), E2EVersion.UNKNOWN);
160165
}
161166
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* Nextcloud Android Library is available under MIT license
2+
*
3+
* @author Tobias Kaminsky
4+
* Copyright (C) 2024 Tobias Kaminsky
5+
* Copyright (C) 2024 Nextcloud GmbH
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*
26+
*/
27+
package com.owncloud.android.lib.resources.e2ee
28+
29+
import com.owncloud.android.AbstractIT
30+
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
31+
import com.owncloud.android.lib.resources.users.GetPublicKeyRemoteOperation
32+
import com.owncloud.android.lib.resources.users.SendCSRRemoteOperation
33+
import junit.framework.TestCase
34+
import junit.framework.TestCase.assertTrue
35+
import org.junit.Before
36+
import org.junit.Test
37+
import java.security.KeyPairGenerator
38+
import java.security.SecureRandom
39+
40+
class SendCSRRemoteOperationIT : AbstractIT() {
41+
@Before
42+
fun init() {
43+
// E2E server app checks for official NC client with >=3.13.0,
44+
// and blocks all other clients, e.g. 3rd party apps using this lib
45+
OwnCloudClientManagerFactory.setUserAgent("Mozilla/5.0 (Android) Nextcloud-android/3.13.0")
46+
}
47+
48+
@Throws(Throwable::class)
49+
@Test
50+
fun publicKey() {
51+
val keyGen = KeyPairGenerator.getInstance("RSA")
52+
keyGen.initialize(KEY_SIZE, SecureRandom())
53+
54+
val keyPair = keyGen.genKeyPair()
55+
56+
// create CSR
57+
val urlEncoded: String = CsrHelper().generateCsrPemEncodedString(keyPair, client.userId)
58+
59+
val operation = SendCSRRemoteOperation(urlEncoded)
60+
var result = operation.execute(nextcloudClient)
61+
62+
assertTrue(result.isSuccess)
63+
64+
// verify public key
65+
result = GetPublicKeyRemoteOperation(client.userId).execute(nextcloudClient)
66+
assertTrue(result.isSuccess)
67+
TestCase.assertNotNull(result.resultData)
68+
}
69+
70+
companion object {
71+
const val KEY_SIZE = 2048
72+
}
73+
}

0 commit comments

Comments
 (0)