diff --git a/common/include/dm_anonymous.h b/common/include/dm_anonymous.h index df4ff3408bc1d81396feceb519d39d0a0e4d11eb..ecc2878e1da2e624d81bd3007a32939d60630d78 100644 --- a/common/include/dm_anonymous.h +++ b/common/include/dm_anonymous.h @@ -30,6 +30,8 @@ extern const int32_t LIST_SPLIT_LEN; DM_EXPORT std::string GetAnonyString(const std::string &value); std::string GetAnonyStringList(const std::vector &values); std::string GetAnonyInt32(const int32_t value); +std::string GetAnonyInt64(const int64_t value); +std::string GetAnonyUint64(const uint64_t value); std::string GetAnonyInt32List(const std::vector &values); bool IsNumberString(const std::string &inputString); bool IsString(const JsonItemObject &jsonObj, const std::string &key); diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 43a0ecfed58b75fd2d1ae7fbe42ed2c032afe5d0..6829c1179776c4ac59daaac4b6b8456f98bb4ffb 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -84,6 +84,42 @@ std::string GetAnonyInt32(const int32_t value) return tempString; } +std::string GetAnonyInt64(const int64_t value) +{ + std::string tempString = std::to_string(value); + size_t length = tempString.length(); + if (length == 0x01) { + tempString[0] = '*'; + return tempString; + } + if (length == 0x02) { + tempString[1] = '*'; + return tempString; + } + for (size_t i = 1; i < length - 1; i++) { + tempString[i] = '*'; + } + return tempString; +} + +std::string GetAnonyUint64(const uint64_t value) +{ + std::string tempString = std::to_string(value); + size_t length = tempString.length(); + if (length == 0x01) { + tempString[0] = '*'; + return tempString; + } + if (length == 0x02) { + tempString[1] = '*'; + return tempString; + } + for (size_t i = 1; i < length - 1; i++) { + tempString[i] = '*'; + } + return tempString; +} + std::string GetAnonyInt32List(const std::vector &values) { std::string temp = "[ "; diff --git a/commondependency/src/deviceprofile_connector.cpp b/commondependency/src/deviceprofile_connector.cpp index 49ec04f9f2578136af67d0279e13b68250aadf2e..f3f12cb2b56c49623fbc4ac12e2f43a00c5316e1 100644 --- a/commondependency/src/deviceprofile_connector.cpp +++ b/commondependency/src/deviceprofile_connector.cpp @@ -76,6 +76,7 @@ void PrintProfile(const AccessControlProfile &profile) std::string acerPkgName = profile.GetAccesser().GetAccesserBundleName(); std::string acerCredId = profile.GetAccesser().GetAccesserCredentialIdStr(); int32_t acerSkId = profile.GetAccesser().GetAccesserSessionKeyId(); + int64_t acerTokenId = profile.GetAccesser().GetAccesserTokenId(); std::string aceeDeviceId = profile.GetAccessee().GetAccesseeDeviceId(); int32_t aceeUserId = profile.GetAccessee().GetAccesseeUserId(); @@ -83,15 +84,18 @@ void PrintProfile(const AccessControlProfile &profile) std::string aceePkgName = profile.GetAccessee().GetAccesseeBundleName(); std::string aceeCredId = profile.GetAccessee().GetAccesseeCredentialIdStr(); int32_t aceeSkId = profile.GetAccessee().GetAccesseeSessionKeyId(); + int64_t aceeTokenId = profile.GetAccessee().GetAccesseeTokenId(); LOGI("bindType %{public}d, bindLevel %{public}d, acerDeviceId %{public}s, acerUserId %{public}d," "acerAccountId %{public}s, acerPkgName %{public}s, acerCredId %{public}s," "acerSkId %{public}d, aceeDeviceId %{public}s, aceeUserId %{public}d, aceeAccountId %{public}s," - "aceePkgName %{public}s, aceeCredId %{public}s, aceeSkId %{public}d.", + "aceePkgName %{public}s, aceeCredId %{public}s, aceeSkId %{public}d," + "acerTokenId %{public}s, aceeTokenId %{public}s.", bindType, bindLevel, GetAnonyString(acerDeviceId).c_str(), acerUserId, GetAnonyString(acerAccountId).c_str(), acerPkgName.c_str(), GetAnonyString(acerCredId).c_str(), acerSkId, GetAnonyString(aceeDeviceId).c_str(), aceeUserId, GetAnonyString(aceeAccountId).c_str(), - aceePkgName.c_str(), GetAnonyString(aceeCredId).c_str(), aceeSkId); + aceePkgName.c_str(), GetAnonyString(aceeCredId).c_str(), aceeSkId, + GetAnonyInt64(acerTokenId).c_str(), GetAnonyInt64(aceeTokenId).c_str()); } std::string GetLocalDeviceId() @@ -1826,12 +1830,13 @@ DM_EXPORT bool DeviceProfileConnector::CheckAccessControl( const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, const std::string &sinkUdid) { - LOGI("srcUdid %{public}s, srcUserId %{public}d, srcPkgName %{public}s" - "srcAccountId %{public}s, sinkUdid %{public}s, sinkUserId %{public}d, sinkPkgName %{public}s," - "sinkAccountId %{public}s.", GetAnonyString(srcUdid).c_str(), caller.userId, + LOGI("srcUdid %{public}s, srcUserId %{public}d, srcPkgName %{public}s, srcAccountId %{public}s," + "sinkUdid %{public}s, sinkUserId %{public}d, sinkPkgName %{public}s, sinkAccountId %{public}s" + "callerTokenId %{public}s, calleeTokenId %{public}s.", GetAnonyString(srcUdid).c_str(), caller.userId, caller.pkgName.c_str(), GetAnonyString(caller.accountId).c_str(), GetAnonyString(sinkUdid).c_str(), callee.userId, callee.pkgName.c_str(), - GetAnonyString(callee.accountId).c_str()); + GetAnonyString(callee.accountId).c_str(), GetAnonyUint64(caller.tokenId).c_str(), + GetAnonyUint64(callee.tokenId).c_str()); std::vector profiles = GetAllAccessControlProfile(); std::vector profilesFilter = GetACLByDeviceIdAndUserId(profiles, caller, srcUdid, callee, sinkUdid); @@ -1906,10 +1911,12 @@ DM_EXPORT bool DeviceProfileConnector::CheckIsSameAccount( { LOGI("srcUdid %{public}s, srcUserId %{public}d, srcPkgName %{public}s," "srcAccountId %{public}s, sinkUdid %{public}s, sinkUserId %{public}d, sinkPkgName %{public}s," - "sinkAccountId %{public}s.", GetAnonyString(srcUdid).c_str(), caller.userId, + "sinkAccountId %{public}s, callerTokenId %{public}s, calleeTokenId %{public}s.", + GetAnonyString(srcUdid).c_str(), caller.userId, caller.pkgName.c_str(), GetAnonyString(caller.accountId).c_str(), GetAnonyString(sinkUdid).c_str(), callee.userId, callee.pkgName.c_str(), - GetAnonyString(callee.accountId).c_str()); + GetAnonyString(callee.accountId).c_str(), GetAnonyUint64(caller.tokenId).c_str(), + GetAnonyUint64(callee.tokenId).c_str()); std::vector profiles = GetAllAccessControlProfile(); std::vector profilesFilter = GetACLByDeviceIdAndUserId(profiles, caller, srcUdid, callee, sinkUdid); @@ -3124,10 +3131,12 @@ DM_EXPORT bool DeviceProfileConnector::CheckSrcAccessControl(const DmAccessCalle { LOGI("srcUdid %{public}s, srcUserId %{public}d, srcPkgName %{public}s," "srcAccountId %{public}s, sinkUdid %{public}s, sinkUserId %{public}d, sinkPkgName %{public}s," - "sinkAccountId %{public}s.", GetAnonyString(srcUdid).c_str(), caller.userId, + "sinkAccountId %{public}s, callerTokenId %{public}s, calleeTokenId %{public}s.", + GetAnonyString(srcUdid).c_str(), caller.userId, caller.pkgName.c_str(), GetAnonyString(caller.accountId).c_str(), GetAnonyString(sinkUdid).c_str(), callee.userId, callee.pkgName.c_str(), - GetAnonyString(callee.accountId).c_str()); + GetAnonyString(callee.accountId).c_str(), GetAnonyUint64(caller.tokenId).c_str(), + GetAnonyUint64(callee.tokenId).c_str()); std::vector profiles = GetAllAccessControlProfile(); std::string localUdid = GetLocalDeviceId(); std::string trustUdid = (localUdid == srcUdid ? sinkUdid : srcUdid); @@ -3404,12 +3413,14 @@ bool DeviceProfileConnector::CheckSinkAppOrServiceP2PAcl(const DistributedDevice DM_EXPORT bool DeviceProfileConnector::CheckSrcIsSameAccount(const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, const std::string &sinkUdid) { - LOGI("srcUdid %{public}s, srcUserId %{public}d, srcPkgName %{public}s, " + LOGI("srcUdid %{public}s, srcUserId %{public}d, srcPkgName %{public}s," "srcAccountId %{public}s, sinkUdid %{public}s, sinkUserId %{public}d, sinkPkgName %{public}s," - "sinkAccountId %{public}s.", GetAnonyString(srcUdid).c_str(), caller.userId, + "sinkAccountId %{public}s, callerTokenId %{public}s, calleeTokenId %{public}s.", + GetAnonyString(srcUdid).c_str(), caller.userId, caller.pkgName.c_str(), GetAnonyString(caller.accountId).c_str(), GetAnonyString(sinkUdid).c_str(), callee.userId, callee.pkgName.c_str(), - GetAnonyString(callee.accountId).c_str()); + GetAnonyString(callee.accountId).c_str(), GetAnonyUint64(caller.tokenId).c_str(), + GetAnonyUint64(callee.tokenId).c_str()); std::vector profiles = GetAllAccessControlProfile(); std::string localUdid = GetLocalDeviceId(); std::string trustUdid = (localUdid == srcUdid ? sinkUdid : srcUdid); @@ -3430,10 +3441,12 @@ DM_EXPORT bool DeviceProfileConnector::CheckSinkIsSameAccount(const DmAccessCall { LOGI("srcUdid %{public}s, srcUserId %{public}d, srcPkgName %{public}s," "srcAccountId %{public}s, sinkUdid %{public}s, sinkUserId %{public}d, sinkPkgName %{public}s," - "sinkAccountId %{public}s.", GetAnonyString(srcUdid).c_str(), caller.userId, + "sinkAccountId %{public}s, callerTokenId %{public}s, calleeTokenId %{public}s.", + GetAnonyString(srcUdid).c_str(), caller.userId, caller.pkgName.c_str(), GetAnonyString(caller.accountId).c_str(), GetAnonyString(sinkUdid).c_str(), callee.userId, callee.pkgName.c_str(), - GetAnonyString(callee.accountId).c_str()); + GetAnonyString(callee.accountId).c_str(), GetAnonyUint64(caller.tokenId).c_str(), + GetAnonyUint64(callee.tokenId).c_str()); std::vector profiles = GetAllAccessControlProfile(); std::string localUdid = GetLocalDeviceId(); std::string trustUdid = (localUdid == srcUdid ? sinkUdid : srcUdid);