1 /* 2 * Copyright (c) 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 #include "socket_factory.h" 16 17 #include "iam_check.h" 18 #include "iam_logger.h" 19 #include "iam_ptr.h" 20 21 #include "soft_bus_client_socket.h" 22 #include "soft_bus_server_socket.h" 23 24 #define LOG_TAG "USER_AUTH_SA" 25 26 namespace OHOS { 27 namespace UserIam { 28 namespace UserAuth { CreateClientSocket(const int32_t socketId,const std::string & connectionName,const std::string & networkId)29std::shared_ptr<BaseSocket> SocketFactory::CreateClientSocket(const int32_t socketId, const std::string &connectionName, 30 const std::string &networkId) 31 { 32 IAM_LOGI("start."); 33 auto clientSocket = Common::MakeShared<ClientSocket>(socketId); 34 if (clientSocket == nullptr) { 35 return nullptr; 36 } 37 38 clientSocket->SetConnectionName(connectionName); 39 clientSocket->SetNetworkId(connectionName); 40 return clientSocket; 41 } 42 CreateServerSocket(const int32_t socketId)43std::shared_ptr<BaseSocket> SocketFactory::CreateServerSocket(const int32_t socketId) 44 { 45 IAM_LOGI("start."); 46 return Common::MakeShared<ServerSocket>(socketId); 47 } 48 } // namespace UserAuth 49 } // namespace UserIam 50 } // namespace OHOS 51