2 * Copyright (c) 2012 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 /* standard library header */
23 /* SLP library header */
27 #include "ServerSEService.h"
28 #include "ServerReader.h"
31 namespace smartcard_service_api
33 ServerReader::ServerReader(ServerSEService *seService, char *name, Terminal *terminal):ReaderHelper()
35 unsigned int length = 0;
39 if (seService == NULL || name == NULL || strlen(name) == 0 || terminal == NULL)
41 SCARD_DEBUG_ERR("invalid param");
46 this->terminal = terminal;
47 this->seService = seService;
49 length = strlen(name);
50 length = (length < sizeof(this->name)) ? length : sizeof(this->name);
51 memcpy(this->name, name, length);
53 /* open admin channel */
54 adminChannel = new ServerChannel(NULL, NULL, 0, terminal);
55 if (adminChannel == NULL)
57 SCARD_DEBUG_ERR("alloc failed");
61 ServerReader::~ServerReader()
71 if (adminChannel != NULL)
78 void ServerReader::closeSessions()
82 for (i = 0; i < sessions.size(); i++)
84 if (sessions[i] != NULL)
85 ((ServerSession *)sessions[i])->closeSync();
91 AccessControlList *ServerReader::getAccessControlList()
95 /* load access control */
96 acList = new GPSEACL();
99 acList->loadACL(adminChannel);
103 SCARD_DEBUG_ERR("alloc failed");
110 ServerSession *ServerReader::openSessionSync()
112 vector<ByteArray> temp;
114 return openSessionSync(temp, NULL);
118 ServerSession *ServerReader::openSessionSync(vector<ByteArray> &certHashes, void *caller)
120 ServerSession *session = NULL;
122 session = new ServerSession(this, certHashes, caller, terminal);
126 sessions.push_back(session);
131 } /* namespace smartcard_service_api */