mirror of
https://github.com/openharmony/useriam_user_auth.git
synced 2026-07-19 14:23:34 -04:00
fix: code review fix
Signed-off-by: zhirenx <xuzhiren@huawei.com> Change-Id: I0dd0f2535204c68f9de463465abd6b4a7cdebd07
This commit is contained in:
@@ -19,8 +19,8 @@
|
||||
#include <system_ability_definition.h>
|
||||
|
||||
#include "system_ability_definition.h"
|
||||
#include "userauth_hilog_wrapper.h"
|
||||
#include "user_auth.h"
|
||||
#include "userauth_hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
@@ -58,7 +58,7 @@ sptr<IUserAuth> UserAuth::GetProxy()
|
||||
return proxy_;
|
||||
}
|
||||
|
||||
void UserAuth::ResetProxy(const wptr<IRemoteObject>& remote)
|
||||
void UserAuth::ResetProxy(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_INNERKIT, "userauth ResetProxy is start");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
@@ -73,7 +73,7 @@ void UserAuth::ResetProxy(const wptr<IRemoteObject>& remote)
|
||||
}
|
||||
}
|
||||
|
||||
void UserAuth::UserAuthDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
|
||||
void UserAuth::UserAuthDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_INNERKIT, "OnRemoteDied is start");
|
||||
if (remote == nullptr) {
|
||||
@@ -138,7 +138,7 @@ void UserAuth::SetProperty(const SetPropertyRequest request, std::shared_ptr<Set
|
||||
proxy_->SetProperty(request, asyncStub);
|
||||
}
|
||||
uint64_t UserAuth::Auth(const uint64_t challenge, const AuthType authType, const AuthTurstLevel authTurstLevel,
|
||||
std::shared_ptr<UserAuthCallback> callback)
|
||||
std::shared_ptr<UserAuthCallback> callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_INNERKIT, "userauth Auth is start");
|
||||
if (callback == nullptr) {
|
||||
@@ -158,7 +158,7 @@ uint64_t UserAuth::Auth(const uint64_t challenge, const AuthType authType, const
|
||||
return ret;
|
||||
}
|
||||
uint64_t UserAuth::AuthUser(const int32_t userId, const uint64_t challenge, const AuthType authType,
|
||||
const AuthTurstLevel authTurstLevel, std::shared_ptr<UserAuthCallback> callback)
|
||||
const AuthTurstLevel authTurstLevel, std::shared_ptr<UserAuthCallback> callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_INNERKIT, "userauth AuthUser is start");
|
||||
if (callback == nullptr) {
|
||||
@@ -199,6 +199,6 @@ int32_t UserAuth::GetVersion()
|
||||
int32_t ret = proxy_->GetVersion();
|
||||
return ret;
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -23,17 +23,14 @@
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
UserAuthAsyncStub::UserAuthAsyncStub(std::shared_ptr<UserAuthCallback>& impl)
|
||||
UserAuthAsyncStub::UserAuthAsyncStub(std::shared_ptr<UserAuthCallback> &impl) : authCallback_(impl)
|
||||
{
|
||||
authCallback_ = impl;
|
||||
}
|
||||
UserAuthAsyncStub::UserAuthAsyncStub(std::shared_ptr<GetPropCallback>& impl)
|
||||
UserAuthAsyncStub::UserAuthAsyncStub(std::shared_ptr<GetPropCallback> &impl) : getPropCallback_(impl)
|
||||
{
|
||||
getPropCallback_ = impl;
|
||||
}
|
||||
UserAuthAsyncStub::UserAuthAsyncStub(std::shared_ptr<SetPropCallback>& impl)
|
||||
UserAuthAsyncStub::UserAuthAsyncStub(std::shared_ptr<SetPropCallback> &impl) : setPropCallback_(impl)
|
||||
{
|
||||
setPropCallback_ = impl;
|
||||
}
|
||||
int32_t UserAuthAsyncStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
@@ -142,7 +139,7 @@ int32_t UserAuthAsyncStub::onExecutorPropertyInfoStub(MessageParcel& data, Messa
|
||||
uint64_t authSubType;
|
||||
uint32_t remainTimes;
|
||||
uint32_t freezingTime;
|
||||
ExecutorProperty executorProperty;
|
||||
ExecutorProperty executorProperty = {};
|
||||
|
||||
if (!data.ReadInt32(result)) {
|
||||
USERAUTH_HILOGE(MODULE_INNERKIT, "failed to ReadInt32(result).");
|
||||
|
||||
@@ -12,16 +12,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "userauth_proxy.h"
|
||||
#include "userauth_hilog_wrapper.h"
|
||||
#include <cinttypes>
|
||||
#include <message_parcel.h>
|
||||
#include <string_ex.h>
|
||||
#include "userauth_hilog_wrapper.h"
|
||||
#include "userauth_proxy.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
UserAuthProxy::UserAuthProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<IUserAuth>(object) {}
|
||||
UserAuthProxy::UserAuthProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<IUserAuth>(object)
|
||||
{
|
||||
}
|
||||
|
||||
int32_t UserAuthProxy::GetAvailableStatus(const AuthType authType, const AuthTurstLevel authTurstLevel)
|
||||
{
|
||||
@@ -56,7 +58,7 @@ int32_t UserAuthProxy::GetAvailableStatus(const AuthType authType, const AuthTur
|
||||
return result;
|
||||
}
|
||||
|
||||
void UserAuthProxy::GetProperty(const GetPropertyRequest request, sptr<IUserAuthCallback>& callback)
|
||||
void UserAuthProxy::GetProperty(const GetPropertyRequest request, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_INNERKIT, "UserAuthProxy GetProperty is start");
|
||||
MessageParcel data;
|
||||
@@ -81,14 +83,14 @@ void UserAuthProxy::GetProperty(const GetPropertyRequest request, sptr<IUserAuth
|
||||
}
|
||||
bool ret = SendRequest(static_cast<int32_t>(IUserAuth::USER_AUTH_GET_PROPERTY), data, reply, option);
|
||||
if (!ret) {
|
||||
ExecutorProperty result;
|
||||
ExecutorProperty result = {};
|
||||
result.result = IPC_ERROR;
|
||||
callback->onExecutorPropertyInfo(result);
|
||||
USERAUTH_HILOGE(MODULE_INNERKIT, "userauth SendRequest is failed, error code: %{public}d", ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
void UserAuthProxy::SetProperty(const SetPropertyRequest request, sptr<IUserAuthCallback>& callback)
|
||||
void UserAuthProxy::SetProperty(const SetPropertyRequest request, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_INNERKIT, "UserAuthProxy SetProperty is start");
|
||||
MessageParcel data;
|
||||
@@ -124,8 +126,8 @@ void UserAuthProxy::SetProperty(const SetPropertyRequest request, sptr<IUserAuth
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t UserAuthProxy::Auth(const uint64_t challenge, const AuthType authType,
|
||||
const AuthTurstLevel authTurstLevel, sptr<IUserAuthCallback>& callback)
|
||||
uint64_t UserAuthProxy::Auth(const uint64_t challenge, const AuthType authType, const AuthTurstLevel authTurstLevel,
|
||||
sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_INNERKIT, "UserAuthProxy Auth is start");
|
||||
const uint64_t invalidContextID = 0;
|
||||
@@ -168,7 +170,7 @@ uint64_t UserAuthProxy::Auth(const uint64_t challenge, const AuthType authType,
|
||||
}
|
||||
|
||||
uint64_t UserAuthProxy::AuthUser(const int32_t userId, const uint64_t challenge, const AuthType authType,
|
||||
const AuthTurstLevel authTurstLevel, sptr<IUserAuthCallback>& callback)
|
||||
const AuthTurstLevel authTurstLevel, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_INNERKIT, "UserAuthProxy AuthUser is start");
|
||||
const uint64_t invalidContextID = 0;
|
||||
@@ -273,7 +275,7 @@ bool UserAuthProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParce
|
||||
if (remote == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int32_t result = remote->SendRequest(code, data, reply, option);
|
||||
if (result != OHOS::UserIAM::UserAuth::SUCCESS) {
|
||||
USERAUTH_HILOGE(MODULE_INNERKIT, "UserAuthProxy SendRequest fail");
|
||||
@@ -282,5 +284,5 @@ bool UserAuthProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParce
|
||||
return true;
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
|
||||
#include "nocopyable.h"
|
||||
|
||||
#include "auth_common.h"
|
||||
#include "result_convert.h"
|
||||
|
||||
@@ -27,9 +29,9 @@ namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
class AuthBuild {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(AuthBuild);
|
||||
AuthBuild();
|
||||
~AuthBuild();
|
||||
ResultConvert convert;
|
||||
virtual ~AuthBuild();
|
||||
Napi_SetPropertyRequest SetPropertyRequestBuild(napi_env env, napi_value object);
|
||||
Napi_GetPropertyRequest GetPropertyRequestBuild(napi_env env, napi_value object);
|
||||
bool NapiTypeObject(napi_env env, napi_value value);
|
||||
@@ -38,6 +40,9 @@ public:
|
||||
uint64_t GetUint8ArrayTo64(napi_env env, napi_value value);
|
||||
int NapiGetValueInt(napi_env env, napi_value value);
|
||||
napi_value Uint64ToUint8Array(napi_env env, uint64_t value);
|
||||
|
||||
private:
|
||||
ResultConvert convert_;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIAM
|
||||
|
||||
@@ -53,15 +53,14 @@ namespace UserAuth {
|
||||
#define PARAM10 10
|
||||
|
||||
struct CallBackInfo {
|
||||
napi_env env;
|
||||
napi_ref callBack = 0;
|
||||
napi_deferred deferred;
|
||||
napi_env env {nullptr};
|
||||
napi_ref callBack {nullptr};
|
||||
napi_deferred deferred {nullptr};
|
||||
};
|
||||
|
||||
struct GetPropertyInfo {
|
||||
GetPropertyInfo() : result(nullptr) {};
|
||||
CallBackInfo callBackInfo;
|
||||
napi_value result;
|
||||
napi_value result {nullptr};
|
||||
int32_t authType;
|
||||
std::vector<uint32_t> keys;
|
||||
int32_t getResult;
|
||||
@@ -71,10 +70,9 @@ struct GetPropertyInfo {
|
||||
};
|
||||
|
||||
struct SetPropertyInfo {
|
||||
SetPropertyInfo() : asyncWork(nullptr), result(nullptr) {};
|
||||
CallBackInfo callBackInfo;
|
||||
napi_async_work asyncWork;
|
||||
napi_value result;
|
||||
napi_async_work asyncWork {nullptr};
|
||||
napi_value result {nullptr};
|
||||
int32_t authType;
|
||||
uint32_t key;
|
||||
std::vector<uint8_t> setInfo;
|
||||
@@ -93,10 +91,9 @@ struct ExecuteInfo {
|
||||
};
|
||||
|
||||
struct AuthInfo {
|
||||
AuthInfo() : asyncWork(nullptr) {};
|
||||
CallBackInfo callBackInfo;
|
||||
napi_callback_info info;
|
||||
napi_async_work asyncWork;
|
||||
napi_async_work asyncWork {nullptr};
|
||||
napi_value onResultCallBack;
|
||||
napi_value onAcquireInfoCallBack;
|
||||
napi_ref onResult;
|
||||
@@ -113,10 +110,9 @@ struct AuthInfo {
|
||||
};
|
||||
|
||||
struct AuthUserInfo {
|
||||
AuthUserInfo() : asyncWork(nullptr) {};
|
||||
CallBackInfo callBackInfo;
|
||||
napi_callback_info info;
|
||||
napi_async_work asyncWork;
|
||||
napi_async_work asyncWork {nullptr};
|
||||
napi_ref onResult;
|
||||
napi_ref onAcquireInfo;
|
||||
napi_value onResultCallBack;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "nocopyable.h"
|
||||
|
||||
#include "userauth_info.h"
|
||||
|
||||
@@ -32,8 +33,9 @@ namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
class ResultConvert {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(ResultConvert);
|
||||
ResultConvert();
|
||||
~ResultConvert();
|
||||
virtual ~ResultConvert();
|
||||
napi_value Uint64ToUint8Napi(napi_env env, uint64_t value);
|
||||
std::vector<uint8_t> NapiGetValueUint8Array(napi_env env, napi_value jsObject, std::string key);
|
||||
napi_valuetype GetType(napi_env env, napi_value value);
|
||||
|
||||
@@ -22,12 +22,8 @@
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
AuthBuild::AuthBuild(void)
|
||||
{
|
||||
}
|
||||
AuthBuild::~AuthBuild()
|
||||
{
|
||||
}
|
||||
AuthBuild::AuthBuild() = default;
|
||||
AuthBuild::~AuthBuild() = default;
|
||||
|
||||
Napi_SetPropertyRequest AuthBuild::SetPropertyRequestBuild(napi_env env, napi_value object)
|
||||
{
|
||||
@@ -36,9 +32,9 @@ Napi_SetPropertyRequest AuthBuild::SetPropertyRequestBuild(napi_env env, napi_va
|
||||
USERAUTH_HILOGE(MODULE_JS_NAPI, "SetPropertyRequestBuild object is null");
|
||||
return request;
|
||||
}
|
||||
request.authType_ = convert.GetInt32ValueByKey(env, object, "authType");
|
||||
request.key_ = convert.GetInt32ValueByKey(env, object, "key");
|
||||
request.setInfo_ = convert.NapiGetValueUint8Array(env, object, "setInfo");
|
||||
request.authType_ = convert_.GetInt32ValueByKey(env, object, "authType");
|
||||
request.key_ = convert_.GetInt32ValueByKey(env, object, "key");
|
||||
request.setInfo_ = convert_.NapiGetValueUint8Array(env, object, "setInfo");
|
||||
USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthBuild::SetPropertyRequestBuild authType = %{public}d, key = %{public}d",
|
||||
request.authType_, request.key_);
|
||||
return request;
|
||||
@@ -51,8 +47,8 @@ Napi_GetPropertyRequest AuthBuild::GetPropertyRequestBuild(napi_env env, napi_va
|
||||
USERAUTH_HILOGE(MODULE_JS_NAPI, "GetPropertyRequestBuild object is null");
|
||||
return request;
|
||||
}
|
||||
request.authType_ = convert.GetInt32ValueByKey(env, object, "authType");
|
||||
request.keys_ = convert.GetInt32ArrayValueByKey(env, object, "keys");
|
||||
request.authType_ = convert_.GetInt32ValueByKey(env, object, "authType");
|
||||
request.keys_ = convert_.GetInt32ArrayValueByKey(env, object, "keys");
|
||||
USERAUTH_HILOGI(MODULE_JS_NAPI, "AuthBuild::GetPropertyRequestBuild authType = %{public}d", request.authType_);
|
||||
return request;
|
||||
}
|
||||
@@ -62,7 +58,7 @@ bool AuthBuild::NapiTypeObject(napi_env env, napi_value value)
|
||||
if (value == nullptr) {
|
||||
return false;
|
||||
}
|
||||
napi_valuetype isObject = convert.GetType(env, value);
|
||||
napi_valuetype isObject = convert_.GetType(env, value);
|
||||
if (isObject == napi_object) {
|
||||
return true;
|
||||
}
|
||||
@@ -74,7 +70,7 @@ bool AuthBuild::NapiTypeNumber(napi_env env, napi_value value)
|
||||
if (value == nullptr) {
|
||||
return false;
|
||||
}
|
||||
napi_valuetype isNumber = convert.GetType(env, value);
|
||||
napi_valuetype isNumber = convert_.GetType(env, value);
|
||||
if (isNumber == napi_number) {
|
||||
return true;
|
||||
}
|
||||
@@ -116,12 +112,12 @@ uint64_t AuthBuild::GetUint8ArrayTo64(napi_env env, napi_value value)
|
||||
|
||||
int AuthBuild::NapiGetValueInt(napi_env env, napi_value value)
|
||||
{
|
||||
return convert.NapiGetValueInt(env, value);
|
||||
return convert_.NapiGetValueInt(env, value);
|
||||
}
|
||||
|
||||
napi_value AuthBuild::Uint64ToUint8Array(napi_env env, uint64_t value)
|
||||
{
|
||||
return convert.Uint64ToUint8Napi(env, value);
|
||||
return convert_.Uint64ToUint8Napi(env, value);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIAM
|
||||
|
||||
@@ -43,15 +43,15 @@ public:
|
||||
virtual void GetProperty(const GetPropertyRequest request, sptr<IUserAuthCallback> &callback) = 0;
|
||||
virtual void SetProperty(const SetPropertyRequest request, sptr<IUserAuthCallback> &callback) = 0;
|
||||
virtual uint64_t Auth(const uint64_t challenge, const AuthType authType, const AuthTurstLevel authTurstLevel,
|
||||
sptr<IUserAuthCallback> &callback) = 0;
|
||||
sptr<IUserAuthCallback> &callback) = 0;
|
||||
virtual uint64_t AuthUser(const int32_t userId, const uint64_t challenge, const AuthType authType,
|
||||
const AuthTurstLevel authTurstLevel, sptr<IUserAuthCallback> &callback) = 0;
|
||||
const AuthTurstLevel authTurstLevel, sptr<IUserAuthCallback> &callback) = 0;
|
||||
virtual int32_t CancelAuth(const uint64_t contextId) = 0;
|
||||
virtual int32_t GetVersion() = 0;
|
||||
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.UserIAM.UserAuth.IUserAuth");
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // IUSERAUTH_H
|
||||
@@ -26,7 +26,6 @@ namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
class IUserAuthCallback : public IRemoteBroker {
|
||||
public:
|
||||
|
||||
virtual void onAcquireInfo(const int32_t module, const uint32_t acquireInfo, const int32_t extraInfo) = 0;
|
||||
virtual void onResult(const int32_t result, const AuthResult extraInfo) = 0;
|
||||
virtual void onExecutorPropertyInfo(const ExecutorProperty result) = 0;
|
||||
@@ -35,6 +34,6 @@ public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.UserIAM.UserAuth.IUserAuthCallback");
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // IUSERAUTH_CALLBACK_H
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#ifndef USERAUTH_CLIENT_H
|
||||
#define USERAUTH_CLIENT_H
|
||||
|
||||
#include <iremote_object.h>
|
||||
#include <mutex>
|
||||
#include <singleton.h>
|
||||
#include <iremote_object.h>
|
||||
|
||||
#include "iuser_auth.h"
|
||||
#include "userauth_async_stub.h"
|
||||
@@ -28,6 +28,7 @@ namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
class UserAuth : public DelayedRefSingleton<UserAuth> {
|
||||
DECLARE_DELAYED_REF_SINGLETON(UserAuth);
|
||||
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(UserAuth);
|
||||
|
||||
@@ -35,9 +36,9 @@ public:
|
||||
void GetProperty(const GetPropertyRequest request, std::shared_ptr<GetPropCallback> callback);
|
||||
void SetProperty(const SetPropertyRequest request, std::shared_ptr<SetPropCallback> callback);
|
||||
uint64_t Auth(const uint64_t challenge, const AuthType authType, const AuthTurstLevel authTurstLevel,
|
||||
std::shared_ptr<UserAuthCallback> callback);
|
||||
std::shared_ptr<UserAuthCallback> callback);
|
||||
uint64_t AuthUser(const int32_t userId, const uint64_t challenge, const AuthType authType,
|
||||
const AuthTurstLevel authTurstLevel, std::shared_ptr<UserAuthCallback> callback);
|
||||
const AuthTurstLevel authTurstLevel, std::shared_ptr<UserAuthCallback> callback);
|
||||
int32_t CancelAuth(const uint64_t contextId);
|
||||
int32_t GetVersion();
|
||||
|
||||
@@ -45,13 +46,13 @@ private:
|
||||
class UserAuthDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
UserAuthDeathRecipient() = default;
|
||||
~UserAuthDeathRecipient() = default;
|
||||
void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
|
||||
~UserAuthDeathRecipient() override = default;
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &remote) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_MOVE(UserAuthDeathRecipient);
|
||||
};
|
||||
void ResetProxy(const wptr<IRemoteObject>& remote);
|
||||
void ResetProxy(const wptr<IRemoteObject> &remote);
|
||||
sptr<IUserAuth> GetProxy();
|
||||
|
||||
std::mutex mutex_;
|
||||
@@ -59,6 +60,6 @@ private:
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_ {nullptr};
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // USERAUTH_CLIENT_H
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#define USERAUTH_ASYNC_STUB_H
|
||||
|
||||
#include <iremote_stub.h>
|
||||
#include <nocopyable.h>
|
||||
|
||||
#include "iuserauth_callback.h"
|
||||
#include "userauth_callback.h"
|
||||
|
||||
@@ -25,10 +27,11 @@ namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
class UserAuthAsyncStub : public IRemoteStub<IUserAuthCallback> {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(UserAuthAsyncStub);
|
||||
explicit UserAuthAsyncStub(std::shared_ptr<UserAuthCallback>& impl);
|
||||
explicit UserAuthAsyncStub(std::shared_ptr<SetPropCallback>& impl);
|
||||
explicit UserAuthAsyncStub(std::shared_ptr<GetPropCallback>& impl);
|
||||
~UserAuthAsyncStub() = default;
|
||||
~UserAuthAsyncStub() override = default;
|
||||
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
void onAcquireInfo(const int32_t module, const uint32_t acquireInfo, const int32_t extraInfo) override;
|
||||
|
||||
@@ -35,6 +35,6 @@ public:
|
||||
virtual void onSetProperty(const int32_t result) = 0;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // IUSERAUTH_CALLBACK_H
|
||||
|
||||
@@ -18,18 +18,16 @@
|
||||
|
||||
#include "parcel.h"
|
||||
|
||||
#define SIGN_LEN 32
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
// Type of authentication (password, face)
|
||||
enum AuthType: uint32_t {
|
||||
enum AuthType : uint32_t {
|
||||
PIN = 1,
|
||||
FACE = 2,
|
||||
};
|
||||
// Authentication subtype (2D face, 3D face...)
|
||||
enum AuthSubType: uint64_t {
|
||||
enum AuthSubType : uint64_t {
|
||||
/**
|
||||
* Authentication sub type six number pin.
|
||||
*/
|
||||
@@ -52,7 +50,7 @@ enum AuthSubType: uint64_t {
|
||||
FACE_3D = 20001
|
||||
};
|
||||
// Certification result confidence level
|
||||
enum AuthTurstLevel: uint32_t {
|
||||
enum AuthTurstLevel : uint32_t {
|
||||
// level 1-4
|
||||
ATL1 = 10000,
|
||||
ATL2 = 20000,
|
||||
@@ -60,7 +58,7 @@ enum AuthTurstLevel: uint32_t {
|
||||
ATL4 = 40000
|
||||
};
|
||||
// Actuator get property list
|
||||
enum GetPropertyType: uint32_t {
|
||||
enum GetPropertyType : uint32_t {
|
||||
// Authentication subtype (at this point the authentication type has been confirmed)
|
||||
AUTH_SUB_TYPE = 1,
|
||||
// Remaining authentication times
|
||||
@@ -70,9 +68,9 @@ enum GetPropertyType: uint32_t {
|
||||
};
|
||||
// get attribute request
|
||||
struct GetPropertyRequest {
|
||||
AuthType authType;
|
||||
AuthType authType {0};
|
||||
// GetPropertyType
|
||||
std::vector<uint32_t> keys;
|
||||
std::vector<uint32_t> keys {};
|
||||
};
|
||||
// Actuator properties
|
||||
struct ExecutorProperty {
|
||||
@@ -82,7 +80,7 @@ struct ExecutorProperty {
|
||||
uint32_t freezingTime;
|
||||
};
|
||||
// Actuator property mode list
|
||||
enum AuthPropertyMode: uint32_t {
|
||||
enum AuthPropertyMode : uint32_t {
|
||||
PROPERMODE_DELETE = 0,
|
||||
PROPERMODE_GET = 1,
|
||||
PROPERMODE_SET = 2,
|
||||
@@ -92,27 +90,27 @@ enum AuthPropertyMode: uint32_t {
|
||||
PROPERMODE_RELEASE_ALGORITHM = 6,
|
||||
};
|
||||
// Actuator property list
|
||||
enum SetPropertyType: uint32_t {
|
||||
enum SetPropertyType : uint32_t {
|
||||
INIT_ALGORITHM = 1,
|
||||
FREEZE_TEMPLATE = 2,
|
||||
THAW_TEMPLATE = 3,
|
||||
};
|
||||
struct SetPropertyRequest {
|
||||
AuthType authType;
|
||||
SetPropertyType key;
|
||||
std::vector<uint8_t> setInfo;
|
||||
AuthType authType {0};
|
||||
SetPropertyType key {0};
|
||||
std::vector<uint8_t> setInfo {};
|
||||
};
|
||||
// Authentication Result
|
||||
struct AuthResult {
|
||||
std::vector<uint8_t> token;
|
||||
uint32_t remainTimes;
|
||||
uint32_t freezingTime;
|
||||
std::vector<uint8_t> token {};
|
||||
uint32_t remainTimes {0};
|
||||
uint32_t freezingTime {0};
|
||||
};
|
||||
struct CoAuthInfo {
|
||||
AuthType authType;
|
||||
uint64_t callerID;
|
||||
uint64_t contextID;
|
||||
int32_t userID;
|
||||
AuthType authType {0};
|
||||
uint64_t callerID {0};
|
||||
uint64_t contextID {0};
|
||||
int32_t userID {0};
|
||||
std::string pkgName;
|
||||
std::vector<uint64_t> sessionIds;
|
||||
};
|
||||
@@ -125,89 +123,89 @@ struct FreezInfo {
|
||||
};
|
||||
|
||||
// Result Code
|
||||
enum ResultCode: int32_t {
|
||||
enum ResultCode : int32_t {
|
||||
/**
|
||||
* Indicates that authentication is success or ability is supported.
|
||||
*/
|
||||
SUCCESS = 0,
|
||||
/**
|
||||
* Indicates the authenticator fails to identify user.
|
||||
*/
|
||||
* Indicates the authenticator fails to identify user.
|
||||
*/
|
||||
FAIL = 1,
|
||||
/**
|
||||
* Indicates other errors.
|
||||
*/
|
||||
* Indicates other errors.
|
||||
*/
|
||||
GENERAL_ERROR = 2,
|
||||
/**
|
||||
* Indicates that authentication has been canceled.
|
||||
*/
|
||||
* Indicates that authentication has been canceled.
|
||||
*/
|
||||
CANCELED = 3,
|
||||
/**
|
||||
* Indicates that authentication has timed out.
|
||||
*/
|
||||
* Indicates that authentication has timed out.
|
||||
*/
|
||||
TIMEOUT = 4,
|
||||
/**
|
||||
* Indicates that this authentication type is not supported.
|
||||
*/
|
||||
* Indicates that this authentication type is not supported.
|
||||
*/
|
||||
TYPE_NOT_SUPPORT = 5,
|
||||
/**
|
||||
* Indicates that the authentication trust level is not supported.
|
||||
*/
|
||||
* Indicates that the authentication trust level is not supported.
|
||||
*/
|
||||
TRUST_LEVEL_NOT_SUPPORT = 6,
|
||||
/**
|
||||
* Indicates that the authentication task is busy. Wait for a few seconds and try again.
|
||||
*/
|
||||
* Indicates that the authentication task is busy. Wait for a few seconds and try again.
|
||||
*/
|
||||
BUSY = 7,
|
||||
/**
|
||||
* Indicates incorrect parameters.
|
||||
*/
|
||||
* Indicates incorrect parameters.
|
||||
*/
|
||||
INVALID_PARAMETERS = 8,
|
||||
/**
|
||||
* Indicates that the authenticator is locked.
|
||||
*/
|
||||
* Indicates that the authenticator is locked.
|
||||
*/
|
||||
LOCKED = 9,
|
||||
/**
|
||||
* Indicates that the user has not enrolled the authenticator.
|
||||
*/
|
||||
* Indicates that the user has not enrolled the authenticator.
|
||||
*/
|
||||
NOT_ENROLLED = 10,
|
||||
/**
|
||||
* Indicates that IPC communication error.
|
||||
*/
|
||||
* Indicates that IPC communication error.
|
||||
*/
|
||||
IPC_ERROR = 11,
|
||||
/**
|
||||
* Indicates that invalid contextId.
|
||||
*/
|
||||
* Indicates that invalid contextId.
|
||||
*/
|
||||
INVALID_CONTEXTID = 12,
|
||||
/**
|
||||
* Indicates that WRITE PARCEL ERROR.
|
||||
*/
|
||||
* Indicates that WRITE PARCEL ERROR.
|
||||
*/
|
||||
E_WRITE_PARCEL_ERROR = 13,
|
||||
/**
|
||||
* Indicates that READ PARCEL ERROR
|
||||
*/
|
||||
* Indicates that READ PARCEL ERROR
|
||||
*/
|
||||
E_READ_PARCEL_ERROR = 14,
|
||||
/**
|
||||
* Indicates that POWER SERVICE FAILED
|
||||
*/
|
||||
* Indicates that POWER SERVICE FAILED
|
||||
*/
|
||||
E_GET_POWER_SERVICE_FAILED = 15,
|
||||
/**
|
||||
* Indicates that executor schudle undone
|
||||
*/
|
||||
* Indicates that executor schudle undone
|
||||
*/
|
||||
E_RET_UNDONE = 16,
|
||||
/**
|
||||
* Indicates that executor schudle undone
|
||||
*/
|
||||
* Indicates that executor schudle undone
|
||||
*/
|
||||
E_RET_NOSERVER = 17,
|
||||
/**
|
||||
* Check permission failed.
|
||||
*/
|
||||
* Check permission failed.
|
||||
*/
|
||||
E_CHECK_PERMISSION_FAILED = 18,
|
||||
/**
|
||||
* ERRORCODE_MAX.
|
||||
*/
|
||||
* ERRORCODE_MAX.
|
||||
*/
|
||||
ERRORCODE_MAX = 19
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // USERAUTH_INFO_H
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#define USERAUTH_PROXY_H
|
||||
|
||||
#include <iremote_proxy.h>
|
||||
#include <nocopyable.h>
|
||||
|
||||
#include "iuser_auth.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -24,16 +26,17 @@ namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
class UserAuthProxy : public IRemoteProxy<IUserAuth> {
|
||||
public:
|
||||
explicit UserAuthProxy(const sptr<IRemoteObject> &impl);
|
||||
~UserAuthProxy() = default;
|
||||
DISALLOW_COPY_AND_MOVE(UserAuthProxy);
|
||||
explicit UserAuthProxy(const sptr<IRemoteObject> &object);
|
||||
~UserAuthProxy() override = default;
|
||||
|
||||
int32_t GetAvailableStatus(const AuthType authType, const AuthTurstLevel authTurstLevel) override;
|
||||
void GetProperty(const GetPropertyRequest request, sptr<IUserAuthCallback>& callback) override;
|
||||
void SetProperty(const SetPropertyRequest request, sptr<IUserAuthCallback>& callback) override;
|
||||
void GetProperty(const GetPropertyRequest request, sptr<IUserAuthCallback> &callback) override;
|
||||
void SetProperty(const SetPropertyRequest request, sptr<IUserAuthCallback> &callback) override;
|
||||
uint64_t Auth(const uint64_t challenge, const AuthType authType, const AuthTurstLevel authTurstLevel,
|
||||
sptr<IUserAuthCallback>& callback) override;
|
||||
sptr<IUserAuthCallback> &callback) override;
|
||||
uint64_t AuthUser(const int32_t userId, const uint64_t challenge, const AuthType authType,
|
||||
const AuthTurstLevel authTurstLevel, sptr<IUserAuthCallback>& callback) override;
|
||||
const AuthTurstLevel authTurstLevel, sptr<IUserAuthCallback> &callback) override;
|
||||
int32_t CancelAuth(const uint64_t contextId) override;
|
||||
int32_t GetVersion() override;
|
||||
|
||||
@@ -42,6 +45,6 @@ private:
|
||||
static inline BrokerDelegator<UserAuthProxy> delegator_;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // USERAUTH_PROXY_H
|
||||
@@ -15,23 +15,24 @@
|
||||
|
||||
#ifndef USERAUTH_THREADPOOL_H
|
||||
#define USERAUTH_THREADPOOL_H
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include "nocopyable.h"
|
||||
#include "thread_pool.h"
|
||||
|
||||
#define THREADPOOLNAME "userauthThreadPool"
|
||||
#define THREADPOOLMAXSTART 3
|
||||
#define THREADPOOLMAXTASK 6
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
static constexpr char THREADPOOLNAME[] = "userauthThreadPool";
|
||||
static constexpr uint64_t THREADPOOLMAXSTART = 3;
|
||||
static constexpr uint64_t THREADPOOLMAXTASK = 6;
|
||||
|
||||
class ContextThreadPool : ThreadPool {
|
||||
public:
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(ContextThreadPool);
|
||||
static ContextThreadPool &GetInstance();
|
||||
uint32_t Start(int threadsNum)
|
||||
{
|
||||
@@ -61,9 +62,9 @@ public:
|
||||
return ThreadPool::GetThreadsNum();
|
||||
}
|
||||
|
||||
bool AddTask(const uint64_t context, const ThreadPool::Task& f);
|
||||
bool AddTask(const uint64_t context, const ThreadPool::Task &f);
|
||||
|
||||
void TaskFunction(const uint64_t context, const ThreadPool::Task& f);
|
||||
void TaskFunction(const uint64_t context, const ThreadPool::Task &f);
|
||||
|
||||
private:
|
||||
class ContextTask {
|
||||
@@ -73,18 +74,18 @@ private:
|
||||
|
||||
ThreadPool::Task GetTask();
|
||||
|
||||
void AddTask(const ThreadPool::Task& f);
|
||||
void AddTask(const ThreadPool::Task &f);
|
||||
|
||||
private:
|
||||
std::vector<ThreadPool::Task> tasks;
|
||||
};
|
||||
explicit ContextThreadPool(const std::string &name);
|
||||
~ContextThreadPool();
|
||||
private:
|
||||
~ContextThreadPool() override;
|
||||
ThreadPool::Task CheckTask(const uint64_t context);
|
||||
std::map<uint64_t, ContextTask> ctMap_;
|
||||
std::mutex taskMutex_;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -16,12 +16,12 @@
|
||||
#ifndef USERAUTH_ADAPTER_H
|
||||
#define USERAUTH_ADAPTER_H
|
||||
|
||||
#include "userauth_info.h"
|
||||
#include "iuserauth_callback.h"
|
||||
#include "set_prop_callback.h"
|
||||
#include "auth_attributes.h"
|
||||
#include "co_auth.h"
|
||||
#include "context_thread_pool.h"
|
||||
#include "iuserauth_callback.h"
|
||||
#include "set_prop_callback.h"
|
||||
#include "userauth_info.h"
|
||||
#include "userauth_interface.h"
|
||||
|
||||
#include <mutex>
|
||||
@@ -36,47 +36,45 @@ public:
|
||||
|
||||
/* Get the executor authentication properties */
|
||||
void GetPropAuthInfo(int32_t userID, uint64_t callerUID, std::string pkgName, GetPropertyRequest requset,
|
||||
sptr<IUserAuthCallback>& callback);
|
||||
sptr<IUserAuthCallback> &callback);
|
||||
|
||||
/** This method is called to set the executor properties
|
||||
* after the callback of the coAuth is called to obtain the scheduling token
|
||||
* and the authentication result is successful.
|
||||
* */
|
||||
void CoauthSetPropAuthInfo(int32_t userID, int32_t resultCode, uint64_t callerUID, std::string pkgName,
|
||||
UserAuthToken authToken, SetPropertyRequest requset, sptr<IUserAuthCallback>& callback);
|
||||
UserAuthToken authToken, SetPropertyRequest requset, sptr<IUserAuthCallback> &callback);
|
||||
|
||||
/* Set the executor authentication properties for freez or unfreez */
|
||||
void SetPropAuthInfo(uint64_t callerUID, std::string pkgName, int32_t resultCode, UserAuthToken authToken,
|
||||
SetPropertyRequest requset, std::vector<uint64_t> templateIds,
|
||||
sptr<IUserAuthCallback>& callback);
|
||||
SetPropertyRequest requset, std::vector<uint64_t> templateIds, sptr<IUserAuthCallback> &callback);
|
||||
/* get the executor authentication properties for Coauth */
|
||||
void GetPropAuthInfoCoauth(int32_t userID, uint64_t callerUID, std::string pkgName, int32_t resultCode,
|
||||
UserAuthToken authToken, GetPropertyRequest requset, sptr<IUserAuthCallback>& callback);
|
||||
UserAuthToken authToken, GetPropertyRequest requset, sptr<IUserAuthCallback> &callback);
|
||||
int32_t GenerateSolution(AuthSolution param, std::vector<uint64_t> &sessionIds);
|
||||
int32_t RequestAuthResult(uint64_t contextId, std::vector<uint8_t> scheduleToken,
|
||||
UserAuthToken &authToken, std::vector<uint64_t> &sessionIds);
|
||||
int32_t RequestAuthResult(uint64_t contextId, std::vector<uint8_t> scheduleToken, UserAuthToken &authToken,
|
||||
std::vector<uint64_t> &sessionIds);
|
||||
int32_t CancelContext(uint64_t contextId, std::vector<uint64_t> &sessionIds);
|
||||
int32_t Cancel(uint64_t sessionId);
|
||||
/* get the executor authentication properties */
|
||||
int32_t GetExecutorProp(uint64_t callerUID, std::string pkgName, uint64_t templateId, GetPropertyRequest requset,
|
||||
ExecutorProperty &result);
|
||||
ExecutorProperty &result);
|
||||
/* Set the executor authentication properties */
|
||||
int32_t SetExecutorProp(uint64_t callerUID, std::string pkgName, SetPropertyRequest requset,
|
||||
sptr<IUserAuthCallback>& callback);
|
||||
sptr<IUserAuthCallback> &callback);
|
||||
int32_t GetVersion();
|
||||
int32_t coAuth(CoAuthInfo coAuthInfo, sptr<IUserAuthCallback>& callback);
|
||||
int32_t coAuth(CoAuthInfo coAuthInfo, sptr<IUserAuthCallback> &callback);
|
||||
|
||||
private:
|
||||
UserAuthAdapter() = default;
|
||||
~UserAuthAdapter() = default;
|
||||
int32_t GetEachExecutorProp(GetPropertyRequest &requset, ExecutorProperty &result, uint32_t &value,
|
||||
std::shared_ptr<OHOS::UserIAM::AuthResPool::AuthAttributes> pAuthAttributes);
|
||||
int32_t 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);
|
||||
int32_t 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);
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // USERAUTH_ADAPTER_H
|
||||
|
||||
@@ -18,17 +18,19 @@
|
||||
|
||||
#include <iremote_proxy.h>
|
||||
|
||||
#include "useridm_callback.h"
|
||||
#include "iuserauth_callback.h"
|
||||
#include "useridm_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
class UserAuthAsyncProxy : public IRemoteProxy<IUserAuthCallback> {
|
||||
public:
|
||||
explicit UserAuthAsyncProxy(const sptr<IRemoteObject> &object)
|
||||
: IRemoteProxy<IUserAuthCallback>(object) {}
|
||||
~UserAuthAsyncProxy() = default;
|
||||
DISALLOW_COPY_AND_MOVE(UserAuthAsyncProxy);
|
||||
explicit UserAuthAsyncProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<IUserAuthCallback>(object)
|
||||
{
|
||||
}
|
||||
~UserAuthAsyncProxy() override = default;
|
||||
|
||||
void onAcquireInfo(const int32_t module, const uint32_t acquireInfo, const int32_t extraInfo) override;
|
||||
void onResult(const int32_t result, const AuthResult extraInfo) override;
|
||||
@@ -37,11 +39,9 @@ public:
|
||||
|
||||
private:
|
||||
bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<UserAuthAsyncProxy> delegator_;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // USERAUTH_ASYNC_PROXY_H
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#ifndef USERAUTH_CONTROLLER_H
|
||||
#define USERAUTH_CONTROLLER_H
|
||||
|
||||
#include "userauth_info.h"
|
||||
#include "userauth_adapter.h"
|
||||
#include "iuserauth_callback.h"
|
||||
#include "userauth_adapter.h"
|
||||
#include "userauth_info.h"
|
||||
#include "userauth_interface.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -28,20 +28,20 @@ class UserAuthController {
|
||||
public:
|
||||
int32_t GetAuthTrustLevel(int32_t userId, uint32_t authType, uint32_t &authTrustLevel);
|
||||
void GetPropAuthInfo(int32_t userID, std::string pkgName, uint64_t callerUID, GetPropertyRequest getPropertyRequest,
|
||||
sptr<IUserAuthCallback>& callback);
|
||||
sptr<IUserAuthCallback> &callback);
|
||||
int32_t SetExecutorProp(uint64_t callerUID, std::string pkgName, SetPropertyRequest setPropertyrequest,
|
||||
sptr<IUserAuthCallback>& callback);
|
||||
sptr<IUserAuthCallback> &callback);
|
||||
int32_t AddContextID(uint64_t contextID);
|
||||
int32_t IsContextIDExist(uint64_t contextID);
|
||||
int32_t GenerateContextID(uint64_t &contextID);
|
||||
int32_t DeleteContextID(uint64_t contextID);
|
||||
int32_t GenerateSolution(AuthSolution param, std::vector<uint64_t> &sessionIds);
|
||||
int32_t coAuth(CoAuthInfo coAuthInfo, sptr<IUserAuthCallback>& callback);
|
||||
int32_t coAuth(CoAuthInfo coAuthInfo, sptr<IUserAuthCallback> &callback);
|
||||
int32_t CancelContext(uint64_t contextId, std::vector<uint64_t> &sessionIds);
|
||||
int32_t Cancel(uint64_t sessionId);
|
||||
int32_t GetVersion();
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // USERAUTH_CONTROLLER_H
|
||||
|
||||
@@ -18,16 +18,20 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
#include "nocopyable.h"
|
||||
|
||||
#include "iuserauth_callback.h"
|
||||
#include "userauth_adapter.h"
|
||||
#include "singleton.h"
|
||||
|
||||
#define OPENSSLSUCCESS 1
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
|
||||
constexpr int32_t OPENSSLSUCCESS = 1;
|
||||
class UserAuthDataMgr {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(UserAuthDataMgr);
|
||||
static UserAuthDataMgr &GetInstance();
|
||||
int32_t AddContextID(uint64_t contextID);
|
||||
int32_t IsContextIDExist(uint64_t contextID);
|
||||
@@ -41,6 +45,6 @@ private:
|
||||
std::set<uint64_t> contextIDs_;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // USERAUTH_DATAMGR_H
|
||||
|
||||
@@ -17,53 +17,54 @@
|
||||
#define USERAUTH_SERVICE_H
|
||||
|
||||
#include <iremote_stub.h>
|
||||
#include <nocopyable.h>
|
||||
#include <string>
|
||||
#include <system_ability.h>
|
||||
#include <system_ability_definition.h>
|
||||
#include <string>
|
||||
|
||||
#include "userauth_stub.h"
|
||||
#include "userauth_controller.h"
|
||||
#include "iuser_auth.h"
|
||||
#include "userauth_controller.h"
|
||||
#include "userauth_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
class UserAuthService : public UserAuthStub, public SystemAbility {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(UserAuthService);
|
||||
DECLARE_SYSTEM_ABILITY(UserAuthService);
|
||||
explicit UserAuthService(int32_t systemAbilityId, bool runOnCreate = false);
|
||||
~UserAuthService() override;
|
||||
void OnStart() override;
|
||||
void OnStop() override;
|
||||
int32_t GetAvailableStatus(const AuthType authType, const AuthTurstLevel authTurstLevel) override;
|
||||
void GetProperty(const GetPropertyRequest request, sptr<IUserAuthCallback>& callback) override;
|
||||
void SetProperty(const SetPropertyRequest request, sptr<IUserAuthCallback>& callback) override;
|
||||
void GetProperty(const GetPropertyRequest request, sptr<IUserAuthCallback> &callback) override;
|
||||
void SetProperty(const SetPropertyRequest request, sptr<IUserAuthCallback> &callback) override;
|
||||
uint64_t Auth(const uint64_t challenge, const AuthType authType, const AuthTurstLevel authTurstLevel,
|
||||
sptr<IUserAuthCallback>& callback) override;
|
||||
sptr<IUserAuthCallback> &callback) override;
|
||||
uint64_t AuthUser(const int32_t userId, const uint64_t challenge, const AuthType authType,
|
||||
const AuthTurstLevel authTurstLevel, sptr<IUserAuthCallback>& callback) override;
|
||||
const AuthTurstLevel authTurstLevel, sptr<IUserAuthCallback> &callback) override;
|
||||
int32_t CancelAuth(const uint64_t contextId) override;
|
||||
int32_t GetVersion() override;
|
||||
|
||||
private:
|
||||
int32_t GetCallingUserID(int32_t &userID);
|
||||
bool CheckPermission(const std::string &permission);
|
||||
int32_t GetControllerData(sptr<IUserAuthCallback>& callback, AuthResult &extraInfo,
|
||||
const AuthTurstLevel authTurstLevel, uint64_t &callerID,
|
||||
std::string &callerName, uint64_t &contextID);
|
||||
int32_t GetControllerData(sptr<IUserAuthCallback> &callback, AuthResult &extraInfo,
|
||||
const AuthTurstLevel authTurstLevel, uint64_t &callerID, std::string &callerName, uint64_t &contextID);
|
||||
class UserAuthServiceCallbackDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
UserAuthServiceCallbackDeathRecipient(sptr<IUserAuthCallback>& impl);
|
||||
~UserAuthServiceCallbackDeathRecipient() = default;
|
||||
void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
|
||||
explicit UserAuthServiceCallbackDeathRecipient(sptr<IUserAuthCallback> &impl);
|
||||
~UserAuthServiceCallbackDeathRecipient() override = default;
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &remote) override;
|
||||
|
||||
private:
|
||||
sptr<IUserAuthCallback> callback_ { nullptr };
|
||||
sptr<IUserAuthCallback> callback_ {nullptr};
|
||||
DISALLOW_COPY_AND_MOVE(UserAuthServiceCallbackDeathRecipient);
|
||||
};
|
||||
UserAuthController userauthController_;
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // USERAUTH_SERVICE_H
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#ifndef USERAUTH_STUB_H
|
||||
#define USERAUTH_STUB_H
|
||||
|
||||
#include <iremote_stub.h>
|
||||
#include "iuser_auth.h"
|
||||
#include <iremote_stub.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
@@ -27,15 +27,15 @@ public:
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
|
||||
private:
|
||||
int32_t GetAvailableStatusStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t GetPropertyStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t SetPropertyStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t AuthStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t AuthUserStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t CancelAuthStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t GetVersionStub(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t GetAvailableStatusStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t GetPropertyStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t SetPropertyStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t AuthStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t AuthUserStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t CancelAuthStub(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t GetVersionStub(MessageParcel &data, MessageParcel &reply);
|
||||
};
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // USERAUTH_STUB_H
|
||||
@@ -14,15 +14,15 @@
|
||||
*/
|
||||
#include <cinttypes>
|
||||
|
||||
#include "userauth_hilog_wrapper.h"
|
||||
#include "userauth_info.h"
|
||||
#include "auth_attributes.h"
|
||||
#include "co_auth.h"
|
||||
#include "useridm_client.h"
|
||||
#include "useridm_info.h"
|
||||
#include "userauth_adapter.h"
|
||||
#include "userauth_datamgr.h"
|
||||
#include "userauth_excallback_impl.h"
|
||||
#include "userauth_adapter.h"
|
||||
#include "userauth_hilog_wrapper.h"
|
||||
#include "userauth_info.h"
|
||||
#include "useridm_client.h"
|
||||
#include "useridm_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
@@ -46,14 +46,14 @@ int32_t UserAuthAdapter::GetAuthTrustLevel(int32_t userId, uint32_t authType, ui
|
||||
}
|
||||
|
||||
void UserAuthAdapter::GetPropAuthInfo(int32_t userID, uint64_t callerUID, std::string pkgName,
|
||||
GetPropertyRequest requset, sptr<IUserAuthCallback>& callback)
|
||||
GetPropertyRequest requset, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuth GetPropAuthInfo is start!");
|
||||
using namespace UserIDM;
|
||||
std::shared_ptr<GetInfoCallback> getInfoCallback =
|
||||
std::make_shared<UserAuthCallbackImplIDMGetPorp>(callback, requset, callerUID, pkgName);
|
||||
int32_t ret = UserIDMClient::GetInstance().GetAuthInfo(userID,
|
||||
static_cast<UserIDM::AuthType>(requset.authType), getInfoCallback);
|
||||
int32_t ret = UserIDMClient::GetInstance().GetAuthInfo(userID, static_cast<UserIDM::AuthType>(requset.authType),
|
||||
getInfoCallback);
|
||||
if (ret != SUCCESS) {
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth GetPropAuthInfo ERROR!");
|
||||
}
|
||||
@@ -61,9 +61,8 @@ void UserAuthAdapter::GetPropAuthInfo(int32_t userID, uint64_t callerUID, std::s
|
||||
}
|
||||
|
||||
void UserAuthAdapter::SetPropAuthInfo(uint64_t callerUID, std::string pkgName, int32_t resultCode,
|
||||
UserAuthToken authToken, SetPropertyRequest requset,
|
||||
std::vector<uint64_t> templateIds,
|
||||
sptr<IUserAuthCallback>& callback)
|
||||
UserAuthToken authToken, SetPropertyRequest requset, std::vector<uint64_t> templateIds,
|
||||
sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuth SetPropAuthInfo is start!");
|
||||
using namespace AuthResPool;
|
||||
@@ -84,9 +83,8 @@ 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);
|
||||
@@ -96,9 +94,9 @@ int32_t UserAuthAdapter::SetProPropAuthInfo(OHOS::UserIAM::AuthResPool::AuthAttr
|
||||
setPropCallback->OnResult(ret, extraInfo);
|
||||
return ret;
|
||||
}
|
||||
value = requset.key == SetPropertyType::FREEZE_TEMPLATE ?
|
||||
static_cast<uint32_t>(AuthPropertyMode::PROPERMODE_FREEZE)
|
||||
: static_cast<uint32_t>(AuthPropertyMode::PROPERMODE_UNFREEZE);
|
||||
value = requset.key == SetPropertyType::FREEZE_TEMPLATE
|
||||
? static_cast<uint32_t>(AuthPropertyMode::PROPERMODE_FREEZE)
|
||||
: static_cast<uint32_t>(AuthPropertyMode::PROPERMODE_UNFREEZE);
|
||||
ret = authAttributes.SetUint32Value(AUTH_PROPERTY_MODE, value);
|
||||
if (ret != SUCCESS) {
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth SetUint32Value AUTH_PROPERTY_MODE ERROR!");
|
||||
@@ -134,16 +132,14 @@ int32_t UserAuthAdapter::SetProPropAuthInfo(OHOS::UserIAM::AuthResPool::AuthAttr
|
||||
return ret;
|
||||
}
|
||||
void UserAuthAdapter::GetPropAuthInfoCoauth(int32_t userID, uint64_t callerUID, std::string pkgName, int32_t resultCode,
|
||||
UserAuthToken authToken, GetPropertyRequest requset,
|
||||
sptr<IUserAuthCallback>& callback)
|
||||
UserAuthToken authToken, GetPropertyRequest requset, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuth GetPropAuthInfoCoauth is start!");
|
||||
using namespace UserIDM;
|
||||
std::shared_ptr<GetInfoCallback> getInfoCallback =
|
||||
std::make_shared<UserAuthCallbackImplIDMGetPorpCoauth>(callback, callerUID, pkgName, resultCode,
|
||||
authToken, requset);
|
||||
int32_t ret = UserIDMClient::GetInstance().GetAuthInfo(userID,
|
||||
static_cast<UserIDM::AuthType>(requset.authType), getInfoCallback);
|
||||
std::shared_ptr<GetInfoCallback> getInfoCallback = std::make_shared<UserAuthCallbackImplIDMGetPorpCoauth>(callback,
|
||||
callerUID, pkgName, resultCode, authToken, requset);
|
||||
int32_t ret = UserIDMClient::GetInstance().GetAuthInfo(userID, static_cast<UserIDM::AuthType>(requset.authType),
|
||||
getInfoCallback);
|
||||
if (ret != SUCCESS) {
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth GetPropAuthInfoCoauth ERROR!");
|
||||
}
|
||||
@@ -151,16 +147,14 @@ void UserAuthAdapter::GetPropAuthInfoCoauth(int32_t userID, uint64_t callerUID,
|
||||
}
|
||||
|
||||
void UserAuthAdapter::CoauthSetPropAuthInfo(int32_t userID, int32_t resultCode, uint64_t callerUID, std::string pkgName,
|
||||
UserAuthToken authToken, SetPropertyRequest requset,
|
||||
sptr<IUserAuthCallback>& callback)
|
||||
UserAuthToken authToken, SetPropertyRequest requset, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuth CoauthSetPropAuthInfo is start!");
|
||||
using namespace UserIDM;
|
||||
std::shared_ptr<GetInfoCallback> setPropCallback =
|
||||
std::make_shared<UserAuthCallbackImplIDMCothGetPorpFreez>(callback, callerUID, pkgName, resultCode,
|
||||
authToken, requset);
|
||||
int32_t ret = UserIDMClient::GetInstance().GetAuthInfo(userID,
|
||||
static_cast<UserIDM::AuthType>(requset.authType), setPropCallback);
|
||||
std::shared_ptr<GetInfoCallback> setPropCallback = std::make_shared<UserAuthCallbackImplIDMCothGetPorpFreez>(
|
||||
callback, callerUID, pkgName, resultCode, authToken, requset);
|
||||
int32_t ret = UserIDMClient::GetInstance().GetAuthInfo(userID, static_cast<UserIDM::AuthType>(requset.authType),
|
||||
setPropCallback);
|
||||
if (ret != SUCCESS) {
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth CoauthSetPropAuthInfo ERROR!");
|
||||
}
|
||||
@@ -178,7 +172,7 @@ int32_t UserAuthAdapter::GenerateSolution(AuthSolution param, std::vector<uint64
|
||||
}
|
||||
|
||||
int32_t UserAuthAdapter::RequestAuthResult(uint64_t contextId, std::vector<uint8_t> scheduleToken,
|
||||
UserAuthToken &authToken, std::vector<uint64_t> &sessionIds)
|
||||
UserAuthToken &authToken, std::vector<uint64_t> &sessionIds)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuth RequestAuthResult is start!");
|
||||
int32_t ret = OHOS::UserIAM::UserAuth::RequestAuthResult(contextId, scheduleToken, authToken, sessionIds);
|
||||
@@ -218,13 +212,13 @@ int32_t UserAuthAdapter::GetVersion()
|
||||
}
|
||||
|
||||
int32_t UserAuthAdapter::GetExecutorProp(uint64_t callerUID, std::string pkgName, uint64_t templateId,
|
||||
GetPropertyRequest requset, ExecutorProperty &result)
|
||||
GetPropertyRequest requset, ExecutorProperty &result)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuth GetExecutorProp is start!");
|
||||
using namespace AuthResPool;
|
||||
uint32_t value;
|
||||
|
||||
auto pAuthAttributes (std::make_shared<AuthAttributes>());
|
||||
auto pAuthAttributes(std::make_shared<AuthAttributes>());
|
||||
AuthAttributes cAuthAttributes;
|
||||
int32_t ret = cAuthAttributes.SetUint32Value(AUTH_TYPE, requset.authType);
|
||||
if (ret != SUCCESS) {
|
||||
@@ -319,7 +313,7 @@ int32_t UserAuthAdapter::GetEachExecutorProp(GetPropertyRequest &requset, Execut
|
||||
}
|
||||
|
||||
int32_t UserAuthAdapter::SetExecutorProp(uint64_t callerUID, std::string pkgName, SetPropertyRequest requset,
|
||||
sptr<IUserAuthCallback>& callback)
|
||||
sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuth SetExecutorProp is start!");
|
||||
using namespace AuthResPool;
|
||||
@@ -327,9 +321,9 @@ int32_t UserAuthAdapter::SetExecutorProp(uint64_t callerUID, std::string pkgName
|
||||
|
||||
std::shared_ptr<CoAuth::SetPropCallback> setPropCallback = std::make_shared<UserAuthCallbackImplSetProp>(callback);
|
||||
AuthAttributes pAuthAttributes;
|
||||
value = requset.key == SetPropertyType::INIT_ALGORITHM ?
|
||||
static_cast<uint32_t>(AuthPropertyMode::PROPERMODE_INIT_ALGORITHM)
|
||||
: static_cast<uint32_t>(AuthPropertyMode::PROPERMODE_RELEASE_ALGORITHM);
|
||||
value = requset.key == SetPropertyType::INIT_ALGORITHM
|
||||
? static_cast<uint32_t>(AuthPropertyMode::PROPERMODE_INIT_ALGORITHM)
|
||||
: static_cast<uint32_t>(AuthPropertyMode::PROPERMODE_RELEASE_ALGORITHM);
|
||||
int32_t ret = pAuthAttributes.SetUint32Value(AUTH_PROPERTY_MODE, value);
|
||||
if (ret != SUCCESS) {
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuth SetUint32Value SET_AUTH_PROPERTY_MODE ERROR!");
|
||||
@@ -363,7 +357,7 @@ int32_t UserAuthAdapter::SetExecutorProp(uint64_t callerUID, std::string pkgName
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UserAuthAdapter::coAuth(CoAuthInfo coAuthInfo, sptr<IUserAuthCallback>& callback)
|
||||
int32_t UserAuthAdapter::coAuth(CoAuthInfo coAuthInfo, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuth coAuth is start!");
|
||||
|
||||
@@ -393,5 +387,5 @@ int32_t UserAuthAdapter::coAuth(CoAuthInfo coAuthInfo, sptr<IUserAuthCallback>&
|
||||
return SUCCESS;
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -49,7 +49,6 @@ void UserAuthAsyncProxy::onAcquireInfo(const int32_t module, const uint32_t acqu
|
||||
int32_t result = reply.ReadInt32();
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "userauth result = %{public}d", result);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAuthAsyncProxy::onResult(const int32_t result, const AuthResult extraInfo)
|
||||
@@ -82,7 +81,6 @@ void UserAuthAsyncProxy::onResult(const int32_t result, const AuthResult extraIn
|
||||
int32_t result = reply.ReadInt32();
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "userauth result = %{public}d", result);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAuthAsyncProxy::onExecutorPropertyInfo(const ExecutorProperty result)
|
||||
@@ -115,7 +113,6 @@ void UserAuthAsyncProxy::onExecutorPropertyInfo(const ExecutorProperty result)
|
||||
int32_t result = reply.ReadInt32();
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "userauth result = %{public}d", result);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAuthAsyncProxy::onSetExecutorProperty(const int32_t result)
|
||||
@@ -138,8 +135,6 @@ void UserAuthAsyncProxy::onSetExecutorProperty(const int32_t result)
|
||||
int32_t result = reply.ReadInt32();
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "userauth result = %{public}d", result);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool UserAuthAsyncProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply)
|
||||
|
||||
@@ -24,14 +24,12 @@ int32_t UserAuthController::GetAuthTrustLevel(int32_t userId, uint32_t authType,
|
||||
return UserAuthAdapter::GetInstance().GetAuthTrustLevel(userId, authType, authTrustLevel);
|
||||
}
|
||||
int32_t UserAuthController::SetExecutorProp(uint64_t callerUID, std::string pkgName,
|
||||
SetPropertyRequest setPropertyrequest,
|
||||
sptr<IUserAuthCallback>& callback)
|
||||
SetPropertyRequest setPropertyrequest, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
return UserAuthAdapter::GetInstance().SetExecutorProp(callerUID, pkgName, setPropertyrequest, callback);
|
||||
}
|
||||
void UserAuthController::GetPropAuthInfo(int32_t userID, std::string pkgName, uint64_t callerUID,
|
||||
GetPropertyRequest getPropertyRequest,
|
||||
sptr<IUserAuthCallback>& callback)
|
||||
GetPropertyRequest getPropertyRequest, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
UserAuthAdapter::GetInstance().GetPropAuthInfo(userID, callerUID, pkgName, getPropertyRequest, callback);
|
||||
}
|
||||
@@ -39,7 +37,7 @@ int32_t UserAuthController::GenerateSolution(AuthSolution param, std::vector<uin
|
||||
{
|
||||
return UserAuthAdapter::GetInstance().GenerateSolution(param, sessionIds);
|
||||
}
|
||||
int32_t UserAuthController::coAuth(CoAuthInfo coAuthInfo, sptr<IUserAuthCallback>& callback)
|
||||
int32_t UserAuthController::coAuth(CoAuthInfo coAuthInfo, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
return UserAuthAdapter::GetInstance().coAuth(coAuthInfo, callback);
|
||||
}
|
||||
@@ -72,5 +70,5 @@ int32_t UserAuthController::GetVersion()
|
||||
return UserAuthAdapter::GetInstance().GetVersion();
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
|
||||
#include <file_ex.h>
|
||||
#include <string_ex.h>
|
||||
#include "userauth_hilog_wrapper.h"
|
||||
#include "useriam_common.h"
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "userauth_hilog_wrapper.h"
|
||||
#include "userauth_service.h"
|
||||
#include "useriam_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
@@ -35,9 +36,7 @@ UserAuthService::UserAuthService(int32_t systemAbilityId, bool runOnCreate)
|
||||
{
|
||||
}
|
||||
|
||||
UserAuthService::~UserAuthService()
|
||||
{
|
||||
}
|
||||
UserAuthService::~UserAuthService() = default;
|
||||
|
||||
void UserAuthService::OnStart()
|
||||
{
|
||||
@@ -112,7 +111,7 @@ int32_t UserAuthService::GetAvailableStatus(const AuthType authType, const AuthT
|
||||
return ret;
|
||||
}
|
||||
|
||||
void UserAuthService::GetProperty(const GetPropertyRequest request, sptr<IUserAuthCallback>& callback)
|
||||
void UserAuthService::GetProperty(const GetPropertyRequest request, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthService GetProperty is start");
|
||||
uint64_t callerID = 0;
|
||||
@@ -147,12 +146,12 @@ void UserAuthService::GetProperty(const GetPropertyRequest request, sptr<IUserAu
|
||||
userauthController_.GetPropAuthInfo(userID, callerName, callerID, request, callback);
|
||||
}
|
||||
|
||||
void UserAuthService::SetProperty(const SetPropertyRequest request, sptr<IUserAuthCallback>& callback)
|
||||
void UserAuthService::SetProperty(const SetPropertyRequest request, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthService SetProperty is start");
|
||||
int ret = GENERAL_ERROR;
|
||||
uint64_t callerID = 0;
|
||||
std::string callerName = "";
|
||||
std::string callerName;
|
||||
if (callback == nullptr) {
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuthService SetProperty IUserAuthCallback is NULL!");
|
||||
return;
|
||||
@@ -196,20 +195,19 @@ int32_t UserAuthService::GetCallingUserID(int32_t &userID)
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "Get hap token info failed.");
|
||||
return TYPE_NOT_SUPPORT;
|
||||
}
|
||||
userID = (int32_t)hapTokenInfo.userID;
|
||||
userID = static_cast<int32_t>(hapTokenInfo.userID);
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "GetCallingUserID is %{public}d", userID);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
uint64_t UserAuthService::Auth(const uint64_t challenge, const AuthType authType,
|
||||
const AuthTurstLevel authTurstLevel,
|
||||
sptr<IUserAuthCallback>& callback)
|
||||
uint64_t UserAuthService::Auth(const uint64_t challenge, const AuthType authType, const AuthTurstLevel authTurstLevel,
|
||||
sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthService Auth is start");
|
||||
const uint64_t invalidContextID = 0;
|
||||
int32_t userID = 0;
|
||||
uint64_t callerID = 0;
|
||||
std::string callerName = "";
|
||||
std::string callerName;
|
||||
uint64_t contextID = 0;
|
||||
AuthSolution authSolutionParam;
|
||||
CoAuthInfo coAuthInfo;
|
||||
@@ -260,14 +258,13 @@ uint64_t UserAuthService::Auth(const uint64_t challenge, const AuthType authType
|
||||
return contextID;
|
||||
}
|
||||
|
||||
uint64_t UserAuthService::AuthUser(const int32_t userId, const uint64_t challenge,
|
||||
const AuthType authType, const AuthTurstLevel authTurstLevel,
|
||||
sptr<IUserAuthCallback>& callback)
|
||||
uint64_t UserAuthService::AuthUser(const int32_t userId, const uint64_t challenge, const AuthType authType,
|
||||
const AuthTurstLevel authTurstLevel, sptr<IUserAuthCallback> &callback)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthService AuthUser is start");
|
||||
const uint64_t invalidContextID = 0;
|
||||
uint64_t callerID = 0;
|
||||
std::string callerName = "";
|
||||
std::string callerName;
|
||||
uint64_t contextID = 0;
|
||||
AuthSolution authSolutionParam;
|
||||
CoAuthInfo coAuthInfo;
|
||||
@@ -314,9 +311,8 @@ uint64_t UserAuthService::AuthUser(const int32_t userId, const uint64_t challeng
|
||||
return contextID;
|
||||
}
|
||||
|
||||
int32_t UserAuthService::GetControllerData(sptr<IUserAuthCallback>& callback, AuthResult &extraInfo,
|
||||
const AuthTurstLevel authTurstLevel, uint64_t &callerID,
|
||||
std::string &callerName, uint64_t &contextID)
|
||||
int32_t UserAuthService::GetControllerData(sptr<IUserAuthCallback> &callback, AuthResult &extraInfo,
|
||||
const AuthTurstLevel authTurstLevel, uint64_t &callerID, std::string &callerName, uint64_t &contextID)
|
||||
{
|
||||
int ret = SUCCESS;
|
||||
int result = SUCCESS;
|
||||
@@ -356,7 +352,7 @@ int32_t UserAuthService::CancelAuth(const uint64_t contextId)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthService CancelAuth is start");
|
||||
int result = INVALID_CONTEXTID;
|
||||
std::vector<uint64_t> sessionIds;
|
||||
std::vector<uint64_t> sessionIds;
|
||||
if (!CheckPermission(ACCESS_USER_AUTH_INTERNAL_PERMISSION) && !CheckPermission(ACCESS_BIOMETRIC_PERMISSION)) {
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "Permission check failed");
|
||||
return E_CHECK_PERMISSION_FAILED;
|
||||
@@ -391,7 +387,7 @@ int32_t UserAuthService::GetVersion()
|
||||
return userauthController_.GetVersion();
|
||||
}
|
||||
UserAuthService::UserAuthServiceCallbackDeathRecipient::UserAuthServiceCallbackDeathRecipient(
|
||||
sptr<IUserAuthCallback>& impl)
|
||||
sptr<IUserAuthCallback> &impl)
|
||||
{
|
||||
if (impl != nullptr) {
|
||||
callback_ = impl;
|
||||
@@ -399,11 +395,10 @@ UserAuthService::UserAuthServiceCallbackDeathRecipient::UserAuthServiceCallbackD
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuthServiceCallbackDeathRecipient is error");
|
||||
}
|
||||
}
|
||||
void UserAuthService::UserAuthServiceCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
|
||||
void UserAuthService::UserAuthServiceCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
if (remote == nullptr) {
|
||||
USERAUTH_HILOGE(MODULE_SERVICE,
|
||||
"UserAuthServiceCallbackDeathRecipient OnRemoteDied failed, remote is nullptr");
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuthServiceCallbackDeathRecipient OnRemoteDied failed, remote is nullptr");
|
||||
return;
|
||||
}
|
||||
callback_ = nullptr;
|
||||
@@ -411,5 +406,5 @@ void UserAuthService::UserAuthServiceCallbackDeathRecipient::OnRemoteDied(const
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "UserAuthServiceCallbackDeathRecipient::Recv death notice.");
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -12,23 +12,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <message_parcel.h>
|
||||
#include "userauth_hilog_wrapper.h"
|
||||
#include "userauth_stub.h"
|
||||
#include "userauth_hilog_wrapper.h"
|
||||
#include <message_parcel.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
int32_t UserAuthStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
int32_t UserAuthStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub::OnRemoteRequest, cmd = %d, flags= %d",
|
||||
code, option.GetFlags());
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub::OnRemoteRequest, cmd = %d, flags= %d", code, option.GetFlags());
|
||||
std::u16string descripter = UserAuthStub::GetDescriptor();
|
||||
std::u16string remoteDescripter = data.ReadInterfaceToken();
|
||||
if (descripter != remoteDescripter) {
|
||||
USERAUTH_HILOGD(MODULE_SERVICE,
|
||||
"DisplayMgrStub::OnRemoteRequest failed, descriptor is not matched!");
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "DisplayMgrStub::OnRemoteRequest failed, descriptor is not matched!");
|
||||
return E_GET_POWER_SERVICE_FAILED;
|
||||
}
|
||||
|
||||
@@ -52,7 +49,7 @@ int32_t UserAuthStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
}
|
||||
}
|
||||
|
||||
int32_t UserAuthStub::GetAvailableStatusStub(MessageParcel& data, MessageParcel& reply)
|
||||
int32_t UserAuthStub::GetAvailableStatusStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub GetAvailableStatusStub is start");
|
||||
uint32_t authType;
|
||||
@@ -77,7 +74,7 @@ int32_t UserAuthStub::GetAvailableStatusStub(MessageParcel& data, MessageParcel&
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t UserAuthStub::GetPropertyStub(MessageParcel& data, MessageParcel& reply)
|
||||
int32_t UserAuthStub::GetPropertyStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub GetPropertyStub is start");
|
||||
GetPropertyRequest getPropertyRequest;
|
||||
@@ -110,7 +107,7 @@ int32_t UserAuthStub::GetPropertyStub(MessageParcel& data, MessageParcel& reply)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t UserAuthStub::SetPropertyStub(MessageParcel& data, MessageParcel& reply)
|
||||
int32_t UserAuthStub::SetPropertyStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub SetPropertyStub is start");
|
||||
SetPropertyRequest setPropertyRequest;
|
||||
@@ -131,7 +128,7 @@ int32_t UserAuthStub::SetPropertyStub(MessageParcel& data, MessageParcel& reply)
|
||||
return E_READ_PARCEL_ERROR;
|
||||
}
|
||||
|
||||
setPropertyRequest.authType = static_cast<AuthType>(authType);
|
||||
setPropertyRequest.authType = static_cast<AuthType>(authType);
|
||||
setPropertyRequest.key = static_cast<SetPropertyType>(key);
|
||||
setPropertyRequest.setInfo.assign(setInfo.begin(), setInfo.end());
|
||||
|
||||
@@ -149,7 +146,7 @@ int32_t UserAuthStub::SetPropertyStub(MessageParcel& data, MessageParcel& reply)
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
int32_t UserAuthStub::AuthStub(MessageParcel& data, MessageParcel& reply)
|
||||
int32_t UserAuthStub::AuthStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub AuthStub is start");
|
||||
uint64_t challenge;
|
||||
@@ -188,7 +185,7 @@ int32_t UserAuthStub::AuthStub(MessageParcel& data, MessageParcel& reply)
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
int32_t UserAuthStub::AuthUserStub(MessageParcel& data, MessageParcel& reply)
|
||||
int32_t UserAuthStub::AuthUserStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub AuthUserStub is start");
|
||||
int32_t userID;
|
||||
@@ -224,8 +221,8 @@ int32_t UserAuthStub::AuthUserStub(MessageParcel& data, MessageParcel& reply)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
ret = AuthUser(userID, challenge, static_cast<AuthType>(authType),
|
||||
static_cast<AuthTurstLevel>(authTurstLevel), callback);
|
||||
ret = AuthUser(userID, challenge, static_cast<AuthType>(authType), static_cast<AuthTurstLevel>(authTurstLevel),
|
||||
callback);
|
||||
if (!reply.WriteUint64(ret)) {
|
||||
USERAUTH_HILOGE(MODULE_SERVICE, "Failed to write AuthUser return value");
|
||||
return E_WRITE_PARCEL_ERROR;
|
||||
@@ -233,7 +230,7 @@ int32_t UserAuthStub::AuthUserStub(MessageParcel& data, MessageParcel& reply)
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
int32_t UserAuthStub::GetVersionStub(MessageParcel& data, MessageParcel& reply)
|
||||
int32_t UserAuthStub::GetVersionStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub GetVersionStub is start");
|
||||
|
||||
@@ -245,7 +242,7 @@ int32_t UserAuthStub::GetVersionStub(MessageParcel& data, MessageParcel& reply)
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
int32_t UserAuthStub::CancelAuthStub(MessageParcel& data, MessageParcel& reply)
|
||||
int32_t UserAuthStub::CancelAuthStub(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub CancelAuthStub is start");
|
||||
uint64_t contextID;
|
||||
@@ -265,5 +262,5 @@ int32_t UserAuthStub::CancelAuthStub(MessageParcel& data, MessageParcel& reply)
|
||||
return SUCCESS;
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIam
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user