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