Merge branch 'master' into DAO_phase1

This commit is contained in:
Manfred Karrer 2017-07-09 23:07:04 +02:00
commit 77f8bdb7b0
15 changed files with 279 additions and 106 deletions

29
.travis.yml Normal file
View File

@ -0,0 +1,29 @@
language: java
jdk:
- oraclejdk8
install:
- git clone -b bisq_0.14.4.1 https://github.com/bitsquare/bitcoinj.git
- cd bitcoinj
- mvn clean install
- git clone https://github.com/bitsquare/libdohj.git
- cd libdohj
- mvn clean install
- git clone https://github.com/bitsquare/btcd-cli4j.git
- cd btcd-cli4j
- mvn clean install
- cd ..
script: mvn clean install
#notifications:
# irc:
# channels: chat.freenode.net#bisq
# template:
# - '%{message} (%{repository}#%{build_number}, %{duration})'
# - '%{repository}/%{branch} %{commit} %{author}: %{commit_message}'
# - '%{build_url}'
# on_success: change
# on_failure: always
# use_notice: true
# skip_join: true

View File

@ -1,20 +0,0 @@
language: java
jdk: oraclejdk8
install:
- "sudo apt-get purge openjdk*"
- "sudo add-apt-repository -y ppa:webupd8team/java"
- "sudo apt-get update"
- "sudo apt-get install oracle-java8-installer"
notifications:
irc:
channels: chat.freenode.net#bisq
template:
- '%{message} (%{repository}#%{build_number}, %{duration})'
- '%{repository}/%{branch} %{commit} %{author}: %{commit_message}'
- '%{build_url}'
on_success: change
on_failure: always
use_notice: true
skip_join: true

View File

