mirror of
https://gitee.com/openharmony/account_os_account
synced 2024-11-23 10:10:11 +00:00
commit
a5c0e5808b
@ -362,6 +362,7 @@ ErrCode DomainAccountClient::GetAccountServerConfig(const DomainAccountInfo &inf
|
|||||||
|
|
||||||
void DomainAccountClient::RestoreListenerRecords()
|
void DomainAccountClient::RestoreListenerRecords()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(recordMutex_);
|
||||||
if (listenerManager_ == nullptr) {
|
if (listenerManager_ == nullptr) {
|
||||||
ACCOUNT_LOGI("listenerManager_ is nullptr");
|
ACCOUNT_LOGI("listenerManager_ is nullptr");
|
||||||
return;
|
return;
|
||||||
|
@ -35,7 +35,7 @@ class InnerDomainAccountManager {
|
|||||||
public:
|
public:
|
||||||
static InnerDomainAccountManager &GetInstance();
|
static InnerDomainAccountManager &GetInstance();
|
||||||
ErrCode RegisterPlugin(const sptr<IDomainAccountPlugin> &plugin);
|
ErrCode RegisterPlugin(const sptr<IDomainAccountPlugin> &plugin);
|
||||||
void UnregisterPlugin();
|
ErrCode UnregisterPlugin();
|
||||||
ErrCode Auth(const DomainAccountInfo &info, const std::vector<uint8_t> &password,
|
ErrCode Auth(const DomainAccountInfo &info, const std::vector<uint8_t> &password,
|
||||||
const sptr<IDomainAccountCallback> &callback);
|
const sptr<IDomainAccountCallback> &callback);
|
||||||
ErrCode AuthUser(int32_t userId, const std::vector<uint8_t> &password,
|
ErrCode AuthUser(int32_t userId, const std::vector<uint8_t> &password,
|
||||||
|
@ -39,8 +39,7 @@ ErrCode DomainAccountManagerService::RegisterPlugin(const sptr<IDomainAccountPlu
|
|||||||
|
|
||||||
ErrCode DomainAccountManagerService::UnregisterPlugin()
|
ErrCode DomainAccountManagerService::UnregisterPlugin()
|
||||||
{
|
{
|
||||||
InnerDomainAccountManager::GetInstance().UnregisterPlugin();
|
return InnerDomainAccountManager::GetInstance().UnregisterPlugin();
|
||||||
return ERR_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrCode DomainAccountManagerService::HasDomainAccount(
|
ErrCode DomainAccountManagerService::HasDomainAccount(
|
||||||
|
@ -119,10 +119,15 @@ InnerDomainAuthCallback::~InnerDomainAuthCallback()
|
|||||||
|
|
||||||
void InnerDomainAuthCallback::OnResult(const int32_t errCode, Parcel &parcel)
|
void InnerDomainAuthCallback::OnResult(const int32_t errCode, Parcel &parcel)
|
||||||
{
|
{
|
||||||
|
if (callback_ == nullptr) {
|
||||||
|
ACCOUNT_LOGI("callback_ is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Parcel resultParcel;
|
||||||
std::shared_ptr<DomainAuthResult> authResult(DomainAuthResult::Unmarshalling(parcel));
|
std::shared_ptr<DomainAuthResult> authResult(DomainAuthResult::Unmarshalling(parcel));
|
||||||
if (authResult == nullptr) {
|
if (authResult == nullptr) {
|
||||||
ACCOUNT_LOGE("authResult is nullptr");
|
ACCOUNT_LOGE("authResult is nullptr");
|
||||||
return;
|
return callback_->OnResult(ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR, resultParcel);
|
||||||
}
|
}
|
||||||
if ((errCode == ERR_OK) && (userId_ != 0)) {
|
if ((errCode == ERR_OK) && (userId_ != 0)) {
|
||||||
InnerDomainAccountManager::GetInstance().InsertTokenToMap(userId_, (*authResult).token);
|
InnerDomainAccountManager::GetInstance().InsertTokenToMap(userId_, (*authResult).token);
|
||||||
@ -137,16 +142,12 @@ void InnerDomainAuthCallback::OnResult(const int32_t errCode, Parcel &parcel)
|
|||||||
}
|
}
|
||||||
(void)memset_s(authResult->token.data(), authResult->token.size(), 0, authResult->token.size());
|
(void)memset_s(authResult->token.data(), authResult->token.size(), 0, authResult->token.size());
|
||||||
authResult->token.clear();
|
authResult->token.clear();
|
||||||
Parcel resultParcel;
|
|
||||||
if (!(*authResult).Marshalling(resultParcel)) {
|
if (!(*authResult).Marshalling(resultParcel)) {
|
||||||
ACCOUNT_LOGE("authResult Marshalling failed");
|
ACCOUNT_LOGE("authResult Marshalling failed");
|
||||||
return;
|
return callback_->OnResult(ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR, resultParcel);
|
||||||
}
|
}
|
||||||
AccountInfoReport::ReportSecurityInfo("", userId_, ReportEvent::EVENT_LOGIN, errCode);
|
AccountInfoReport::ReportSecurityInfo("", userId_, ReportEvent::EVENT_LOGIN, errCode);
|
||||||
if (callback_ == nullptr) {
|
|
||||||
ACCOUNT_LOGI("callback_ is nullptr");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return callback_->OnResult(errCode, resultParcel);
|
return callback_->OnResult(errCode, resultParcel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,15 +173,21 @@ ErrCode InnerDomainAccountManager::RegisterPlugin(const sptr<IDomainAccountPlugi
|
|||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerDomainAccountManager::UnregisterPlugin()
|
ErrCode InnerDomainAccountManager::UnregisterPlugin()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
|
if (callingUid_ != IPCSkeleton::GetCallingUid()) {
|
||||||
|
ACCOUNT_LOGE("Failed to check callingUid, register callingUid=%{public}d, unregister callingUid=%{public}d.",
|
||||||
|
callingUid_, IPCSkeleton::GetCallingUid());
|
||||||
|
return ERR_ACCOUNT_COMMON_PERMISSION_DENIED;
|
||||||
|
}
|
||||||
if ((plugin_ != nullptr) && (plugin_->AsObject() != nullptr)) {
|
if ((plugin_ != nullptr) && (plugin_->AsObject() != nullptr)) {
|
||||||
plugin_->AsObject()->RemoveDeathRecipient(deathRecipient_);
|
plugin_->AsObject()->RemoveDeathRecipient(deathRecipient_);
|
||||||
}
|
}
|
||||||
plugin_ = nullptr;
|
plugin_ = nullptr;
|
||||||
callingUid_ = -1;
|
callingUid_ = -1;
|
||||||
deathRecipient_ = nullptr;
|
deathRecipient_ = nullptr;
|
||||||
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrCode InnerDomainAccountManager::StartAuth(const sptr<IDomainAccountPlugin> &plugin, const DomainAccountInfo &info,
|
ErrCode InnerDomainAccountManager::StartAuth(const sptr<IDomainAccountPlugin> &plugin, const DomainAccountInfo &info,
|
||||||
|
@ -214,14 +214,10 @@ ErrCode OsAccountInterface::SendToIDMAccountDelete(OsAccountInfo &osAccountInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// wait callback
|
// wait callback
|
||||||
struct tm startTime = {0};
|
{
|
||||||
struct tm nowTime = {0};
|
std::unique_lock<std::mutex> lck(callback->mutex_);
|
||||||
OHOS::GetSystemCurrentTime(&startTime);
|
if (!callback->isCalled_) {
|
||||||
OHOS::GetSystemCurrentTime(&nowTime);
|
callback->onResultCondition_.wait_for(lck, std::chrono::seconds(Constants::TIME_WAIT_TIME_OUT));
|
||||||
while (OHOS::GetSecondsBetween(startTime, nowTime) < Constants::TIME_WAIT_TIME_OUT &&
|
|
||||||
!callback->isCalled_) {
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(Constants::WAIT_ONE_TIME));
|
|
||||||
OHOS::GetSystemCurrentTime(&nowTime);
|
|
||||||
}
|
}
|
||||||
if (!callback->isCalled_) {
|
if (!callback->isCalled_) {
|
||||||
ACCOUNT_LOGE("idm did not call back! timeout!");
|
ACCOUNT_LOGE("idm did not call back! timeout!");
|
||||||
@ -230,6 +226,8 @@ ErrCode OsAccountInterface::SendToIDMAccountDelete(OsAccountInfo &osAccountInfo)
|
|||||||
FinishTraceAdapter();
|
FinishTraceAdapter();
|
||||||
return ERR_OK; // do not return fail
|
return ERR_OK; // do not return fail
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ACCOUNT_LOGI("send to idm account delete and get callback succeed!");
|
ACCOUNT_LOGI("send to idm account delete and get callback succeed!");
|
||||||
FinishTraceAdapter();
|
FinishTraceAdapter();
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user