diff --git a/frameworks/native/common/attributes/src/attributes.cpp b/frameworks/native/common/attributes/src/attributes.cpp index a8939c0cd89d14aaafb0f78f2e870727a9a5d0b9..4560fe4cc689c03c8bb1f728b594bfcb1a22db60 100644 --- a/frameworks/native/common/attributes/src/attributes.cpp +++ b/frameworks/native/common/attributes/src/attributes.cpp @@ -71,6 +71,7 @@ public: bool GetAttributesValue(AttributeKey key, Impl &array) const; std::vector Serialize() const; std::vector GetKeys() const; + bool HasAttribute(AttributeKey key) const; static bool EncodeUint32Value(uint32_t src, std::vector &dst); static bool DecodeUint32Value(const std::vector &src, uint32_t &dst); @@ -674,6 +675,11 @@ std::vector Attributes::Impl::GetKeys() const return keys; } +bool Attributes::Impl::HasAttribute(AttributeKey key) const +{ + return (map_.find(key) != map_.end()); +} + bool Attributes::Impl::EncodeBoolValue(bool src, std::vector &dst) { std::vector out(1); // only 1 @@ -1384,6 +1390,14 @@ std::vector Attributes::GetKeys() const } return impl_->GetKeys(); } + +bool Attributes::HasAttribute(AttributeKey key) const +{ + if (!impl_) { + return false; + } + return impl_->HasAttribute(key); +} } // namespace UserAuth } // namespace UserIam } // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/attributes.h b/interfaces/inner_api/attributes.h index a1eea5065a5925ecb862c505bdb8e9095777b3fd..5fa2ebc3473cbf7ca8b0332106beb31797437ff5 100644 --- a/interfaces/inner_api/attributes.h +++ b/interfaces/inner_api/attributes.h @@ -205,6 +205,11 @@ public: ATTR_TOKEN_TIME_INTERVAL = 100091, /* credential length, the value type is uint32_t. */ ATTR_CREDENTIAL_LENGTH = 100092, + /* + * Is token in attribute generated by remote device, if not setted indicate token generated by local device. + * The value type is bool. + */ + ATTR_TOKEN_FROM_REMOTE_DEVICE = 100093, }; /** @@ -525,6 +530,13 @@ public: */ std::vector GetKeys() const; + /** + * @brief Is specific attribute setted. + * + * @return Return is specific attribute setted. + */ + bool HasAttribute(AttributeKey key) const; + private: class Impl; std::unique_ptr impl_ {nullptr}; diff --git a/services/context/src/remote_auth_invoker_context.cpp b/services/context/src/remote_auth_invoker_context.cpp index 266ba6fd81e438c5d5a7e61a5444df266e1f8887..89d8166a7dac7a3ac3323d7d1a8555e6bd244da7 100644 --- a/services/context/src/remote_auth_invoker_context.cpp +++ b/services/context/src/remote_auth_invoker_context.cpp @@ -359,6 +359,8 @@ int32_t RemoteAuthInvokerContext::ProcAuthResultMsgInner(Attributes &message, in if (resultCode == ResultCode::SUCCESS) { bool setTokenRet = attr.SetUint8ArrayValue(Attributes::ATTR_SIGNATURE, authResultInfo.token); IF_FALSE_LOGE_AND_RETURN_VAL(setTokenRet, ResultCode::GENERAL_ERROR); + bool setTokenFromRemoteDevice = attr.SetBoolValue(Attributes::ATTR_TOKEN_FROM_REMOTE_DEVICE, true); + IF_FALSE_LOGE_AND_RETURN_VAL(setTokenFromRemoteDevice, ResultCode::GENERAL_ERROR); bool setUserId = attr.SetInt32Value(Attributes::ATTR_USER_ID, authResultInfo.userId); IF_FALSE_LOGE_AND_RETURN_VAL(setUserId, ResultCode::GENERAL_ERROR); }