• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2024-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "user_auth_ffi.h"
17 
18 using namespace OHOS::UserIam::UserAuth;
19 
OnAcquireInfo(const int32_t module,const uint32_t acquireInfo,const Attributes & extraInfo)20 void CjUserAuthCallback::OnAcquireInfo(const int32_t module, const uint32_t acquireInfo, const Attributes &extraInfo)
21 {
22     (void) module;
23     (void) acquireInfo;
24     (void) extraInfo;
25 }
26 
OnResult(const int32_t result,const Attributes & extraInfo)27 void CjUserAuthCallback::OnResult(const int32_t result, const Attributes &extraInfo)
28 {
29     if (this->onResult_ == nullptr) {
30         return;
31     }
32 
33     std::vector<uint8_t> token;
34     extraInfo.GetUint8ArrayValue(Attributes::ATTR_SIGNATURE, token);
35     int32_t authType{0};
36     extraInfo.GetInt32Value(Attributes::ATTR_AUTH_TYPE, authType);
37 
38     CjUserAuthResult ret = {
39         .result = result,
40         .token = token.data(),
41         .tokenLen = static_cast<int64_t>(token.size()),
42         .authType = static_cast<uint32_t>(authType),
43     };
44 
45     extraInfo.GetUint64Value(Attributes::ATTR_CREDENTIAL_DIGEST, ret.credentialDigest);
46     extraInfo.GetUint16Value(Attributes::ATTR_CREDENTIAL_COUNT, ret.credentialCount);
47 
48     this->onResult_(ret);
49 }
50