2 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
17 * @file socket-2-id-mockup.cpp
18 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
23 #include <dpl/log/log.h>
24 #include <protocols.h>
25 #include <socket-2-id.h>
29 int Socket2Id::getPkgIdFromSmack(const std::string &smack, std::string &pkgId) {
30 static const std::string SMACK_PREFIX_APPID = "User::App::";
33 LogError("Smack is empty. Connection will be rejected");
37 if (smack.compare(0, SMACK_PREFIX_APPID.size(), SMACK_PREFIX_APPID)) {
39 LogDebug("Smack: " << smack << " Was translated to owner id: " << pkgId);
43 std::string appId = smack.substr(SMACK_PREFIX_APPID.size(), std::string::npos);
46 LogError("After conversion (smack->pkgId) pkgId is empty. Label: " << appId);
50 pkgId = std::move(appId);
51 LogDebug("Smack: " << smack << " Was translated to owner id: " << pkgId);
55 int Socket2Id::translate(int sock, std::string &result) {
59 if (0 > getCredentialsFromSocket(sock, smack)) {
63 if (0 > getPkgIdFromSmack(smack, pkgId)) {
67 result = std::move(pkgId);