Java Code Examples for net.bither.bitherj.crypto.SecureCharSequence#wipe()
The following examples show how to use
net.bither.bitherj.crypto.SecureCharSequence#wipe() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SendHDMBitcoinPanel.java From bither-desktop-java with Apache License 2.0 | 6 votes |
private void validateValues() { boolean isValidAmounts = false; String amtString = tfAmt.getText().trim(); if (Utils.isNubmer(amtString)) { long btc = GenericUtils.toNanoCoins(amtString, 0).longValue(); if (btc > 0) { isValidAmounts = true; } else { } } boolean isValidAddress = Utils.validBicoinAddress(tfAddress.getText().trim()); SecureCharSequence password = new SecureCharSequence(currentPassword.getPassword()); boolean isValidPassword = Utils.validPassword(password) && password.length() >= BitherSetting.PASSWORD_LENGTH_MIN && password.length() <= BitherSetting.PASSWORD_LENGTH_MAX; password.wipe(); setOkEnabled(isValidAddress && isValidAmounts && isValidPassword); }
Example 2
Source File: CheckUtil.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public static Check initCheckForHDMKeychain(final HDMKeychain keychain, final SecureCharSequence password) { String title = LocaliserUtils.getString("hdm_keychain_check_title_cold"); if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.HOT) { title = LocaliserUtils.getString("hdm_keychain_check_title_hot"); } Check check = new Check(title, new ICheckAction() { @Override public boolean check() { boolean result = false; try { result = keychain.checkWithPassword(password); if (result) { result = keychain.checkSingularBackupWithPassword(password); } //TODO need to check backup here? } catch (Exception e) { e.printStackTrace(); } password.wipe(); return result; } }); return check; }
Example 3
Source File: DialogPasswordWithOther.java From bither-android with Apache License 2.0 | 6 votes |
@Override public void afterTextChanged(Editable s) { tvError.setVisibility(View.GONE); SecureCharSequence p = new SecureCharSequence(etPassword.getText()); if (p.length() > 0) { if (!Utils.validPassword(p)) { etPassword.setText(password); } } p.wipe(); if (etPasswordConfirm.getVisibility() == View.VISIBLE) { SecureCharSequence pc = new SecureCharSequence(etPasswordConfirm.getText()); if (pc.length() > 0) { if (!Utils.validPassword(pc)) { etPasswordConfirm.setText(passwordConfirm); } } pc.wipe(); } checkValid(); password.wipe(); passwordConfirm.wipe(); }
Example 4
Source File: SendActivity.java From bither-android with Apache License 2.0 | 6 votes |
private void validateValues() { boolean isValidAmounts = false; final BigInteger amount = BigInteger.valueOf(amountCalculatorLink.getAmount()); if (amount == null) { } else if (amount.signum() > 0) { isValidAmounts = true; } else { } String address = etAddress.getText().toString().trim(); boolean isValidAddress = Utils.validBicoinAddress(address); if (isColdSendBtc && isValidAddress && Utils.validBech32Address(address)) { isValidAddress = false; DropdownMessage.showDropdownMessage(this, R.string.cold_no_support_bc1_segwit_address); etAddress.setText(""); } boolean isValidPassword = true; if (etPassword.getVisibility() == View.VISIBLE) { SecureCharSequence password = new SecureCharSequence(etPassword.getText()); isValidPassword = Utils.validPassword(password) && password.length() >= 6 && password.length() <= getResources().getInteger(R.integer.password_length_max); password.wipe(); } btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword); }
Example 5
Source File: SplitBCCHDAccountSendActivity.java From bither-android with Apache License 2.0 | 6 votes |
@Override protected void validateValues() { boolean isValidAmounts = false; btcAmount = getAmount(AbstractDb.hdAccountAddressProvider.getUnspentOutputByBlockNo(splitCoin.getForkBlockHeight(), AddressManager.getInstance().getHDAccountHot().getHdSeedId())); if (btcAmount > 0) { isValidAmounts = true; } toAddress = etAddress.getText().toString().trim(); boolean isValidAddress = Utils.validSplitBitCoinAddress(toAddress,splitCoin); boolean isValidPassword = true; if (etPassword.getVisibility() == View.VISIBLE) { SecureCharSequence password = new SecureCharSequence(etPassword.getText()); isValidPassword = Utils.validPassword(password) && password.length() >= 6 && password.length() <= getResources().getInteger(R.integer.password_length_max); password.wipe(); } btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword); }
Example 6
Source File: SendHDMBitcoinPanel.java From bither-desktop-java with Apache License 2.0 | 6 votes |
private void validateValues() { boolean isValidAmounts = false; String amtString = tfAmt.getText().trim(); if (Utils.isNubmer(amtString)) { long btc = GenericUtils.toNanoCoins(amtString, 0).longValue(); if (btc > 0) { isValidAmounts = true; } else { } } boolean isValidAddress = Utils.validBicoinAddress(tfAddress.getText().trim()); SecureCharSequence password = new SecureCharSequence(currentPassword.getPassword()); boolean isValidPassword = Utils.validPassword(password) && password.length() >= BitherSetting.PASSWORD_LENGTH_MIN && password.length() <= BitherSetting.PASSWORD_LENGTH_MAX; password.wipe(); setOkEnabled(isValidAddress && isValidAmounts && isValidPassword); }
Example 7
Source File: BCCAssetsHDAccountMonitoredActivity.java From bither-android with Apache License 2.0 | 6 votes |
@Override protected void validateValues() { boolean isValidAmounts = false; btcAmount = getAmount(outs); if (btcAmount > 0) { isValidAmounts = true; } toAddress = etAddress.getText().toString().trim(); boolean isValidAddress = Utils.validBicoinAddress(toAddress); boolean isValidPassword = true; if (etPassword.getVisibility() == View.VISIBLE) { SecureCharSequence password = new SecureCharSequence(etPassword.getText()); isValidPassword = Utils.validPassword(password) && password.length() >= 6 && password.length() <= getResources().getInteger(R.integer.password_length_max); password.wipe(); } btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword); }
Example 8
Source File: BCCAssetsHotMonitoredActivity.java From bither-android with Apache License 2.0 | 6 votes |
@Override protected void validateValues() { boolean isValidAmounts = false; btcAmount = getAmount(outs); if (btcAmount > 0) { isValidAmounts = true; } toAddress = etAddress.getText().toString().trim(); boolean isValidAddress = Utils.validBicoinAddress(toAddress); boolean isValidPassword = true; if (etPassword.getVisibility() == View.VISIBLE) { SecureCharSequence password = new SecureCharSequence(etPassword.getText()); isValidPassword = Utils.validPassword(password) && password.length() >= 6 && password.length() <= getResources().getInteger(R.integer.password_length_max); password.wipe(); } btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword); }
Example 9
Source File: SplitBccColdWalletSendActivity.java From bither-android with Apache License 2.0 | 6 votes |
@Override protected void validateValues() { boolean isValidAmounts = false; btcAmount = getAmount(AbstractDb.txProvider.getUnspentOutputByBlockNo(splitCoin.getForkBlockHeight(), address.getAddress())); if (btcAmount > 0) { isValidAmounts = true; } toAddress = etAddress.getText().toString().trim(); boolean isValidAddress = Utils.validSplitBitCoinAddress(toAddress,splitCoin); boolean isValidPassword = true; if (etPassword.getVisibility() == View.VISIBLE) { SecureCharSequence password = new SecureCharSequence(etPassword.getText()); isValidPassword = Utils.validPassword(password) && password.length() >= 6 && password.length() <= getResources().getInteger(R.integer.password_length_max); password.wipe(); } btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword); }
Example 10
Source File: BCCAssetsDetectHDActivity.java From bither-android with Apache License 2.0 | 6 votes |
@Override protected void validateValues() { boolean isValidAmounts = false; btcAmount = getAmount(outs); if (btcAmount > 0) { isValidAmounts = true; } toAddress = etAddress.getText().toString().trim(); boolean isValidAddress = Utils.validBicoinAddress(toAddress); boolean isValidPassword = true; if (etPassword.getVisibility() == View.VISIBLE) { SecureCharSequence password = new SecureCharSequence(etPassword.getText()); isValidPassword = Utils.validPassword(password) && password.length() >= 6 && password.length() <= getResources().getInteger(R.integer.password_length_max); password.wipe(); } btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword); }
Example 11
Source File: CheckUtil.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public static Check initCheckForHDAccount(final HDAccount account, final SecureCharSequence password) { String title = LocaliserUtils.getString("add_hd_account_tab_hd"); Check check = new Check(title, new ICheckAction() { @Override public boolean check() { boolean result; try { result = account.checkWithPassword(password); } catch (Exception e) { result = false; } password.wipe(); return result; } }); return check; }
Example 12
Source File: SendBitcoinPanel.java From bither-desktop-java with Apache License 2.0 | 6 votes |
private void validateValues() { boolean isValidAmounts = false; String amtString = tfAmt.getText().trim(); if (Utils.isNubmer(amtString)) { long btc = GenericUtils.toNanoCoins(amtString, 0).longValue(); if (btc > 0) { isValidAmounts = true; } else { } } boolean isValidAddress = Utils.validBicoinAddress(tfAddress.getText().trim()); SecureCharSequence password = new SecureCharSequence(currentPassword.getPassword()); boolean isValidPassword = Utils.validPassword(password) && password.length() >= BitherSetting.PASSWORD_LENGTH_MIN && password.length() <= BitherSetting.PASSWORD_LENGTH_MAX; password.wipe(); setOkEnabled(isValidAddress && isValidAmounts && isValidPassword); }
Example 13
Source File: CheckUtil.java From bither-desktop-java with Apache License 2.0 | 5 votes |
public static Check initCheckForPrivateKey( final Address address, final SecureCharSequence password) { String title = String.format(LocaliserUtils.getString("check_address_private_key_title"), address .getShortAddress()); Check check = new Check(title, new ICheckAction() { @Override public boolean check() { boolean result = new PasswordSeed(address.getAddress(), address.getFullEncryptPrivKey()).checkPassword(password); if (!result) { try { ECKey eckeyFromBackup = BackupUtil.getEckeyFromBackup( address.getAddress(), password); if (eckeyFromBackup != null) { String encryptPrivateKey = PrivateKeyUtil.getEncryptedString(eckeyFromBackup); if (!Utils.isEmpty(encryptPrivateKey)) { address.recoverFromBackup(encryptPrivateKey); result = true; } eckeyFromBackup.clearPrivateKey(); } } catch (Exception e) { e.printStackTrace(); } finally { password.wipe(); } } return result; } }); return check; }
Example 14
Source File: ExportPrivateKeyPanel.java From bither-desktop-java with Apache License 2.0 | 5 votes |
private void showPrivateKeyQRCode(SecureCharSequence password) { final SecureCharSequence str = PrivateKeyUtil.getDecryptPrivateKeyString(Bither.getActionAddress().getFullEncryptPrivKey(), password); password.wipe(); DisplayQRCodePanle displayQRCodePanle = new DisplayQRCodePanle(str.toString()); displayQRCodePanle.showPanel(); }
Example 15
Source File: AddAddressColdHDMFragment.java From bither-android with Apache License 2.0 | 5 votes |
@Override public void onPasswordEntered(final SecureCharSequence password) { btnAdd.setKeepScreenOn(true); ThreadNeedService thread = new ThreadNeedService(dp, activity) { @Override public void runWithService(BlockchainService service) { chain = new HDMKeychain(new SecureRandom(), password); KeyUtil.setHDKeyChain(chain); password.wipe(); ArrayList<String> addresses = getAddresses(); Intent intent = new Intent(); intent.putExtra(BitherSetting.INTENT_REF.ADDRESS_POSITION_PASS_VALUE_TAG, addresses); getActivity().setResult(Activity.RESULT_OK, intent); activity.runOnUiThread(new Runnable() { @Override public void run() { btnAdd.setKeepScreenOn(false); if (dp.isShowing()) { dp.dismiss(); } activity.save(); } }); } }; thread.start(); }
Example 16
Source File: SplitBCCHDAccountSendActivity.java From bither-android with Apache License 2.0 | 5 votes |
private void send(String...blockhash) { txs = null; HDAccount account = (HDAccount) address; SecureCharSequence password = new SecureCharSequence(etPassword.getText()); try { txs = account.newForkTx(etAddress.getText().toString().trim(), btcAmount, password, splitCoin,blockhash); } catch (Exception e) { e.printStackTrace(); btcAmount = 0; txs = null; String msg = getString(R.string.send_failed); if (e instanceof KeyCrypterException || e instanceof MnemonicException .MnemonicLengthException) { msg = getString(R.string.password_wrong); } else if (e instanceof TxBuilderException) { msg = e.getMessage(); } final String m = msg; runOnUiThread(new Runnable() { @Override public void run() { if (dp.isShowing()) { dp.dismiss(); } DropdownMessage.showDropdownMessage(SplitBCCHDAccountSendActivity.this, m); } }); } finally { password.wipe(); } if (txs != null) { runOnUiThread(new Runnable() { @Override public void run() { showConfirm(); } }); } }
Example 17
Source File: DialogEditPassword.java From bither-android with Apache License 2.0 | 5 votes |
@Override public boolean check() { if (passwordSeed != null) { SecureCharSequence password = new SecureCharSequence(etOldPassword.getText()); boolean result = passwordSeed.checkPassword(password); password.wipe(); return result; } else { return true; } }
Example 18
Source File: DialogEditPassword.java From bither-android with Apache License 2.0 | 4 votes |
@Override public void onClick(View v) { if (v.getId() == R.id.btn_ok) { SecureCharSequence oldP = new SecureCharSequence(etOldPassword.getText()); SecureCharSequence newP = new SecureCharSequence(etNewPassword.getText()); SecureCharSequence newCP = new SecureCharSequence(etNewPasswordConfirm.getText()); if (!newP.equals(newCP)) { shake(); tvError.setText(R.string.add_address_generate_address_password_not_same); tvError.setVisibility(View.VISIBLE); etNewPasswordConfirm.requestFocus(); oldP.wipe(); newP.wipe(); newCP.wipe(); return; } if (oldP.equals(newP)) { shake(); tvError.setText(R.string.edit_password_new_old_same); tvError.setVisibility(View.VISIBLE); etNewPasswordConfirm.requestFocus(); oldP.wipe(); newP.wipe(); newCP.wipe(); return; } if (AppSharedPreference.getInstance().getPasswordStrengthCheck()) { PasswordStrengthUtil.PasswordStrength strength = PasswordStrengthUtil .checkPassword(newP); oldP.wipe(); newP.wipe(); newCP.wipe(); if (!strength.passed()) { etNewPassword.requestFocus(); shakeStrength(); return; } if (strength.warning()) { new DialogConfirmTask(getContext(), String.format(getContext().getString(R .string.password_strength_warning), strength.getName()), new Runnable () { @Override public void run() { executor = CheckUtil.runChecks(Arrays.asList(new Check[]{passwordCheck}), 1); } }).show(); return; } } oldP.wipe(); newP.wipe(); newCP.wipe(); if (passwordSeed != null) { ArrayList<Check> checks = new ArrayList<Check>(); checks.add(passwordCheck); executor = CheckUtil.runChecks(checks, 1); } else { dismiss(); } } else { dismiss(); } }
Example 19
Source File: PrivateTextPanel.java From bither-desktop-java with Apache License 2.0 | 4 votes |
public PrivateTextPanel(SecureCharSequence secureCharSequence) { super(MessageKey.PRIVATE_KEY_TEXT, AwesomeIcon.FA_FILE_TEXT); this.secureCharSequence = Utils.formatHashFromCharSequence(secureCharSequence, 4, 16); secureCharSequence.wipe(); }
Example 20
Source File: PrivateTextPanel.java From bither-desktop-java with Apache License 2.0 | 4 votes |
public PrivateTextPanel(SecureCharSequence secureCharSequence) { super(MessageKey.PRIVATE_KEY_TEXT, AwesomeIcon.FA_FILE_TEXT); this.secureCharSequence = Utils.formatHashFromCharSequence(secureCharSequence, 4, 16); secureCharSequence.wipe(); }