diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-09-20 15:07:40 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-09-20 15:07:40 +0200 |
| commit | 2a619ceba75a4c16b25de12d59a87eac795a4468 (patch) | |
| tree | 1d63a35217011fa761b703633b3f91fd839ec71e /wrappers/java-android | |
| parent | 7e309b67de74fe5bd5a1c70c1880c2a381c4f78b (diff) | |
Remove: unused wrappers
Diffstat (limited to 'wrappers/java-android')
23 files changed, 0 insertions, 887 deletions
diff --git a/wrappers/java-android/.gitignore b/wrappers/java-android/.gitignore deleted file mode 100644 index 41445b2..0000000 --- a/wrappers/java-android/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.iml -.gradle/ -.idea/ -/build/ -/captures/ -.cxx/ -.externalNativeBuild/ -CMakeFiles/ -local.properties diff --git a/wrappers/java-android/Makefile b/wrappers/java-android/Makefile deleted file mode 100644 index c60b074..0000000 --- a/wrappers/java-android/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -.PHONY: build pack android-test connected-android-test test clean - -EXPORTS_PATH ?= ../../exports -include $(EXPORTS_PATH)/common.mk - -ifeq ($(NO_DAEMON),1) -override GRADLE_FLAGS += --no-daemon -endif - -build: - ./gradlew $(GRADLE_FLAGS) assembleRelease - -pack: build - -# Unit tests use library for desktop OS platform, so we still need .try-build-lib for this -# The unit tests find this library through the library path set in common.mk -unit-test: .try-build-lib - ./gradlew $(GRADLE_FLAGS) test - -android-test: - ./gradlew $(GRADLE_FLAGS) pixel2DebugAndroidTest - -connected-android-test: - ./gradlew $(GRADLE_FLAGS) connectedAndroidTest - -test: .try-build-lib -ifeq ($(NO_EMULATOR),1) - ./gradlew $(GRADLE_FLAGS) test -else - ./gradlew $(GRADLE_FLAGS) test pixel2DebugAndroidTest -endif - -clean: - rm -rf lib/build lib/.cxx lib/CMakeFiles lib/src/test/resources/* -ifeq ($(CLEAN_ALL),1) - rm -rf .gradle/ -endif diff --git a/wrappers/java-android/README.md b/wrappers/java-android/README.md deleted file mode 100644 index 50e1868..0000000 --- a/wrappers/java-android/README.md +++ /dev/null @@ -1,89 +0,0 @@ -# Android (Java) wrapper - -## Requirements - -You will need to install the JDK compatible with Gradle and the Android Gradle plugin. Gradle specifies -a [maximum supported JDK version](https://docs.gradle.org/current/userguide/compatibility.html), while the Android -Gradle plugin specifies a [minimum supported JDK version](https://developer.android.com/studio/releases/gradle-plugin) ( -see 'Compatibility' table for the right Gradle version). Additionally, the Android Gradle plugin requires -a [certain Gradle version range](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle). Lastly, ( -older versions of) Android Studio and especially IntelliJ Ultimate may not support some newer Android Gradle plugin -versions. - -If you see `Unsupported class file major version xx` then Gradle wants you to use an older Java version. If you -see `Android Gradle plugin requires Java xx to run.` then the Android Gradle plugin wants you to use a newer Java -version. Set `JAVA_HOME` to the right JDK install. - -See the [list of Gradle releases](https://github.com/gradle/gradle/releases) -and [list of Android Gradle plugin releases](https://maven.google.com/web/?q=com.android.tools.build#com.android.tools.build:gradle) -. - -Versions are managed per project by -the [Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html) (see `gradle*` files). -Run `./gradlew --version` to get the project Gradle version. Look at the dependencies in `/build.gradle` for the current -Android Gradle plugin version. This means that you do not need to install Gradle separately yourself. - -Currently, versions are Gradle 7.0.2 and Android Gradle plugin 7.0.4, which means you have to install a **JDK with a -version between 11 and 16**. If desired, these can be upgraded to e.g. 7.4 and 7.1.1 respectively without problems, but -as mentioned, IDE support may be limited with newer versions. The Gradle wrapper may be updated using -e.g. `./gradlew wrapper --gradle-version 7.4`. After that, the Android Gradle plugin may be updated by changing the -version in `/build.gradle`. - -You will also need the Android SDK, which comes with [Android Studio](https://developer.android.com/studio/). - -## Build & test - -Build AAR (Gradle will also run unit tests): - -```shell -make -``` - -This will build an AAR in `lib/build/outputs/aar`, which will include the shared Go library for all Android -architectures, which it will build using the Android NDK via CMake, which calls `make` with the right compiler. - -Run unit tests without an Android emulator: - -```shell -make unit-test -``` - -This will build the library for your current desktop OS and use that. - -Run Android instrumented tests on a new emulator: - -```shell -make android-test -``` - -This uses [Gradle managed virtual devices](https://developer.android.com/studio/preview/features#gmd). This experimental -feature is enabled in `gradle.properties`. It is normal that tests that pass are not logged. - -Run Android instrumented tests on an already running emulator: - -```shell -make connected-android-test -``` - -This will be faster when used multiple times, as the emulator is reused. - -Run both unit tests and Android instrumented tests on a new emulator: - -```shell -make test -``` - -For all commands you can specify options to pass to Gradle via `GRADLE_FLAGS=`, e.g. `GRADLE_FLAGS=--info`. -Specify `NO_DAEMON=1` to add `--no-daemon`. - -## Notes - -The same Java code is used for the Android instrumented tests as for the unit tests. Both use Java resources that are -copied from the `../../src/test_data` folder by Gradle. - -This library uses JNA, not JNI. Hence, there is no C wrapper. The library is dynamically opened with `dlopen` -via `libjnidispatch.so` which comes with the JNA AAR. - -If you want to know how the tests would look like with JUnit 5, or if for some reason you want to look at a pure Java -wrapper using Maven, -see [`b60ecf2`](https://github.com/stevenwdv/eduvpn-common/tree/b60ecf2fe5ddfe506e02093286b3931873187e91/wrappers/java). diff --git a/wrappers/java-android/build.gradle b/wrappers/java-android/build.gradle deleted file mode 100644 index c9f995e..0000000 --- a/wrappers/java-android/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - repositories { - google() - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - tasks.withType(JavaCompile) { - options.deprecation = true - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/wrappers/java-android/gradle.properties b/wrappers/java-android/gradle.properties deleted file mode 100644 index 4b5f10f..0000000 --- a/wrappers/java-android/gradle.properties +++ /dev/null @@ -1,24 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true -# Enable all warnings -org.gradle.warning.mode=all -# Enable Gradle managed devices for older Android plugin versions -android.experimental.androidTest.useUnifiedTestPlatform=true -# To test with ATD images (but native stuff seems to malfunction?): android.sdk.channel=3 diff --git a/wrappers/java-android/gradle/wrapper/gradle-wrapper.jar b/wrappers/java-android/gradle/wrapper/gradle-wrapper.jar Binary files differdeleted file mode 100644 index 7454180..0000000 --- a/wrappers/java-android/gradle/wrapper/gradle-wrapper.jar +++ /dev/null diff --git a/wrappers/java-android/gradle/wrapper/gradle-wrapper.properties b/wrappers/java-android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 0f80bbf..0000000 --- a/wrappers/java-android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/wrappers/java-android/gradlew b/wrappers/java-android/gradlew deleted file mode 100755 index 1b6c787..0000000 --- a/wrappers/java-android/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# 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 -# -# https://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. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/wrappers/java-android/gradlew.bat b/wrappers/java-android/gradlew.bat deleted file mode 100755 index 107acd3..0000000 --- a/wrappers/java-android/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/wrappers/java-android/lib/.gitignore b/wrappers/java-android/lib/.gitignore deleted file mode 100644 index 1ac6136..0000000 --- a/wrappers/java-android/lib/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/build -/src/test/resources/* diff --git a/wrappers/java-android/lib/CMakeLists.txt b/wrappers/java-android/lib/CMakeLists.txt deleted file mode 100644 index 8e8ff87..0000000 --- a/wrappers/java-android/lib/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.18.1) -project(eduvpn_common) - -# Android -> Go architecture map -set(arch_map_x86 386) -set(arch_map_x86_64 amd64) -set(arch_map_arm arm) -set(arch_map_arm64 arm64) - -set(GOARCH ${arch_map_${ANDROID_ARCH_NAME}}) - -find_program(MAKE_EXECUTABLE - NAMES gmake mingw32-make make - NAMES_PER_DIR - DOC "GNU Make" - REQUIRED -) - -# Inspired by https://github.com/WireGuard/wireguard-android/blob/1.0.20211029/tunnel/tools/CMakeLists.txt - -# --target has to be specified to compiler & linker as e.g. ANDROID_C_COMPILER may just be 'clang' without prefixes -# CGO_CPPFLAGS are concatenated to CGO_CFLAGS and CGO_CXXFLAGS -add_custom_target(shared-lib - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../exports" - COMMENT "Building shared library for ${ANDROID_LLVM_TRIPLE}" - VERBATIM - COMMAND ${MAKE_EXECUTABLE} - GOOS=android GOARCH=${GOARCH} - CC=${ANDROID_C_COMPILER} CXX=${ANDROID_CXX_COMPILER} - CGO_CPPFLAGS=--target=${ANDROID_LLVM_TRIPLE} CGO_CFLAGS=${CMAKE_C_FLAGS} CGO_CXXFLAGS=${CMAKE_CXX_FLAGS} - CGO_LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}\ --target=${ANDROID_LLVM_TRIPLE} - COPY_LIB_TO=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} -) - -# Note about COPY_LIB_TO: this is an easy cross-platform alternative to calling `cp` -# file(COPY ...) does not work since it runs at the configure stage... diff --git a/wrappers/java-android/lib/build.gradle b/wrappers/java-android/lib/build.gradle deleted file mode 100644 index 04cb00e..0000000 --- a/wrappers/java-android/lib/build.gradle +++ /dev/null @@ -1,107 +0,0 @@ -import com.android.build.api.dsl.ManagedVirtualDevice - -plugins { - id 'com.android.library' // Build AAR -} - -android { - compileSdk 31 - - defaultConfig { - minSdk 21 - targetSdk 31 - versionCode 1 - versionName '1.0' - - testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' - - consumerProguardFiles 'consumer-rules.pro' - - externalNativeBuild { - cmake { - // Specify which target we want to build - targets 'shared-lib' - } - } - } - - buildTypes { - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - // Support Java 8+ - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - externalNativeBuild { - cmake { - version '3.18.1' // See cmake_minimum_required in CMakeLists.txt - path 'CMakeLists.txt' - } - } - - sourceSets { - androidTest { - // Use same sources & resources for Android instrumented tests as unit tests - java.srcDirs = sourceSets.test.java.srcDirs - resources.srcDirs = sourceSets.test.resources.srcDirs - } - } - - task copyTestData(type: Copy, description: 'Copy test_data to test resources') { - from('../../../src/test_data') { - exclude '**/*.py', '**/*.sh' - } - into sourceSets.test.resources.srcDirs[0].toPath().resolve('org/eduvpn/common') - } - - // Copy test_data to Java resources before these are processed - // (.named does not find all tasks. Task names were obtained with com.dorongold.task-tree plugin) - tasks.matching { t -> - t.name in [ - 'processDebugUnitTestJavaRes', 'processReleaseUnitTestJavaRes', - 'processDebugAndroidTestJavaRes', 'processReleaseAndroidTestJavaRes'] - }.all { - dependsOn copyTestData - } - - // Do not cache unit test results as the shared library may have changed - tasks.matching { t -> t.name in ['testDebugUnitTest', 'testReleaseUnitTest'] }.all { - outputs.upToDateWhen { false } - } - - testOptions { - // Display full exceptions and passed tests for unit tests - unitTests.all { - testLogging { - events 'passed', 'skipped', 'failed' - exceptionFormat 'full' - } - } - - devices { - pixel2(ManagedVirtualDevice) { - device = 'Pixel 2' - apiLevel = 30 - systemImageSource = 'aosp' - abi = 'x86_64' - } - } - } -} - -dependencies { - implementation 'net.java.dev.jna:jna:5.10.0@aar' - - testImplementation 'commons-io:commons-io:2.11.0' - testImplementation 'net.java.dev.jna:jna:5.10.0' // Include jnidispatch library in unit tests - testImplementation 'junit:junit:4.+' - - androidTestImplementation 'commons-io:commons-io:2.11.0' - androidTestImplementation 'androidx.test:runner:1.4.0' -} diff --git a/wrappers/java-android/lib/consumer-rules.pro b/wrappers/java-android/lib/consumer-rules.pro deleted file mode 100644 index e69de29..0000000 --- a/wrappers/java-android/lib/consumer-rules.pro +++ /dev/null diff --git a/wrappers/java-android/lib/proguard-rules.pro b/wrappers/java-android/lib/proguard-rules.pro deleted file mode 100644 index f1b4245..0000000 --- a/wrappers/java-android/lib/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile diff --git a/wrappers/java-android/lib/src/main/AndroidManifest.xml b/wrappers/java-android/lib/src/main/AndroidManifest.xml deleted file mode 100644 index 5a49838..0000000 --- a/wrappers/java-android/lib/src/main/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest package="org.eduvpn.common"> - -</manifest> diff --git a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/Discovery.java b/wrappers/java-android/lib/src/main/java/org/eduvpn/common/Discovery.java deleted file mode 100644 index dfeef71..0000000 --- a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/Discovery.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.eduvpn.common; - -import com.sun.jna.*; - -import java.nio.charset.StandardCharsets; - -public final class Discovery { - private static final String LIB_NAME = "eduvpn_common"; - private static final NativeApi discovery = Native.load(LIB_NAME, NativeApi.class); - - /** - * Verifies the signature on the JSON server_list.json/organization_list.json file. - * If the function returns, the signature is valid for the given file type. - * - * @param signature .minisig signature file contents. - * @param signedJson Signed .json file contents. - * @param expectedFileName The file type to be verified, one of {@code "server_list.json"} or {@code "organization_list.json"}. - * @param minSignTime Minimum time for signature (UNIX timestamp, seconds). Should be set to at least the time of the previous signature. - * @throws IllegalArgumentException If {@code expectedFileName} is not one of the allowed values or one of the parameters is empty. - * @throws VerifyException If signature verification fails. - */ - public static void verify(byte[] signature, byte[] signedJson, String expectedFileName, long minSignTime) throws VerifyException { - byte err = discovery.Verify(NativeApi.GoSlice.fromArray(signature), NativeApi.GoSlice.fromArray(signedJson), - NativeApi.GoSlice.fromString(expectedFileName), minSignTime); - - switch (err) { - case 0: - return; - case 1: - throw new IllegalArgumentException("unknown expected file name"); - case 2: - throw new InvalidSignatureException(); - case 3: - throw new InvalidSignatureUnknownKeyException(); - case 4: - throw new SignatureTooOldException(); - default: - throw new UnknownVerifyException(err); - } - } - - /** Use for testing only, see Go documentation. */ - /*package-private*/ - static void insecureTestingSetExtraKey(String keyString) { - discovery.InsecureTestingSetExtraKey(NativeApi.GoSlice.fromArray(keyString.getBytes(StandardCharsets.UTF_8))); - } - - private interface NativeApi extends Library { - // C-compatible structure - @Structure.FieldOrder({"data", "len", "cap"}) - class GoSlice extends Structure implements Structure.ByValue { - public Pointer data; - public long len, cap; - - public GoSlice(Pointer data, long len, long cap) { - this.data = data; - this.len = len; - this.cap = cap; - } - - public static GoSlice fromArray(byte[] bytes) { - Memory memory = new Memory(bytes.length); - memory.write(0, bytes, 0, bytes.length); - return new GoSlice(memory, bytes.length, bytes.length); - } - - /** From string as UTF-8. */ - public static GoSlice fromString(String str) { - return fromArray(str.getBytes(StandardCharsets.UTF_8)); - } - } - - byte Verify(GoSlice signatureFileContent, GoSlice signedJson, GoSlice expectedFileName, long minSignTime); - - void InsecureTestingSetExtraKey(GoSlice keyString); - } - - private Discovery() { - } -} diff --git a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/InvalidSignatureException.java b/wrappers/java-android/lib/src/main/java/org/eduvpn/common/InvalidSignatureException.java deleted file mode 100644 index b739dd7..0000000 --- a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/InvalidSignatureException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.eduvpn.common; - -/** Signature is invalid (for the expected file type). */ -public final class InvalidSignatureException extends VerifyException { - public InvalidSignatureException() { - super("invalid signature"); - } -} diff --git a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/InvalidSignatureUnknownKeyException.java b/wrappers/java-android/lib/src/main/java/org/eduvpn/common/InvalidSignatureUnknownKeyException.java deleted file mode 100644 index 6d651e5..0000000 --- a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/InvalidSignatureUnknownKeyException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.eduvpn.common; - -/** Signature was created with an unknown key and has not been verified. */ -public final class InvalidSignatureUnknownKeyException extends VerifyException { - public InvalidSignatureUnknownKeyException() { - super("invalid signature (unknown key)"); - } -} diff --git a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/SignatureTooOldException.java b/wrappers/java-android/lib/src/main/java/org/eduvpn/common/SignatureTooOldException.java deleted file mode 100644 index c89136f..0000000 --- a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/SignatureTooOldException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.eduvpn.common; - -/** Signature timestamp smaller than specified minimum signing time (rollback). */ -public final class SignatureTooOldException extends VerifyException { - public SignatureTooOldException() { - super("replay of previous signature (rollback)"); - } -} diff --git a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/UnknownVerifyException.java b/wrappers/java-android/lib/src/main/java/org/eduvpn/common/UnknownVerifyException.java deleted file mode 100644 index 80b74ea..0000000 --- a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/UnknownVerifyException.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.eduvpn.common; - -/** Other unknown error. */ -public final class UnknownVerifyException extends VerifyException { - public UnknownVerifyException(byte code) { - super(String.format("unknown verify error (%d)", code)); - assert code != 0; - } -} diff --git a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/VerifyException.java b/wrappers/java-android/lib/src/main/java/org/eduvpn/common/VerifyException.java deleted file mode 100644 index 686ea41..0000000 --- a/wrappers/java-android/lib/src/main/java/org/eduvpn/common/VerifyException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.eduvpn.common; - -/** Verification failed, do not trust the file. */ -public abstract class VerifyException extends Exception { - protected VerifyException(String message) { - super(message); - } -} diff --git a/wrappers/java-android/lib/src/test/java/org/eduvpn/common/VerifyTests.java b/wrappers/java-android/lib/src/test/java/org/eduvpn/common/VerifyTests.java deleted file mode 100644 index 92a4648..0000000 --- a/wrappers/java-android/lib/src/test/java/org/eduvpn/common/VerifyTests.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.eduvpn.common; - -import org.apache.commons.io.IOUtils; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - -public class VerifyTests { - private static byte[] readAll(String resource) throws IOException { - try (InputStream stream = VerifyTests.class.getResourceAsStream(resource)) { - return IOUtils.toByteArray(stream); - } - } - - @SuppressWarnings("OptionalGetWithoutIsPresent") - @BeforeClass - public static void oneTimeSetup() throws IOException { - try (BufferedReader reader = new BufferedReader(new InputStreamReader( - VerifyTests.class.getResourceAsStream("public.key")))) { - Discovery.insecureTestingSetExtraKey(reader.lines().reduce((a, b) -> b).get()); - } - } - - @Test - public void testValid() throws IOException, VerifyException { - Discovery.verify( - readAll("server_list.json.minisig"), - readAll("server_list.json"), - "server_list.json", - 10 - ); - } - - @Test(expected = InvalidSignatureException.class) - public void testInvalidSignature() throws IOException, VerifyException { - Discovery.verify( - readAll("random.txt"), - readAll("server_list.json"), - "server_list.json", - 0 - ); - } - - @Test(expected = InvalidSignatureUnknownKeyException.class) - public void testWrongKey() throws IOException, VerifyException { - Discovery.verify( - readAll("server_list.json.wrong_key.minisig"), - readAll("server_list.json"), - "server_list.json", - 0 - ); - } - - @Test(expected = SignatureTooOldException.class) - public void testOldSignature() throws IOException, VerifyException { - Discovery.verify( - readAll("server_list.json.minisig"), - readAll("server_list.json"), - "server_list.json", - 11 - ); - } - - @Test(expected = IllegalArgumentException.class) - public void testUnknownExpectedFile() throws IOException, VerifyException { - Discovery.verify( - readAll("other_list.json.minisig"), - readAll("other_list.json"), - "other_list.json", - 0 - ); - } -} diff --git a/wrappers/java-android/settings.gradle b/wrappers/java-android/settings.gradle deleted file mode 100644 index b603bb3..0000000 --- a/wrappers/java-android/settings.gradle +++ /dev/null @@ -1,9 +0,0 @@ -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - } -} -rootProject.name = 'eduvpn_common' -include ':lib' |
