From 3bc1b6f66971b6a5400a600317909aa24fe734df Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Mon, 28 Dec 2015 16:09:52 +0100 Subject: [PATCH] Removed webview --- .../bitsquare/common/crypto/Encryption.java | 1 + .../io/bitsquare/common/util/Utilities.java | 24 ----- doc/build.md | 6 ++ .../java/io/bitsquare/app/BitsquareApp.java | 4 - .../io/bitsquare/gui/main/MainViewModel.java | 22 ++++- .../bitsquare/gui/main/funds/FundsView.java | 11 ++- .../gui/popups/FirstTimeWebViewPopup.java | 84 ----------------- .../java/io/bitsquare/gui/popups/Popup.java | 4 +- .../io/bitsquare/gui/popups/TacPopup.java | 57 ------------ .../io/bitsquare/gui/popups/WebViewPopup.java | 90 ------------------- gui/src/main/resources/html/base.css | 2 +- package/mac/Info.plist | 4 +- .../io/bitsquare/p2p/seed/SeedNodeMain.java | 3 - 13 files changed, 39 insertions(+), 273 deletions(-) delete mode 100644 gui/src/main/java/io/bitsquare/gui/popups/FirstTimeWebViewPopup.java delete mode 100644 gui/src/main/java/io/bitsquare/gui/popups/TacPopup.java delete mode 100644 gui/src/main/java/io/bitsquare/gui/popups/WebViewPopup.java diff --git a/common/src/main/java/io/bitsquare/common/crypto/Encryption.java b/common/src/main/java/io/bitsquare/common/crypto/Encryption.java index 8ab4f05089..2f01359ec2 100644 --- a/common/src/main/java/io/bitsquare/common/crypto/Encryption.java +++ b/common/src/main/java/io/bitsquare/common/crypto/Encryption.java @@ -260,6 +260,7 @@ public class Encryption { return keyPairGenerator.generateKey(); } catch (Throwable e) { e.printStackTrace(); + log.error(e.getMessage()); throw new RuntimeException("Couldn't generate key"); } } diff --git a/common/src/main/java/io/bitsquare/common/util/Utilities.java b/common/src/main/java/io/bitsquare/common/util/Utilities.java index e0b37144c5..4506dda055 100644 --- a/common/src/main/java/io/bitsquare/common/util/Utilities.java +++ b/common/src/main/java/io/bitsquare/common/util/Utilities.java @@ -25,7 +25,6 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.gson.*; import javafx.scene.input.Clipboard; import javafx.scene.input.ClipboardContent; -import javafx.scene.web.WebEngine; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -135,29 +134,6 @@ public class Utilities { log.info("System load (nr. threads/used memory (MB)): " + Thread.activeCount() + "/" + used); } - // Opens links with http and _blank in default web browser instead of webView - // WebView has not feature to open link in default browser, so we use the hack recommended here: - // https://stackoverflow.com/questions/15555510/javafx-stop-opening-url-in-webview-open-in-browser-instead - public static void setupWebViewPopupHandler(WebEngine webEngine) { - webEngine.setCreatePopupHandler( - config -> { - // grab the last hyperlink that has :hover pseudoclass - Object result = webEngine - .executeScript( - "var list = document.querySelectorAll( ':hover' );" - + "for (i=list.length-1; i>-1; i--) " - + "{ if ( list.item(i).getAttribute('href') ) " - + "{ list.item(i).getAttribute('href'); break; } }"); - - if (result instanceof String && ((String) result).contains("http")) { - openWebPage((String) result); - return null; - } else { - return webEngine; - } - }); - } - public static void openMail(String to, String subject, String body) { try { subject = URLEncoder.encode(subject, "UTF-8").replace("+", "%20"); diff --git a/doc/build.md b/doc/build.md index 4d74b273ff..218022e5af 100644 --- a/doc/build.md +++ b/doc/build.md @@ -107,6 +107,12 @@ Here are example program arguments for using regtest and using the Tor network: $ java -jar gui/target/shaded.jar --bitcoin.network=regtest node.port=4442 --devTest=true --app.name=Bitsquare-Tor-Regtest-Bob +### 6. Enable unlimited Strength for cryptographic keys + +Bitsquare uses 256 bit length keys which are still not permitted by default. +Get around that ridiculous fact by adding the missing [jars from Oracle](http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html). + + Problems? --------- diff --git a/gui/src/main/java/io/bitsquare/app/BitsquareApp.java b/gui/src/main/java/io/bitsquare/app/BitsquareApp.java index 3d1c840fcf..d78db5b9b1 100644 --- a/gui/src/main/java/io/bitsquare/app/BitsquareApp.java +++ b/gui/src/main/java/io/bitsquare/app/BitsquareApp.java @@ -53,7 +53,6 @@ import javafx.scene.layout.StackPane; import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.StageStyle; -import org.bitcoinj.crypto.DRMWorkaround; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.controlsfx.dialog.Dialogs; import org.reactfx.EventStreams; @@ -118,11 +117,8 @@ public class BitsquareApp extends Application { Thread.setDefaultUncaughtExceptionHandler(handler); Thread.currentThread().setUncaughtExceptionHandler(handler); - DRMWorkaround.maybeDisableExportControls(); - Security.addProvider(new BouncyCastleProvider()); - BitsquareApp.primaryStage = primaryStage; shutDownHandler = this::stop; diff --git a/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java b/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java index 29ad67cefb..5f8c17f9f9 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java +++ b/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java @@ -33,7 +33,9 @@ import io.bitsquare.gui.common.model.ViewModel; import io.bitsquare.gui.components.BalanceTextField; import io.bitsquare.gui.components.BalanceWithConfirmationTextField; import io.bitsquare.gui.components.TxIdTextField; -import io.bitsquare.gui.popups.*; +import io.bitsquare.gui.popups.DisplayAlertMessagePopup; +import io.bitsquare.gui.popups.Popup; +import io.bitsquare.gui.popups.WalletPasswordPopup; import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.p2p.P2PService; import io.bitsquare.p2p.P2PServiceListener; @@ -349,9 +351,23 @@ class MainViewModel implements ViewModel { // tac + String text = "1. This software is experimental and provided \"as is\", without warranty of any kind, " + + "express or implied, including but not limited to the warranties of " + + "merchantability, fitness for a particular purpose and non-infringement.\n" + + "In no event shall the authors or copyright holders be liable for any claim, damages or other " + + "liability, whether in an action of contract, tort or otherwise, " + + "arising from, out of or in connection with the software or the use or other dealings in the software.\n\n" + + "2. The user is responsible to use the software in compliance with local laws.\n\n" + + "3. The user confirms that he has read and agreed to the rules defined in our " + + "Wiki regrading the dispute process."; if (!preferences.getTacAccepted() && !BitsquareApp.DEV_MODE) - new TacPopup().url(WebViewPopup.getLocalUrl("tac")).onAgree(() -> preferences.setTacAccepted(true)).show(); - + new Popup().headLine("USER AGREEMENT") + .message(text) + .actionButtonText("I agree") + .closeButtonText("Quit") + .onAction(() -> preferences.setTacAccepted(true)) + .onClose(() -> BitsquareApp.shutDownHandler.run()) + .show(); // update nr of peers in footer p2PService.getNumAuthenticatedPeers().addListener((observable, oldValue, newValue) -> updateP2pNetworkInfo()); diff --git a/gui/src/main/java/io/bitsquare/gui/main/funds/FundsView.java b/gui/src/main/java/io/bitsquare/gui/main/funds/FundsView.java index 647c5491b0..031baf646c 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/funds/FundsView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/funds/FundsView.java @@ -25,8 +25,7 @@ import io.bitsquare.gui.main.MainView; import io.bitsquare.gui.main.funds.reserved.ReservedView; import io.bitsquare.gui.main.funds.transactions.TransactionsView; import io.bitsquare.gui.main.funds.withdrawal.WithdrawalView; -import io.bitsquare.gui.popups.FirstTimeWebViewPopup; -import io.bitsquare.gui.popups.WebViewPopup; +import io.bitsquare.gui.popups.Popup; import io.bitsquare.user.PopupId; import io.bitsquare.user.Preferences; import javafx.beans.value.ChangeListener; @@ -86,8 +85,14 @@ public class FundsView extends ActivatableViewAndModel { navigation.navigateTo(MainView.class, FundsView.class, TransactionsView.class); String key = PopupId.TRADE_WALLET; + String text = "Bitsquare does not use a single application wallet, but dedicated wallets for every trade.\n" + + "Funding of the wallet will be done when needed, for instance when you create or take an offer.\n" + + "Withdrawing funds can be done after a trade is completed.\n" + + "Dedicated wallets help protect user privacy and prevent leaking information of previous trades to other\n" + + "traders.\n\n" + + "For more background information please see the Bitsquare FAQ on our web page."; if (preferences.showAgain(key) && !BitsquareApp.DEV_MODE) - new FirstTimeWebViewPopup(preferences).id(key).url(WebViewPopup.getLocalUrl(key)).show(); + new Popup().information(text).dontShowAgainId(key, preferences).show(); } @Override diff --git a/gui/src/main/java/io/bitsquare/gui/popups/FirstTimeWebViewPopup.java b/gui/src/main/java/io/bitsquare/gui/popups/FirstTimeWebViewPopup.java deleted file mode 100644 index ddaf5374cc..0000000000 --- a/gui/src/main/java/io/bitsquare/gui/popups/FirstTimeWebViewPopup.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.gui.popups; - -import io.bitsquare.user.Preferences; -import javafx.geometry.Insets; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.layout.GridPane; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Optional; - -import static io.bitsquare.gui.util.FormBuilder.addCheckBox; - -public class FirstTimeWebViewPopup extends WebViewPopup { - private static final Logger log = LoggerFactory.getLogger(FirstTimeWebViewPopup.class); - private Preferences preferences; - private String id; - - - /////////////////////////////////////////////////////////////////////////////////////////// - // Public API - /////////////////////////////////////////////////////////////////////////////////////////// - - public FirstTimeWebViewPopup(Preferences preferences) { - this.preferences = preferences; - } - - @Override - public FirstTimeWebViewPopup url(String url) { - super.url(url); - return this; - } - - public FirstTimeWebViewPopup onClose(Runnable closeHandler) { - this.closeHandlerOptional = Optional.of(closeHandler); - return this; - } - - public FirstTimeWebViewPopup id(String dontShowAgainId) { - this.id = dontShowAgainId; - return this; - } - - @Override - protected void addHtmlContent() { - super.addHtmlContent(); - - CheckBox dontShowAgain = addCheckBox(gridPane, ++rowIndex, "Don't show again", 10); - dontShowAgain.setOnAction(e -> { - if (dontShowAgain.isSelected()) - preferences.dontShowAgain(id); - }); - closeButton = new Button("Close"); - closeButton.setOnAction(e -> { - hide(); - closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run()); - }); - - GridPane.setRowIndex(closeButton, ++rowIndex); - GridPane.setColumnIndex(closeButton, 1); - gridPane.getChildren().add(closeButton); - GridPane.setMargin(closeButton, new Insets(10, 0, 0, 0)); - } - - -} diff --git a/gui/src/main/java/io/bitsquare/gui/popups/Popup.java b/gui/src/main/java/io/bitsquare/gui/popups/Popup.java index b82eb4f996..e79a9d555c 100644 --- a/gui/src/main/java/io/bitsquare/gui/popups/Popup.java +++ b/gui/src/main/java/io/bitsquare/gui/popups/Popup.java @@ -356,8 +356,8 @@ public class Popup { } protected void setTruncatedMessage() { - if (message != null && message.length() > 600) - truncatedMessage = message.substring(0, 600) + "..."; + if (message != null && message.length() > 650) + truncatedMessage = message.substring(0, 650) + "..."; else truncatedMessage = message; } diff --git a/gui/src/main/java/io/bitsquare/gui/popups/TacPopup.java b/gui/src/main/java/io/bitsquare/gui/popups/TacPopup.java deleted file mode 100644 index 419ac336c5..0000000000 --- a/gui/src/main/java/io/bitsquare/gui/popups/TacPopup.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.gui.popups; - -import io.bitsquare.app.BitsquareApp; -import io.bitsquare.common.util.Tuple2; -import javafx.scene.control.Button; - -import java.util.Optional; - -import static io.bitsquare.gui.util.FormBuilder.add2ButtonsAfterGroup; - -public class TacPopup extends WebViewPopup { - - private Optional agreeHandlerOptional; - - public TacPopup onAgree(Runnable agreeHandler) { - this.agreeHandlerOptional = Optional.of(agreeHandler); - return this; - } - - @Override - public TacPopup url(String url) { - super.url(url); - return this; - } - - @Override - protected void addHtmlContent() { - super.addHtmlContent(); - - Tuple2 tuple = add2ButtonsAfterGroup(gridPane, ++rowIndex, "I agree", "Quit"); - Button agreeButton = tuple.first; - Button quitButton = tuple.second; - - agreeButton.setOnAction(e -> { - agreeHandlerOptional.ifPresent(agreeHandler -> agreeHandler.run()); - hide(); - }); - quitButton.setOnAction(e -> BitsquareApp.shutDownHandler.run()); - } -} diff --git a/gui/src/main/java/io/bitsquare/gui/popups/WebViewPopup.java b/gui/src/main/java/io/bitsquare/gui/popups/WebViewPopup.java deleted file mode 100644 index d047e795f3..0000000000 --- a/gui/src/main/java/io/bitsquare/gui/popups/WebViewPopup.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.gui.popups; - -import io.bitsquare.app.BitsquareApp; -import io.bitsquare.common.util.Utilities; -import javafx.geometry.HPos; -import javafx.geometry.Insets; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.Priority; -import javafx.scene.web.WebView; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WebViewPopup extends Popup { - private static final Logger log = LoggerFactory.getLogger(WebViewPopup.class); - - protected WebView webView; - protected String url; - - public static String getLocalUrl(String htmlFile) { - return WebViewPopup.class.getResource("/html/" + htmlFile + ".html").toExternalForm(); - } - - public WebViewPopup() { - } - - @Override - public WebViewPopup show() { - width = 700; - - webView = new WebView(); - webView.setPrefHeight(0); - - // open links with http and _blank in default web browser instead of webView - Utilities.setupWebViewPopupHandler(webView.getEngine()); - - webView.getEngine().documentProperty().addListener((observable, oldValue, newValue) -> { - // TODO At linux the heightInPx is screwed up.... need to find a better solution that that ugly html hack - String heightInPx = webView.getEngine() - .executeScript("window.getComputedStyle(document.body, null).getPropertyValue('height')").toString(); - double webViewHeight = Math.min(Double.valueOf(heightInPx.replace("px", "")) * 1.2, - BitsquareApp.getPrimaryStage().getHeight() - 200); - double stageHeight = Math.min(webViewHeight + gridPane.getHeight(), - BitsquareApp.getPrimaryStage().getHeight()); - webView.setPrefHeight(webViewHeight); - stage.setMinHeight(stageHeight); - stage.setMaxHeight(stageHeight); - centerPopup(); - gridPane.setVisible(true); - }); - - createGridPane(); - gridPane.setVisible(false); - addHtmlContent(); - createPopup(); - return this; - } - - public WebViewPopup url(String url) { - this.url = url; - return this; - } - - protected void addHtmlContent() { - webView.getEngine().load(url); - GridPane.setHalignment(webView, HPos.LEFT); - GridPane.setHgrow(webView, Priority.ALWAYS); - GridPane.setMargin(webView, new Insets(3, 0, 0, 0)); - GridPane.setRowIndex(webView, ++rowIndex); - GridPane.setColumnIndex(webView, 0); - GridPane.setColumnSpan(webView, 2); - gridPane.getChildren().add(webView); - } -} diff --git a/gui/src/main/resources/html/base.css b/gui/src/main/resources/html/base.css index 38b3a259f4..c4451ed1bf 100644 --- a/gui/src/main/resources/html/base.css +++ b/gui/src/main/resources/html/base.css @@ -16,7 +16,7 @@ */ body { - font-family: sans-serif; + font-family: sans-serif, Helvetica, Arial; color: #333; font-size: 14px; line-height: 1.5; diff --git a/package/mac/Info.plist b/package/mac/Info.plist index bab94feb1e..a4f00dda3f 100644 --- a/package/mac/Info.plist +++ b/package/mac/Info.plist @@ -55,8 +55,8 @@ - NSAppSleepDisabled - YES + + diff --git a/seednode/src/main/java/io/bitsquare/p2p/seed/SeedNodeMain.java b/seednode/src/main/java/io/bitsquare/p2p/seed/SeedNodeMain.java index a70c12ee71..31c72ce57d 100644 --- a/seednode/src/main/java/io/bitsquare/p2p/seed/SeedNodeMain.java +++ b/seednode/src/main/java/io/bitsquare/p2p/seed/SeedNodeMain.java @@ -3,7 +3,6 @@ package io.bitsquare.p2p.seed; import com.google.common.util.concurrent.ThreadFactoryBuilder; import io.bitsquare.app.BitsquareEnvironment; import io.bitsquare.common.UserThread; -import org.bitcoinj.crypto.DRMWorkaround; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,8 +42,6 @@ public class SeedNodeMain { Thread.setDefaultUncaughtExceptionHandler(handler); Thread.currentThread().setUncaughtExceptionHandler(handler); - DRMWorkaround.maybeDisableExportControls(); - Security.addProvider(new BouncyCastleProvider()); UserThread.execute(() -> {