net.bither.bitherj.api.http.HttpSetting Java Examples
The following examples show how to use
net.bither.bitherj.api.http.HttpSetting.
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: RecoveryHDMApi.java From bitherj with Apache License 2.0 | 6 votes |
@Override public void setResult(String response) throws Exception { JSONObject json = new JSONObject(response); this.result = new ArrayList<HDMAddress.Pubs>(); List<byte[]> pubHots = new ArrayList<byte[]>(); List<byte[]> pubColds = new ArrayList<byte[]>(); List<byte[]> pubService = new ArrayList<byte[]>(); if (!json.isNull(HttpSetting.PUB_HOT)) { String pubHotString = json.getString(HttpSetting.PUB_HOT); pubHots = Utils.decodeServiceResult(pubHotString); } if (!json.isNull(HttpSetting.PUB_COLD)) { String pubColdString = json.getString(HttpSetting.PUB_COLD); pubColds = Utils.decodeServiceResult(pubColdString); } if (!json.isNull(HttpSetting.PUB_SERVER)) { String pubServiceString = json.getString(HttpSetting.PUB_SERVER); pubService = Utils.decodeServiceResult(pubServiceString); } for (int i = 0; i < pubHots.size(); i++) { HDMAddress.Pubs pubs = new HDMAddress.Pubs(pubHots.get(i), pubColds.get(i), pubService.get(i), i); this.result.add(pubs); } }
Example #2
Source File: ExceptionUtil.java From bither-desktop-java with Apache License 2.0 | 5 votes |
public static final String getHDMHttpExceptionMessage(int code) { switch (code) { case HttpSetting.HDMBIdIsAlready: return LocaliserUtils.getString("hdm_exception_bid_already_exists"); case HttpSetting.MessageSignatureIsWrong: return LocaliserUtils.getString("hdm_keychain_add_sign_server_qr_code_error"); default: return LocaliserUtils.getString("network_or_connection_error"); } }
Example #3
Source File: ExceptionUtil.java From bither-android with Apache License 2.0 | 5 votes |
public static final int getHDMHttpExceptionMessage(int code) { switch (code) { case HttpSetting.HDMBIdIsAlready: return R.string.hdm_exception_bid_already_exists; case HttpSetting.MessageSignatureIsWrong: return R.string.hdm_keychain_add_sign_server_qr_code_error; default: return R.string.network_or_connection_error; } }
Example #4
Source File: UploadHDMBidApi.java From bitherj with Apache License 2.0 | 5 votes |
@Override public Map<String, String> getParams() throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put(HttpSetting.PASSWORD, Utils.base64Encode(this.password)); params.put(HttpSetting.SIGNATURE, Utils.base64Encode(this.signature)); params.put(HttpSetting.HOT_ADDRESS, this.hotAddress); return params; }
Example #5
Source File: UploadHDMBidApi.java From bitherj with Apache License 2.0 | 5 votes |
@Override public void setResult(String response) throws Exception { this.result = false; JSONObject json = new JSONObject(response); if (!json.isNull(HttpSetting.RESULT)) { this.result = Utils.compareString(json.getString(HttpSetting.RESULT) , HttpSetting.STATUS_OK); } }
Example #6
Source File: CreateHDMAddressApi.java From bitherj with Apache License 2.0 | 5 votes |
@Override public Map<String, String> getParams() throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put(HttpSetting.PASSWORD, Utils.base64Encode(this.password)); params.put(HttpSetting.PUB_HOT, this.pubHot); params.put(HttpSetting.PUB_COLD, this.pubCold); params.put(HttpSetting.START, Integer.toString(this.start)); params.put(HttpSetting.END, Integer.toString(this.end)); return params; }
Example #7
Source File: RecoveryHDMApi.java From bitherj with Apache License 2.0 | 5 votes |
@Override public Map<String, String> getParams() throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put(HttpSetting.PASSWORD, Utils.base64Encode(this.password)); params.put(HttpSetting.SIGNATURE, Utils.base64Encode(this.signature)); return params; }
Example #8
Source File: SignatureHDMApi.java From bitherj with Apache License 2.0 | 5 votes |
@Override public Map<String, String> getParams() throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put(HttpSetting.PASSWORD, Utils.base64Encode(password)); params.put(HttpSetting.UNSIGN, Utils.encodeBytesForService(unSigns)); return params; }
Example #9
Source File: ExceptionUtil.java From bither-desktop-java with Apache License 2.0 | 5 votes |
public static final String getHDMHttpExceptionMessage(int code) { switch (code) { case HttpSetting.HDMBIdIsAlready: return LocaliserUtils.getString("hdm_exception_bid_already_exists"); case HttpSetting.MessageSignatureIsWrong: return LocaliserUtils.getString("hdm_keychain_add_sign_server_qr_code_error"); default: return LocaliserUtils.getString("network_or_connection_error"); } }
Example #10
Source File: SendHDMBitcoinPanel.java From bither-desktop-java with Apache License 2.0 | 4 votes |
@Override public List<TransactionSignature> getOtherSignature(int addressIndex, CharSequence password, List<byte[]> unsignHash, Tx tx) { List<TransactionSignature> transactionSignatureList = new ArrayList<TransactionSignature>(); try { HDMBId hdmbId = HDMBId.getHDMBidFromDb(); byte[] decryptedPassword = hdmbId.decryptHDMBIdPassword(password); SignatureHDMApi signatureHDMApi = new SignatureHDMApi(HDMBId.getHDMBidFromDb() .getAddress(), addressIndex, decryptedPassword, unsignHash); signatureHDMApi.handleHttpPost(); List<byte[]> bytesList = signatureHDMApi.getResult(); for (byte[] bytes : bytesList) { TransactionSignature transactionSignature = new TransactionSignature(ECKey .ECDSASignature.decodeFromDER(bytes), TransactionSignature.SigHash .ALL, false); transactionSignatureList.add(transactionSignature); } } catch (Exception e) { if (e instanceof Http400Exception) { if (((Http400Exception) e).getErrorCode() == HttpSetting.PasswordWrong) { toChangePassword = false; final ReentrantLock lock = new ReentrantLock(); final Condition changePasswordCondition = lock.newCondition(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dp.dispose(); DialogConfirmTask dialogConfirmTask = new DialogConfirmTask(LocaliserUtils.getString("hdm_reset_server_password_password_wrong_confirm"), new Runnable() { @Override public void run() { toChangePassword = true; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }, new Runnable() { @Override public void run() { toChangePassword = false; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }); dialogConfirmTask.pack(); dialogConfirmTask.setVisible(true); } }); try { lock.lock(); changePasswordCondition.awaitUninterruptibly(); } finally { lock.unlock(); } if (!toChangePassword) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } resetServerPasswordUtil.setPassword(password); if (!resetServerPasswordUtil.changePassword()) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } return getOtherSignature(addressIndex, password, unsignHash, tx); } else { throw new CompleteTransactionRunnable.HDMServerSignException(LocaliserUtils.getString( "hdm_address_sign_tx_server_error")); } } else if (e instanceof KeyCrypterException) { throw new PasswordException("hdm password decrypting error"); } else { throw new RuntimeException(e); } } return transactionSignatureList; }
Example #11
Source File: HdmSendActivity.java From bither-android with Apache License 2.0 | 4 votes |
@Override public List<TransactionSignature> getOtherSignature(int addressIndex, CharSequence password, List<byte[]> unsignHash, Tx tx) { List<TransactionSignature> transactionSignatureList = new ArrayList<TransactionSignature>(); try { HDMBId hdmbId = HDMBId.getHDMBidFromDb(); byte[] decryptedPassword = hdmbId.decryptHDMBIdPassword(password); SignatureHDMApi signatureHDMApi = new SignatureHDMApi(HDMBId.getHDMBidFromDb() .getAddress(), addressIndex, decryptedPassword, unsignHash); signatureHDMApi.handleHttpPost(); List<byte[]> bytesList = signatureHDMApi.getResult(); for (byte[] bytes : bytesList) { TransactionSignature transactionSignature = new TransactionSignature(ECKey .ECDSASignature.decodeFromDER(bytes), TransactionSignature.SigHash .ALL, false); transactionSignatureList.add(transactionSignature); } } catch (Exception e) { if (e instanceof Http400Exception) { if (((Http400Exception) e).getErrorCode() == HttpSetting.PasswordWrong) { toChangePassword = false; final ReentrantLock lock = new ReentrantLock(); final Condition changePasswordCondition = lock.newCondition(); runOnUiThread(new Runnable() { @Override public void run() { if (dp.isShowing()) { dp.dismiss(); } new DialogConfirmTask(HdmSendActivity.this, getString(R.string.hdm_reset_server_password_password_wrong_confirm), new Runnable() { @Override public void run() { toChangePassword = true; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }, new Runnable() { @Override public void run() { toChangePassword = false; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }).show(); } }); try { lock.lock(); changePasswordCondition.awaitUninterruptibly(); } finally { lock.unlock(); } if (!toChangePassword) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } resetServerPasswordUtil.setPassword(password); if (!resetServerPasswordUtil.changePassword()) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } return getOtherSignature(addressIndex, password, unsignHash, tx); } else { throw new CompleteTransactionRunnable.HDMServerSignException(R.string .hdm_address_sign_tx_server_error); } } else if (e instanceof KeyCrypterException) { throw new PasswordException("hdm password decrypting error"); } else { throw new RuntimeException(e); } } return transactionSignatureList; }
Example #12
Source File: SendHDMBitcoinPanel.java From bither-desktop-java with Apache License 2.0 | 4 votes |
@Override public List<TransactionSignature> getOtherSignature(int addressIndex, CharSequence password, List<byte[]> unsignHash, Tx tx) { List<TransactionSignature> transactionSignatureList = new ArrayList<TransactionSignature>(); try { HDMBId hdmbId = HDMBId.getHDMBidFromDb(); byte[] decryptedPassword = hdmbId.decryptHDMBIdPassword(password); SignatureHDMApi signatureHDMApi = new SignatureHDMApi(HDMBId.getHDMBidFromDb() .getAddress(), addressIndex, decryptedPassword, unsignHash); signatureHDMApi.handleHttpPost(); List<byte[]> bytesList = signatureHDMApi.getResult(); for (byte[] bytes : bytesList) { TransactionSignature transactionSignature = new TransactionSignature(ECKey .ECDSASignature.decodeFromDER(bytes), TransactionSignature.SigHash .ALL, false); transactionSignatureList.add(transactionSignature); } } catch (Exception e) { if (e instanceof Http400Exception) { if (((Http400Exception) e).getErrorCode() == HttpSetting.PasswordWrong) { toChangePassword = false; final ReentrantLock lock = new ReentrantLock(); final Condition changePasswordCondition = lock.newCondition(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dp.dispose(); DialogConfirmTask dialogConfirmTask = new DialogConfirmTask(LocaliserUtils.getString("hdm_reset_server_password_password_wrong_confirm"), new Runnable() { @Override public void run() { toChangePassword = true; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }, new Runnable() { @Override public void run() { toChangePassword = false; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }); dialogConfirmTask.pack(); dialogConfirmTask.setVisible(true); } }); try { lock.lock(); changePasswordCondition.awaitUninterruptibly(); } finally { lock.unlock(); } if (!toChangePassword) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } resetServerPasswordUtil.setPassword(password); if (!resetServerPasswordUtil.changePassword()) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } return getOtherSignature(addressIndex, password, unsignHash, tx); } else { throw new CompleteTransactionRunnable.HDMServerSignException(LocaliserUtils.getString( "hdm_address_sign_tx_server_error")); } } else if (e instanceof KeyCrypterException) { throw new PasswordException("hdm password decrypting error"); } else { throw new RuntimeException(e); } } return transactionSignatureList; }