Skip to content

Commit 48f14ca

Browse files
committed
remove check of password
1 parent 4db818f commit 48f14ca

File tree

5 files changed

+37
-36
lines changed

5 files changed

+37
-36
lines changed

sdk-core/src/main/java/org/fisco/bcos/sdk/config/model/AccountConfig.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
package org.fisco.bcos.sdk.config.model;
1717

18-
import static org.fisco.bcos.sdk.model.CryptoProviderType.HSM;
19-
import static org.fisco.bcos.sdk.model.CryptoProviderType.SSM;
18+
import org.fisco.bcos.sdk.config.exceptions.ConfigException;
2019

2120
import java.util.Map;
2221
import java.util.Objects;
23-
import org.fisco.bcos.sdk.config.exceptions.ConfigException;
22+
23+
import static org.fisco.bcos.sdk.model.CryptoProviderType.SSM;
2424

2525
/** Account configuration */
2626
public class AccountConfig {
@@ -55,12 +55,6 @@ private void checkAccountConfig(ConfigProperty configProperty) throws ConfigExce
5555
Map<String, Object> cryptoProvider = configProperty.getCryptoProvider();
5656
if (cryptoProvider != null) {
5757
String cryptoType = ConfigProperty.getValue(cryptoProvider, "type", SSM);
58-
if (cryptoType != null && cryptoType.equals(HSM)) {
59-
if (!this.accountKeyIndex.equals("") && this.accountPassword.equals("")) {
60-
throw new ConfigException(
61-
"cannot load hsm inner key, please config the password");
62-
}
63-
}
6458
}
6559
if (this.accountAddress.equals("")) {
6660
return;

sdk-crypto/src/main/java/org/fisco/bcos/sdk/crypto/CryptoSuite.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
*/
1414
package org.fisco.bcos.sdk.crypto;
1515

16-
import static org.fisco.bcos.sdk.model.CryptoProviderType.HSM;
17-
18-
import java.security.KeyPair;
1916
import org.fisco.bcos.sdk.config.ConfigOption;
2017
import org.fisco.bcos.sdk.config.model.AccountConfig;
2118
import org.fisco.bcos.sdk.config.model.CryptoProviderConfig;
@@ -41,6 +38,10 @@
4138
import org.slf4j.Logger;
4239
import org.slf4j.LoggerFactory;
4340

41+
import java.security.KeyPair;
42+
43+
import static org.fisco.bcos.sdk.model.CryptoProviderType.HSM;
44+
4445
public class CryptoSuite {
4546

4647
private static Logger logger = LoggerFactory.getLogger(CryptoSuite.class);
@@ -106,6 +107,7 @@ protected void initCryptoSuite(int cryptoTypeConfig) {
106107
this.hashImpl = new Keccak256();
107108
this.keyPairFactory = new ECDSAKeyPair();
108109
} else if (cryptoTypeConfig == CryptoType.SM_HSM_TYPE) {
110+
logger.info("Use hsm crypto");
109111
this.signatureImpl = new SDFSM2Signature();
110112
this.hashImpl = new SDFSM3Hash();
111113
this.keyPairFactory = new SDFSM2KeyPair();
@@ -149,7 +151,7 @@ public void loadAccount(String accountFileFormat, String accountFilePath, String
149151
+ accountFileFormat
150152
+ ", current supported are p12 and pem");
151153
}
152-
logger.debug("Load account from {}", accountFilePath);
154+
logger.info("Load account from {}", accountFilePath);
153155
createKeyPair(keyTool.getKeyPair());
154156
}
155157

@@ -162,10 +164,13 @@ private void loadAccount(ConfigOption configOption) {
162164
AccountConfig accountConfig = configOption.getAccountConfig();
163165
CryptoProviderConfig cryptoProviderConfig = config.getCryptoProviderConfig();
164166
String cryptoType = cryptoProviderConfig.getType();
167+
logger.debug("cryptoType = "+ cryptoType);
165168
if (cryptoType != null && cryptoType.equals(HSM)) {
169+
logger.debug("use hsm key");
166170
String accountKeyIndex = accountConfig.getAccountKeyIndex();
167-
if (accountKeyIndex != null && !accountKeyIndex.equals("")) {
171+
if (accountKeyIndex != null) {
168172
loadSDFInternalAccount(accountKeyIndex, accountConfig.getAccountPassword());
173+
logger.debug("Load sdf internal account, keyIndex = ", accountKeyIndex);
169174
return;
170175
}
171176
}

sdk-transaction/src/main/java/org/fisco/bcos/sdk/transaction/codec/encode/TransactionEncoderInterface.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public interface TransactionEncoderInterface {
3030
*
3131
* @param rawTransaction data to be encoded
3232
* @param signature signature result
33-
* @return encoded & signed transaction byte array
33+
* @return encoded and signed transaction byte array
3434
*/
3535
byte[] encode(RawTransaction rawTransaction, SignatureResult signature);
3636

@@ -39,7 +39,7 @@ public interface TransactionEncoderInterface {
3939
*
4040
* @param rawTransaction data to be encoded
4141
* @param cryptoKeyPair keypair
42-
* @return encoded & signed transaction byte array
42+
* @return encoded and signed transaction byte array
4343
*/
4444
byte[] encodeAndSignBytes(RawTransaction rawTransaction, CryptoKeyPair cryptoKeyPair);
4545

@@ -48,7 +48,7 @@ public interface TransactionEncoderInterface {
4848
*
4949
* @param rawTransaction data to be encoded
5050
* @param cryptoKeyPair keypair
51-
* @return encoded & signed transaction hexed String
51+
* @return encoded and signed transaction hexed String
5252
*/
5353
String encodeAndSign(RawTransaction rawTransaction, CryptoKeyPair cryptoKeyPair);
5454

@@ -57,7 +57,7 @@ public interface TransactionEncoderInterface {
5757
*
5858
* @param rawTransaction data to be encoded
5959
* @param cryptoKeyPair keypair
60-
* @return encoded & hashed transaction byte array
60+
* @return encoded and hashed transaction byte array
6161
*/
6262
byte[] encodeAndHashBytes(RawTransaction rawTransaction, CryptoKeyPair cryptoKeyPair);
6363
}

sdk-transaction/src/main/java/org/fisco/bcos/sdk/transaction/manager/AssembleTransactionProcessorInterface.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
*/
1515
package org.fisco.bcos.sdk.transaction.manager;
1616

17-
import java.math.BigInteger;
18-
import java.util.List;
19-
import java.util.concurrent.CompletableFuture;
2017
import org.fisco.bcos.sdk.abi.ABICodecException;
2118
import org.fisco.bcos.sdk.model.TransactionReceipt;
2219
import org.fisco.bcos.sdk.model.callback.TransactionCallback;
@@ -27,6 +24,10 @@
2724
import org.fisco.bcos.sdk.transaction.model.exception.TransactionBaseException;
2825
import org.fisco.bcos.sdk.transaction.model.po.RawTransaction;
2926

27+
import java.math.BigInteger;
28+
import java.util.List;
29+
import java.util.concurrent.CompletableFuture;
30+
3031
public interface AssembleTransactionProcessorInterface {
3132

3233
/**
@@ -50,7 +51,7 @@ public interface AssembleTransactionProcessorInterface {
5051
* deploy contract to fisco bcos node and get response.
5152
*
5253
* @param abi contract abi, which could be obtained by compiling solidity contract.
53-
* @param signedData signed & encoded constructor data
54+
* @param signedData signed and encoded constructor data
5455
* @return transaction response @See TransactionResponse
5556
*/
5657
public TransactionResponse deployAndGetResponse(String abi, String signedData);
@@ -101,7 +102,7 @@ public CompletableFuture<TransactionReceipt> deployAsync(
101102

102103
/**
103104
* deploy contract to fisco bcos node and get response by contract name. The contract loader
104-
* will load the transaction abi & bin information.
105+
* will load the transaction abi and bin information.
105106
*
106107
* @param contractName contract name.
107108
* @param params contract construct parameters
@@ -112,7 +113,7 @@ public TransactionResponse deployByContractLoader(String contractName, List<Obje
112113

113114
/**
114115
* deploy contract to fisco bcos node and get response by contract name asynchronously. The
115-
* contract loader will load the transaction abi & bin information.
116+
* contract loader will load the transaction abi and bin information.
116117
*
117118
* @param contractName contract name.
118119
* @param params contract construct parameters
@@ -125,13 +126,13 @@ public void deployByContractLoaderAsync(
125126
/**
126127
* send transaction only.
127128
*
128-
* @param signedData signed & encoded transaction data
129+
* @param signedData signed and encoded transaction data
129130
*/
130131
public void sendTransactionOnly(String signedData);
131132

132133
/**
133134
* send transaction to fisco bcos node and get transaction receipt by contract name. The
134-
* contract loader will load the transaction abi & bin information.
135+
* contract loader will load the transaction abi and bin information.
135136
*
136137
* @param contractName contract name.
137138
* @param contractAddress contract address
@@ -185,7 +186,7 @@ public TransactionResponse sendTransactionWithStringParamsAndGetResponse(
185186
/**
186187
* send transaction to fisco bcos node asynchronously.
187188
*
188-
* @param signedTransaction signed & encoded transaction data
189+
* @param signedTransaction signed and encoded transaction data
189190
* @param callback transaction with callback function
190191
*/
191192
public void sendTransactionAsync(String signedTransaction, TransactionCallback callback);
@@ -211,7 +212,7 @@ public void sendTransactionAsync(
211212
/**
212213
* send transaction to fisco bcos node asynchronously.
213214
*
214-
* @param signedData signed & encoded transaction data
215+
* @param signedData signed and encoded transaction data
215216
* @return CompletableFuture wrapper transaction receipt
216217
*/
217218
public CompletableFuture<TransactionReceipt> sendTransactionAsync(String signedData);

sdk-transaction/src/main/java/org/fisco/bcos/sdk/transaction/tools/ContractLoader.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414
*/
1515
package org.fisco.bcos.sdk.transaction.tools;
1616

17-
import java.io.File;
18-
import java.io.IOException;
19-
import java.util.Collection;
20-
import java.util.Collections;
21-
import java.util.HashMap;
22-
import java.util.List;
23-
import java.util.Map;
2417
import org.apache.commons.io.FileUtils;
2518
import org.apache.commons.lang3.StringUtils;
2619
import org.apache.commons.lang3.tuple.Pair;
@@ -34,6 +27,14 @@
3427
import org.slf4j.Logger;
3528
import org.slf4j.LoggerFactory;
3629

30+
import java.io.File;
31+
import java.io.IOException;
32+
import java.util.Collection;
33+
import java.util.Collections;
34+
import java.util.HashMap;
35+
import java.util.List;
36+
import java.util.Map;
37+
3738
/**
3839
* ContractLoader @Description: ContractLoader
3940
*
@@ -47,7 +48,7 @@ public class ContractLoader {
4748
private Map<String, String> contractAbiMap = new HashMap<>();
4849

4950
/**
50-
* create ContractLoader, which load abi & binary files from configured file path
51+
* create ContractLoader, which load abi and binary files from configured file path
5152
*
5253
* @param abiFilePath abi files path which are compiled by solc from solidity files. Don't
5354
* support recursive directories.

0 commit comments

Comments
 (0)