2 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Bumjin Im <bj.im@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
19 * @file client-get-object-name.cpp
20 * @author Jan Olszak (j.olszak@samsung.com)
22 * @brief This file constains implementation of get NAME function.
27 #include <dpl/log/log.h>
28 #include <dpl/exception.h>
30 #include <message-buffer.h>
31 #include <client-common.h>
32 #include <protocols.h>
34 #include <security-server.h>
37 int security_server_get_object_name(gid_t gid, char *pObjectName, size_t maxObjectSize)
39 using namespace SecurityServer;
40 return try_catch([&] {
41 if (pObjectName == NULL){
42 LogDebug("Objects name is NULL or empty");
43 return SECURITY_SERVER_API_ERROR_INPUT_PARAM;
46 MessageBuffer send, recv;
47 Serialization::Serialize(send, gid);
49 int result = sendToServer(
50 SERVICE_SOCKET_GET_OBJECT_NAME,
55 if (result != SECURITY_SERVER_API_SUCCESS)
58 Deserialization::Deserialize(recv, result);
60 std::string retObjectName;
61 Deserialization::Deserialize(recv, retObjectName);
63 if(retObjectName.size() > maxObjectSize){
64 LogError("Objects name is too big. Need more space in pObjectName buffer.");
65 return SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL;
68 strcpy(pObjectName,retObjectName.c_str());