mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-03-15 10:26:37 -04:00
refactoring: bank account, user, persistence
This commit is contained in:
parent
016ec4fe85
commit
603e86f14c
@ -11,7 +11,7 @@ import io.bitsquare.gui.popups.Popups;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.AWTSystemTray;
|
||||
import io.bitsquare.util.FileUtil;
|
||||
@ -90,10 +90,14 @@ public class BitSquare extends Application
|
||||
// apply stored data
|
||||
final User user = injector.getInstance(User.class);
|
||||
final Settings settings = injector.getInstance(Settings.class);
|
||||
final Storage storage = injector.getInstance(Storage.class);
|
||||
storage.init();
|
||||
user.updateFromStorage((User) storage.read(user.getClass().getName()));
|
||||
settings.updateFromStorage((Settings) storage.read(settings.getClass().getName()));
|
||||
final Persistence persistence = injector.getInstance(Persistence.class);
|
||||
persistence.init();
|
||||
|
||||
User persistedUser = (User) persistence.read(user);
|
||||
user.applyPersistedUser(persistedUser);
|
||||
persistence.write(user);
|
||||
|
||||
settings.applyPersistedSettings((Settings) persistence.read(settings.getClass().getName()));
|
||||
|
||||
primaryStage.setTitle("BitSquare (" + getUID() + ")");
|
||||
|
||||
|
@ -4,26 +4,21 @@ import io.bitsquare.locale.Country;
|
||||
import java.io.Serializable;
|
||||
import java.util.Currency;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
public class BankAccount implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1792577576443221268L;
|
||||
|
||||
|
||||
private final BankAccountType bankAccountType;
|
||||
|
||||
private final String accountPrimaryID;
|
||||
|
||||
private final String accountSecondaryID;
|
||||
|
||||
private final String accountPrimaryID; // like IBAN
|
||||
private final String accountSecondaryID; // like BIC
|
||||
private final String accountHolderName;
|
||||
|
||||
private final Country country;
|
||||
|
||||
private final Country country; // where bank is registered
|
||||
// The main currency if account support multiple currencies.
|
||||
// The user can create multiple bank accounts with same bank account but other currency if his bank account support that.
|
||||
private final Currency currency;
|
||||
|
||||
private final String uid;
|
||||
|
||||
private final String accountTitle;
|
||||
|
||||
public BankAccount(BankAccountType bankAccountType, Currency currency, Country country, String accountTitle, String accountHolderName, String accountPrimaryID, String accountSecondaryID)
|
||||
@ -35,28 +30,20 @@ public class BankAccount implements Serializable
|
||||
this.accountHolderName = accountHolderName;
|
||||
this.accountPrimaryID = accountPrimaryID;
|
||||
this.accountSecondaryID = accountSecondaryID;
|
||||
|
||||
uid = accountTitle;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(uid);
|
||||
return Objects.hashCode(accountTitle);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof BankAccount))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (obj == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof BankAccount)) return false;
|
||||
if (obj == this) return true;
|
||||
|
||||
final BankAccount other = (BankAccount) obj;
|
||||
return uid.equals(other.getUid());
|
||||
return accountTitle.equals(other.getUid());
|
||||
}
|
||||
|
||||
|
||||
@ -65,49 +52,42 @@ public class BankAccount implements Serializable
|
||||
return accountPrimaryID;
|
||||
}
|
||||
|
||||
|
||||
public String getAccountSecondaryID()
|
||||
{
|
||||
return accountSecondaryID;
|
||||
}
|
||||
|
||||
|
||||
public String getAccountHolderName()
|
||||
{
|
||||
return accountHolderName;
|
||||
}
|
||||
|
||||
|
||||
public BankAccountType getBankAccountType()
|
||||
{
|
||||
return bankAccountType;
|
||||
}
|
||||
|
||||
|
||||
public Currency getCurrency()
|
||||
{
|
||||
return currency;
|
||||
}
|
||||
|
||||
|
||||
public Country getCountry()
|
||||
{
|
||||
return country;
|
||||
}
|
||||
|
||||
|
||||
// we use the accountTitle as unique id
|
||||
public String getUid()
|
||||
{
|
||||
return uid;
|
||||
return accountTitle;
|
||||
}
|
||||
|
||||
|
||||
public String getAccountTitle()
|
||||
{
|
||||
return accountTitle;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@ -116,11 +96,9 @@ public class BankAccount implements Serializable
|
||||
", accountPrimaryID='" + accountPrimaryID + '\'' +
|
||||
", accountSecondaryID='" + accountSecondaryID + '\'' +
|
||||
", accountHolderName='" + accountHolderName + '\'' +
|
||||
", countryLocale=" + country +
|
||||
", country=" + country +
|
||||
", currency=" + currency +
|
||||
", uid='" + uid + '\'' +
|
||||
", accountTitle='" + accountTitle + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,9 +13,7 @@ public enum BankAccountType
|
||||
PERFECT_MONEY("primary ID", "secondary ID"),
|
||||
OTHER("primary ID", "secondary ID");
|
||||
|
||||
|
||||
private final String primaryId;
|
||||
|
||||
private final String secondaryId;
|
||||
|
||||
BankAccountType(String primaryId, String secondaryId)
|
||||
@ -24,19 +22,16 @@ public enum BankAccountType
|
||||
this.secondaryId = secondaryId;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<BankAccountType> getAllBankAccountTypes()
|
||||
{
|
||||
return new ArrayList<>(Arrays.asList(BankAccountType.values()));
|
||||
}
|
||||
|
||||
|
||||
public String getPrimaryId()
|
||||
{
|
||||
return primaryId;
|
||||
}
|
||||
|
||||
|
||||
public String getSecondaryId()
|
||||
{
|
||||
return secondaryId;
|
||||
|
@ -17,7 +17,7 @@ import io.bitsquare.BitSquare;
|
||||
import io.bitsquare.btc.listeners.BalanceListener;
|
||||
import io.bitsquare.btc.listeners.ConfidenceListener;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
@ -48,12 +48,11 @@ public class WalletFacade
|
||||
private final ReentrantLock lock = Threading.lock("lock");
|
||||
|
||||
|
||||
private final String saveAddressEntryListId;
|
||||
private final NetworkParameters params;
|
||||
private final BitSquareWalletAppKit walletAppKit;
|
||||
private final FeePolicy feePolicy;
|
||||
private final CryptoFacade cryptoFacade;
|
||||
private final Storage storage;
|
||||
private final Persistence persistence;
|
||||
private final List<DownloadListener> downloadListeners = new ArrayList<>();
|
||||
private final List<ConfidenceListener> confidenceListeners = new ArrayList<>();
|
||||
private final List<BalanceListener> balanceListeners = new ArrayList<>();
|
||||
@ -68,15 +67,13 @@ public class WalletFacade
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public WalletFacade(NetworkParameters params, BitSquareWalletAppKit walletAppKit, FeePolicy feePolicy, CryptoFacade cryptoFacade, Storage storage)
|
||||
public WalletFacade(NetworkParameters params, BitSquareWalletAppKit walletAppKit, FeePolicy feePolicy, CryptoFacade cryptoFacade, Persistence persistence)
|
||||
{
|
||||
this.params = params;
|
||||
this.walletAppKit = walletAppKit;
|
||||
this.feePolicy = feePolicy;
|
||||
this.cryptoFacade = cryptoFacade;
|
||||
this.storage = storage;
|
||||
|
||||
saveAddressEntryListId = this.getClass().getName() + ".addressEntryList";
|
||||
this.persistence = persistence;
|
||||
}
|
||||
|
||||
|
||||
@ -173,11 +170,11 @@ public class WalletFacade
|
||||
};
|
||||
wallet.addEventListener(walletEventListener);
|
||||
|
||||
Serializable serializable = storage.read(saveAddressEntryListId);
|
||||
List<AddressEntry> savedAddressEntryList = (List<AddressEntry>) serializable;
|
||||
Serializable serializable = persistence.read(this, "addressEntryList");
|
||||
List<AddressEntry> persistedAddressEntryList = (List<AddressEntry>) serializable;
|
||||
if (serializable instanceof List)
|
||||
{
|
||||
addressEntryList = savedAddressEntryList;
|
||||
addressEntryList = persistedAddressEntryList;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1120,7 +1117,7 @@ public class WalletFacade
|
||||
lock.lock();
|
||||
try
|
||||
{
|
||||
storage.write(saveAddressEntryListId, addressEntryList);
|
||||
persistence.write(this, "addressEntryList", addressEntryList);
|
||||
} finally
|
||||
{
|
||||
lock.unlock();
|
||||
|
@ -17,7 +17,7 @@ import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.SeedNodeAddress;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import io.bitsquare.trade.Trading;
|
||||
import io.bitsquare.trade.orderbook.OrderBook;
|
||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
@ -33,7 +33,7 @@ public class BitSquareModule extends AbstractModule
|
||||
{
|
||||
bind(User.class).asEagerSingleton();
|
||||
bind(OrderBook.class).asEagerSingleton();
|
||||
bind(Storage.class).asEagerSingleton();
|
||||
bind(Persistence.class).asEagerSingleton();
|
||||
bind(Settings.class).asEagerSingleton();
|
||||
bind(OrderBookFilter.class).asEagerSingleton();
|
||||
|
||||
|
@ -13,7 +13,7 @@ import io.bitsquare.gui.util.Transitions;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.msg.BootstrapListener;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Trading;
|
||||
import io.bitsquare.user.User;
|
||||
@ -50,7 +50,7 @@ public class MainController implements Initializable, NavigationController
|
||||
private final WalletFacade walletFacade;
|
||||
private final MessageFacade messageFacade;
|
||||
private final Trading trading;
|
||||
private final Storage storage;
|
||||
private final Persistence persistence;
|
||||
private final ToggleGroup toggleGroup = new ToggleGroup();
|
||||
|
||||
|
||||
@ -79,13 +79,13 @@ public class MainController implements Initializable, NavigationController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private MainController(User user, WalletFacade walletFacade, MessageFacade messageFacade, Trading trading, Storage storage)
|
||||
private MainController(User user, WalletFacade walletFacade, MessageFacade messageFacade, Trading trading, Persistence persistence)
|
||||
{
|
||||
this.user = user;
|
||||
this.walletFacade = walletFacade;
|
||||
this.messageFacade = messageFacade;
|
||||
this.trading = trading;
|
||||
this.storage = storage;
|
||||
this.persistence = persistence;
|
||||
|
||||
MainController.INSTANCE = this;
|
||||
}
|
||||
@ -224,7 +224,7 @@ public class MainController implements Initializable, NavigationController
|
||||
Transitions.fadeIn(rightNavPane);
|
||||
Transitions.fadeIn(contentPane);
|
||||
|
||||
NavigationItem selectedNavigationItem = (NavigationItem) storage.read(this, "selectedNavigationItem");
|
||||
NavigationItem selectedNavigationItem = (NavigationItem) persistence.read(this, "selectedNavigationItem");
|
||||
if (selectedNavigationItem == null)
|
||||
{
|
||||
selectedNavigationItem = NavigationItem.HOME;
|
||||
@ -297,7 +297,7 @@ public class MainController implements Initializable, NavigationController
|
||||
((MarketController) childController).setDirection(navigationItem == NavigationItem.BUY ? Direction.BUY : Direction.SELL);
|
||||
}
|
||||
|
||||
storage.write(this, "selectedNavigationItem", navigationItem);
|
||||
persistence.write(this, "selectedNavigationItem", navigationItem);
|
||||
|
||||
prevToggleButton = toggleButton;
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.ArbitratorListener;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
@ -38,7 +38,7 @@ import net.tomp2p.storage.Data;
|
||||
public class ArbitratorOverviewController implements Initializable, ChildController, NavigationController, ArbitratorListener
|
||||
{
|
||||
private final Settings settings;
|
||||
private final Storage storage;
|
||||
private final Persistence persistence;
|
||||
|
||||
private final MessageFacade messageFacade;
|
||||
private final List<Arbitrator> allArbitrators = new ArrayList<>();
|
||||
@ -59,11 +59,11 @@ public class ArbitratorOverviewController implements Initializable, ChildControl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public ArbitratorOverviewController(Settings settings, Storage storage, MessageFacade messageFacade)
|
||||
public ArbitratorOverviewController(Settings settings, Persistence persistence, MessageFacade messageFacade)
|
||||
{
|
||||
|
||||
this.settings = settings;
|
||||
this.storage = storage;
|
||||
this.persistence = persistence;
|
||||
this.messageFacade = messageFacade;
|
||||
|
||||
messageFacade.addArbitratorListener(this);
|
||||
@ -214,7 +214,7 @@ public class ArbitratorOverviewController implements Initializable, ChildControl
|
||||
public void onSelect()
|
||||
{
|
||||
settings.addAcceptedArbitrator(currentArbitrator);
|
||||
storage.write(settings.getClass().getName(), settings);
|
||||
persistence.write(settings);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -4,7 +4,7 @@ import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.util.BitSquareFormatter;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
@ -21,7 +21,7 @@ public class ArbitratorProfileController implements Initializable, ChildControll
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
private final Storage storage;
|
||||
private final Persistence persistence;
|
||||
private Arbitrator arbitrator;
|
||||
private NavigationController navigationController;
|
||||
|
||||
@ -39,13 +39,13 @@ public class ArbitratorProfileController implements Initializable, ChildControll
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public ArbitratorProfileController(Settings settings, Storage storage)
|
||||
public ArbitratorProfileController(Settings settings, Persistence persistence)
|
||||
{
|
||||
this.settings = settings;
|
||||
this.storage = storage;
|
||||
this.persistence = persistence;
|
||||
|
||||
// Settings savedSettings = (Settings) storage.read(settings.getClass().getName());
|
||||
// settings.updateFromStorage(savedSettings);
|
||||
// Settings persistedSettings = (Settings) storage.read(settings.getClass().getName());
|
||||
// settings.applyPersistedSettings(persistedSettings);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ import io.bitsquare.gui.util.ConfidenceDisplay;
|
||||
import io.bitsquare.locale.LanguageUtil;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import io.bitsquare.user.Reputation;
|
||||
import io.bitsquare.user.User;
|
||||
@ -45,7 +45,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationController.class);
|
||||
|
||||
private final Storage storage;
|
||||
private final Persistence persistence;
|
||||
private final WalletFacade walletFacade;
|
||||
private final MessageFacade messageFacade;
|
||||
private User user;
|
||||
@ -93,9 +93,9 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private ArbitratorRegistrationController(Storage storage, WalletFacade walletFacade, MessageFacade messageFacade, User user)
|
||||
private ArbitratorRegistrationController(Persistence persistence, WalletFacade walletFacade, MessageFacade messageFacade, User user)
|
||||
{
|
||||
this.storage = storage;
|
||||
this.persistence = persistence;
|
||||
this.walletFacade = walletFacade;
|
||||
this.messageFacade = messageFacade;
|
||||
this.user = user;
|
||||
@ -128,10 +128,10 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
{
|
||||
accordion.setExpandedPane(profileTitledPane);
|
||||
|
||||
Arbitrator savedArbitrator = (Arbitrator) storage.read(arbitrator.getClass().getName());
|
||||
if (savedArbitrator != null)
|
||||
Arbitrator persistedArbitrator = (Arbitrator) persistence.read(arbitrator);
|
||||
if (persistedArbitrator != null)
|
||||
{
|
||||
arbitrator.updateFromStorage(savedArbitrator);
|
||||
arbitrator.applyPersistedArbitrator(persistedArbitrator);
|
||||
applyArbitrator();
|
||||
}
|
||||
else
|
||||
@ -327,7 +327,7 @@ public class ArbitratorRegistrationController implements Initializable, ChildCon
|
||||
arbitrator = getEditedArbitrator();
|
||||
if (arbitrator != null)
|
||||
{
|
||||
storage.write(arbitrator.getClass().getName(), arbitrator);
|
||||
persistence.write(arbitrator);
|
||||
|
||||
if (isEditMode)
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.Hibernate;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -22,10 +22,9 @@ public class LazyLoadingTabPane extends TabPane
|
||||
private final Map<Integer, Node> views = new HashMap<>();
|
||||
private final Map<Integer, ChildController> controllers = new HashMap<>();
|
||||
private SingleSelectionModel<Tab> selectionModel;
|
||||
private String storageId;
|
||||
private NavigationController navigationController;
|
||||
private String[] tabContentFXMLUrls;
|
||||
private Storage storage;
|
||||
private Persistence persistence;
|
||||
private ChildController childController;
|
||||
private int selectedTabIndex = -1;
|
||||
|
||||
@ -39,7 +38,7 @@ public class LazyLoadingTabPane extends TabPane
|
||||
super();
|
||||
}
|
||||
|
||||
public void initialize(NavigationController navigationController, Storage storage, String... tabContentFXMLUrls)
|
||||
public void initialize(NavigationController navigationController, Persistence persistence, String... tabContentFXMLUrls)
|
||||
{
|
||||
if (tabContentFXMLUrls.length == 0)
|
||||
{
|
||||
@ -49,16 +48,14 @@ public class LazyLoadingTabPane extends TabPane
|
||||
this.tabContentFXMLUrls = tabContentFXMLUrls;
|
||||
this.navigationController = navigationController;
|
||||
this.tabContentFXMLUrls = tabContentFXMLUrls;
|
||||
this.storage = storage;
|
||||
|
||||
storageId = navigationController.getClass().getName() + ".selectedTabIndex";
|
||||
this.persistence = persistence;
|
||||
|
||||
selectionModel = getSelectionModel();
|
||||
selectionModel.selectedItemProperty().addListener((observableValue, oldTab, newTab) -> onTabSelectedIndexChanged());
|
||||
|
||||
if (selectedTabIndex == -1)
|
||||
{
|
||||
Object indexObject = storage.read(storageId);
|
||||
Object indexObject = persistence.read(this, "selectedTabIndex");
|
||||
log.trace("saved index" + indexObject);
|
||||
if (indexObject != null)
|
||||
{
|
||||
@ -138,7 +135,7 @@ public class LazyLoadingTabPane extends TabPane
|
||||
childController.setNavigationController(navigationController);
|
||||
((Hibernate) childController).awake();
|
||||
}
|
||||
storage.write(storageId, index);
|
||||
persistence.write(this, "selectedTabIndex", index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.components.LazyLoadingTabPane;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
@ -16,7 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||
public class FundsController implements Initializable, ChildController, NavigationController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(FundsController.class);
|
||||
private final Storage storage;
|
||||
private final Persistence persistence;
|
||||
|
||||
@FXML
|
||||
private LazyLoadingTabPane tabPane;
|
||||
@ -27,9 +27,9 @@ public class FundsController implements Initializable, ChildController, Navigati
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private FundsController(Storage storage)
|
||||
private FundsController(Persistence persistence)
|
||||
{
|
||||
this.storage = storage;
|
||||
this.persistence = persistence;
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ public class FundsController implements Initializable, ChildController, Navigati
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb)
|
||||
{
|
||||
tabPane.initialize(this, storage, NavigationItem.DEPOSIT.getFxmlUrl(), NavigationItem.WITHDRAWAL.getFxmlUrl(), NavigationItem.TRANSACTIONS.getFxmlUrl());
|
||||
tabPane.initialize(this, persistence, NavigationItem.DEPOSIT.getFxmlUrl(), NavigationItem.WITHDRAWAL.getFxmlUrl(), NavigationItem.TRANSACTIONS.getFxmlUrl());
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.orderbook.OrderBook;
|
||||
@ -65,7 +65,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
private final MessageFacade messageFacade;
|
||||
private final WalletFacade walletFacade;
|
||||
private final Settings settings;
|
||||
private final Storage storage;
|
||||
private final Persistence persistence;
|
||||
private final Image buyIcon = Icons.getIconImage(Icons.BUY);
|
||||
private final Image sellIcon = Icons.getIconImage(Icons.SELL);
|
||||
@FXML
|
||||
@ -93,7 +93,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private OrderBookController(OrderBook orderBook, OrderBookFilter orderBookFilter, User user, MessageFacade messageFacade, WalletFacade walletFacade, Settings settings, Storage storage)
|
||||
private OrderBookController(OrderBook orderBook, OrderBookFilter orderBookFilter, User user, MessageFacade messageFacade, WalletFacade walletFacade, Settings settings, Persistence persistence)
|
||||
{
|
||||
this.orderBook = orderBook;
|
||||
this.orderBookFilter = orderBookFilter;
|
||||
@ -101,7 +101,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
this.messageFacade = messageFacade;
|
||||
this.walletFacade = walletFacade;
|
||||
this.settings = settings;
|
||||
this.storage = storage;
|
||||
this.persistence = persistence;
|
||||
}
|
||||
|
||||
|
||||
@ -304,7 +304,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||
user.setAccountID(walletFacade.getRegistrationAddressInfo().toString());
|
||||
}
|
||||
|
||||
storage.write(user.getClass().getName(), user);
|
||||
persistence.write(user.getClass().getName(), user);
|
||||
} catch (InsufficientMoneyException e1)
|
||||
{
|
||||
Popups.openInsufficientMoneyPopup();
|
||||
|
@ -4,7 +4,7 @@ import io.bitsquare.gui.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.components.LazyLoadingTabPane;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.fxml.FXML;
|
||||
@ -18,14 +18,14 @@ public class OrdersController implements Initializable, ChildController, Navigat
|
||||
private static final Logger log = LoggerFactory.getLogger(OrdersController.class);
|
||||
private static int SELECTED_TAB_INDEX = -1;
|
||||
private static OrdersController INSTANCE;
|
||||
private final Storage storage;
|
||||
private final Persistence persistence;
|
||||
@FXML
|
||||
private LazyLoadingTabPane tabPane;
|
||||
|
||||
@Inject
|
||||
private OrdersController(Storage storage)
|
||||
private OrdersController(Persistence persistence)
|
||||
{
|
||||
this.storage = storage;
|
||||
this.persistence = persistence;
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public class OrdersController implements Initializable, ChildController, Navigat
|
||||
{
|
||||
log.trace("setSelectedTabIndex " + index);
|
||||
tabPane.setSelectedTabIndex(index);
|
||||
storage.write(this.getClass().getName() + ".selectedTabIndex", index);
|
||||
persistence.write(this, "selectedTabIndex", index);
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ public class OrdersController implements Initializable, ChildController, Navigat
|
||||
public void initialize(URL url, ResourceBundle rb)
|
||||
{
|
||||
log.trace("initialize ");
|
||||
tabPane.initialize(this, storage, NavigationItem.OFFER.getFxmlUrl(), NavigationItem.PENDING_TRADE.getFxmlUrl(), NavigationItem.CLOSED_TRADE.getFxmlUrl());
|
||||
tabPane.initialize(this, persistence, NavigationItem.OFFER.getFxmlUrl(), NavigationItem.PENDING_TRADE.getFxmlUrl(), NavigationItem.CLOSED_TRADE.getFxmlUrl());
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@ import io.bitsquare.gui.util.Icons;
|
||||
import io.bitsquare.locale.*;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import io.bitsquare.user.Arbitrator;
|
||||
import io.bitsquare.user.Reputation;
|
||||
import io.bitsquare.user.User;
|
||||
@ -46,7 +46,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
private final Storage storage;
|
||||
private final Persistence persistence;
|
||||
private final MessageFacade messageFacade;
|
||||
private final ObservableList<Locale> languageList;
|
||||
private final ObservableList<Country> countryList;
|
||||
@ -83,17 +83,17 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public SettingsController(User user, Settings settings, Storage storage, MessageFacade messageFacade)
|
||||
public SettingsController(User user, Settings settings, Persistence persistence, MessageFacade messageFacade)
|
||||
{
|
||||
this.user = user;
|
||||
this.settings = settings;
|
||||
this.storage = storage;
|
||||
this.persistence = persistence;
|
||||
this.messageFacade = messageFacade;
|
||||
|
||||
Settings savedSettings = (Settings) storage.read(settings.getClass().getName());
|
||||
if (savedSettings != null)
|
||||
Settings persistedSettings = (Settings) persistence.read(settings);
|
||||
if (persistedSettings != null)
|
||||
{
|
||||
settings.updateFromStorage(savedSettings);
|
||||
settings.applyPersistedSettings(persistedSettings);
|
||||
languageList = FXCollections.observableArrayList(settings.getAcceptedLanguageLocales());
|
||||
countryList = FXCollections.observableArrayList(settings.getAcceptedCountries());
|
||||
arbitratorList = FXCollections.observableArrayList(settings.getAcceptedArbitrators());
|
||||
@ -166,7 +166,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
|
||||
arbitratorList.add(arbitrator);
|
||||
settings.addAcceptedArbitrator(arbitrator);
|
||||
storage.write(settings.getClass().getName(), settings);
|
||||
persistence.write(settings);
|
||||
|
||||
messageFacade.addArbitrator(arbitrator);
|
||||
}
|
||||
@ -284,7 +284,7 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
if (bankAccount != null && bankAccount != user.getCurrentBankAccount())
|
||||
{
|
||||
user.setCurrentBankAccount(bankAccount);
|
||||
storage.write(user.getClass().getName(), user);
|
||||
persistence.write(user);
|
||||
initBankAccountScreen();
|
||||
}
|
||||
}
|
||||
@ -595,12 +595,12 @@ public class SettingsController implements Initializable, ChildController, Navig
|
||||
|
||||
private void saveSettings()
|
||||
{
|
||||
storage.write(settings.getClass().getName(), settings);
|
||||
persistence.write(settings);
|
||||
}
|
||||
|
||||
private void saveUser()
|
||||
{
|
||||
storage.write(user.getClass().getName(), user);
|
||||
persistence.write(user);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -46,11 +46,14 @@ public class MessageFacade implements MessageBroker
|
||||
private static final Logger log = LoggerFactory.getLogger(MessageFacade.class);
|
||||
private static final String ARBITRATORS_ROOT = "ArbitratorsRoot";
|
||||
|
||||
private final P2PNode p2pNode;
|
||||
private P2PNode p2pNode;
|
||||
|
||||
private final List<OrderBookListener> orderBookListeners = new ArrayList<>();
|
||||
private final List<ArbitratorListener> arbitratorListeners = new ArrayList<>();
|
||||
private final List<IncomingTradeMessageListener> incomingTradeMessageListeners = new ArrayList<>();
|
||||
private User user;
|
||||
private Boolean useDiskStorage;
|
||||
private SeedNodeAddress.StaticSeedNodeAddresses defaultStaticSeedNodeAddresses;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -60,7 +63,9 @@ public class MessageFacade implements MessageBroker
|
||||
@Inject
|
||||
public MessageFacade(User user, @Named("useDiskStorage") Boolean useDiskStorage, @Named("defaultSeedNode") SeedNodeAddress.StaticSeedNodeAddresses defaultStaticSeedNodeAddresses)
|
||||
{
|
||||
this.p2pNode = new P2PNode(user.getMessageKeyPair(), useDiskStorage, defaultStaticSeedNodeAddresses, this);
|
||||
this.user = user;
|
||||
this.useDiskStorage = useDiskStorage;
|
||||
this.defaultStaticSeedNodeAddresses = defaultStaticSeedNodeAddresses;
|
||||
}
|
||||
|
||||
|
||||
@ -70,6 +75,7 @@ public class MessageFacade implements MessageBroker
|
||||
|
||||
public void init(BootstrapListener bootstrapListener)
|
||||
{
|
||||
p2pNode = new P2PNode(user.getMessageKeyPair(), useDiskStorage, defaultStaticSeedNodeAddresses, this);
|
||||
p2pNode.start(new FutureCallback<PeerDHT>()
|
||||
{
|
||||
@Override
|
||||
|
@ -36,15 +36,15 @@ public class Settings implements Serializable
|
||||
// Public API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void updateFromStorage(Settings savedSettings)
|
||||
public void applyPersistedSettings(Settings persistedSettings)
|
||||
{
|
||||
if (savedSettings != null)
|
||||
if (persistedSettings != null)
|
||||
{
|
||||
acceptedLanguageLocales = savedSettings.getAcceptedLanguageLocales();
|
||||
acceptedCountryLocales = savedSettings.getAcceptedCountries();
|
||||
acceptedArbitrators = savedSettings.getAcceptedArbitrators();
|
||||
maxCollateral = savedSettings.getMaxCollateral();
|
||||
minCollateral = savedSettings.getMinCollateral();
|
||||
acceptedLanguageLocales = persistedSettings.getAcceptedLanguageLocales();
|
||||
acceptedCountryLocales = persistedSettings.getAcceptedCountries();
|
||||
acceptedArbitrators = persistedSettings.getAcceptedArbitrators();
|
||||
maxCollateral = persistedSettings.getMaxCollateral();
|
||||
minCollateral = persistedSettings.getMinCollateral();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,9 @@ import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
* Simple storage solution for serialized data
|
||||
*/
|
||||
public class Storage
|
||||
public class Persistence
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(Storage.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(Persistence.class);
|
||||
private static final ReentrantLock lock = Threading.lock("Storage");
|
||||
|
||||
private final String prefix = BitSquare.getAppName() + "_pref";
|
||||
@ -33,7 +33,7 @@ public class Storage
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public Storage()
|
||||
public Persistence()
|
||||
{
|
||||
}
|
||||
|
||||
@ -112,6 +112,11 @@ public class Storage
|
||||
write(classInstance.getClass().getName(), value);
|
||||
}
|
||||
|
||||
public void write(Serializable classInstance)
|
||||
{
|
||||
write(classInstance.getClass().getName(), classInstance);
|
||||
}
|
||||
|
||||
public void write(String key, Serializable value)
|
||||
{
|
||||
// log.trace("Write object with key = " + key + " / value = " + value);
|
@ -9,7 +9,7 @@ import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.gui.popups.Popups;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.TakeOfferRequestListener;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.storage.Persistence;
|
||||
import io.bitsquare.trade.protocol.TradeMessage;
|
||||
import io.bitsquare.trade.protocol.offerer.*;
|
||||
import io.bitsquare.trade.protocol.taker.*;
|
||||
@ -32,10 +32,8 @@ public class Trading
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(Trading.class);
|
||||
|
||||
private final String storageKey = this.getClass().getName();
|
||||
|
||||
private final User user;
|
||||
private final Storage storage;
|
||||
private final Persistence persistence;
|
||||
private final MessageFacade messageFacade;
|
||||
private final BlockChainFacade blockChainFacade;
|
||||
private final WalletFacade walletFacade;
|
||||
@ -60,16 +58,16 @@ public class Trading
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public Trading(User user, Storage storage, MessageFacade messageFacade, BlockChainFacade blockChainFacade, WalletFacade walletFacade, CryptoFacade cryptoFacade)
|
||||
public Trading(User user, Persistence persistence, MessageFacade messageFacade, BlockChainFacade blockChainFacade, WalletFacade walletFacade, CryptoFacade cryptoFacade)
|
||||
{
|
||||
this.user = user;
|
||||
this.storage = storage;
|
||||
this.persistence = persistence;
|
||||
this.messageFacade = messageFacade;
|
||||
this.blockChainFacade = blockChainFacade;
|
||||
this.walletFacade = walletFacade;
|
||||
this.cryptoFacade = cryptoFacade;
|
||||
|
||||
Object offersObject = storage.read(storageKey + ".offers");
|
||||
Object offersObject = persistence.read(this, "offers");
|
||||
if (offersObject instanceof HashMap)
|
||||
{
|
||||
offers = (Map<String, Offer>) offersObject;
|
||||
@ -79,7 +77,7 @@ public class Trading
|
||||
offers = new HashMap<>();
|
||||
}
|
||||
|
||||
Object tradesObject = storage.read(storageKey + ".trades");
|
||||
Object tradesObject = persistence.read(this, "trades");
|
||||
if (tradesObject instanceof HashMap)
|
||||
{
|
||||
trades = (Map<String, Trade>) tradesObject;
|
||||
@ -405,12 +403,12 @@ public class Trading
|
||||
|
||||
private void saveOffers()
|
||||
{
|
||||
storage.write(storageKey + ".offers", offers);
|
||||
persistence.write(this, "offers", offers);
|
||||
}
|
||||
|
||||
private void saveTrades()
|
||||
{
|
||||
storage.write(storageKey + ".trades", trades);
|
||||
persistence.write(this, "trades", trades);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -68,23 +68,23 @@ public class Arbitrator implements Serializable
|
||||
id = name;
|
||||
}
|
||||
|
||||
public void updateFromStorage(Arbitrator savedArbitrator)
|
||||
public void applyPersistedArbitrator(Arbitrator persistedArbitrator)
|
||||
{
|
||||
this.pubKeyAsHex = savedArbitrator.getPubKeyAsHex();
|
||||
this.messagePubKeyAsHex = savedArbitrator.getPubKeyAsHex();
|
||||
this.name = savedArbitrator.getName();
|
||||
this.idType = savedArbitrator.getIdType();
|
||||
this.languages = savedArbitrator.getLanguages();
|
||||
this.reputation = savedArbitrator.getReputation();
|
||||
this.maxTradeVolume = savedArbitrator.getMaxTradeVolume();
|
||||
this.passiveServiceFee = savedArbitrator.getPassiveServiceFee();
|
||||
this.minPassiveServiceFee = savedArbitrator.getMinPassiveServiceFee();
|
||||
this.arbitrationFee = savedArbitrator.getArbitrationFee();
|
||||
this.minArbitrationFee = savedArbitrator.getMinArbitrationFee();
|
||||
this.arbitrationMethods = savedArbitrator.getArbitrationMethods();
|
||||
this.idVerifications = savedArbitrator.getIdVerifications();
|
||||
this.webUrl = savedArbitrator.getWebUrl();
|
||||
this.description = savedArbitrator.getDescription();
|
||||
this.pubKeyAsHex = persistedArbitrator.getPubKeyAsHex();
|
||||
this.messagePubKeyAsHex = persistedArbitrator.getPubKeyAsHex();
|
||||
this.name = persistedArbitrator.getName();
|
||||
this.idType = persistedArbitrator.getIdType();
|
||||
this.languages = persistedArbitrator.getLanguages();
|
||||
this.reputation = persistedArbitrator.getReputation();
|
||||
this.maxTradeVolume = persistedArbitrator.getMaxTradeVolume();
|
||||
this.passiveServiceFee = persistedArbitrator.getPassiveServiceFee();
|
||||
this.minPassiveServiceFee = persistedArbitrator.getMinPassiveServiceFee();
|
||||
this.arbitrationFee = persistedArbitrator.getArbitrationFee();
|
||||
this.minArbitrationFee = persistedArbitrator.getMinArbitrationFee();
|
||||
this.arbitrationMethods = persistedArbitrator.getArbitrationMethods();
|
||||
this.idVerifications = persistedArbitrator.getIdVerifications();
|
||||
this.webUrl = persistedArbitrator.getWebUrl();
|
||||
this.description = persistedArbitrator.getDescription();
|
||||
|
||||
//TODO for mock arbitrator
|
||||
id = name;
|
||||
|
@ -8,23 +8,26 @@ import java.security.PublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The User is stored locally it is never transmitted over the wire.
|
||||
*/
|
||||
public class User implements Serializable
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(User.class);
|
||||
private static final long serialVersionUID = 7409078808248518638L;
|
||||
|
||||
transient private final SimpleBooleanProperty bankAccountChangedProperty = new SimpleBooleanProperty();
|
||||
transient private KeyPair messageKeyPair = DSAKeyUtil.getKeyPair();
|
||||
|
||||
private PublicKey messagePublicKey;
|
||||
private KeyPair messageKeyPair;
|
||||
private String accountID;
|
||||
private boolean isOnline;
|
||||
private List<BankAccount> bankAccounts = new ArrayList<>();
|
||||
private BankAccount currentBankAccount = null;
|
||||
private List<BankAccount> bankAccounts;
|
||||
private BankAccount currentBankAccount;
|
||||
|
||||
public User()
|
||||
{
|
||||
messagePublicKey = messageKeyPair.getPublic();
|
||||
}
|
||||
|
||||
|
||||
@ -32,46 +35,36 @@ public class User implements Serializable
|
||||
// Public Methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void updateFromStorage(User savedUser)
|
||||
public void applyPersistedUser(User persistedUser)
|
||||
{
|
||||
if (savedUser != null)
|
||||
if (persistedUser != null)
|
||||
{
|
||||
accountID = savedUser.getAccountId();
|
||||
// TODO handled by DSAKeyUtil -> change that storage check is only done here
|
||||
// messagePublicKey = savedUser.getMessagePublicKey();
|
||||
isOnline = savedUser.getIsOnline();
|
||||
bankAccounts = savedUser.getBankAccounts();
|
||||
currentBankAccount = savedUser.getCurrentBankAccount();
|
||||
accountID = persistedUser.getAccountId();
|
||||
bankAccounts = persistedUser.getBankAccounts();
|
||||
setCurrentBankAccount(persistedUser.getCurrentBankAccount());
|
||||
messageKeyPair = persistedUser.getMessageKeyPair();
|
||||
}
|
||||
else
|
||||
{
|
||||
// First time
|
||||
bankAccounts = new ArrayList<>();
|
||||
messageKeyPair = DSAKeyUtil.getKeyPair(); // DSAKeyUtil.getKeyPair() runs in same thread now
|
||||
}
|
||||
|
||||
messagePublicKey = messageKeyPair.getPublic();
|
||||
}
|
||||
|
||||
public void addBankAccount(BankAccount bankAccount)
|
||||
{
|
||||
if (!bankAccounts.contains(bankAccount))
|
||||
{
|
||||
bankAccounts.add(bankAccount);
|
||||
}
|
||||
if (!bankAccounts.contains(bankAccount)) bankAccounts.add(bankAccount);
|
||||
|
||||
currentBankAccount = bankAccount;
|
||||
setCurrentBankAccount(bankAccount);
|
||||
}
|
||||
|
||||
public void removeCurrentBankAccount()
|
||||
{
|
||||
if (currentBankAccount != null)
|
||||
{
|
||||
bankAccounts.remove(currentBankAccount);
|
||||
}
|
||||
if (currentBankAccount != null) bankAccounts.remove(currentBankAccount);
|
||||
|
||||
if (bankAccounts.isEmpty())
|
||||
{
|
||||
currentBankAccount = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentBankAccount = bankAccounts.get(0);
|
||||
}
|
||||
if (bankAccounts.isEmpty()) currentBankAccount = null;
|
||||
else setCurrentBankAccount(bankAccounts.get(0));
|
||||
}
|
||||
|
||||
|
||||
@ -79,6 +72,22 @@ public class User implements Serializable
|
||||
// Setters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Will be written after registration.
|
||||
// Public key from the input for the registration payment tx (or address) will be used
|
||||
public void setAccountID(String accountID)
|
||||
{
|
||||
this.accountID = accountID;
|
||||
}
|
||||
|
||||
public void setCurrentBankAccount(BankAccount bankAccount)
|
||||
{
|
||||
this.currentBankAccount = bankAccount;
|
||||
bankAccountChangedProperty.set(!bankAccountChangedProperty.get());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getStringifiedBankAccounts()
|
||||
{
|
||||
@ -97,46 +106,21 @@ public class User implements Serializable
|
||||
return bankAccountUIDs;
|
||||
}
|
||||
|
||||
|
||||
public String getAccountId()
|
||||
{
|
||||
return accountID;
|
||||
}
|
||||
|
||||
public void setAccountID(String accountID)
|
||||
{
|
||||
this.accountID = accountID;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public List<BankAccount> getBankAccounts()
|
||||
{
|
||||
return bankAccounts;
|
||||
}
|
||||
|
||||
public void setBankAccounts(List<BankAccount> bankAccounts)
|
||||
{
|
||||
this.bankAccounts = bankAccounts;
|
||||
}
|
||||
|
||||
|
||||
public BankAccount getCurrentBankAccount()
|
||||
{
|
||||
return currentBankAccount;
|
||||
}
|
||||
|
||||
public void setCurrentBankAccount(BankAccount bankAccount)
|
||||
{
|
||||
this.currentBankAccount = bankAccount;
|
||||
bankAccountChangedProperty.set(!bankAccountChangedProperty.get());
|
||||
}
|
||||
|
||||
|
||||
public BankAccount getBankAccount(String bankAccountId)
|
||||
{
|
||||
for (final BankAccount bankAccount : bankAccounts)
|
||||
@ -149,36 +133,11 @@ public class User implements Serializable
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean getIsOnline()
|
||||
{
|
||||
return isOnline;
|
||||
}
|
||||
|
||||
public void setIsOnline(boolean isOnline)
|
||||
{
|
||||
this.isOnline = isOnline;
|
||||
}
|
||||
|
||||
|
||||
public SimpleBooleanProperty getBankAccountChangedProperty()
|
||||
{
|
||||
return bankAccountChangedProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "User{" +
|
||||
"bankAccountChangedProperty=" + bankAccountChangedProperty +
|
||||
", messageKeyPair=" + messageKeyPair +
|
||||
", messagePublicKey=" + messagePublicKey +
|
||||
", accountID='" + accountID + '\'' +
|
||||
", isOnline=" + isOnline +
|
||||
", bankAccounts=" + bankAccounts +
|
||||
", currentBankAccount=" + currentBankAccount +
|
||||
'}';
|
||||
}
|
||||
|
||||
public KeyPair getMessageKeyPair()
|
||||
{
|
||||
return messageKeyPair;
|
||||
@ -186,6 +145,18 @@ public class User implements Serializable
|
||||
|
||||
public PublicKey getMessagePublicKey()
|
||||
{
|
||||
return messagePublicKey;
|
||||
return messageKeyPair.getPublic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "User{" +
|
||||
"bankAccountChangedProperty=" + bankAccountChangedProperty +
|
||||
", messageKeyPair=" + messageKeyPair +
|
||||
", accountID='" + accountID + '\'' +
|
||||
", bankAccounts=" + bankAccounts +
|
||||
", currentBankAccount=" + currentBankAccount +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,10 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Runs in JavaFX Application Thread now but might be sent to a background thread.
|
||||
* We need to handle threading issues in the client classes if we change.
|
||||
*/
|
||||
public class DSAKeyUtil
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(DSAKeyUtil.class);
|
||||
@ -177,7 +181,6 @@ public class DSAKeyUtil
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
privKeyFileInputStream.read(encodedPrivKey);
|
||||
final PrivateKey privKey = keyFactory.generatePrivate(new PKCS8EncodedKeySpec(encodedPrivKey));
|
||||
|
||||
return new KeyPair(pubKey, privKey);
|
||||
} finally
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user