mirror of
https://github.com/openharmony/device_manager.git
synced 2026-07-18 16:24:27 -04:00
修复跨设备认证中pin码明文传输导致的安全问题
Signed-off-by: renguang1116 <renguang@huawei.com>
This commit is contained in:
@@ -143,6 +143,7 @@ const int32_t AUTH_TYPE_SCAN = 2;
|
||||
const int32_t AUTH_TYPE_TOUCH = 3;
|
||||
const int32_t DEFAULT_PIN_CODE = 0;
|
||||
const int32_t DEFAULT_PIN_TOKEN = 0;
|
||||
const int32_t DEFAULT_PIN_CODE_LENGTH = 6;
|
||||
|
||||
// Softbus
|
||||
const int32_t SOFTBUS_CHECK_INTERVAL = 100000; // 100ms
|
||||
|
||||
@@ -31,16 +31,15 @@ export default {
|
||||
onInit() {
|
||||
callNativeHandler(EVENT_INIT, EVENT_INIT_CODE);
|
||||
},
|
||||
onChange(e){
|
||||
onChange(e){
|
||||
inputValue = e.value;
|
||||
},
|
||||
},
|
||||
onConfirm() {
|
||||
if ((inputValue == null) || (inputValue == "")) {
|
||||
return;
|
||||
}
|
||||
this.isTimes--;
|
||||
callNativeHandler(EVENT_CONFIRM, inputValue);
|
||||
inputValue = "";
|
||||
},
|
||||
onCancel() {
|
||||
console.info('click cancel');
|
||||
|
||||
@@ -76,13 +76,21 @@ int32_t PinAuthUi::InputPinDialog(std::shared_ptr<DmAuthManager> authManager)
|
||||
OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
|
||||
ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT,
|
||||
[authManager](int32_t id, const std::string& event, const std::string& params) {
|
||||
if (event == EVENT_INIT) {
|
||||
authManager->SetPageId(id);
|
||||
} else if (event == EVENT_CONFIRM) {
|
||||
LOGI("On confirm event for page id:%d, parms:%s", id, params.c_str());
|
||||
authManager->AddMember(std::stoi(params));
|
||||
} else {
|
||||
authManager->SetReasonAndFinish(ERR_DM_AUTH_INPUT_PARAMETER_FAILED, AuthState::AUTH_REQUEST_JOIN);
|
||||
switch (event) {
|
||||
case EVENT_INIT:
|
||||
authManager->SetPageId(id);
|
||||
break;
|
||||
case EVENT_CONFIRM:
|
||||
LOGI("On confirm event for page id:%d, parms:%s", id, params.c_str());
|
||||
if (params.length() == DEFAULT_PIN_CODE_LENGTH) {
|
||||
authManager->AddMember(std::stoi(params));
|
||||
} else {
|
||||
UpdatePinDialog(id);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
authManager->SetReasonAndFinish(ERR_DM_AUTH_INPUT_PARAMETER_FAILED, AuthState::AUTH_REQUEST_JOIN);
|
||||
break;
|
||||
}
|
||||
});
|
||||
LOGI("ShowConfigDialog end");
|
||||
|
||||
@@ -487,6 +487,7 @@ HWTEST_F(AuthRequestStateTest, Enter_012, testing::ext::TestSize.Level0)
|
||||
authManager->authRequestContext_ = std::make_shared<DmAuthRequestContext>();
|
||||
authManager->authMessageProcessor_ = std::make_shared<AuthMessageProcessor>(authManager);
|
||||
authManager->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
|
||||
authManager->authPtr_ = authManager->authenticationMap_[1];
|
||||
authManager->authResponseContext_->groupId = "111";
|
||||
authManager->authResponseContext_->groupName = "222";
|
||||
authManager->authResponseContext_->code = 123;
|
||||
@@ -609,6 +610,7 @@ HWTEST_F(AuthRequestStateTest, Enter_016, testing::ext::TestSize.Level0)
|
||||
std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector);
|
||||
std::shared_ptr<AuthRequestState> authRequestState = std::make_shared<AuthRequestFinishState>();
|
||||
authManager->timer_ = std::make_shared<DmTimer>();
|
||||
authManager->authPtr_ = authManager->authenticationMap_[1];
|
||||
authManager->authMessageProcessor_ = std::make_shared<AuthMessageProcessor>(authManager);
|
||||
authManager->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
|
||||
authManager->authRequestContext_ = std::make_shared<DmAuthRequestContext>();
|
||||
|
||||
@@ -235,6 +235,7 @@ HWTEST_F(AuthResponseStateTest, Enter_003, testing::ext::TestSize.Level0)
|
||||
authManager->authRequestState_ = std::make_shared<AuthRequestNegotiateState>();
|
||||
authManager->authResponseContext_->deviceId = "111";
|
||||
authManager->authResponseContext_->localDeviceId = "222";
|
||||
authManager->authPtr_ = authManager->authenticationMap_[1];
|
||||
authManager->authMessageProcessor_->SetResponseContext(authManager->authResponseContext_);
|
||||
authManager->authMessageProcessor_->SetRequestContext(authManager->authRequestContext_);
|
||||
authManager->softbusConnector_->GetSoftbusSession()->RegisterSessionCallback(authManager);
|
||||
@@ -397,6 +398,8 @@ HWTEST_F(AuthResponseStateTest, Enter_009, testing::ext::TestSize.Level0)
|
||||
std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector);
|
||||
authManager->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
|
||||
std::shared_ptr<AuthResponseState> authResponseState = std::make_shared<AuthResponseShowState>();
|
||||
authManager->authPtr_ = authManager->authenticationMap_[1];
|
||||
authManager->authResponseContext_->code = 123456;
|
||||
authResponseState->SetAuthManager(authManager);
|
||||
int32_t ret = authResponseState->Enter();
|
||||
ASSERT_EQ(ret, DM_OK);
|
||||
@@ -453,6 +456,7 @@ HWTEST_F(AuthResponseStateTest, Enter_011, testing::ext::TestSize.Level0)
|
||||
authManager->authRequestContext_ = std::make_shared<DmAuthRequestContext>();
|
||||
authManager->authMessageProcessor_ = std::make_shared<AuthMessageProcessor>(authManager);
|
||||
authManager->listener_ = std::make_shared<DeviceManagerServiceListener>();
|
||||
authManager->authPtr_ = authManager->authenticationMap_[1];
|
||||
authManager->authResponseContext_->sessionId = 1;
|
||||
authManager->authRequestContext_->deviceId = "2";
|
||||
authManager->authRequestContext_->hostPkgName = "3";
|
||||
|
||||
Reference in New Issue
Block a user