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-gid.cpp
20 * @author Jan Olszak (j.olszak@samsung.com)
22 * @brief This file constains implementation of get GID 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_gid(const char *objectName) {
38 using namespace SecurityServer;
40 return try_catch([&] {
41 if (NULL == objectName){
42 LogDebug("Objects name is NULL");
43 return SECURITY_SERVER_API_ERROR_INPUT_PARAM;
46 int objectsNameLen = strlen(objectName);
47 if (0 == objectsNameLen || objectsNameLen > SECURITY_SERVER_MAX_OBJ_NAME){
48 LogDebug("Objects name is empty or too long");
49 return SECURITY_SERVER_API_ERROR_INPUT_PARAM;
52 MessageBuffer send, recv;
53 Serialization::Serialize(send, std::string(objectName));
55 int retCode = sendToServer(
56 SERVICE_SOCKET_GET_GID,
60 if (retCode != SECURITY_SERVER_API_SUCCESS)
63 Deserialization::Deserialize(recv, retCode);
69 // No errors, return gid
71 Deserialization::Deserialize(recv, gid);
72 return static_cast<int>(gid);