!6 Update structure

Merge pull request !6 from 王旭/master
This commit is contained in:
openharmony_sig_ci
2022-01-19 08:11:53 +00:00
committed by Gitee
45 changed files with 177 additions and 123 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
<oatconfig>
<filefilterlist>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filename" name="*.png" desc="The framework image"/>
<filteritem type="filename" name="*.png" desc="The framework image"/>
</filefilter>
</filefilterlist>
</oatconfig>
+83
View File
@@ -0,0 +1,83 @@
{
"name": "@openharmony/user_auth",
"version": "3.1.0",
"description": "User Authentication capability",
"homePage": "https://gitee.com/openharmony",
"author": {},
"repository": "",
"license": "Apache License 2.0",
"publishAs": "code-segment",
"segment": {
"destPath" : "base/user_iam/user_auth"
},
"dirs": {},
"scripts": {},
"component": {
"name": "user_auth",
"subsystem": "useriam",
"adapted_system_type": [ "standard" ],
"syscap": ["SystemCapability.UserIAM.UserAuth"],
"features": [],
"rom": "200KB",
"ram": "1500KB",
"deps": {
"components": [
"hiviewdfx_hilog_native",
"ipc",
"safwk",
"samgr_standard",
"hilog",
"auth_executor_mgr"
],
"third_party": [
"openssl",
"googletest"
]
},
"build": {
"sub_component": [
"//base/user_iam/user_auth/sa_profile:userauth_sa_profile",
"//base/user_iam/user_auth/services:userauthservice",
"//base/user_iam/user_auth/interfaces/kits/napi:userauthnorth"
],
"inner_kits": [
{
"type": "so",
"name": "//base/user_iam/user_auth/interfaces/innerkits/native:userauth_framework",
"header": {
"header_files": [
"iuser_auth.h",
"iuserauth_callback.h",
"user_auth.h",
"userauth_async_stub.h",
"userauth_callback.h",
"userauth_info.h",
"userauth_proxy.h"
],
"header_base": "//base/user_iam/user_auth/interfaces/innerkits/native/include"
}
},
{
"type": "so",
"name": "//base/user_iam/user_auth/interfaces/innerkits/napi:userauth",
"header": {
"header_files": [
"auth_build.h",
"auth_common.h",
"auth_hilog_wrapper.h",
"auth_object.h",
"authapi_callback.h",
"result_convert.h",
"user_auth_helper.h",
"user_auth_impl.h"
],
"header_base": "//base/user_iam/user_auth/interfaces/innerkits/napi/include"
}
}
],
"test": [
"//base/user_iam/user_auth/test:userauth_native_test"
]
}
}
}
+1 -1
View File
@@ -39,7 +39,7 @@ sptr<IUserAuth> UserAuth::GetProxy()
USERAUTH_HILOGE(MODULE_INNERKIT, "userauth Failed to get system manager");
return nullptr;
}
sptr<IRemoteObject> obj = sam->CheckSystemAbility(USERAUTH_SERVICE_SA_ID);
sptr<IRemoteObject> obj = sam->CheckSystemAbility(SUBSYS_USERIAM_SYS_ABILITY_USERAUTH);
if (obj == nullptr) {
USERAUTH_HILOGE(MODULE_INNERKIT, "userauth Failed to get userauth manager service");
return nullptr;
View File
+3 -11
View File
@@ -12,7 +12,7 @@
# limitations under the License.
import("//build/ohos.gni")
import("//base/useriam/userauth/userauth.gni")
import("//base/user_iam/user_auth/userauth.gni")
config("userauth_public_config") {
include_dirs = [
@@ -21,14 +21,6 @@ config("userauth_public_config") {
}
ohos_shared_library("userauth") {
include_dirs = [
# "common/include",
# "//third_party/node/src",
# "//foundation/ace/napi/interfaces/kits",
# "//foundation/distributeddatamgr/distributeddatamgr/frameworks/innerkitsimpl/distributeddatafwk/include",
]
cflags = [
"-fPIC",
"-g3",
@@ -64,6 +56,6 @@ ohos_shared_library("userauth") {
relative_install_dir = "module"
part_name = "userauth"
subsystem_name = "userauth"
part_name = "user_auth"
subsystem_name = "user_iam"
}
View File
View File
View File
View File
View File
+2 -1
View File
@@ -52,8 +52,9 @@ private:
void SetPropertyBigint(napi_env env, napi_value &jsObject, uint64_t value, std::string key);
std::string NapiGetValueString(napi_env env, napi_value value);
napi_value GetNapiValue(napi_env env, const std::string keyChar, napi_value object);
std::vector<uint32_t> GetCppArrayUint32(napi_env env, napi_value value);
};
} // namespace UserAuth
} // namespace UserIAM
} // namespace OHOS
#endif // RESULT_CONVERT_H
#endif // RESULT_CONVERT_H
View File
View File
+8 -4
View File
@@ -15,6 +15,7 @@
#include "auth_build.h"
#include "securec.h"
#include "auth_common.h"
#include "auth_hilog_wrapper.h"
#include "auth_object.h"
@@ -247,7 +248,6 @@ void AuthBuild::AuthCallBackResult(napi_env env, AuthInfo *authInfo)
uint64_t AuthBuild::GetUint8ArrayTo64(napi_env env, napi_value value)
{
napi_typedarray_type arraytype;
std::string challenge;
size_t length = 0;
napi_value buffer = nullptr;
size_t offset = 0;
@@ -270,9 +270,13 @@ uint64_t AuthBuild::GetUint8ArrayTo64(napi_env env, napi_value value)
HILOG_INFO(" offset is =============>%{public}d", offset);
return 0;
}
std::vector<uint8_t> result(data, data+length);
challenge.assign(result.begin(), result.end());
uint64_t resultUint64 = atol(challenge.c_str());
uint64_t resultUint64;
HILOG_INFO("data len = %{public}u", length);
if (memcpy_s(&resultUint64, sizeof(resultUint64), data, length) != EOK) {
HILOG_INFO("memcpy_s fail");
return 0;
}
HILOG_INFO("resultUint64 = %{public}llu", resultUint64);
return resultUint64;
}
View File
+1
View File
@@ -140,6 +140,7 @@ void AuthApiCallback::onAcquireInfo(const int32_t module, const uint32_t acquire
void AuthApiCallback::onResult(const int32_t result, const AuthResult extraInfo)
{
HILOG_INFO("AuthApiCallback onResult enter");
napi_status status;
if (userInfo_ != nullptr) {
HILOG_INFO("AuthApiCallback onResult userInfo_");
@@ -246,47 +246,52 @@ int32_t ResultConvert::GetInt32ValueByKey(napi_env env, napi_value jsObject, std
return NapiGetValueInt32(env, value);
}
std::vector<uint32_t> ResultConvert::GetCppArrayUint32(napi_env env, napi_value value)
{
uint32_t arrayLength = 0;
napi_get_array_length(env, value, &arrayLength);
if (arrayLength == 0) {
HILOG_ERROR("%{public}s The array is empty.", __func__);
return std::vector<uint32_t>();
}
std::vector<uint32_t> paramArrays;
for (size_t i = 0; i < arrayLength; i++) {
napi_value napiElement = nullptr;
napi_get_element(env, value, i, &napiElement);
napi_valuetype napiValueType = napi_undefined;
napi_typeof(env, napiElement, &napiValueType);
if (napiValueType != napi_number) {
HILOG_ERROR("%{public}s Wrong argument type. Numbers expected.", __func__);
return std::vector<uint32_t>();
}
uint32_t napiValue = 0;
napi_get_value_uint32(env, napiElement, &napiValue);
paramArrays.push_back(napiValue);
}
return paramArrays;
}
std::vector<uint32_t> ResultConvert::GetInt32ArrayValueByKey(napi_env env, napi_value jsObject, std::string key)
{
napi_status status;
napi_value array = GetNapiValue(env, key.c_str(), jsObject);
std::vector<uint32_t> values;
if (array == nullptr) {
return values;
return std::vector<uint32_t>();
}
std::vector<uint32_t>RetNull = {0};
napi_typedarray_type arraytype;
size_t length = 0;
napi_value buffer = nullptr;
size_t offset = 0;
uint8_t *data = nullptr;
bool isTypedArray = false;
status = napi_is_typedarray(env, array, &isTypedArray);
bool isArray = false;
status = napi_is_array(env, array, &isArray);
if (status != napi_ok) {
HILOG_INFO("napi_is_typedarray is failed");
HILOG_INFO("napi_is_array is failed");
return std::vector<uint32_t>();
}
if (isTypedArray) {
if (isArray) {
HILOG_INFO("args[PIN_PARAMS_ONE] is a array");
} else {
HILOG_INFO("args[PIN_PARAMS_ONE] is not a uint8array");
return RetNull;
HILOG_INFO("args[PIN_PARAMS_ONE] is not a array");
return std::vector<uint32_t>();
}
status = napi_get_typedarray_info(env, array, &arraytype, &length, reinterpret_cast<void **>(&data), &buffer, &offset);
if (status != napi_ok) {
HILOG_INFO("napi_get_typedarray_info is failed");
}
if (arraytype == napi_uint32_array) {
HILOG_INFO("InputerImpl, OnSetData get uint8 array ");
} else {
HILOG_ERROR("InputerImpl, OnSetData get uint8 array error");
return RetNull;
}
if (offset != 0) {
HILOG_INFO(" offset is =============>%{public}d",offset);
return RetNull;
}
std::vector<uint32_t>result(data, data + length);
return result;
return GetCppArrayUint32(env, array);
}
std::string ResultConvert::NapiGetValueString(napi_env env, napi_value value)
@@ -358,4 +363,4 @@ napi_value ResultConvert::GetNapiValue(napi_env env, const std::string keyChar,
}
} // namespace UserAuth
} // namespace UserIAM
} // namespace OHOS
} // namespace OHOS
View File
View File
+3 -4
View File
@@ -11,12 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/useriam/userauth/userauth.gni")
import("//base/user_iam/user_auth/userauth.gni")
config("userauth_private_config") {
include_dirs = [
"//utils/system/safwk/napi/include",
#"${userauth_frameworks_path}/kitsimpl/include",
"//utils/system/safwk/native/include",
"//foundation/distributeddatamgr/distributeddatamgr/frameworks/innerkitsimpl/distributeddatafwk/include",
]
}
@@ -41,7 +40,7 @@ ohos_shared_library("userauth_framework") {
deps = [
"//utils/native/base:utils",
"//base/useriam/coauth/interfaces/innerkits:coauth_framework",
"//base/user_iam/auth_executor_mgr/interfaces/innerkits:coauth_framework",
]
external_deps = [
View File
View File
View File
View File
View File
View File
View File
Regular → Executable
+4 -5
View File
@@ -12,7 +12,7 @@
# limitations under the License.
import("//build/ohos.gni")
import("//base/useriam/userauth/userauth.gni")
import("//base/user_iam/user_auth/userauth.gni")
import("//build/lite/config/component/lite_component.gni")
## Build userauth.so {{{
@@ -36,7 +36,7 @@ ohos_shared_library("userauthnorth") {
deps = [
"//foundation/ace/napi:ace_napi",
"//base/useriam/userauth/interfaces/innerkits/napi:userauth",
"//base/user_iam/user_auth/interfaces/innerkits/napi:userauth",
"${userauth_innerkits_path}/native:userauth_framework"
]
@@ -53,7 +53,6 @@ ohos_shared_library("userauthnorth") {
public_deps = []
relative_install_dir = "module"
part_name = "userauth"
subsystem_name = "userauth"
part_name = "user_auth"
subsystem_name = "useriam"
}
## Build userauth.so }}}
View File
View File
View File
-24
View File
@@ -1,24 +0,0 @@
{
"subsystem": "useriam",
"parts": {
"userauth": {
"variants": [
"wearable",
"phone"
],
"module_list": [
"//base/useriam/userauth/sa_profile:userauth_sa_profile",
"//base/useriam/userauth/services:userauthservice",
"//base/useriam/userauth/interfaces/innerkits/native:userauth_framework",
"//base/useriam/userauth/interfaces/kits/napi:userauthnorth",
"//base/useriam/userauth/interfaces/innerkits/napi:userauth"
],
"inner_kits": [
],
"test_list": [
"//base/useriam/userauth/test:userauth_native_test"
]
}
}
}
+1 -1
View File
@@ -15,7 +15,7 @@
<info>
<process>useriam</process>
<systemability>
<name>5201</name>
<name>922</name>
<libpath>libuserauthservice.z.so</libpath>
<run-on-create>true</run-on-create>
<distributed>false</distributed>
+2 -2
View File
@@ -11,11 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/useriam/userauth/userauth.gni")
import("//base/user_iam/user_auth/userauth.gni")
import("//build/ohos/sa_profile/sa_profile.gni")
import("//build/ohos.gni")
ohos_sa_profile("userauth_sa_profile") {
sources = [ "5201.xml" ]
sources = [ "922.xml" ]
part_name = "${userauth_native_part_name}"
}
+7 -9
View File
@@ -11,16 +11,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/useriam/userauth/userauth.gni")
import("//base/user_iam/user_auth/userauth.gni")
config("userauth_private_config") {
include_dirs = [
"include",
"//base/useriam/coauth/common/interface",
# "//utils/system/safwk/native/include",
# "//third_party/openssl/include/openssl",
# "//foundation/distributeddatamgr/distributeddatamgr/frameworks/innerkitsimpl/distributeddatafwk/include",
]
"//base/user_iam/auth_executor_mgr/common/interface",
"//utils/system/safwk/native/include",
]
}
ohos_shared_library("userauthservice") {
@@ -41,14 +39,14 @@ ohos_shared_library("userauthservice") {
]
deps = [
"//base/useriam/coauth/interfaces/innerkits:coauth_framework",
"//base/useriam/useridm/interfaces/innerkits:useridm_framework",
"//base/user_iam/auth_executor_mgr/interfaces/innerkits:coauth_framework",
"//base/user_iam/user_idm/interfaces/innerkits:useridm_framework",
"//third_party/openssl:libcrypto_static",
"${userauth_innerkits_path}/native:userauth_framework",
"//drivers/peripheral/display/hal:hdi_display_device",
"//utils/native/base:utils",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
"//base/useriam/coauth/common:useriam_common_lib",
"//base/user_iam/auth_executor_mgr/common:useriam_common_lib",
]
external_deps = [
+12 -14
View File
@@ -26,7 +26,7 @@
namespace OHOS {
namespace UserIAM {
namespace UserAuth {
const int32_t cUserId = 12345;
const int32_t cUserId = 0;
const uint64_t cCallerUID = 0;
UserAuthAdapter &UserAuthAdapter::GetInstance()
@@ -83,9 +83,9 @@ void UserAuthAdapter::SetPropAuthInfo(uint64_t callerUID, std::string pkgName, i
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuth SetPropAuthInfo is end!");
}
int32_t UserAuthAdapter::SetProPropAuthInfo(OHOS::UserIAM::AuthResPool::AuthAttributes &authAttributes,
uint64_t callerUID, std::string pkgName,
SetPropertyRequest requset, std::vector<uint64_t> templateIds,
std::shared_ptr<CoAuth::SetPropCallback> &setPropCallback)
uint64_t callerUID, std::string pkgName,
SetPropertyRequest requset, std::vector<uint64_t> templateIds,
std::shared_ptr<CoAuth::SetPropCallback> &setPropCallback)
{
uint32_t value;
int32_t ret = authAttributes.SetUint32Value(AUTH_TYPE, requset.authType);
@@ -140,7 +140,7 @@ void UserAuthAdapter::GetPropAuthInfoCoauth(uint64_t callerUID, std::string pkgN
sptr<IUserAuthCallback>& callback)
{
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuth GetPropAuthInfoCoauth is start!");
USERAUTH_HILOGD(MODULE_SERVICE, "GetPropertyRequest requset key is %{public}u!", requset.keys.front());
std::shared_ptr<UserIDM::GetInfoCallback> getInfoCallback =
std::make_shared<UserAuthCallbackImplIDMGetPorpCoauth>(callback, callerUID, pkgName, resultCode,
authToken, requset);
@@ -287,7 +287,6 @@ int32_t UserAuthAdapter::GetExecutorProp(uint64_t callerUID, std::string pkgName
result.result = ret;
return ret;
}
USERAUTH_HILOGD(MODULE_SERVICE, "GetPropertyRequest requset key is %{public}u!", requset.keys.front());
if (GetEachExecutorProp(requset, result, value, pAuthAttributes) != SUCCESS) {
return ret;
}
@@ -300,10 +299,8 @@ int32_t UserAuthAdapter::GetEachExecutorProp(GetPropertyRequest &requset, Execut
{
uint64_t tmpValue;
int32_t ret = SUCCESS;
for (size_t i = 0; i < requset.keys.size(); i++) {
//for (std::vector<uint32_t>::const_iterator iter = requset.keys.begin(); iter != requset.keys.end(); ++iter) {
USERAUTH_HILOGD(MODULE_SERVICE, "GetPropertyRequest *iter is %{public}u!", requset.keys[i]);
switch (requset.keys[i]) {
for (std::vector<uint32_t>::const_iterator iter = requset.keys.begin(); iter != requset.keys.end(); ++iter) {
switch (*iter) {
case AUTH_SUB_TYPE:
ret = pAuthAttributes->GetUint64Value(AUTH_SUBTYPE, tmpValue);
if (ret != SUCCESS) {
@@ -314,7 +311,7 @@ int32_t UserAuthAdapter::GetEachExecutorProp(GetPropertyRequest &requset, Execut
value = static_cast<uint32_t>(tmpValue);
result.authSubType = static_cast<AuthSubType>(value);
break;
case AUTH_REMAIN_COUNT:
case REMAIN_TIMES:
ret = pAuthAttributes->GetUint32Value(AUTH_REMAIN_COUNT, result.remainTimes);
if (ret != SUCCESS) {
USERAUTH_HILOGE(MODULE_SERVICE, "GetUint32Value->AUTH_REMAIN_COUNT ERROR!");
@@ -322,7 +319,7 @@ int32_t UserAuthAdapter::GetEachExecutorProp(GetPropertyRequest &requset, Execut
return ret;
}
break;
case AUTH_REMAIN_TIME:
case FREEZING_TIME:
ret = pAuthAttributes->GetUint32Value(AUTH_REMAIN_TIME, result.freezingTime);
if (ret != SUCCESS) {
USERAUTH_HILOGE(MODULE_SERVICE, "GetUint32Value->AUTH_REMAIN_TIME ERROR!");
@@ -332,10 +329,11 @@ int32_t UserAuthAdapter::GetEachExecutorProp(GetPropertyRequest &requset, Execut
break;
default:
USERAUTH_HILOGE(MODULE_SERVICE, "The key to get ExecutorProp is invalid.");
result.result = INVALID_PARAMETERS;
return INVALID_PARAMETERS;
break;
}
}
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuthAdapter::GetEachExecutorProp %{public}ull:%{public}u:%{public}u",
result.authSubType, result.remainTimes, result.freezingTime);
return ret;
}
+1
View File
@@ -207,6 +207,7 @@ bool UserAuthAsyncProxy::SendRequest(uint32_t code, MessageParcel &data, Message
USERAUTH_HILOGE(MODULE_SERVICE, "userauth failed to SendRequest.result = %{public}d", result);
return false;
}
USERAUTH_HILOGD(MODULE_SERVICE, "userauthAsyncProxy SendRequest end");
return true;
}
} // namespace UserAuth
View File
+3 -3
View File
@@ -72,8 +72,9 @@ void UserAuthCallbackImplSetPropFreez::OnResult(uint32_t result, std::vector<uin
}
getPropertyRequest.authType = authType_;
getPropertyRequest.keys.push_back(AuthAttributeType::AUTH_REMAIN_COUNT);
getPropertyRequest.keys.push_back(AuthAttributeType::AUTH_REMAIN_TIME);
getPropertyRequest.keys.push_back(AUTH_SUB_TYPE);
getPropertyRequest.keys.push_back(REMAIN_TIMES);
getPropertyRequest.keys.push_back(FREEZING_TIME);
if (callback_ == nullptr) {
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuthCallbackImplSetPropFreez callback_ is Null");
return;
@@ -355,7 +356,6 @@ void UserAuthCallbackImplIDMGetPorpCoauth::OnGetInfo(std::vector<UserIDM::Creden
return;
}
uint64_t tmp = info.begin()->templateId;
USERAUTH_HILOGD(MODULE_SERVICE, "GetPropertyRequest requset key is %{public}u!", requset_.keys.front());
ret = UserAuthAdapter::GetInstance().GetExecutorProp(callerUid_, pkgName_, tmp, requset_, executorProperty);
if (ret != SUCCESS) {
executorProperty.freezingTime = 0;
+1 -1
View File
@@ -22,7 +22,7 @@
namespace OHOS {
namespace UserIAM {
namespace UserAuth {
REGISTER_SYSTEM_ABILITY_BY_ID(UserAuthService, USERAUTH_SERVICE_SA_ID, true);
REGISTER_SYSTEM_ABILITY_BY_ID(UserAuthService, SUBSYS_USERIAM_SYS_ABILITY_USERAUTH, true);
UserAuthService::UserAuthService(int32_t systemAbilityId, bool runOnCreate)
: SystemAbility(systemAbilityId, runOnCreate)
Executable → Regular
View File
+1 -1
View File
@@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/useriam/userauth/userauth.gni")
import("//base/user_iam/user_auth/userauth.gni")
import("//build/test.gni")
group("userauth_native_test") {
+4 -7
View File
@@ -12,7 +12,7 @@
# limitations under the License.
import("//build/ohos.gni")
import("//build/test.gni")
import("//base/useriam/userauth/userauth.gni")
import("//base/user_iam/user_auth/userauth.gni")
module_output_path = "${userauth_native_part_name}/UserAuth_test"
@@ -24,7 +24,6 @@ config("module_private_config") {
include_dirs = [
"include",
"//utils/system/safwk/native/include",
#"//base/distributeddatamgr/distributeddatamgr/frameworks/innerkitsimpl/distributeddatafwk/include",
]
}
@@ -36,10 +35,10 @@ ohos_unittest("unittest_test") {
include_dirs = [
"include",
#"//base/useriam/useridm/unittest/include",
#"//base/user_iam/user_idm/unittest/include",
"//out/hi3516dv300/innerkits/ohos-arm/ipc/ipc_single/include",
"//base/useriam/userauth/interfaces/innerkits/include",
#"//base/useriam/useridm/services/include",
"//base/user_iam/user_auth/interfaces/innerkits/include",
#"//base/user_iam/user_idm/services/include",
]
configs = [
@@ -52,8 +51,6 @@ ohos_unittest("unittest_test") {
"//drivers/peripheral/display/hal:hdi_display_device",
"//third_party/googletest:gtest_main",
"//utils/native/base:utils",
#"//base/useriam/userauth/interfaces/innerkits/userauth:userauth_inner",
#"//base/useriam/userauth/services/userauthservice/adapter:userauth_adapter",
]
external_deps = [
+2 -2
View File
@@ -13,9 +13,9 @@
import("//build/ohos.gni")
userauth_native_part_name = "userauth"
userauth_native_part_name = "user_auth"
userauth_root_path = "//base/useriam/userauth"
userauth_root_path = "//base/user_iam/user_auth"
userauth_service_path = "${userauth_root_path}/services"
+1 -1
View File
@@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/useriam/userauth/userauth.gni")
import("//base/user_iam/user_auth/userauth.gni")
config("utils_config") {
include_dirs = [