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) :
36 unsigned int length = 0;
40 if (seService == NULL || name == NULL || strlen(name) == 0 || terminal == NULL)
42 SCARD_DEBUG_ERR("invalid param");
47 this->terminal = terminal;
48 this->seService = seService;
50 length = strlen(name);
51 length = (length < sizeof(this->name)) ? length : sizeof(this->name);
52 memcpy(this->name, name, length);
54 /* open admin channel */
55 adminChannel = new ServerChannel(NULL, NULL, 0, terminal);
56 if (adminChannel == NULL)
58 SCARD_DEBUG_ERR("alloc failed");
62 ServerReader::~ServerReader()
72 if (adminChannel != NULL)
79 void ServerReader::closeSessions()
80 throw(ErrorIO &, ErrorIllegalState &)
84 for (i = 0; i < sessions.size(); i++)
86 if (sessions[i] != NULL)
87 ((ServerSession *)sessions[i])->closeSync();
93 AccessControlList *ServerReader::getAccessControlList()
97 /* load access control */
98 acList = new GPSEACL();
101 acList->loadACL(adminChannel);
105 SCARD_DEBUG_ERR("alloc failed");
112 ServerSession *ServerReader::openSessionSync()
113 throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
115 vector<ByteArray> temp;
117 return openSessionSync(temp, NULL);
120 ServerSession *ServerReader::openSessionSync(vector<ByteArray> &certHashes, void *caller)
121 throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
123 ServerSession *session = NULL;
125 session = new ServerSession(this, certHashes, caller, terminal);
129 sessions.push_back(session);
134 } /* namespace smartcard_service_api */