diff --git a/android/build.gradle b/android/build.gradle index e02dcfa32..df7e11a75 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,10 +8,6 @@ buildscript { } } -plugins { - id 'digital.wup.android-maven-publish' version '3.6.2' -} - description = 'Conscrypt: Android' ext { @@ -28,10 +24,6 @@ ext { if (androidSdkInstalled) { apply plugin: 'com.android.library' - // Since we're not taking a direct dependency on the constants module, we need to add an - // explicit task dependency to make sure the code is generated. - evaluationDependsOn(':conscrypt-constants') - android { namespace "org.conscrypt" @@ -66,7 +58,6 @@ if (androidSdkInstalled) { '-D_XOPEN_SOURCE=700', '-Wno-unused-parameter' targets 'conscrypt_jni' - version androidCmakeVersion } } ndk { @@ -81,16 +72,12 @@ if (androidSdkInstalled) { } sourceSets.main { java { - srcDirs = [ - "${rootDir}/common/src/main/java", - "src/main/java" - ] - // Requires evaluationDependsOn(':conscrypt-constants') above. - srcDirs += project(':conscrypt-constants').sourceSets.main.java.srcDirs + srcDirs = [ "src/main/java" ] } resources { srcDirs += "build/generated/resources" } + project(':conscrypt-common').sourceSets.main } externalNativeBuild { cmake { @@ -112,7 +99,10 @@ if (androidSdkInstalled) { } dependencies { + compileOnly project(':conscrypt-common') + publicApiDocs project(':conscrypt-api-doclet') + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1', { exclude module: 'support-annotations' exclude module: 'support-v4' @@ -121,10 +111,9 @@ if (androidSdkInstalled) { exclude module: 'appcompat-v7' exclude module: 'design' }) - compileOnly project(':conscrypt-android-stub') - // Adds the constants module as a dependency so that we can include its generated source - compileOnly project(':conscrypt-constants') + compileOnly project(':conscrypt-android-stub'), + project(':conscrypt-constants') } def configureJavaDocs = tasks.register("configureJavadocs") { @@ -136,13 +125,19 @@ if (androidSdkInstalled) { def javadocs = tasks.register("javadocs", Javadoc) { dependsOn configureJavadocs - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + project(':conscrypt-android-stub').sourceSets.main.output + dependsOn generateProperties + source = project(':conscrypt-common').sourceSets.main.java + + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + classpath += project(':conscrypt-android-stub').sourceSets.main.output + classpath += project(':conscrypt-constants').sourceSets.main.output + classpath += project(':conscrypt-platform-stub').sourceSets.main.output + // TODO(nmittler): Fix the javadoc errors. failOnError false options { encoding = 'UTF-8' - links "https://docs.oracle.com/javase/7/docs/api/" + links "https://docs.oracle.com/javase/8/docs/api/" // TODO(prb): Update doclet to Java 11. // doclet = "org.conscrypt.doclet.FilterDoclet" } @@ -150,22 +145,46 @@ if (androidSdkInstalled) { def javadocsJar = tasks.register("javadocsJar", Jar) { dependsOn javadocs - classifier = 'javadoc' + archiveClassifier = 'javadoc' from { javadocs.get().destinationDir } } def sourcesJar = tasks.register("sourcesJar", Jar) { - classifier = 'sources' + archiveClassifier = 'sources' from android.sourceSets.main.java.srcDirs + from project(":conscrypt-common").sourceSets.main.java.srcDirs } - apply from: "$rootDir/gradle/publishing.gradle" - publishing.publications.maven { - from components.android - artifact sourcesJar.get() - artifact javadocsJar.get() + // This is ugly but works: For both release and debug builds copy the classes from the + // common compilation before the final AAR is built. + def copyDebugCommon = tasks.register('copyDebugCommon', Copy) { + from project(':conscrypt-common').sourceSets.main.output + into buildDir.absolutePath + '/intermediates/javac/debug/classes' + dependsOn ':conscrypt-common:compileJava' + } + + def copyReleaseCommon = tasks.register('copyReleaseCommon', Copy) { + from project(':conscrypt-common').sourceSets.main.output + into buildDir.absolutePath + '/intermediates/javac/release/classes' + dependsOn ':conscrypt-common:compileJava' + } + + afterEvaluate { + tasks.named('javaPreCompileDebug') { + dependsOn copyDebugCommon + } + tasks.named('javaPreCompileRelease') { + dependsOn copyReleaseCommon + } + + apply from: "$rootDir/gradle/publishing.gradle" + publishing.publications.maven { + from components.release + artifact sourcesJar.get() + artifact javadocsJar.get() + } } } else { logger.warn('Android SDK has not been detected. The Android module will not be built.') diff --git a/build.gradle b/build.gradle index 9d90d6a51..e7f603370 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,6 @@ subprojects { } } } - apply plugin: "idea" apply plugin: "jacoco" apply plugin: "net.ltgt.errorprone" @@ -201,13 +200,15 @@ subprojects { } tasks.register("javadocJar", Jar) { - classifier = 'javadoc' + archiveClassifier = 'javadoc' from javadoc } tasks.register("sourcesJar", Jar) { - classifier = 'sources' + archiveClassifier = 'sources' from sourceSets.main.allSource + from project(":conscrypt-common").sourceSets.main.java.srcDirs + } // At a test failure, log the stack trace to the console so that we don't diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 000000000..c4a66559f --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,46 @@ +sourceSets { + main { + java { + srcDirs = [ + "src/main/java", + ] + } + } + test { + java { + srcDirs = [ + "src/test/java", + ] + } + resources { + srcDirs [ + "src/test/resources", + ] + } + } +} + +dependencies { + compileOnly project(':conscrypt-constants'), + project(':conscrypt-platform-stub') + + testImplementation project(path: ':conscrypt-testing', configuration: 'shadow'), + libraries.junit, + libraries.mockito +} + +// Always tested from one of the other subprojects. +tasks.withType(Test).configureEach { + enabled = false +} + +// Only export source as part of other sub-projects' source jars. +tasks.named("sourcesJar") { + enabled = false +} + +// Whhyyyyyyyyyyyyyyyyyyyyyyyy! +// For some reason Gradle seems to be copying all the resources twice, so errors without this. +tasks.named("processTestResources") { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} diff --git a/openjdk/src/test/java/org/conscrypt/VeryBasicHttpServerTest.java b/common/src/test/java/org/conscrypt/VeryBasicHttpServerTest.java similarity index 100% rename from openjdk/src/test/java/org/conscrypt/VeryBasicHttpServerTest.java rename to common/src/test/java/org/conscrypt/VeryBasicHttpServerTest.java diff --git a/openjdk/build.gradle b/openjdk/build.gradle index cda93c34d..9933c3028 100644 --- a/openjdk/build.gradle +++ b/openjdk/build.gradle @@ -129,34 +129,24 @@ ext { } sourceSets { - main { java { - srcDirs += "${rootDir}/common/src/main/java" - srcDirs += project(':conscrypt-constants').sourceSets.main.java.srcDirs + srcDirs = [ "src/main/java" ] } resources { srcDirs += "build/generated/resources" } - } - - platform { - java { - srcDirs = [ "src/main/java" ] - includes = [ "org/conscrypt/Platform.java" ] - } - } + project(':conscrypt-common').sourceSets.main + } test { java { - srcDirs += "${rootDir}/common/src/test/java" + srcDirs = [ "src/test/java" ] } resources { - srcDirs += "${rootDir}/common/src/test/resources" - // This shouldn't be needed but seems to help IntelliJ locate the native artifact. - // srcDirs += preferredNativeFileDir - srcDirs += buildToTest.nativeResourcesDir() + srcDirs = [ "src/test/resources" ] } + project(':conscrypt-common').sourceSets.test } // Add the source sets for each of the native builds @@ -179,16 +169,16 @@ processResources { dependsOn generateProperties } -tasks.register("platformJar", Jar) { - from sourceSets.platform.output -} - tasks.register("testJar", ShadowJar) { - classifier = 'tests' + archiveClassifier = 'tests' configurations = [project.configurations.testRuntimeClasspath] from sourceSets.test.output } +tasks.named("sourcesJar") { + dependsOn generateProperties +} + if (isExecutableOnPath('cpplint')) { def cpplint = tasks.register("cpplint", Exec) { executable = 'cpplint' @@ -244,11 +234,6 @@ if (isExecutableOnPath('cpplint')) { configurations { publicApiDocs - platform -} - -artifacts { - platform platformJar } apply from: "$rootDir/gradle/publishing.gradle" @@ -268,17 +253,18 @@ dependencies { // This is used for the @Internal annotation processing in JavaDoc publicApiDocs project(':conscrypt-api-doclet') + api project(':conscrypt-common') + // This is listed as compile-only, but we absorb its contents. compileOnly project(':conscrypt-constants') + testCompileOnly project(':conscrypt-constants') - testImplementation project(':conscrypt-constants'), + testImplementation project(':conscrypt-common').sourceSets.test.output, project(path: ':conscrypt-testing', configuration: 'shadow'), libraries.junit, libraries.mockito testRuntimeOnly sourceSets["$preferredSourceSet"].output - - platformCompileOnly sourceSets.main.output } nativeBuilds.each { nativeBuild -> @@ -345,7 +331,16 @@ jacocoTestReport { } javadoc { - dependsOn(configurations.publicApiDocs) + dependsOn configurations.publicApiDocs + dependsOn generateProperties + source = project(':conscrypt-common').sourceSets.main.java + + failOnError false + options { + encoding = 'UTF-8' + links "https://docs.oracle.com/javase/8/docs/api/" + } + // TODO(prb): Update doclet to Java 11. // options.doclet = "org.conscrypt.doclet.FilterDoclet" // options.docletpath = configurations.publicApiDocs.files as List diff --git a/platform-stub/build.gradle b/platform-stub/build.gradle new file mode 100644 index 000000000..f32a429c2 --- /dev/null +++ b/platform-stub/build.gradle @@ -0,0 +1,14 @@ +sourceSets { + main { + java { + srcDirs = [ + "src/main/java", + ] + } + } +} + +// Nope. +tasks.named("sourcesJar") { + enabled = false +} diff --git a/platform-stub/src/main/java/org/conscrypt/AbstractConscryptSocket.java b/platform-stub/src/main/java/org/conscrypt/AbstractConscryptSocket.java new file mode 100644 index 000000000..ee55df508 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/AbstractConscryptSocket.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class AbstractConscryptSocket { +} diff --git a/platform-stub/src/main/java/org/conscrypt/CertBlocklist.java b/platform-stub/src/main/java/org/conscrypt/CertBlocklist.java new file mode 100644 index 000000000..5e61e4edf --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/CertBlocklist.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class CertBlocklist { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ConscryptCertStore.java b/platform-stub/src/main/java/org/conscrypt/ConscryptCertStore.java new file mode 100644 index 000000000..2e02a3480 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ConscryptCertStore.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class ConscryptCertStore { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ConscryptEngine.java b/platform-stub/src/main/java/org/conscrypt/ConscryptEngine.java new file mode 100644 index 000000000..a193064de --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ConscryptEngine.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class ConscryptEngine { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ConscryptEngineSocket.java b/platform-stub/src/main/java/org/conscrypt/ConscryptEngineSocket.java new file mode 100644 index 000000000..8e0cf1924 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ConscryptEngineSocket.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class ConscryptEngineSocket { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ConscryptFileDescriptorSocket.java b/platform-stub/src/main/java/org/conscrypt/ConscryptFileDescriptorSocket.java new file mode 100644 index 000000000..66f694c70 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ConscryptFileDescriptorSocket.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class ConscryptFileDescriptorSocket { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ConscryptHostnameVerifier.java b/platform-stub/src/main/java/org/conscrypt/ConscryptHostnameVerifier.java new file mode 100644 index 000000000..3b862d51f --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ConscryptHostnameVerifier.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class ConscryptHostnameVerifier { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ExternalSession.java b/platform-stub/src/main/java/org/conscrypt/ExternalSession.java new file mode 100644 index 000000000..04274443f --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ExternalSession.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class ExternalSession { +} diff --git a/platform-stub/src/main/java/org/conscrypt/GCMParameters.java b/platform-stub/src/main/java/org/conscrypt/GCMParameters.java new file mode 100644 index 000000000..fa52c958c --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/GCMParameters.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class GCMParameters { +} diff --git a/platform-stub/src/main/java/org/conscrypt/NativeCryptoJni.java b/platform-stub/src/main/java/org/conscrypt/NativeCryptoJni.java new file mode 100644 index 000000000..36261ce35 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/NativeCryptoJni.java @@ -0,0 +1,39 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class NativeCryptoJni { + static void init() { + throw new RuntimeException("Stub!"); + } +} diff --git a/platform-stub/src/main/java/org/conscrypt/OpenSSLKey.java b/platform-stub/src/main/java/org/conscrypt/OpenSSLKey.java new file mode 100644 index 000000000..3e83e6eda --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/OpenSSLKey.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class OpenSSLKey { +} diff --git a/platform-stub/src/main/java/org/conscrypt/OpenSSLSocketFactoryImpl.java b/platform-stub/src/main/java/org/conscrypt/OpenSSLSocketFactoryImpl.java new file mode 100644 index 000000000..ffcf64dee --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/OpenSSLSocketFactoryImpl.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class OpenSSLSocketFactoryImpl { +} diff --git a/platform-stub/src/main/java/org/conscrypt/Platform.java b/platform-stub/src/main/java/org/conscrypt/Platform.java new file mode 100644 index 000000000..c1607959a --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/Platform.java @@ -0,0 +1,374 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +import org.conscrypt.ct.CTLogStore; +import org.conscrypt.ct.CTPolicy; + +import java.io.File; +import java.io.FileDescriptor; +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketException; +import java.security.AlgorithmParameters; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.PrivateKey; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.ECParameterSpec; + +import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.X509TrustManager; + +final class Platform { + private Platform() {} + + static void setup() { + throw new RuntimeException("Stub!"); + } + + static File createTempFile(String prefix, String suffix, File directory) { + throw new RuntimeException("Stub!"); + } + + static String getDefaultProviderName() { + throw new RuntimeException("Stub!"); + } + + static boolean provideTrustManagerByDefault() { + throw new RuntimeException("Stub!"); + } + + static boolean canExecuteExecutable(File file) throws IOException { + throw new RuntimeException("Stub!"); + } + + static FileDescriptor getFileDescriptor(Socket s) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static FileDescriptor getFileDescriptorFromSSLSocket(AbstractConscryptSocket socket) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static String getCurveName(ECParameterSpec spec) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void setCurveName(@SuppressWarnings("unused") ECParameterSpec spec, + @SuppressWarnings("unused") String curveName) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void setSocketWriteTimeout(@SuppressWarnings("unused") Socket s, + @SuppressWarnings("unused") long timeoutMillis) throws SocketException { + throw new RuntimeException("Stub!"); + } + + static void setSSLParameters( + SSLParameters params, SSLParametersImpl impl, AbstractConscryptSocket socket) { + throw new RuntimeException("Stub!"); + } + + static void getSSLParameters( + SSLParameters params, SSLParametersImpl impl, AbstractConscryptSocket socket) { + throw new RuntimeException("Stub!"); + } + + static void setSSLParameters( + SSLParameters params, SSLParametersImpl impl, ConscryptEngine engine) { + throw new RuntimeException("Stub!"); + } + + static void getSSLParameters( + SSLParameters params, SSLParametersImpl impl, ConscryptEngine engine) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void setEndpointIdentificationAlgorithm( + SSLParameters params, String endpointIdentificationAlgorithm) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static String getEndpointIdentificationAlgorithm(SSLParameters params) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void checkClientTrusted(X509TrustManager tm, X509Certificate[] chain, String authType, + AbstractConscryptSocket socket) throws CertificateException { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void checkServerTrusted(X509TrustManager tm, X509Certificate[] chain, String authType, + AbstractConscryptSocket socket) throws CertificateException { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void checkClientTrusted(X509TrustManager tm, X509Certificate[] chain, String authType, + ConscryptEngine engine) throws CertificateException { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void checkServerTrusted(X509TrustManager tm, X509Certificate[] chain, String authType, + ConscryptEngine engine) throws CertificateException { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static OpenSSLKey wrapRsaKey(@SuppressWarnings("unused") PrivateKey javaKey) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void logEvent(@SuppressWarnings("unused") String message) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static boolean isSniEnabledByDefault() { + throw new RuntimeException("Stub!"); + } + + static SSLEngine wrapEngine(ConscryptEngine engine) { + throw new RuntimeException("Stub!"); + } + + static SSLEngine unwrapEngine(SSLEngine engine) { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(String hostname, int port, + SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(InetAddress address, int port, + SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(String hostname, int port, + InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(InetAddress address, int port, + InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(Socket socket, String hostname, int port, + boolean autoClose, SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(String hostname, int port, + SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(InetAddress address, int port, + SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(String hostname, int port, + InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(InetAddress address, int port, + InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(Socket socket, String hostname, + int port, boolean autoClose, SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static SSLSocketFactory wrapSocketFactoryIfNeeded(OpenSSLSocketFactoryImpl factory) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static GCMParameters fromGCMParameterSpec(AlgorithmParameterSpec params) { + throw new RuntimeException("Stub!"); + } + + static AlgorithmParameterSpec fromGCMParameters(AlgorithmParameters params) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static AlgorithmParameterSpec toGCMParameterSpec(int tagLenInBits, byte[] iv) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static Object closeGuardGet() { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void closeGuardOpen(@SuppressWarnings("unused") Object guardObj, + @SuppressWarnings("unused") String message) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void closeGuardClose(@SuppressWarnings("unused") Object guardObj) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void closeGuardWarnIfOpen(@SuppressWarnings("unused") Object guardObj) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void blockGuardOnNetwork() { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static String oidToAlgorithmName(String oid) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static SSLSession wrapSSLSession(ExternalSession sslSession) { + throw new RuntimeException("Stub!"); + } + + public static String getOriginalHostNameFromInetAddress(InetAddress addr) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static String getHostStringFromInetSocketAddress(InetSocketAddress addr) { + throw new RuntimeException("Stub!"); + } + + static boolean supportsX509ExtendedTrustManager() { + throw new RuntimeException("Stub!"); + } + + static boolean isCTVerificationRequired(String hostname) { + throw new RuntimeException("Stub!"); + } + + static boolean supportsConscryptCertStore() { + throw new RuntimeException("Stub!"); + } + + static KeyStore getDefaultCertKeyStore() throws KeyStoreException { + throw new RuntimeException("Stub!"); + } + + static ConscryptCertStore newDefaultCertStore() { + throw new RuntimeException("Stub!"); + } + + static CertBlocklist newDefaultBlocklist() { + throw new RuntimeException("Stub!"); + } + + static CTLogStore newDefaultLogStore() { + throw new RuntimeException("Stub!"); + } + + static CTPolicy newDefaultPolicy(CTLogStore logStore) { + throw new RuntimeException("Stub!"); + } + + static boolean serverNamePermitted(SSLParametersImpl parameters, String serverName) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + public static ConscryptHostnameVerifier getDefaultHostnameVerifier() { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static long getMillisSinceBoot() { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void countTlsHandshake( + boolean success, String protocol, String cipherSuite, long duration) { + throw new RuntimeException("Stub!"); + } + + public static boolean isJavaxCertificateSupported() { + throw new RuntimeException("Stub!"); + } + + public static boolean isTlsV1Deprecated() { + throw new RuntimeException("Stub!"); + } +} diff --git a/platform-stub/src/main/java/org/conscrypt/SSLParametersImpl.java b/platform-stub/src/main/java/org/conscrypt/SSLParametersImpl.java new file mode 100644 index 000000000..f2db0ce26 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/SSLParametersImpl.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt; + +public class SSLParametersImpl { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ct/CTLogStore.java b/platform-stub/src/main/java/org/conscrypt/ct/CTLogStore.java new file mode 100644 index 000000000..4d7ffa2d9 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ct/CTLogStore.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt.ct; + +public class CTLogStore { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ct/CTPolicy.java b/platform-stub/src/main/java/org/conscrypt/ct/CTPolicy.java new file mode 100644 index 000000000..131a5f4eb --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ct/CTPolicy.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package org.conscrypt.ct; + +public class CTPolicy { +} diff --git a/platform/build.gradle b/platform/build.gradle index e2da924b9..42da3988a 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -68,10 +68,7 @@ if (androidSdkInstalled) { sourceSets { main { java { - srcDirs = [ - "${rootDir}/common/src/main/java", - "src/main/java", - ] + srcDirs = [ "src/main/java" ] excludes = [ 'org/conscrypt/Platform.java' ] } } @@ -86,7 +83,7 @@ if (androidSdkInstalled) { } dependencies { - implementation project(path: ':conscrypt-openjdk', configuration: 'platform') + implementation project(':conscrypt-common') publicApiDocs project(':conscrypt-api-doclet') androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1', { exclude module: 'support-annotations' diff --git a/settings.gradle b/settings.gradle index 2eefbc7a4..6f39af8cd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,10 +7,12 @@ include ":conscrypt-benchmark-android" include ":conscrypt-benchmark-base" include ":conscrypt-benchmark-graphs" include ":conscrypt-benchmark-jmh" +include ":conscrypt-common" include ":conscrypt-constants" include ":conscrypt-libcore-stub" include ":conscrypt-openjdk" include ":conscrypt-openjdk-uber" +include ":conscrypt-platform-stub" include ":conscrypt-testing" project(':conscrypt-android').projectDir = "$rootDir/android" as File @@ -21,8 +23,10 @@ project(':conscrypt-benchmark-android').projectDir = "$rootDir/benchmark-android project(':conscrypt-benchmark-base').projectDir = "$rootDir/benchmark-base" as File project(':conscrypt-benchmark-graphs').projectDir = "$rootDir/benchmark-graphs" as File project(':conscrypt-benchmark-jmh').projectDir = "$rootDir/benchmark-jmh" as File +project(':conscrypt-common').projectDir = "$rootDir/common" as File project(':conscrypt-constants').projectDir = "$rootDir/constants" as File project(':conscrypt-libcore-stub').projectDir = "$rootDir/libcore-stub" as File project(':conscrypt-openjdk').projectDir = "$rootDir/openjdk" as File project(':conscrypt-openjdk-uber').projectDir = "$rootDir/openjdk-uber" as File +project(':conscrypt-platform-stub').projectDir = "$rootDir/platform-stub" as File project(':conscrypt-testing').projectDir = "$rootDir/testing" as File