Java Code Examples for net.bither.bitherj.utils.Utils#validPassword()

The following examples show how to use net.bither.bitherj.utils.Utils#validPassword() . 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: DialogPasswordWithOther.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: SplitBccColdWalletSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: SplitBCCHDAccountSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@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 4
Source File: HdmSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
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);
    SecureCharSequence password = new SecureCharSequence(etPassword.getText());
    boolean 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: SplitBCCHDAccountMonitoredSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void validateValues() {
    boolean isValidAmounts = false;
        btcAmount = AddressManager.getInstance().getAmount(AbstractDb.
                hdAccountAddressProvider.getUnspentOutputByBlockNo(splitCoin.getForkBlockHeight(),AddressManager.getInstance()
                .getHDAccountMonitored().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: BCCAssetsDetectHDActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@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 7
Source File: DialogPassword.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@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 8
Source File: SendBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
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 9
Source File: SendBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
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 10
Source File: SendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
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 11
Source File: BCCAssetsDetectHotActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
protected void validateValues() {
    boolean isValidAmounts = false;
    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 12
Source File: BCCAssetsHDAccountMonitoredActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@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 13
Source File: BCCAssetsHotMonitoredActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@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 14
Source File: SendHDMBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
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 15
Source File: SendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    SecureCharSequence p = new SecureCharSequence(etPassword.getText());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            etPassword.setText(password);
        }
    }
    p.wipe();
    validateValues();
    password.wipe();
}
 
Example 16
Source File: PasswordPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public void keyReleased(KeyEvent keyEvent) {

    SecureCharSequence p = new SecureCharSequence(newPassword.getPassword());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            newPassword.setText(password.toString());
        }
    }
    p.wipe();
    if (repeatNewPassword.isVisible()) {
        SecureCharSequence pc = new SecureCharSequence(repeatNewPassword.getPassword());
        if (pc.length() > 0) {
            if (!Utils.validPassword(pc)) {
                repeatNewPassword.setText(passwordConfirm.toString());
            }
        }
        pc.wipe();
    }
    checkValid();
    if (password != null) {
        password.wipe();
    }
    if (passwordConfirm != null) {
        passwordConfirm.wipe();
    }

}
 
Example 17
Source File: SplitBCCSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    SecureCharSequence p = new SecureCharSequence(etPassword.getText());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            etPassword.setText(password);
        }
    }
    p.wipe();
    validateValues();
    password.wipe();
}
 
Example 18
Source File: UtilsTest.java    From bitherj with Apache License 2.0 5 votes vote down vote up
@Test
public void testPassword() {
    String password = "0aA`~!@#$%^&*()_-+={}[]|:;\\\"'<>,.?/";
    boolean validP = Utils.validPassword(password);
    assertTrue(validP);
    password = "ASDF简繁";
    assertFalse(Utils.validPassword(password));
}
 
Example 19
Source File: HdmSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    SecureCharSequence p = new SecureCharSequence(etPassword.getText());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            etPassword.setText(password);
        }
    }
    p.wipe();
    validateValues();
    password.wipe();
}
 
Example 20
Source File: PasswordPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public void keyReleased(KeyEvent keyEvent) {

    SecureCharSequence p = new SecureCharSequence(newPassword.getPassword());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            newPassword.setText(password.toString());
        }
    }
    p.wipe();
    if (repeatNewPassword.isVisible()) {
        SecureCharSequence pc = new SecureCharSequence(repeatNewPassword.getPassword());
        if (pc.length() > 0) {
            if (!Utils.validPassword(pc)) {
                repeatNewPassword.setText(passwordConfirm.toString());
            }
        }
        pc.wipe();
    }
    checkValid();
    if (password != null) {
        password.wipe();
    }
    if (passwordConfirm != null) {
        passwordConfirm.wipe();
    }

}