mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Compare commits
2 Commits
beta-2017-
...
377_replac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cef4c31e0b | ||
|
|
62527a62c1 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -9,18 +9,15 @@ Thumbs.db
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# Eclipse project files
|
# Eclipse project files
|
||||||
.classpath
|
#.classpath
|
||||||
.project
|
#.project
|
||||||
.settings
|
|
||||||
|
|
||||||
# Local configuration file (sdk path, etc)
|
# Local configuration file (sdk path, etc)
|
||||||
local.properties
|
local.properties
|
||||||
|
|
||||||
# Android Studio
|
# Android Studio
|
||||||
.idea/*
|
.idea/*
|
||||||
!.idea/runConfigurations/
|
|
||||||
!.idea/codeStyleSettings.xml
|
!.idea/codeStyleSettings.xml
|
||||||
.gradle
|
.gradle
|
||||||
build/
|
build/
|
||||||
*.iml
|
*.iml
|
||||||
projectFilesBackup/
|
|
||||||
2
.idea/codeStyleSettings.xml
generated
2
.idea/codeStyleSettings.xml
generated
@@ -31,8 +31,6 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
<option name="RIGHT_MARGIN" value="100" />
|
<option name="RIGHT_MARGIN" value="100" />
|
||||||
<option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
|
|
||||||
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
|
|
||||||
<AndroidXmlCodeStyleSettings>
|
<AndroidXmlCodeStyleSettings>
|
||||||
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
||||||
</AndroidXmlCodeStyleSettings>
|
</AndroidXmlCodeStyleSettings>
|
||||||
|
|||||||
28
.idea/runConfigurations/All_tests.xml
generated
28
.idea/runConfigurations/All_tests.xml
generated
@@ -1,28 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="All tests" type="AndroidJUnit" factoryName="Android JUnit">
|
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
|
||||||
<module name="briar-android" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
|
||||||
<option name="METHOD_NAME" value="" />
|
|
||||||
<option name="TEST_OBJECT" value="package" />
|
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/briar-android" />
|
|
||||||
<option name="ENV_VARIABLES" />
|
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
|
||||||
<value defaultName="singleModule" />
|
|
||||||
</option>
|
|
||||||
<envs />
|
|
||||||
<patterns />
|
|
||||||
<method>
|
|
||||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in bramble-api" run_configuration_type="AndroidJUnit" />
|
|
||||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in bramble-core" run_configuration_type="AndroidJUnit" />
|
|
||||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in bramble-j2se" run_configuration_type="AndroidJUnit" />
|
|
||||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in briar-core" run_configuration_type="AndroidJUnit" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
23
.idea/runConfigurations/All_tests_in_bramble_api.xml
generated
23
.idea/runConfigurations/All_tests_in_bramble_api.xml
generated
@@ -1,23 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="All tests in bramble-api" type="AndroidJUnit" factoryName="Android JUnit">
|
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
|
||||||
<module name="bramble-api" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
|
||||||
<option name="METHOD_NAME" value="" />
|
|
||||||
<option name="TEST_OBJECT" value="package" />
|
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-api" />
|
|
||||||
<option name="ENV_VARIABLES" />
|
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
|
||||||
<value defaultName="singleModule" />
|
|
||||||
</option>
|
|
||||||
<envs />
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="All tests in bramble-core" type="AndroidJUnit" factoryName="Android JUnit">
|
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
|
||||||
<module name="bramble-core" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
|
||||||
<option name="METHOD_NAME" value="" />
|
|
||||||
<option name="TEST_OBJECT" value="package" />
|
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-core" />
|
|
||||||
<option name="ENV_VARIABLES" />
|
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
|
||||||
<value defaultName="singleModule" />
|
|
||||||
</option>
|
|
||||||
<envs />
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="All tests in bramble-j2se" type="AndroidJUnit" factoryName="Android JUnit">
|
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
|
||||||
<module name="bramble-j2se" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
|
||||||
<option name="METHOD_NAME" value="" />
|
|
||||||
<option name="TEST_OBJECT" value="package" />
|
|
||||||
<option name="VM_PARAMETERS" value="-ea -Djava.library.path=libs" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-j2se" />
|
|
||||||
<option name="ENV_VARIABLES" />
|
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
|
||||||
<value defaultName="singleModule" />
|
|
||||||
</option>
|
|
||||||
<envs />
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="All tests in briar-android" type="AndroidJUnit" factoryName="Android JUnit">
|
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
|
||||||
<module name="briar-android" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
|
||||||
<option name="METHOD_NAME" value="" />
|
|
||||||
<option name="TEST_OBJECT" value="package" />
|
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/briar-android" />
|
|
||||||
<option name="ENV_VARIABLES" />
|
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
|
||||||
<value defaultName="singleModule" />
|
|
||||||
</option>
|
|
||||||
<envs />
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
23
.idea/runConfigurations/All_tests_in_briar_core.xml
generated
23
.idea/runConfigurations/All_tests_in_briar_core.xml
generated
@@ -1,23 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="All tests in briar-core" type="AndroidJUnit" factoryName="Android JUnit">
|
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
|
||||||
<module name="briar-core" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
|
||||||
<option name="METHOD_NAME" value="" />
|
|
||||||
<option name="TEST_OBJECT" value="package" />
|
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/briar-core" />
|
|
||||||
<option name="ENV_VARIABLES" />
|
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
|
||||||
<value defaultName="singleModule" />
|
|
||||||
</option>
|
|
||||||
<envs />
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
17
LICENSE.txt
17
LICENSE.txt
@@ -13,6 +13,23 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
All files under the directories briar-android/src, briar-api/src,
|
||||||
|
briar-core/src, briar-desktop/src and briar-test/src are licensed
|
||||||
|
under the Apache License, version 2.0 (the "License"); you may not
|
||||||
|
use these files 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.
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
import de.undercouch.gradle.tasks.download.Download
|
|
||||||
import de.undercouch.gradle.tasks.download.Verify
|
|
||||||
|
|
||||||
apply plugin: 'com.android.library'
|
|
||||||
apply plugin: 'witness'
|
|
||||||
apply plugin: 'de.undercouch.download'
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 23
|
|
||||||
buildToolsVersion "23.0.3"
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
minSdkVersion 14
|
|
||||||
targetSdkVersion 22
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0"
|
|
||||||
consumerProguardFiles 'proguard-rules.txt'
|
|
||||||
}
|
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile project(':bramble-core')
|
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
|
||||||
provided 'javax.annotation:jsr250-api:1.0'
|
|
||||||
}
|
|
||||||
|
|
||||||
def torBinaryDir = 'src/main/res/raw'
|
|
||||||
|
|
||||||
task downloadTorGeoIp(type: Download) {
|
|
||||||
src 'https://briarproject.org/build/geoip-2015-12-01.zip'
|
|
||||||
dest "$torBinaryDir/geoip.zip"
|
|
||||||
onlyIfNewer true
|
|
||||||
}
|
|
||||||
|
|
||||||
task downloadTorBinaryArm(type: Download) {
|
|
||||||
src 'https://briarproject.org/build/tor-0.2.7.6-arm.zip'
|
|
||||||
dest "$torBinaryDir/tor_arm.zip"
|
|
||||||
onlyIfNewer true
|
|
||||||
}
|
|
||||||
|
|
||||||
task downloadTorBinaryArmPie(type: Download) {
|
|
||||||
src 'https://briarproject.org/build/tor-0.2.7.6-arm-pie.zip'
|
|
||||||
dest "$torBinaryDir/tor_arm_pie.zip"
|
|
||||||
onlyIfNewer true
|
|
||||||
}
|
|
||||||
|
|
||||||
task downloadTorBinaryX86(type: Download) {
|
|
||||||
src 'https://briarproject.org/build/tor-0.2.7.6-x86.zip'
|
|
||||||
dest "$torBinaryDir/tor_x86.zip"
|
|
||||||
onlyIfNewer true
|
|
||||||
}
|
|
||||||
|
|
||||||
task downloadTorBinaryX86Pie(type: Download) {
|
|
||||||
src 'https://briarproject.org/build/tor-0.2.7.6-x86-pie.zip'
|
|
||||||
dest "$torBinaryDir/tor_x86_pie.zip"
|
|
||||||
onlyIfNewer true
|
|
||||||
}
|
|
||||||
|
|
||||||
task verifyTorGeoIp(type: Verify, dependsOn: 'downloadTorGeoIp') {
|
|
||||||
src "$torBinaryDir/geoip.zip"
|
|
||||||
algorithm 'SHA-256'
|
|
||||||
checksum '9bcdaf0a7ba0933735328d8ec466c25c25dbb459efc2bce9e55c774eabea5162'
|
|
||||||
}
|
|
||||||
|
|
||||||
task verifyTorBinaryArm(type: Verify, dependsOn: 'downloadTorBinaryArm') {
|
|
||||||
src "$torBinaryDir/tor_arm.zip"
|
|
||||||
algorithm 'SHA-256'
|
|
||||||
checksum '83272962eda701cd5d74d2418651c4ff0f0b1dff51f558a292d1a1c42bf12146'
|
|
||||||
}
|
|
||||||
|
|
||||||
task verifyTorBinaryArmPie(type: Verify, dependsOn: 'downloadTorBinaryArmPie') {
|
|
||||||
src "$torBinaryDir/tor_arm_pie.zip"
|
|
||||||
algorithm 'SHA-256'
|
|
||||||
checksum 'd0300d1e45de11ebb24ed62b9c492be9c2e88590b7822195ab38c7a76ffcf646'
|
|
||||||
}
|
|
||||||
|
|
||||||
task verifyTorBinaryX86(type: Verify, dependsOn: 'downloadTorBinaryX86') {
|
|
||||||
src "$torBinaryDir/tor_x86.zip"
|
|
||||||
algorithm 'SHA-256'
|
|
||||||
checksum 'b8813d97b01ee1b9c9a4233c1b9bbe9f9f6b494ae6f9cbd84de8a3911911615e'
|
|
||||||
}
|
|
||||||
|
|
||||||
task verifyTorBinaryX86Pie(type: Verify, dependsOn: 'downloadTorBinaryX86Pie') {
|
|
||||||
src "$torBinaryDir/tor_x86_pie.zip"
|
|
||||||
algorithm 'SHA-256'
|
|
||||||
checksum '9c66e765aa196dc089951a1b2140cc8290305c2fcbf365121f99e01a233baf4e'
|
|
||||||
}
|
|
||||||
|
|
||||||
project.afterEvaluate {
|
|
||||||
preBuild.dependsOn {
|
|
||||||
[
|
|
||||||
'verifyTorGeoIp',
|
|
||||||
'verifyTorBinaryArm',
|
|
||||||
'verifyTorBinaryArmPie',
|
|
||||||
'verifyTorBinaryX86',
|
|
||||||
'verifyTorBinaryX86Pie'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
-keep,includedescriptorclasses class org.briarproject.** { *; }
|
|
||||||
|
|
||||||
-keep class org.h2.** { *; }
|
|
||||||
-dontwarn org.h2.**
|
|
||||||
-dontnote org.h2.**
|
|
||||||
|
|
||||||
-keep class dagger.** { *; }
|
|
||||||
-dontwarn dagger.**
|
|
||||||
-dontnote dagger.**
|
|
||||||
|
|
||||||
-dontwarn sun.misc.Unsafe
|
|
||||||
-dontnote com.google.common.**
|
|
||||||
|
|
||||||
# UPnP library isn't used
|
|
||||||
-dontwarn org.bitlet.weupnp.**
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<manifest
|
|
||||||
package="org.briarproject.bramble"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<uses-feature android:name="android.hardware.bluetooth"/>
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH"/>
|
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
|
||||||
<uses-permission android:name="android.permission.READ_LOGS"/>
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
||||||
<!-- Since API 23, this is needed to add contacts via Bluetooth -->
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
|
||||||
|
|
||||||
<application
|
|
||||||
android:allowBackup="false"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:supportsRtl="true">
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package org.briarproject.bramble;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.plugin.AndroidPluginModule;
|
|
||||||
import org.briarproject.bramble.system.AndroidSystemModule;
|
|
||||||
|
|
||||||
import dagger.Module;
|
|
||||||
|
|
||||||
@Module(includes = {
|
|
||||||
AndroidPluginModule.class,
|
|
||||||
AndroidSystemModule.class
|
|
||||||
})
|
|
||||||
public class BrambleAndroidModule {
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
package org.briarproject.bramble.system;
|
|
||||||
|
|
||||||
import android.app.Application;
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.wifi.WifiConfiguration;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import static android.content.Context.WIFI_SERVICE;
|
|
||||||
import static android.provider.Settings.Secure.ANDROID_ID;
|
|
||||||
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
class AndroidSecureRandomProvider extends LinuxSecureRandomProvider {
|
|
||||||
|
|
||||||
private static final int SEED_LENGTH = 32;
|
|
||||||
|
|
||||||
private final Context appContext;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
AndroidSecureRandomProvider(Application app) {
|
|
||||||
appContext = app.getApplicationContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeToEntropyPool(DataOutputStream out) throws IOException {
|
|
||||||
super.writeToEntropyPool(out);
|
|
||||||
out.writeInt(android.os.Process.myPid());
|
|
||||||
out.writeInt(android.os.Process.myTid());
|
|
||||||
out.writeInt(android.os.Process.myUid());
|
|
||||||
if (Build.FINGERPRINT != null) out.writeUTF(Build.FINGERPRINT);
|
|
||||||
if (Build.SERIAL != null) out.writeUTF(Build.SERIAL);
|
|
||||||
ContentResolver contentResolver = appContext.getContentResolver();
|
|
||||||
String id = Settings.Secure.getString(contentResolver, ANDROID_ID);
|
|
||||||
if (id != null) out.writeUTF(id);
|
|
||||||
Parcel parcel = Parcel.obtain();
|
|
||||||
WifiManager wm =
|
|
||||||
(WifiManager) appContext.getSystemService(WIFI_SERVICE);
|
|
||||||
List<WifiConfiguration> configs = wm.getConfiguredNetworks();
|
|
||||||
if (configs != null) {
|
|
||||||
for (WifiConfiguration config : configs)
|
|
||||||
parcel.writeParcelable(config, 0);
|
|
||||||
}
|
|
||||||
BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter();
|
|
||||||
if (bt != null) {
|
|
||||||
for (BluetoothDevice device : bt.getBondedDevices())
|
|
||||||
parcel.writeParcelable(device, 0);
|
|
||||||
}
|
|
||||||
out.write(parcel.marshall());
|
|
||||||
parcel.recycle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeSeed() {
|
|
||||||
super.writeSeed();
|
|
||||||
if (Build.VERSION.SDK_INT >= 16 && Build.VERSION.SDK_INT <= 18)
|
|
||||||
applyOpenSslFix();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Based on https://android-developers.googleblog.com/2013/08/some-securerandom-thoughts.html
|
|
||||||
private void applyOpenSslFix() {
|
|
||||||
byte[] seed = new LinuxSecureRandomSpi().engineGenerateSeed(
|
|
||||||
SEED_LENGTH);
|
|
||||||
try {
|
|
||||||
// Seed the OpenSSL PRNG
|
|
||||||
Class.forName("org.apache.harmony.xnet.provider.jsse.NativeCrypto")
|
|
||||||
.getMethod("RAND_seed", byte[].class)
|
|
||||||
.invoke(null, seed);
|
|
||||||
// Mix the output of the Linux PRNG into the OpenSSL PRNG
|
|
||||||
int bytesRead = (Integer) Class.forName(
|
|
||||||
"org.apache.harmony.xnet.provider.jsse.NativeCrypto")
|
|
||||||
.getMethod("RAND_load_file", String.class, long.class)
|
|
||||||
.invoke(null, "/dev/urandom", 1024);
|
|
||||||
if (bytesRead != 1024) throw new IOException();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new SecurityException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package org.briarproject.bramble.system;
|
|
||||||
|
|
||||||
import android.app.Application;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.system.AndroidExecutor;
|
|
||||||
import org.briarproject.bramble.api.system.LocationUtils;
|
|
||||||
import org.briarproject.bramble.api.system.SecureRandomProvider;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import dagger.Module;
|
|
||||||
import dagger.Provides;
|
|
||||||
|
|
||||||
@Module
|
|
||||||
public class AndroidSystemModule {
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
SecureRandomProvider provideSecureRandomProvider(Application app) {
|
|
||||||
return new AndroidSecureRandomProvider(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
LocationUtils provideLocationUtils(Application app) {
|
|
||||||
return new AndroidLocationUtils(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
AndroidExecutor provideAndroidExecutor(Application app) {
|
|
||||||
return new AndroidExecutorImpl(app);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
package org.briarproject.bramble.util;
|
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static android.content.Context.MODE_PRIVATE;
|
|
||||||
|
|
||||||
public class AndroidUtils {
|
|
||||||
|
|
||||||
// Fake Bluetooth address returned by BluetoothAdapter on API 23 and later
|
|
||||||
private static final String FAKE_BLUETOOTH_ADDRESS = "02:00:00:00:00:00";
|
|
||||||
|
|
||||||
private static final String STORED_REPORTS = "dev-reports";
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static Collection<String> getSupportedArchitectures() {
|
|
||||||
List<String> abis = new ArrayList<>();
|
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
|
||||||
abis.addAll(Arrays.asList(Build.SUPPORTED_ABIS));
|
|
||||||
} else {
|
|
||||||
abis.add(Build.CPU_ABI);
|
|
||||||
if (Build.CPU_ABI2 != null) abis.add(Build.CPU_ABI2);
|
|
||||||
}
|
|
||||||
return abis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getBluetoothAddress(Context ctx,
|
|
||||||
BluetoothAdapter adapter) {
|
|
||||||
// Return the adapter's address if it's valid and not fake
|
|
||||||
String address = adapter.getAddress();
|
|
||||||
if (isValidBluetoothAddress(address)) return address;
|
|
||||||
// Return the address from settings if it's valid and not fake
|
|
||||||
address = Settings.Secure.getString(ctx.getContentResolver(),
|
|
||||||
"bluetooth_address");
|
|
||||||
if (isValidBluetoothAddress(address)) return address;
|
|
||||||
// Let the caller know we can't find the address
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isValidBluetoothAddress(String address) {
|
|
||||||
return !StringUtils.isNullOrEmpty(address)
|
|
||||||
&& BluetoothAdapter.checkBluetoothAddress(address)
|
|
||||||
&& !address.equals(FAKE_BLUETOOTH_ADDRESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void deleteAppData(Context ctx) {
|
|
||||||
File dataDir = new File(ctx.getApplicationInfo().dataDir);
|
|
||||||
File[] children = dataDir.listFiles();
|
|
||||||
if (children != null) {
|
|
||||||
for (File child : children) {
|
|
||||||
if (!child.getName().equals("lib"))
|
|
||||||
IoUtils.deleteFileOrDir(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Recreate the cache dir as some OpenGL drivers expect it to exist
|
|
||||||
new File(dataDir, "cache").mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getReportDir(Context ctx) {
|
|
||||||
return ctx.getDir(STORED_REPORTS, MODE_PRIVATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">Bramble</string>
|
|
||||||
</resources>
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
apply plugin: 'java'
|
|
||||||
sourceCompatibility = 1.6
|
|
||||||
targetCompatibility = 1.6
|
|
||||||
|
|
||||||
apply plugin: 'witness'
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile "com.google.dagger:dagger:2.0.2"
|
|
||||||
compile 'com.google.dagger:dagger-compiler:2.0.2'
|
|
||||||
compile 'com.google.code.findbugs:jsr305:3.0.1'
|
|
||||||
|
|
||||||
testCompile 'junit:junit:4.12'
|
|
||||||
testCompile "org.jmock:jmock:2.8.1"
|
|
||||||
testCompile "org.jmock:jmock-junit4:2.8.1"
|
|
||||||
testCompile "org.jmock:jmock-legacy:2.8.1"
|
|
||||||
testCompile "org.hamcrest:hamcrest-library:1.3"
|
|
||||||
testCompile "org.hamcrest:hamcrest-core:1.3"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencyVerification {
|
|
||||||
verify = [
|
|
||||||
'com.google.dagger:dagger:84c0282ed8be73a29e0475d639da030b55dee72369e58dd35ae7d4fe6243dcf9',
|
|
||||||
'com.google.dagger:dagger-compiler:b74bc9de063dd4c6400b232231f2ef5056145b8fbecbf5382012007dd1c071b3',
|
|
||||||
'com.google.code.findbugs:jsr305:c885ce34249682bc0236b4a7d56efcc12048e6135a5baf7a9cde8ad8cda13fcd',
|
|
||||||
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
|
|
||||||
'com.google.dagger:dagger-producers:99ec15e8a0507ba569e7655bc1165ee5e5ca5aa914b3c8f7e2c2458f724edd6b',
|
|
||||||
'com.google.guava:guava:d664fbfc03d2e5ce9cab2a44fb01f1d0bf9dfebeccc1a473b1f9ea31f79f6f99',
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
// needed to make test output available to bramble-core and briar-core
|
|
||||||
configurations {
|
|
||||||
testOutput.extendsFrom(testCompile)
|
|
||||||
}
|
|
||||||
task jarTest(type: Jar, dependsOn: testClasses) {
|
|
||||||
from sourceSets.test.output
|
|
||||||
classifier = 'test'
|
|
||||||
}
|
|
||||||
artifacts {
|
|
||||||
testOutput jarTest
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package org.briarproject.bramble.api;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An exception that indicates an unrecoverable formatting error.
|
|
||||||
*/
|
|
||||||
public class FormatException extends IOException {
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package org.briarproject.bramble.api;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.ThreadSafe;
|
|
||||||
|
|
||||||
@ThreadSafe
|
|
||||||
@NotNullByDefault
|
|
||||||
public abstract class UniqueId extends Bytes {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The length of a unique identifier in bytes.
|
|
||||||
*/
|
|
||||||
public static final int LENGTH = 32;
|
|
||||||
|
|
||||||
protected UniqueId(byte[] id) {
|
|
||||||
super(id);
|
|
||||||
if (id.length != LENGTH) throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.client;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class BdfMessageContext {
|
|
||||||
|
|
||||||
private final BdfDictionary dictionary;
|
|
||||||
private final Collection<MessageId> dependencies;
|
|
||||||
|
|
||||||
public BdfMessageContext(BdfDictionary dictionary,
|
|
||||||
Collection<MessageId> dependencies) {
|
|
||||||
this.dictionary = dictionary;
|
|
||||||
this.dependencies = dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BdfMessageContext(BdfDictionary dictionary) {
|
|
||||||
this(dictionary, Collections.<MessageId>emptyList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BdfDictionary getDictionary() {
|
|
||||||
return dictionary;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<MessageId> getDependencies() {
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.client;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.FormatException;
|
|
||||||
import org.briarproject.bramble.api.data.BdfList;
|
|
||||||
import org.briarproject.bramble.api.data.MetadataEncoder;
|
|
||||||
import org.briarproject.bramble.api.db.Metadata;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.sync.Group;
|
|
||||||
import org.briarproject.bramble.api.sync.InvalidMessageException;
|
|
||||||
import org.briarproject.bramble.api.sync.Message;
|
|
||||||
import org.briarproject.bramble.api.sync.MessageContext;
|
|
||||||
import org.briarproject.bramble.api.sync.ValidationManager.MessageValidator;
|
|
||||||
import org.briarproject.bramble.api.system.Clock;
|
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
import static org.briarproject.bramble.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
|
||||||
import static org.briarproject.bramble.api.transport.TransportConstants.MAX_CLOCK_DIFFERENCE;
|
|
||||||
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public abstract class BdfMessageValidator implements MessageValidator {
|
|
||||||
|
|
||||||
protected static final Logger LOG =
|
|
||||||
Logger.getLogger(BdfMessageValidator.class.getName());
|
|
||||||
|
|
||||||
protected final ClientHelper clientHelper;
|
|
||||||
protected final MetadataEncoder metadataEncoder;
|
|
||||||
protected final Clock clock;
|
|
||||||
|
|
||||||
protected BdfMessageValidator(ClientHelper clientHelper,
|
|
||||||
MetadataEncoder metadataEncoder, Clock clock) {
|
|
||||||
this.clientHelper = clientHelper;
|
|
||||||
this.metadataEncoder = metadataEncoder;
|
|
||||||
this.clock = clock;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract BdfMessageContext validateMessage(Message m, Group g,
|
|
||||||
BdfList body) throws InvalidMessageException, FormatException;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MessageContext validateMessage(Message m, Group g)
|
|
||||||
throws InvalidMessageException {
|
|
||||||
// Reject the message if it's too far in the future
|
|
||||||
long now = clock.currentTimeMillis();
|
|
||||||
if (m.getTimestamp() - now > MAX_CLOCK_DIFFERENCE) {
|
|
||||||
throw new InvalidMessageException(
|
|
||||||
"Timestamp is too far in the future");
|
|
||||||
}
|
|
||||||
byte[] raw = m.getRaw();
|
|
||||||
if (raw.length <= MESSAGE_HEADER_LENGTH) {
|
|
||||||
throw new InvalidMessageException("Message is too short");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
BdfList body = clientHelper.toList(raw, MESSAGE_HEADER_LENGTH,
|
|
||||||
raw.length - MESSAGE_HEADER_LENGTH);
|
|
||||||
BdfMessageContext result = validateMessage(m, g, body);
|
|
||||||
Metadata meta = metadataEncoder.encode(result.getDictionary());
|
|
||||||
return new MessageContext(meta, result.getDependencies());
|
|
||||||
} catch (FormatException e) {
|
|
||||||
throw new InvalidMessageException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.client;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.Contact;
|
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.sync.ClientId;
|
|
||||||
import org.briarproject.bramble.api.sync.Group;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface ContactGroupFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a group that is not shared with any contacts.
|
|
||||||
*/
|
|
||||||
Group createLocalGroup(ClientId clientId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a group for the given client to share with the given contact.
|
|
||||||
*/
|
|
||||||
Group createContactGroup(ClientId clientId, Contact contact);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a group for the given client to share between the given authors
|
|
||||||
* identified by their AuthorIds.
|
|
||||||
*/
|
|
||||||
Group createContactGroup(ClientId clientId, AuthorId authorId1,
|
|
||||||
AuthorId authorId2);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.contact;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface ContactExchangeListener {
|
|
||||||
|
|
||||||
void contactExchangeSucceeded(Author remoteAuthor);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The exchange failed because the contact already exists.
|
|
||||||
*/
|
|
||||||
void duplicateContact(Author remoteAuthor);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A general failure.
|
|
||||||
*/
|
|
||||||
void contactExchangeFailed();
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.contact;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
|
||||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.plugin.TransportId;
|
|
||||||
import org.briarproject.bramble.api.plugin.duplex.DuplexTransportConnection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A task for conducting a contact information exchange with a remote peer.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface ContactExchangeTask {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exchanges contact information with a remote peer.
|
|
||||||
*/
|
|
||||||
void startExchange(ContactExchangeListener listener,
|
|
||||||
LocalAuthor localAuthor, SecretKey masterSecret,
|
|
||||||
DuplexTransportConnection conn, TransportId transportId,
|
|
||||||
boolean alice);
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.contact;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
|
||||||
import org.briarproject.bramble.api.db.Transaction;
|
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface ContactManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a hook to be called whenever a contact is added.
|
|
||||||
*/
|
|
||||||
void registerAddContactHook(AddContactHook hook);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a hook to be called whenever a contact is removed.
|
|
||||||
*/
|
|
||||||
void registerRemoveContactHook(RemoveContactHook hook);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores a contact within the given transaction associated with the given
|
|
||||||
* local and remote pseudonyms, and returns an ID for the contact.
|
|
||||||
*/
|
|
||||||
ContactId addContact(Transaction txn, Author remote, AuthorId local,
|
|
||||||
SecretKey master, long timestamp, boolean alice, boolean verified,
|
|
||||||
boolean active) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores a contact associated with the given local and remote pseudonyms,
|
|
||||||
* and returns an ID for the contact.
|
|
||||||
*/
|
|
||||||
ContactId addContact(Author remote, AuthorId local,
|
|
||||||
SecretKey master, long timestamp, boolean alice, boolean verified,
|
|
||||||
boolean active) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the contact with the given ID.
|
|
||||||
*/
|
|
||||||
Contact getContact(ContactId c) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the contact with the given remoteAuthorId
|
|
||||||
* that was added by the LocalAuthor with the given localAuthorId
|
|
||||||
*
|
|
||||||
* @throws org.briarproject.bramble.api.db.NoSuchContactException
|
|
||||||
*/
|
|
||||||
Contact getContact(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
|
||||||
throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the contact with the given remoteAuthorId
|
|
||||||
* that was added by the LocalAuthor with the given localAuthorId
|
|
||||||
*
|
|
||||||
* @throws org.briarproject.bramble.api.db.NoSuchContactException
|
|
||||||
*/
|
|
||||||
Contact getContact(Transaction txn, AuthorId remoteAuthorId,
|
|
||||||
AuthorId localAuthorId) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all active contacts.
|
|
||||||
*/
|
|
||||||
Collection<Contact> getActiveContacts() throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a contact and all associated state.
|
|
||||||
*/
|
|
||||||
void removeContact(ContactId c) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a contact and all associated state.
|
|
||||||
*/
|
|
||||||
void removeContact(Transaction txn, ContactId c) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks a contact as active or inactive.
|
|
||||||
*/
|
|
||||||
void setContactActive(Transaction txn, ContactId c, boolean active)
|
|
||||||
throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if a contact with this name and public key already exists
|
|
||||||
*/
|
|
||||||
boolean contactExists(Transaction txn, AuthorId remoteAuthorId,
|
|
||||||
AuthorId localAuthorId) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if a contact with this name and public key already exists
|
|
||||||
*/
|
|
||||||
boolean contactExists(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
|
||||||
throws DbException;
|
|
||||||
|
|
||||||
interface AddContactHook {
|
|
||||||
void addingContact(Transaction txn, Contact c) throws DbException;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RemoveContactHook {
|
|
||||||
void removingContact(Transaction txn, Contact c) throws DbException;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.contact.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a contact is added.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class ContactAddedEvent extends Event {
|
|
||||||
|
|
||||||
private final ContactId contactId;
|
|
||||||
private final boolean active;
|
|
||||||
|
|
||||||
public ContactAddedEvent(ContactId contactId, boolean active) {
|
|
||||||
this.contactId = contactId;
|
|
||||||
this.active = active;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContactId getContactId() {
|
|
||||||
return contactId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActive() {
|
|
||||||
return active;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.contact.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a contact is removed.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class ContactRemovedEvent extends Event {
|
|
||||||
|
|
||||||
private final ContactId contactId;
|
|
||||||
|
|
||||||
public ContactRemovedEvent(ContactId contactId) {
|
|
||||||
this.contactId = contactId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContactId getContactId() {
|
|
||||||
return contactId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.contact.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a contact is marked active or inactive.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class ContactStatusChangedEvent extends Event {
|
|
||||||
|
|
||||||
private final ContactId contactId;
|
|
||||||
private final boolean active;
|
|
||||||
|
|
||||||
public ContactStatusChangedEvent(ContactId contactId, boolean active) {
|
|
||||||
this.contactId = contactId;
|
|
||||||
this.active = active;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContactId getContactId() {
|
|
||||||
return contactId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActive() {
|
|
||||||
return active;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.contact.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a contact is verified.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class ContactVerifiedEvent extends Event {
|
|
||||||
|
|
||||||
private final ContactId contactId;
|
|
||||||
|
|
||||||
public ContactVerifiedEvent(ContactId contactId) {
|
|
||||||
this.contactId = contactId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContactId getContactId() {
|
|
||||||
return contactId;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.crypto;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
import javax.inject.Qualifier;
|
|
||||||
|
|
||||||
import static java.lang.annotation.ElementType.FIELD;
|
|
||||||
import static java.lang.annotation.ElementType.METHOD;
|
|
||||||
import static java.lang.annotation.ElementType.PARAMETER;
|
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation for injecting the executor for long-running crypto tasks. Also
|
|
||||||
* used for annotating methods that should run on the crypto executor.
|
|
||||||
* <p>
|
|
||||||
* The contract of this executor is that tasks may be run concurrently, and
|
|
||||||
* submitting a task will never block. Tasks must not run indefinitely. Tasks
|
|
||||||
* submitted during shutdown are discarded.
|
|
||||||
*/
|
|
||||||
@Qualifier
|
|
||||||
@Target({FIELD, METHOD, PARAMETER})
|
|
||||||
@Retention(RUNTIME)
|
|
||||||
public @interface CryptoExecutor {
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.crypto;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The private half of a public/private {@link KeyPair}.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface PrivateKey {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the encoded representation of this key.
|
|
||||||
*/
|
|
||||||
byte[] getEncoded();
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.crypto;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A deterministic pseudo-random number generator.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface PseudoRandom {
|
|
||||||
|
|
||||||
byte[] nextBytes(int bytes);
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.crypto;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The public half of a public/private {@link KeyPair}.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface PublicKey {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the encoded representation of this key.
|
|
||||||
*/
|
|
||||||
byte[] getEncoded();
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.crypto;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface StreamEncrypter {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encrypts the given frame and writes it to the stream.
|
|
||||||
*/
|
|
||||||
void writeFrame(byte[] payload, int payloadLength, int paddingLength,
|
|
||||||
boolean finalFrame) throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flushes the stream.
|
|
||||||
*/
|
|
||||||
void flush() throws IOException;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.data;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface BdfReaderFactory {
|
|
||||||
|
|
||||||
BdfReader createReader(InputStream in);
|
|
||||||
|
|
||||||
BdfReader createReader(InputStream in, int nestedLimit);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.data;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface BdfWriterFactory {
|
|
||||||
|
|
||||||
BdfWriter createWriter(OutputStream out);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.data;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.FormatException;
|
|
||||||
import org.briarproject.bramble.api.db.Metadata;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface MetadataEncoder {
|
|
||||||
|
|
||||||
Metadata encode(BdfDictionary d) throws FormatException;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.data;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.FormatException;
|
|
||||||
import org.briarproject.bramble.api.db.Metadata;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface MetadataParser {
|
|
||||||
|
|
||||||
BdfDictionary parse(Metadata m) throws FormatException;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.data;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface ObjectReader<T> {
|
|
||||||
|
|
||||||
T readObject(BdfReader r) throws IOException;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.db;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface DatabaseConfig {
|
|
||||||
|
|
||||||
boolean databaseExists();
|
|
||||||
|
|
||||||
File getDatabaseDirectory();
|
|
||||||
|
|
||||||
void setEncryptionKey(SecretKey key);
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
SecretKey getEncryptionKey();
|
|
||||||
|
|
||||||
void setLocalAuthorName(String nickname);
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String getLocalAuthorName();
|
|
||||||
|
|
||||||
long getMaxSize();
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.db;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
import javax.inject.Qualifier;
|
|
||||||
|
|
||||||
import static java.lang.annotation.ElementType.FIELD;
|
|
||||||
import static java.lang.annotation.ElementType.METHOD;
|
|
||||||
import static java.lang.annotation.ElementType.PARAMETER;
|
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation for injecting the executor for database tasks. Also used for
|
|
||||||
* annotating methods that should run on the database executor.
|
|
||||||
* <p>
|
|
||||||
* The contract of this executor is that tasks are run in the order they're
|
|
||||||
* submitted, tasks are not run concurrently, and submitting a task will never
|
|
||||||
* block. Tasks must not run indefinitely. Tasks submitted during shutdown are
|
|
||||||
* discarded.
|
|
||||||
*/
|
|
||||||
@Qualifier
|
|
||||||
@Target({FIELD, METHOD, PARAMETER})
|
|
||||||
@Retention(RUNTIME)
|
|
||||||
public @interface DatabaseExecutor {
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.db;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Thrown when a database operation is attempted and the database is closed.
|
|
||||||
*/
|
|
||||||
public class DbClosedException extends DbException {
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.db;
|
|
||||||
|
|
||||||
public class DbException extends Exception {
|
|
||||||
|
|
||||||
public DbException() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public DbException(Throwable t) {
|
|
||||||
super(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.event;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An abstract superclass for events.
|
|
||||||
*/
|
|
||||||
public abstract class Event {
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface EventBus {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a listener to be notified when events occur.
|
|
||||||
*/
|
|
||||||
void addListener(EventListener l);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a listener.
|
|
||||||
*/
|
|
||||||
void removeListener(EventListener l);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notifies all listeners of an event.
|
|
||||||
*/
|
|
||||||
void broadcast(Event e);
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An interface for receiving notifications when events occur.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface EventListener {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when an event is broadcast. Implementations of this method must
|
|
||||||
* not block.
|
|
||||||
*/
|
|
||||||
void eventOccurred(Event e);
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.identity;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
|
||||||
import org.briarproject.bramble.api.db.Transaction;
|
|
||||||
import org.briarproject.bramble.api.identity.Author.Status;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface IdentityManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores the local pseudonym.
|
|
||||||
*/
|
|
||||||
void registerLocalAuthor(LocalAuthor a) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the cached main local identity, non-blocking, or loads it from
|
|
||||||
* the db, blocking
|
|
||||||
*/
|
|
||||||
LocalAuthor getLocalAuthor() throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the cached main local identity, non-blocking, or loads it from
|
|
||||||
* the db, blocking, within the given Transaction.
|
|
||||||
*/
|
|
||||||
LocalAuthor getLocalAuthor(Transaction txn) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the trust-level status of the author
|
|
||||||
*/
|
|
||||||
Status getAuthorStatus(AuthorId a) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the trust-level status of the author
|
|
||||||
*/
|
|
||||||
Status getAuthorStatus(Transaction txn, AuthorId a) throws DbException;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.identity.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a local pseudonym is added.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class LocalAuthorAddedEvent extends Event {
|
|
||||||
|
|
||||||
private final AuthorId authorId;
|
|
||||||
|
|
||||||
public LocalAuthorAddedEvent(AuthorId authorId) {
|
|
||||||
this.authorId = authorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthorId getAuthorId() {
|
|
||||||
return authorId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.identity.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a local pseudonym is removed.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class LocalAuthorRemovedEvent extends Event {
|
|
||||||
|
|
||||||
private final AuthorId authorId;
|
|
||||||
|
|
||||||
public LocalAuthorRemovedEvent(AuthorId authorId) {
|
|
||||||
this.authorId = authorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthorId getAuthorId() {
|
|
||||||
return authorId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.invitation;
|
|
||||||
|
|
||||||
public interface InvitationConstants {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The connection timeout in milliseconds.
|
|
||||||
*/
|
|
||||||
long CONNECTION_TIMEOUT = 60 * 1000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The confirmation timeout in milliseconds.
|
|
||||||
*/
|
|
||||||
long CONFIRMATION_TIMEOUT = 60 * 1000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The number of bits in an invitation or confirmation code. Codes must fit
|
|
||||||
* into six decimal digits.
|
|
||||||
*/
|
|
||||||
int CODE_BITS = 19;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.invitation;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates tasks for exchanging invitations with remote peers.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface InvitationTaskFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a task using the given local and remote invitation codes.
|
|
||||||
*/
|
|
||||||
InvitationTask createTask(int localCode, int remoteCode);
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.keyagreement;
|
|
||||||
|
|
||||||
public interface KeyAgreementConstants {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current version of the BQP protocol.
|
|
||||||
*/
|
|
||||||
byte PROTOCOL_VERSION = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The length of the record header in bytes.
|
|
||||||
*/
|
|
||||||
int RECORD_HEADER_LENGTH = 4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The offset of the payload length in the record header, in bytes.
|
|
||||||
*/
|
|
||||||
int RECORD_HEADER_PAYLOAD_LENGTH_OFFSET = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The length of the BQP key commitment in bytes.
|
|
||||||
*/
|
|
||||||
int COMMIT_LENGTH = 16;
|
|
||||||
|
|
||||||
long CONNECTION_TIMEOUT = 20 * 1000; // Milliseconds
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The transport identifier for Bluetooth.
|
|
||||||
*/
|
|
||||||
int TRANSPORT_ID_BLUETOOTH = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The transport identifier for LAN.
|
|
||||||
*/
|
|
||||||
int TRANSPORT_ID_LAN = 1;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.keyagreement;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manages tasks for conducting key agreements with remote peers.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface KeyAgreementTaskFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current key agreement task.
|
|
||||||
*/
|
|
||||||
KeyAgreementTask createTask();
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.keyagreement;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface PayloadEncoder {
|
|
||||||
|
|
||||||
byte[] encode(Payload p);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.keyagreement;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface PayloadParser {
|
|
||||||
|
|
||||||
Payload parse(byte[] raw) throws IOException;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.keyagreement;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.data.BdfList;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.plugin.TransportId;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class TransportDescriptor {
|
|
||||||
|
|
||||||
private final TransportId id;
|
|
||||||
private final BdfList descriptor;
|
|
||||||
|
|
||||||
public TransportDescriptor(TransportId id, BdfList descriptor) {
|
|
||||||
this.id = id;
|
|
||||||
this.descriptor = descriptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransportId getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BdfList getDescriptor() {
|
|
||||||
return descriptor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.keyagreement.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a BQP protocol aborts.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class KeyAgreementAbortedEvent extends Event {
|
|
||||||
|
|
||||||
private final boolean remoteAborted;
|
|
||||||
|
|
||||||
public KeyAgreementAbortedEvent(boolean remoteAborted) {
|
|
||||||
this.remoteAborted = remoteAborted;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean didRemoteAbort() {
|
|
||||||
return remoteAborted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.keyagreement.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a BQP connection cannot be created.
|
|
||||||
*/
|
|
||||||
public class KeyAgreementFailedEvent extends Event {
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.keyagreement.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.keyagreement.KeyAgreementResult;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a BQP protocol completes.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class KeyAgreementFinishedEvent extends Event {
|
|
||||||
|
|
||||||
private final KeyAgreementResult result;
|
|
||||||
|
|
||||||
public KeyAgreementFinishedEvent(KeyAgreementResult result) {
|
|
||||||
this.result = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KeyAgreementResult getResult() {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.keyagreement.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.keyagreement.Payload;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a BQP task is listening.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class KeyAgreementListeningEvent extends Event {
|
|
||||||
|
|
||||||
private final Payload localPayload;
|
|
||||||
|
|
||||||
public KeyAgreementListeningEvent(Payload localPayload) {
|
|
||||||
this.localPayload = localPayload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Payload getLocalPayload() {
|
|
||||||
return localPayload;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.keyagreement.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a BQP protocol completes.
|
|
||||||
*/
|
|
||||||
public class KeyAgreementStartedEvent extends Event {
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.lifecycle;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
import javax.inject.Qualifier;
|
|
||||||
|
|
||||||
import static java.lang.annotation.ElementType.FIELD;
|
|
||||||
import static java.lang.annotation.ElementType.METHOD;
|
|
||||||
import static java.lang.annotation.ElementType.PARAMETER;
|
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotation for injecting the executor for long-running IO tasks. Also used
|
|
||||||
* for annotating methods that should run on the UI executor.
|
|
||||||
* <p>
|
|
||||||
* The contract of this executor is that tasks may be run concurrently, and
|
|
||||||
* submitting a task will never block. Tasks may run indefinitely. Tasks
|
|
||||||
* submitted during shutdown are discarded.
|
|
||||||
*/
|
|
||||||
@Qualifier
|
|
||||||
@Target({FIELD, METHOD, PARAMETER})
|
|
||||||
@Retention(RUNTIME)
|
|
||||||
public @interface IoExecutor {
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.lifecycle;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.sync.Client;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manages the lifecycle of the app, starting {@link Client Clients}, starting
|
|
||||||
* and stopping {@link Service Services}, shutting down
|
|
||||||
* {@link ExecutorService ExecutorServices}, and opening and closing the
|
|
||||||
* {@link DatabaseComponent}.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface LifecycleManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The result of calling {@link #startServices(String)}.
|
|
||||||
*/
|
|
||||||
enum StartResult {
|
|
||||||
ALREADY_RUNNING, DB_ERROR, SERVICE_ERROR, SUCCESS
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a {@link Service} to be started and stopped.
|
|
||||||
*/
|
|
||||||
void registerService(Service s);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a {@link Client} to be started.
|
|
||||||
*/
|
|
||||||
void registerClient(Client c);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an {@link ExecutorService} to be shut down.
|
|
||||||
*/
|
|
||||||
void registerForShutdown(ExecutorService e);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens the {@link DatabaseComponent}, optionally creates a local author
|
|
||||||
* with the provided nickname, and starts any registered
|
|
||||||
* {@link Client Clients} and {@link Service Services}.
|
|
||||||
*/
|
|
||||||
StartResult startServices(@Nullable String nickname);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stops any registered {@link Service Services}, shuts down any
|
|
||||||
* registered {@link ExecutorService ExecutorServices}, and closes the
|
|
||||||
* {@link DatabaseComponent}.
|
|
||||||
*/
|
|
||||||
void stopServices();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Waits for the {@link DatabaseComponent} to be opened before returning.
|
|
||||||
*/
|
|
||||||
void waitForDatabase() throws InterruptedException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Waits for the {@link DatabaseComponent} to be opened and all registered
|
|
||||||
* {@link Client Clients} and {@link Service Services} to start before
|
|
||||||
* returning.
|
|
||||||
*/
|
|
||||||
void waitForStartup() throws InterruptedException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Waits for all registered {@link Service Services} to stop, all
|
|
||||||
* registered {@link ExecutorService ExecutorServices} to shut down, and
|
|
||||||
* the {@link DatabaseComponent} to be closed before returning.
|
|
||||||
*/
|
|
||||||
void waitForShutdown() throws InterruptedException;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.lifecycle.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when the app is shutting down.
|
|
||||||
*/
|
|
||||||
public class ShutdownEvent extends Event {
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.nullsafety;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.meta.TypeQualifierDefault;
|
|
||||||
|
|
||||||
import static java.lang.annotation.ElementType.FIELD;
|
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This annotation can be applied to a package or class to indicate that
|
|
||||||
* the fields in that element are non-null by default unless:
|
|
||||||
* <ul>
|
|
||||||
* <li> There is an explicit nullness annotation
|
|
||||||
* <li> There is a default nullness annotation applied to a more tightly
|
|
||||||
* nested element.
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Nonnull
|
|
||||||
@TypeQualifierDefault(FIELD)
|
|
||||||
@Retention(RUNTIME)
|
|
||||||
public @interface FieldsNotNullByDefault {
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.nullsafety;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.meta.TypeQualifierDefault;
|
|
||||||
|
|
||||||
import static java.lang.annotation.ElementType.METHOD;
|
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This annotation can be applied to a package or class to indicate that
|
|
||||||
* the methods in that element are non-null by default unless:
|
|
||||||
* <ul>
|
|
||||||
* <li> There is an explicit nullness annotation
|
|
||||||
* <li> The method overrides a method in a superclass (in which case the
|
|
||||||
* annotation of the corresponding method in the superclass applies)
|
|
||||||
* <li> There is a default nullness annotation applied to a more tightly
|
|
||||||
* nested element.
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Nonnull
|
|
||||||
@TypeQualifierDefault(METHOD)
|
|
||||||
@Retention(RUNTIME)
|
|
||||||
public @interface MethodsNotNullByDefault {
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.nullsafety;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.meta.TypeQualifierDefault;
|
|
||||||
|
|
||||||
import static java.lang.annotation.ElementType.FIELD;
|
|
||||||
import static java.lang.annotation.ElementType.METHOD;
|
|
||||||
import static java.lang.annotation.ElementType.PARAMETER;
|
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This annotation can be applied to a package or class to indicate that
|
|
||||||
* the fields, methods and parameters in that element are non-null by default
|
|
||||||
* unless:
|
|
||||||
* <ul>
|
|
||||||
* <li> There is an explicit nullness annotation
|
|
||||||
* <li> The method overrides a method in a superclass (in which case the
|
|
||||||
* annotation of the corresponding method or parameter in the superclass
|
|
||||||
* applies)
|
|
||||||
* <li> There is a default nullness annotation applied to a more tightly
|
|
||||||
* nested element.
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Nonnull
|
|
||||||
@TypeQualifierDefault({FIELD, METHOD, PARAMETER})
|
|
||||||
@Retention(RUNTIME)
|
|
||||||
public @interface NotNullByDefault {
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.nullsafety;
|
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.meta.TypeQualifierDefault;
|
|
||||||
|
|
||||||
import static java.lang.annotation.ElementType.PARAMETER;
|
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This annotation can be applied to a package or class to indicate that
|
|
||||||
* the method parameters in that element are non-null by default unless:
|
|
||||||
* <ul>
|
|
||||||
* <li> There is an explicit nullness annotation
|
|
||||||
* <li> The method overrides a method in a superclass (in which case the
|
|
||||||
* annotation of the corresponding parameter in the superclass applies)
|
|
||||||
* <li> There is a default nullness annotation applied to a more tightly
|
|
||||||
* nested element.
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Nonnull
|
|
||||||
@TypeQualifierDefault(PARAMETER)
|
|
||||||
@Retention(RUNTIME)
|
|
||||||
public @interface ParametersNotNullByDefault {
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin;
|
|
||||||
|
|
||||||
public interface BluetoothConstants {
|
|
||||||
|
|
||||||
TransportId ID = new TransportId("org.briarproject.bramble.bluetooth");
|
|
||||||
|
|
||||||
int UUID_BYTES = 16;
|
|
||||||
|
|
||||||
String PROP_ADDRESS = "address";
|
|
||||||
String PROP_UUID = "uuid";
|
|
||||||
|
|
||||||
String PREF_BT_ENABLE = "enable";
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin;
|
|
||||||
|
|
||||||
public interface LanTcpConstants {
|
|
||||||
|
|
||||||
TransportId ID = new TransportId("org.briarproject.bramble.lan");
|
|
||||||
|
|
||||||
String PREF_LAN_IP_PORTS = "ipPorts";
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPluginFactory;
|
|
||||||
import org.briarproject.bramble.api.plugin.simplex.SimplexPluginFactory;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface PluginConfig {
|
|
||||||
|
|
||||||
Collection<DuplexPluginFactory> getDuplexFactories();
|
|
||||||
|
|
||||||
Collection<SimplexPluginFactory> getSimplexFactories();
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An exception that indicates an error starting or stopping a {@link Plugin}.
|
|
||||||
*/
|
|
||||||
public class PluginException extends Exception {
|
|
||||||
|
|
||||||
public PluginException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PluginException(Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin;
|
|
||||||
|
|
||||||
public interface TorConstants {
|
|
||||||
|
|
||||||
TransportId ID = new TransportId("org.briarproject.bramble.tor");
|
|
||||||
|
|
||||||
int SOCKS_PORT = 59050;
|
|
||||||
int CONTROL_PORT = 59051;
|
|
||||||
|
|
||||||
int CONNECT_TO_PROXY_TIMEOUT = 5000; // Milliseconds
|
|
||||||
|
|
||||||
String PREF_TOR_NETWORK = "network";
|
|
||||||
String PREF_TOR_PORT = "port";
|
|
||||||
|
|
||||||
int PREF_TOR_NETWORK_NEVER = 0;
|
|
||||||
int PREF_TOR_NETWORK_WIFI = 1;
|
|
||||||
int PREF_TOR_NETWORK_ALWAYS = 2;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin;
|
|
||||||
|
|
||||||
public interface WanTcpConstants {
|
|
||||||
|
|
||||||
TransportId ID = new TransportId("org.briarproject.bramble.wan");
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin.duplex;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.crypto.PseudoRandom;
|
|
||||||
import org.briarproject.bramble.api.data.BdfList;
|
|
||||||
import org.briarproject.bramble.api.keyagreement.KeyAgreementListener;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.plugin.Plugin;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An interface for transport plugins that support duplex communication.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface DuplexPlugin extends Plugin {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to create and return a connection to the given contact using
|
|
||||||
* the current transport and configuration properties. Returns null if a
|
|
||||||
* connection cannot be created.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
DuplexTransportConnection createConnection(ContactId c);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the plugin supports exchanging invitations.
|
|
||||||
*/
|
|
||||||
boolean supportsInvitations();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to create and return an invitation connection to the remote
|
|
||||||
* peer. Returns null if no connection can be established within the given
|
|
||||||
* time.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
DuplexTransportConnection createInvitationConnection(PseudoRandom r,
|
|
||||||
long timeout, boolean alice);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the plugin supports short-range key agreement.
|
|
||||||
*/
|
|
||||||
boolean supportsKeyAgreement();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to create and return a listener that can be used to perform key
|
|
||||||
* agreement. Returns null if a listener cannot be created.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
KeyAgreementListener createKeyAgreementListener(byte[] localCommitment);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to connect to the remote peer specified in the given descriptor.
|
|
||||||
* Returns null if no connection can be established within the given time.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
DuplexTransportConnection createKeyAgreementConnection(
|
|
||||||
byte[] remoteCommitment, BdfList descriptor, long timeout);
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin.duplex;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.plugin.TransportConnectionReader;
|
|
||||||
import org.briarproject.bramble.api.plugin.TransportConnectionWriter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An interface for reading and writing data over a duplex transport. The
|
|
||||||
* connection is not responsible for encrypting/decrypting or authenticating
|
|
||||||
* the data.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface DuplexTransportConnection {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a {@link TransportConnectionReader TransportConnectionReader}
|
|
||||||
* for reading from the connection.
|
|
||||||
*/
|
|
||||||
TransportConnectionReader getReader();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a {@link TransportConnectionWriter TransportConnectionWriter}
|
|
||||||
* for writing to the connection.
|
|
||||||
*/
|
|
||||||
TransportConnectionWriter getWriter();
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.plugin.TransportId;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a transport is disabled.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class TransportDisabledEvent extends Event {
|
|
||||||
|
|
||||||
private final TransportId transportId;
|
|
||||||
|
|
||||||
public TransportDisabledEvent(TransportId transportId) {
|
|
||||||
this.transportId = transportId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransportId getTransportId() {
|
|
||||||
return transportId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.plugin.TransportId;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when a transport is enabled.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class TransportEnabledEvent extends Event {
|
|
||||||
|
|
||||||
private final TransportId transportId;
|
|
||||||
|
|
||||||
public TransportEnabledEvent(TransportId transportId) {
|
|
||||||
this.transportId = transportId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransportId getTransportId() {
|
|
||||||
return transportId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin.simplex;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.plugin.Plugin;
|
|
||||||
import org.briarproject.bramble.api.plugin.TransportConnectionReader;
|
|
||||||
import org.briarproject.bramble.api.plugin.TransportConnectionWriter;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An interface for transport plugins that support simplex communication.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface SimplexPlugin extends Plugin {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to create and return a reader for the given contact using the
|
|
||||||
* current transport and configuration properties. Returns null if a reader
|
|
||||||
* cannot be created.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
TransportConnectionReader createReader(ContactId c);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to create and return a writer for the given contact using the
|
|
||||||
* current transport and configuration properties. Returns null if a writer
|
|
||||||
* cannot be created.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
TransportConnectionWriter createWriter(ContactId c);
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.plugin.simplex;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.bramble.api.plugin.PluginCallback;
|
|
||||||
import org.briarproject.bramble.api.plugin.TransportConnectionReader;
|
|
||||||
import org.briarproject.bramble.api.plugin.TransportConnectionWriter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An interface for handling readers and writers created by a simplex transport
|
|
||||||
* plugin.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface SimplexPluginCallback extends PluginCallback {
|
|
||||||
|
|
||||||
void readerCreated(TransportConnectionReader r);
|
|
||||||
|
|
||||||
void writerCreated(ContactId c, TransportConnectionWriter w);
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.properties;
|
|
||||||
|
|
||||||
public interface TransportPropertyConstants {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum number of properties per transport.
|
|
||||||
*/
|
|
||||||
int MAX_PROPERTIES_PER_TRANSPORT = 100;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum length of a property's key or value in UTF-8 bytes.
|
|
||||||
*/
|
|
||||||
int MAX_PROPERTY_LENGTH = 100;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.reliability;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface ReadHandler {
|
|
||||||
|
|
||||||
void handleRead(byte[] b) throws IOException;
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.reliability;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface ReliabilityLayerFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a reliability layer that writes to the given lower layer.
|
|
||||||
*/
|
|
||||||
ReliabilityLayer createReliabilityLayer(WriteHandler writeHandler);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.reliability;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface WriteHandler {
|
|
||||||
|
|
||||||
void handleWrite(byte[] b) throws IOException;
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.reporting;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface DevConfig {
|
|
||||||
|
|
||||||
PublicKey getDevPublicKey();
|
|
||||||
|
|
||||||
String getDevOnionAddress();
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.reporting;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A task for reporting back to the developers.
|
|
||||||
*/
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface DevReporter {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores an encrypted report on disk to be sent later.
|
|
||||||
*
|
|
||||||
* @param reportDir the directory where reports are stored.
|
|
||||||
* @param report the report in the form expected by the server.
|
|
||||||
* @throws FileNotFoundException if the report could not be written.
|
|
||||||
*/
|
|
||||||
void encryptReportToFile(File reportDir, String filename, String report)
|
|
||||||
throws FileNotFoundException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends any reports previously stored on disk.
|
|
||||||
*
|
|
||||||
* @param reportDir the directory where reports are stored.
|
|
||||||
*/
|
|
||||||
void sendReports(File reportDir);
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.settings;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.StringMap;
|
|
||||||
|
|
||||||
public class Settings extends StringMap {
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.settings;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface SettingsManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all settings in the given namespace.
|
|
||||||
*/
|
|
||||||
Settings getSettings(String namespace) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Merges the given settings with any existing settings in the given
|
|
||||||
* namespace.
|
|
||||||
*/
|
|
||||||
void mergeSettings(Settings s, String namespace) throws DbException;
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.settings.event;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.Event;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event that is broadcast when one or more settings are updated.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class SettingsUpdatedEvent extends Event {
|
|
||||||
|
|
||||||
private final String namespace;
|
|
||||||
|
|
||||||
public SettingsUpdatedEvent(String namespace) {
|
|
||||||
this.namespace = namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNamespace() {
|
|
||||||
return namespace;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.sync;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
|
||||||
import org.briarproject.bramble.api.db.Transaction;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface Client {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called at startup to create any local state needed by the client.
|
|
||||||
*/
|
|
||||||
void createLocalState(Transaction txn) throws DbException;
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.sync;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper for a name-spaced string that uniquely identifies a sync client.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class ClientId implements Comparable<ClientId> {
|
|
||||||
|
|
||||||
private final String id;
|
|
||||||
|
|
||||||
public ClientId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getString() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(ClientId clientId) {
|
|
||||||
return id.compareTo(clientId.getString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
return o instanceof ClientId && id.equals(((ClientId) o).id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return id.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.sync;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface GroupFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a group with the given client ID and descriptor.
|
|
||||||
*/
|
|
||||||
Group createGroup(ClientId c, byte[] descriptor);
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.sync;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.db.Metadata;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
|
||||||
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public class MessageContext {
|
|
||||||
|
|
||||||
private final Metadata metadata;
|
|
||||||
private final Collection<MessageId> dependencies;
|
|
||||||
|
|
||||||
public MessageContext(Metadata metadata,
|
|
||||||
Collection<MessageId> dependencies) {
|
|
||||||
this.metadata = metadata;
|
|
||||||
this.dependencies = dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageContext(Metadata metadata) {
|
|
||||||
this(metadata, Collections.<MessageId>emptyList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Metadata getMetadata() {
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<MessageId> getDependencies() {
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.sync;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface MessageFactory {
|
|
||||||
|
|
||||||
Message createMessage(GroupId g, long timestamp, byte[] body);
|
|
||||||
|
|
||||||
Message createMessage(MessageId m, byte[] raw);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.sync;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface RecordReaderFactory {
|
|
||||||
|
|
||||||
RecordReader createRecordReader(InputStream in);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.sync;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Record types for the sync protocol.
|
|
||||||
*/
|
|
||||||
public interface RecordTypes {
|
|
||||||
|
|
||||||
byte ACK = 0;
|
|
||||||
byte MESSAGE = 1;
|
|
||||||
byte OFFER = 2;
|
|
||||||
byte REQUEST = 3;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.sync;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface RecordWriterFactory {
|
|
||||||
|
|
||||||
RecordWriter createRecordWriter(OutputStream out);
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.sync;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A record requesting one or more {@link Message Messages} from the recipient.
|
|
||||||
*/
|
|
||||||
public class Request {
|
|
||||||
|
|
||||||
private final Collection<MessageId> requested;
|
|
||||||
|
|
||||||
public Request(Collection<MessageId> requested) {
|
|
||||||
this.requested = requested;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the identifiers of the requested messages.
|
|
||||||
*/
|
|
||||||
public Collection<MessageId> getMessageIds() {
|
|
||||||
return requested;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.sync;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.UniqueId;
|
|
||||||
|
|
||||||
public interface SyncConstants {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current version of the sync protocol.
|
|
||||||
*/
|
|
||||||
byte PROTOCOL_VERSION = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The length of the record header in bytes.
|
|
||||||
*/
|
|
||||||
int RECORD_HEADER_LENGTH = 4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum length of the record payload in bytes.
|
|
||||||
*/
|
|
||||||
int MAX_RECORD_PAYLOAD_LENGTH = 48 * 1024; // 48 KiB
|
|
||||||
|
|
||||||
/** The maximum length of a group descriptor in bytes. */
|
|
||||||
int MAX_GROUP_DESCRIPTOR_LENGTH = 16 * 1024; // 16 KiB
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The length of the message header in bytes.
|
|
||||||
*/
|
|
||||||
int MESSAGE_HEADER_LENGTH = UniqueId.LENGTH + 8;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum length of a message body in bytes.
|
|
||||||
*/
|
|
||||||
int MAX_MESSAGE_BODY_LENGTH = 32 * 1024; // 32 KiB
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum length of a message in bytes.
|
|
||||||
*/
|
|
||||||
int MAX_MESSAGE_LENGTH = MESSAGE_HEADER_LENGTH + MAX_MESSAGE_BODY_LENGTH;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum number of message IDs in an ack, offer or request record.
|
|
||||||
*/
|
|
||||||
int MAX_MESSAGE_IDS = MAX_RECORD_PAYLOAD_LENGTH / UniqueId.LENGTH;
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user