use of network.bisq.api.service.TokenRegistry in project bisq-api by mrosseel.
the class BisqProxy method changePassword.
public AuthResult changePassword(String oldPassword, String newPassword) {
if (!btcWalletService.isWalletReady())
throw new WalletNotReadyException("Wallet not ready yet");
final WalletsManager walletsManager = injector.getInstance(WalletsManager.class);
if (btcWalletService.isEncrypted()) {
final KeyParameter aesKey = null == oldPassword ? null : getAESKey(oldPassword);
if (!isWalletPasswordValid(aesKey))
throw new UnauthorizedException();
walletsManager.decryptWallets(aesKey);
}
if (null != newPassword && newPassword.length() > 0) {
final Tuple2<KeyParameter, KeyCrypterScrypt> aesKeyAndScrypt = getAESKeyAndScrypt(newPassword);
walletsManager.encryptWallets(aesKeyAndScrypt.second, aesKeyAndScrypt.first);
final TokenRegistry tokenRegistry = injector.getInstance(TokenRegistry.class);
tokenRegistry.clear();
return new AuthResult(tokenRegistry.generateToken());
}
return null;
}
use of network.bisq.api.service.TokenRegistry in project bisq-api by mrosseel.
the class BisqProxy method authenticate.
public AuthResult authenticate(String password) {
final TokenRegistry tokenRegistry = injector.getInstance(TokenRegistry.class);
final boolean isPasswordValid = btcWalletService.isWalletReady() && btcWalletService.isEncrypted() && isWalletPasswordValid(password);
if (isPasswordValid) {
return new AuthResult(tokenRegistry.generateToken());
}
throw new UnauthorizedException();
}
Aggregations