@ -11,18 +11,90 @@
<artifactId>common</artifactId>
<properties>
<protobuf.version>3.3.0</protobuf.version>
</properties>
<profiles>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<protobuf.classifier>windows-x86_64</protobuf.classifier>
<protobuf.exe>protoc.exe</protobuf.exe>
</properties>
</profile>
<profile>
<id>unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<protobuf.classifier>linux-x86_64</protobuf.classifier>
<protobuf.exe>protoc</protobuf.exe>
</properties>
</profile>
<profile>
<id>macos</id>
<activation>
<os>
<family>macos</family>
</os>
</activation>
<properties>
<protobuf.classifier>osx-x86_64</protobuf.classifier>
<protobuf.exe>protoc</protobuf.exe>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-protoc</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<version>${protobuf.version}</version>
<classifier>${protobuf.classifier}</classifier>
<type>exe</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
<destFileName>${protobuf.exe}</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<!-- https://www.xolstice.org/protobuf-maven-plugin/usage.html -->
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.0</version>
<configuration>
<protocExecutable>/usr/local/bin/protoc</protocExecutable>
<protocExecutable>${project.build.directory}/${protobuf.exe}</protocExecutable>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
@ -37,7 +109,7 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.3.0</version>
<version>${protobuf.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>

View File

@ -15,12 +15,12 @@
<dependency>
<groupId>io.bisq</groupId>
<artifactId>common</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.bisq</groupId>
<artifactId>network</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -91,7 +91,7 @@ public class ArbitratorManager {
private final User user;
private final Preferences preferences;
private final ObservableMap<NodeAddress, Arbitrator> arbitratorsObservableMap = FXCollections.observableHashMap();
private final List<Arbitrator> persistedAcceptedArbitrators;
private List<Arbitrator> persistedAcceptedArbitrators;
private Timer republishArbitratorTimer, retryRepublishArbitratorTimer;
@ -105,13 +105,19 @@ public class ArbitratorManager {
this.arbitratorService = arbitratorService;
this.user = user;
this.preferences = preferences;
}
persistedAcceptedArbitrators = new ArrayList<>(user.getAcceptedArbitrators());
user.clearAcceptedArbitrators();
public void shutDown() {
stopRepublishArbitratorTimer();
stopRetryRepublishArbitratorTimer();
}
// TODO we mirror arbitrator data for mediator as long we have not impl. it in the UI
user.clearAcceptedMediators();
///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////
public void onAllServicesInitialized() {
arbitratorService.addHashSetChangedListener(new HashMapChangedListener() {
@Override
public void onAdded(ProtectedStorageEntry data) {
@ -129,19 +135,13 @@ public class ArbitratorManager {
}
}
});
}
public void shutDown() {
stopRepublishArbitratorTimer();
stopRetryRepublishArbitratorTimer();
}
persistedAcceptedArbitrators = new ArrayList<>(user.getAcceptedArbitrators());
user.clearAcceptedArbitrators();
// TODO we mirror arbitrator data for mediator as long we have not impl. it in the UI
user.clearAcceptedMediators();
///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////
public void onAllServicesInitialized() {
if (user.getRegisteredArbitrator() != null) {
P2PService p2PService = arbitratorService.getP2PService();
if (p2PService.isBootstrapped())

View File

@ -74,8 +74,8 @@ For Mac OSX, you will need to set JAVA_HOME as:
$ . ~/.bashrc
### 2. Install the latest protobuffer release on your machine (3.3.0 at the time of writing):
https://github.com/google/protobuf/releases
### Protobuf
Note that Bisq use protobuf during maven build https://github.com/google/protobuf/releases
### 2.1 Increase the Intellij Idea Code insight limit, because it breaks on the generated protobuffer files:
Go to Help > Edit custom properties => paste the following line:
@ -108,58 +108,16 @@ It is not needed for a normal user to run such a "full node" but for the build i
$ cd btcd-cli4j
$ mvn clean install -DskipTests -Dmaven.javadoc.skip=true
Prepare bisq build
-----------------
### 4. Install Protobuffer
Install Protobuffer.
$ wget https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip
$ unzip protoc-3.3.0-linux-x86_64.zip -d protoc3
$ sudo mv protoc3/bin/protoc /usr/local/bin/protoc
### 5. Get bisq source code and build a preliminary bisq version (don't run the jar, it wont work)
We need to get the bisq dependencies resolved first as we need to copy the BouncyCastle jar to the JRE directory.
$ git clone https://github.com/bitsquare/bitsquare.git
$ cd bisq
$ mvn clean package -DskipTests -Dmaven.javadoc.skip=true
### 6. Copy the BouncyCastle provider jar file
Copy the BountyCastle provider jar file from the local maven repository to the jre/lib/ext directory.
This prevents a "JCE cannot authenticate the provider BC" exception when starting the bisq client.
$ sudo cp ~/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.53/bcprov-jdk15on-1.53.jar $JAVA_HOME/jre/lib/ext/
### 7. Edit the java.security file and add BouncyCastleProvider
Add org.bouncycastle.jce.provider.BouncyCastleProvider as last entry at: List of providers and their preference orders
E.g.:
security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider
$ sudo gedit $JAVA_HOME/jre/lib/security/java.security
... edit and save
### 8. Enable unlimited Strength for cryptographic keys (only required for Oracle JDK)
If you are using Oracle JDK 8 you must **[enable strong cryptographic cyphers](https://github.com/jonathancross/jc-docs/blob/master/java-strong-crypto-test/README.md)**. If you use OpenJDK + OpenJFX you can skip this step.
In Windows the new crypto files need to be copied to `Java/jdk1.8.0_xxx/jre/lib/security` AND `Java/jre1.8.0_xxx/jre/lib/security` otherwise the test in the above page will fail.
Build bisq
-----------------
### 9. Build final bisq jar
### 1. Build final bisq jar
Now we have all prepared to build the correct bisq jar.
$ mvn clean package verify -DskipTests -Dmaven.javadoc.skip=true
When the build completes, you will find an executable jar: `gui/target/shaded.jar`.
When the build completes, you will find an executable jar: `gui/target/shaded.jar` and a ./lib directory.
To run it use:
$ java -jar gui/target/shaded.jar
@ -167,7 +125,7 @@ To run it use:
Build binaries
-----------------
If you want to build the binaries check out the build scripts under the package directory.
If you want to build the binaries check out the build scripts under the package directory. copy shaded.jar and the lib directory.
DAO full node

View File

@ -49,19 +49,62 @@
</resources>
<plugins>
<!-- Bouncycastle jars are signed and cannot be placed inside shaded jar.
we ship them beside our app in /lib -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-bouncycastle</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<stripVersion>true</stripVersion>
<artifactItems>
<artifactItem>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk15on</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<artifactSet>
<excludes>
<exclude>org.bouncycastle:*:*:*</exclude>
</excludes>
</artifactSet>
<!-- broken with Java 8 (MSHADE-174), using ProGuard instead. -->
<minimizeJar>false</minimizeJar>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.bisq.gui.app.BisqAppMain</mainClass>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>io.bisq.gui.app.BisqAppMain</Main-Class>
<!-- the specified bouncy castle jar classes -->
<Class-Path>lib/bcpg-jdk15on.jar lib/bcprov-jdk15on.jar</Class-Path>
</manifestEntries>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<filters>
<filter>
<!-- exclude signatures, the bundling process breaks them for some reason -->
@ -233,7 +276,7 @@
org.bitcoinj:orchid:1.1.1:jar:null:compile:7898329eae76ec6bfdf27081234bb222d5be09df
</urn>
<urn>
org.bouncycastle:bcprov-jdk15on:1.53:jar:null:compile:9d3def2fa5a0d2ed0c1146e9945df10d29eb4ccb
org.bouncycastle:bcprov-jdk15on:1.56:jar:null:compile:a153c6f9744a3e9dd6feab5e210e1c9861362ec7
</urn>
<urn>
org.controlsfx:controlsfx:8.0.6_20:jar:null:compile:5a4ca2765419fe12af0f0c7c5a8129c53bb661d9
@ -296,7 +339,7 @@
<dependency>
<groupId>io.bisq</groupId>
<artifactId>core</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -24,17 +24,26 @@ import joptsimple.OptionException;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Locale;
import java.util.Map;
import static io.bisq.core.app.BisqEnvironment.DEFAULT_APP_NAME;
import static io.bisq.core.app.BisqEnvironment.DEFAULT_USER_DATA_DIR;
public class BisqAppMain extends BisqExecutable {
static {
removeCryptographyRestrictions();
}
public static void main(String[] args) throws Exception {
// Need to set default locale initially otherwise we get problems with non-english systems
Locale.setDefault(Locale.ENGLISH);
// We don't want to do the full argument parsing here as that might easily change in update versions
// So we only handle the absolute minimum which is APP_NAME, APP_DATA_DIR_KEY and USER_DATA_DIR
OptionParser parser = new OptionParser();
@ -71,4 +80,55 @@ public class BisqAppMain extends BisqExecutable {
BisqApp.setEnvironment(getBisqEnvironment(options));
javafx.application.Application.launch(BisqApp.class);
}
private static void removeCryptographyRestrictions() {
if (!isRestrictedCryptography()) {
System.out.println("Cryptography restrictions removal not needed");
return;
}
try {
/*
* Do the following, but with reflection to bypass access checks:
*
* JceSecurity.isRestricted = false;
* JceSecurity.defaultPolicy.perms.clear();
* JceSecurity.defaultPolicy.add(CryptoAllPermission.INSTANCE);
*/
final Class<?> jceSecurity = Class.forName("javax.crypto.JceSecurity");
final Class<?> cryptoPermissions = Class.forName("javax.crypto.CryptoPermissions");
final Class<?> cryptoAllPermission = Class.forName("javax.crypto.CryptoAllPermission");
final Field isRestrictedField = jceSecurity.getDeclaredField("isRestricted");
isRestrictedField.setAccessible(true);
final Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(isRestrictedField, isRestrictedField.getModifiers() & ~Modifier.FINAL);
isRestrictedField.set(null, false);
final Field defaultPolicyField = jceSecurity.getDeclaredField("defaultPolicy");
defaultPolicyField.setAccessible(true);
final PermissionCollection defaultPolicy = (PermissionCollection) defaultPolicyField.get(null);
final Field perms = cryptoPermissions.getDeclaredField("perms");
perms.setAccessible(true);
((Map<?, ?>) perms.get(defaultPolicy)).clear();
final Field instance = cryptoAllPermission.getDeclaredField("INSTANCE");
instance.setAccessible(true);
defaultPolicy.add((Permission) instance.get(null));
System.out.println("Successfully removed cryptography restrictions");
} catch (final Exception e) {
System.err.println("Failed to remove cryptography restrictions" + e);
}
}
private static boolean isRestrictedCryptography() {
// This matches Oracle Java 7 and 8, but not Java 9 or OpenJDK.
final String name = System.getProperty("java.runtime.name");
final String ver = System.getProperty("java.version");
return name != null && name.equals("Java(TM) SE Runtime Environment")
&& ver != null && (ver.startsWith("1.7") || ver.startsWith("1.8"));
}
}

View File

@ -15,12 +15,12 @@
<dependency>
<groupId>io.bisq</groupId>
<artifactId>jsocks</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.bisq</groupId>
<artifactId>jtorctl</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
</dependencies>

View File

@ -15,12 +15,12 @@
<dependency>
<groupId>io.bisq</groupId>
<artifactId>common</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.bisq</groupId>
<artifactId>jtorproxy</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -18,6 +18,7 @@ import mockit.integration.junit4.JMockit;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import java.io.File;
@ -31,6 +32,8 @@ import java.util.Set;
@Slf4j
@RunWith(JMockit.class)
// TODO
@Ignore("CoreProtobufferResolver is not accessible here: We should refactor it so that the classes themselves know how to deserialize so we don't get dependencies from core objects here")
public class P2PDataStorageTest {
private final Set<NodeAddress> seedNodes = new HashSet<>();
private EncryptionService encryptionService1, encryptionService2;
@ -84,10 +87,6 @@ public class P2PDataStorageTest {
FileUtil.deleteDirectory(dir2);
}
//TODO CoreProtobufferResolver is not accessible here
// We should refactor it so that the classes themselves know how to deserialize
// so we don't get dependencies from core objects here
/* @Test
public void testProtectedStorageEntryAddAndRemove() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException, NoSuchProviderException {
storagePayload = new AlertPayload(new AlertVO("alert",

38
pom.xml
View File

@ -131,19 +131,16 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.56</version>
</dependency>
<!-- We need both bcpg-jdk15on and bcpg-jdk16 -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk15on</artifactId>
<version>1.56</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk16</artifactId>
<version>1.46</version>
</dependency>
<!--utils-->
@ -250,4 +247,39 @@
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<!-- Oracle JDK 9 will support strong cyphers, but they must be explicitly enabled-->
<id>enable-strong-cipher-jdk9</id>
<activation>
<jdk>[1.9,)</jdk>
</activation>
<properties>
<crypto.policy>unlimited</crypto.policy>
</properties>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.56</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk15on</artifactId>
<version>1.56</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk16</artifactId>
<version>1.46</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -79,7 +79,7 @@
<dependency>
<groupId>io.bisq</groupId>
<artifactId>core</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -79,7 +79,7 @@
<dependency>
<groupId>io.bisq</groupId>
<artifactId>core</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -78,7 +78,7 @@
<dependency>
<groupId>io.bisq</groupId>
<artifactId>core</artifactId>
<version>${project.parent.version}</version>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>