From b3454f5e4f5cb85d68700e2e22ae0a46e5e995b1 Mon Sep 17 00:00:00 2001 From: liuhu Date: Mon, 26 May 2025 17:26:35 +0800 Subject: [PATCH] add pinLenth Change-Id: I86ecb5d869d3554d3f3befea7f9f8c3816511fdb Signed-off-by: liuhu --- .../framework/framework_executor_callback.cpp | 31 +++++++++++-------- interfaces/inner_api/attributes.h | 2 ++ .../iam_executor_framework_types.h | 2 ++ services/ipc/src/user_auth_service.cpp | 3 +- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/frameworks/native/executors/src/framework/framework_executor_callback.cpp b/frameworks/native/executors/src/framework/framework_executor_callback.cpp index 837d8464b..f42b1b803 100644 --- a/frameworks/native/executors/src/framework/framework_executor_callback.cpp +++ b/frameworks/native/executors/src/framework/framework_executor_callback.cpp @@ -369,6 +369,7 @@ ResultCode FrameworkExecutorCallback::ProcessAbandonCommand(uint64_t scheduleId, ResultCode FrameworkExecutorCallback::FillPropertyToAttribute(const std::vector &keyList, const Property property, std::shared_ptr values) { + bool ret = false; for (auto &key : keyList) { switch (key) { case Attributes::ATTR_PIN_SUB_TYPE: { @@ -377,32 +378,36 @@ ResultCode FrameworkExecutorCallback::FillPropertyToAttribute(const std::vector< break; } case Attributes::ATTR_FREEZING_TIME: { - bool setAuthRemainTimeRet = - values->SetInt32Value(Attributes::ATTR_FREEZING_TIME, property.lockoutDuration); - IF_FALSE_LOGE_AND_RETURN_VAL(setAuthRemainTimeRet == true, ResultCode::GENERAL_ERROR); + ret = values->SetInt32Value(Attributes::ATTR_FREEZING_TIME, property.lockoutDuration); + IF_FALSE_LOGE_AND_RETURN_VAL(ret == true, ResultCode::GENERAL_ERROR); break; } case Attributes::ATTR_REMAIN_TIMES: { - bool setAuthRemainCountRet = - values->SetInt32Value(Attributes::ATTR_REMAIN_TIMES, property.remainAttempts); - IF_FALSE_LOGE_AND_RETURN_VAL(setAuthRemainCountRet == true, ResultCode::GENERAL_ERROR); + ret = values->SetInt32Value(Attributes::ATTR_REMAIN_TIMES, property.remainAttempts); + IF_FALSE_LOGE_AND_RETURN_VAL(ret == true, ResultCode::GENERAL_ERROR); break; } case Attributes::ATTR_ENROLL_PROGRESS: { - bool setEnrollProgressRet = - values->SetStringValue(Attributes::ATTR_ENROLL_PROGRESS, property.enrollmentProgress); - IF_FALSE_LOGE_AND_RETURN_VAL(setEnrollProgressRet == true, ResultCode::GENERAL_ERROR); + ret = values->SetStringValue(Attributes::ATTR_ENROLL_PROGRESS, property.enrollmentProgress); + IF_FALSE_LOGE_AND_RETURN_VAL(ret == true, ResultCode::GENERAL_ERROR); break; } case Attributes::ATTR_SENSOR_INFO: { - bool setSensorInfoRet = values->SetStringValue(Attributes::ATTR_SENSOR_INFO, property.sensorInfo); - IF_FALSE_LOGE_AND_RETURN_VAL(setSensorInfoRet == true, ResultCode::GENERAL_ERROR); + ret = values->SetStringValue(Attributes::ATTR_SENSOR_INFO, property.sensorInfo); + IF_FALSE_LOGE_AND_RETURN_VAL(ret == true, ResultCode::GENERAL_ERROR); break; } case Attributes::ATTR_NEXT_FAIL_LOCKOUT_DURATION: { - bool setNextFailLockoutDurationRet = values->SetInt32Value(Attributes::ATTR_NEXT_FAIL_LOCKOUT_DURATION, + ret = values->SetInt32Value(Attributes::ATTR_NEXT_FAIL_LOCKOUT_DURATION, property.nextFailLockoutDuration); - IF_FALSE_LOGE_AND_RETURN_VAL(setNextFailLockoutDurationRet == true, ResultCode::GENERAL_ERROR); + IF_FALSE_LOGE_AND_RETURN_VAL(ret == true, ResultCode::GENERAL_ERROR); + break; + } + case Attributes::ATTR_CREDENTIAL_LENGTH: { + if (property.credentialLength != 0) { + ret = values->SetUint32Value(Attributes::ATTR_CREDENTIAL_LENGTH, property.credentialLength); + IF_FALSE_LOGE_AND_RETURN_VAL(ret == true, ResultCode::GENERAL_ERROR); + } break; } default: diff --git a/interfaces/inner_api/attributes.h b/interfaces/inner_api/attributes.h index e7d2df8cb..a1eea5065 100644 --- a/interfaces/inner_api/attributes.h +++ b/interfaces/inner_api/attributes.h @@ -203,6 +203,8 @@ public: ATTR_TOKEN_TYPE = 100090, /* Token time interval between sign and verify, the value type is int64_t. */ ATTR_TOKEN_TIME_INTERVAL = 100091, + /* credential length, the value type is uint32_t. */ + ATTR_CREDENTIAL_LENGTH = 100092, }; /** diff --git a/interfaces/inner_api/iam_executor/iam_executor_framework_types.h b/interfaces/inner_api/iam_executor/iam_executor_framework_types.h index 6573b3f67..4e081036a 100644 --- a/interfaces/inner_api/iam_executor/iam_executor_framework_types.h +++ b/interfaces/inner_api/iam_executor/iam_executor_framework_types.h @@ -122,6 +122,8 @@ struct Property { std::string sensorInfo; /** Next fail lockout duration. */ int32_t nextFailLockoutDuration; + /** credential length. */ + uint32_t credentialLength; }; /** diff --git a/services/ipc/src/user_auth_service.cpp b/services/ipc/src/user_auth_service.cpp index 4e3a9d12e..cc888bed8 100644 --- a/services/ipc/src/user_auth_service.cpp +++ b/services/ipc/src/user_auth_service.cpp @@ -87,7 +87,8 @@ bool IsTemplateIdListRequired(const std::vector &keys) if (key == Attributes::AttributeKey::ATTR_PIN_SUB_TYPE || key == Attributes::AttributeKey::ATTR_REMAIN_TIMES || key == Attributes::AttributeKey::ATTR_FREEZING_TIME || - key == Attributes::AttributeKey::ATTR_NEXT_FAIL_LOCKOUT_DURATION) { + key == Attributes::AttributeKey::ATTR_NEXT_FAIL_LOCKOUT_DURATION || + key == Attributes::AttributeKey::ATTR_CREDENTIAL_LENGTH) { return true; } } -- Gitee