pre query tag check

Match-id-44b7f6b867adfb41baf2c547be5c7a7af26a1853
This commit is contained in:
authName 2023-10-17 18:51:48 +08:00 committed by userName
parent 5c71733fd7
commit 2deb5170cc
5 changed files with 21 additions and 2 deletions

View File

@ -19,6 +19,7 @@ ohos_rust_shared_library("asset_service") {
sources = [ "src/lib.rs" ]
deps = [
"$COMPONENT_DIR/interfaces/inner_api/rs:asset_sdk",
"$COMPONENT_DIR/frameworks/common:asset_common",
"$COMPONENT_DIR/frameworks/ipc_interface:asset_ipc_interface",
"$COMPONENT_DIR/frameworks/ipc_proxy:asset_ipc_proxy",

View File

@ -11,3 +11,4 @@ asset_ipc_interface = { path = "../../frameworks/ipc_interface" }
asset_ipc_proxy = { path = "../../frameworks/ipc_proxy" }
db_operator = { path = "../../services/db_operator" }
crypto_manager = { path = "../crypto_manager" }
asset_sdk = { path = "../../interfaces/inner_api/rs" }

View File

@ -56,6 +56,12 @@ const ADD_AVAILABLE_ARGUMENTS: [Tag; 15] = [
Tag::DataLabelCritical4, Tag::DataLabelNormal1, Tag::DataLabelNormal2, Tag::DataLabelNormal3, Tag::DataLabelNormal4
];
const PRE_QUERY_AVAILABLE_ARGUMENTS: [Tag; 13] = [
Tag::Alias, Tag::Accessibility, Tag::AuthType, Tag::SyncType, Tag::AuthValidityPeriod,
Tag::DataLabelCritical1, Tag::DataLabelCritical2, Tag::DataLabelCritical3, Tag::DataLabelCritical4,
Tag::DataLabelNormal1, Tag::DataLabelNormal2, Tag::DataLabelNormal3, Tag::DataLabelNormal4
];
const QUERY_AVAILABLE_ARGUMENTS: [Tag; 19] = [
Tag::Alias, Tag::Accessibility, Tag::RequirePasswordSet, Tag::AuthType, Tag::SyncType,
Tag::DataLabelCritical1, Tag::DataLabelCritical2, Tag::DataLabelCritical3,
@ -88,6 +94,7 @@ pub(crate) fn check_tag_validity(argument: &AssetMap, code: &OperationCode) -> R
check_required_tags(argument, code)?;
match *code { // todo: zwz add等code能否塞到数组里
OperationCode::Add => check_optional_tags(argument, &ADD_AVAILABLE_ARGUMENTS),
OperationCode::PreQuery => check_optional_tags(argument, &PRE_QUERY_AVAILABLE_ARGUMENTS),
OperationCode::Query => check_optional_tags(argument, &QUERY_AVAILABLE_ARGUMENTS),
OperationCode::Update => check_optional_tags(argument, &UPDATE_AVAILABLE_ARGUMENTS),
OperationCode::UpdateQuery => check_optional_tags(argument, &UPDATE_MATCH_AVAILABLE_ARGUMENTS),

View File

@ -31,10 +31,16 @@ use crate::{
use asset_common::{definition::{AssetMap, Result, Value, ErrCode, Tag}, loge, logi};
use asset_sdk::definition::AuthType;
pub(crate) fn pre_query(query: &AssetMap, calling_info: &CallingInfo) -> Result<Vec<u8>> {
let mut db_data = into_db_map(query);
add_owner_info(calling_info, &mut db_data);
// check pre query data
if !query.contains_key(&Tag::Alias) || !query.contains_key(&Tag::AuthValidityPeriod) {
loge!("tag alias or auth validity period missed");
return Err(ErrCode::InvalidArgument);
}
//todo: yzt select AuthType, AccessType from table; 能否distinct?
let all_data = batch_query(calling_info, &db_data, query)?;
// get all secret key
@ -54,7 +60,10 @@ pub(crate) fn pre_query(query: &AssetMap, calling_info: &CallingInfo) -> Result<
return Err(ErrCode::SqliteError);
},
};
secret_key_set.insert((*auth_type, *access_type));
// filter auth type
if *auth_type == AuthType::Any as u32 {
secret_key_set.insert((*auth_type, *access_type));
}
}
// use secret key to get challenge
let mut challenge_vec = Vec::new();

View File

@ -83,6 +83,7 @@ public:
} else if (action == OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_REMOVED) {
// 3. 获取到userID, 删除数据库userId删除密钥-huks)
// get userId
LOGE("COMMON_EVENT_USER_REMOVED start!!!");
int uid = want.GetIntParam(OHOS::AppExecFwk::Constants::UID, -1);
int userId = -1;
OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid, userId);