include/Reader.h
include/Session.h
include/ClientChannel.h
+ include/smartcard-service.h
# include/
)
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/* standard library header */
#include <stdlib.h>
namespace smartcard_service_api
{
- ClientChannel::ClientChannel(void *context, Session *session, int channelNum, ByteArray selectResponse, void *handle):Channel(session)
+ ClientChannel::ClientChannel(void *context, Session *session,
+ int channelNum, ByteArray selectResponse, void *handle)
+ :Channel(session)
{
this->channelNum = -1;
this->handle = NULL;
closeSync();
}
- void ClientChannel::closeSync()
+ void ClientChannel::closeSync() throw(ErrorIO &, ErrorIllegalState &)
{
#ifdef CLIENT_IPC_THREAD
if (isClosed() == false)
msg.caller = (void *)this;
msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
- syncLock();
- if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ try
{
- rv = waitTimedCondition(0);
- if (rv < 0)
+ syncLock();
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ rv = waitTimedCondition(0);
+ if (rv < 0)
+ {
+ SCARD_DEBUG_ERR("closeSync failed [%d]", rv);
+ }
+ }
+ else
{
- SCARD_DEBUG_ERR("closeSync failed [%d]", rv);
+ SCARD_DEBUG_ERR("sendMessage failed");
+ throw ErrorIO(SCARD_ERROR_IPC_FAILED);
}
+ syncUnlock();
}
- else
+ catch (ExceptionBase &e)
{
- SCARD_DEBUG_ERR("sendMessage failed");
+ syncUnlock();
+
+ throw e;
}
- syncUnlock();
channelNum = -1;
}
}
int ClientChannel::transmitSync(ByteArray command, ByteArray &result)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
int rv = -1;
}
else
{
- SCARD_DEBUG_ERR("clientIPC is null");
+ SCARD_DEBUG_ERR("timeout");
rv = -1;
}
else
{
SCARD_DEBUG_ERR("unavailable channel");
+ throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
}
return rv;
return result;
}
-EXTERN_API int channel_transmit(channel_h handle, unsigned char *command, unsigned int length, channel_transmit_cb callback, void *userParam)
+EXTERN_API int channel_transmit(channel_h handle, unsigned char *command,
+ unsigned int length, channel_transmit_cb callback, void *userParam)
{
int result = -1;
{
#ifdef CLIENT_IPC_THREAD
CHANNEL_EXTERN_BEGIN;
- channel->closeSync();
+ try
+ {
+ channel->closeSync();
+ }
+ catch (...)
+ {
+ }
CHANNEL_EXTERN_END;
#endif
}
-EXTERN_API int channel_transmit_sync(channel_h handle, unsigned char *command, unsigned int cmd_len, unsigned char **response, unsigned int *resp_len)
+EXTERN_API int channel_transmit_sync(channel_h handle, unsigned char *command,
+ unsigned int cmd_len, unsigned char **response, unsigned int *resp_len)
{
int result = -1;
ByteArray temp, resp;
temp.setBuffer(command, cmd_len);
- result = channel->transmitSync(temp, resp);
- if (resp.getLength() > 0)
+
+ try
+ {
+ result = channel->transmitSync(temp, resp);
+ if (resp.getLength() > 0)
+ {
+ *resp_len = resp.getLength();
+ *response = (unsigned char *)calloc(1, *resp_len);
+ memcpy(*response, resp.getBuffer(), *resp_len);
+ }
+ }
+ catch (...)
{
- *resp_len = resp.getLength();
- *response = (unsigned char *)calloc(1, *resp_len);
- memcpy(*response, resp.getBuffer(), *resp_len);
+ result = -1;
}
CHANNEL_EXTERN_END;
#endif
return result;
}
-EXTERN_API bool channel_get_select_response(channel_h handle, unsigned char *buffer, unsigned int length)
+EXTERN_API bool channel_get_select_response(channel_h handle,
+ unsigned char *buffer, unsigned int length)
{
bool result = false;
EXTERN_API void channel_destroy_instance(channel_h handle)
{
- CHANNEL_EXTERN_BEGIN;
- delete channel;
- CHANNEL_EXTERN_END;
+ /* do nothing */
}
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/* standard library header */
#include <sys/socket.h>
_launch_daemon();
#endif
#ifdef SECURITY_SERVER
- int length = 0;
+ int length;
if ((length = security_server_get_cookie_size()) > 0)
{
buffer = new uint8_t[length];
if (buffer != NULL)
{
- int error = 0;
+ int error;
- if ((error = security_server_request_cookie(buffer, length)) == SECURITY_SERVER_API_SUCCESS)
+ if ((error = security_server_request_cookie(buffer, length))
+ == SECURITY_SERVER_API_SUCCESS)
{
cookie.setBuffer(buffer, length);
#ifdef USE_AUTOSTART
void ClientIPC::_launch_daemon()
{
- DBusGConnection *connection = NULL;
- DBusGProxy *proxy = NULL;
+ DBusGConnection *connection;
GError *error = NULL;
- gint result = 0;
SCARD_BEGIN();
connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
if (error == NULL)
{
- proxy = dbus_g_proxy_new_for_name(connection, "org.tizen.smartcard_service", "/org/tizen/smartcard_service", "org.tizen.smartcard_service");
+ DBusGProxy *proxy;
+
+ proxy = dbus_g_proxy_new_for_name(connection, "org.tizen.smartcard_service",
+ "/org/tizen/smartcard_service", "org.tizen.smartcard_service");
if (proxy != NULL)
{
- if (dbus_g_proxy_call(proxy, "launch", &error, G_TYPE_INVALID, G_TYPE_INT, &result, G_TYPE_INVALID) == false)
+ gint result = 0;
+
+ if (dbus_g_proxy_call(proxy, "launch", &error, G_TYPE_INVALID,
+ G_TYPE_INT, &result, G_TYPE_INVALID) == false)
{
SCARD_DEBUG_ERR("org_tizen_smartcard_service_launch failed");
if (error != NULL)
bool ClientIPC::sendMessage(Message *msg)
{
ByteArray stream;
- unsigned int length = 0;
+ unsigned int length;
if (ipcSocket == -1)
return false;
#endif
length = stream.getLength();
- SCARD_DEBUG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]", ipcSocket, msg->message, stream.getLength());
+ SCARD_DEBUG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]",
+ ipcSocket, msg->message, stream.getLength());
return IPCHelper::sendMessage(ipcSocket, stream);
}
int ClientIPC::handleIOErrorCondition(void *channel, GIOCondition condition)
{
- DispatcherMsg dispMsg;
-
SCARD_BEGIN();
- /* push or process disconnect message */
- dispMsg.message = Message::MSG_OPERATION_RELEASE_CLIENT;
- dispMsg.error = -1;
-
if (dispatcher != NULL)
{
+ DispatcherMsg dispMsg;
+
+ /* push or process disconnect message */
+ dispMsg.message = Message::MSG_OPERATION_RELEASE_CLIENT;
+ dispMsg.error = -1;
+
#ifdef CLIENT_IPC_THREAD
dispatcher->processMessage(&dispMsg);
#else
#include "ClientIPC.h"
#include "Reader.h"
#include "Session.h"
-#include "SignatureHelper.h"
#ifndef EXTERN_API
#define EXTERN_API __attribute__((visibility("default")))
namespace smartcard_service_api
{
- Reader::Reader(void *context, const char *name, void *handle):ReaderHelper()
+ Reader::Reader(void *context, const char *name, void *handle) : ReaderHelper()
{
unsigned int length = 0;
present = true;
-#if 0
- getPackageCert();
-#endif
-
SCARD_END();
}
}
void Reader::closeSessions()
+ throw(ErrorIO &, ErrorIllegalState &)
{
size_t i;
}
}
- void Reader::getPackageCert()
- {
- packageCert = SignatureHelper::getCertificationHash(getpid());
- }
-
SessionHelper *Reader::openSessionSync()
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
openedSession = NULL;
/* request channel handle from server */
msg.message = Message::MSG_REQUEST_OPEN_SESSION;
msg.param1 = (unsigned int)handle;
- msg.data = packageCert;
msg.error = (unsigned int)context; /* using error to context */
msg.caller = (void *)this;
msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
/* request channel handle from server */
msg.message = Message::MSG_REQUEST_OPEN_SESSION;
msg.param1 = (unsigned int)handle;
-#if 0
- msg.data = packageCert;
-#endif
msg.error = (unsigned int)context; /* using error to context */
msg.caller = (void *)this;
msg.callback = (void *)callback;
EXTERN_API void reader_destroy_instance(reader_h handle)
{
- READER_EXTERN_BEGIN;
- delete reader;
- READER_EXTERN_END;
}
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/* standard library header */
#include <unistd.h>
namespace smartcard_service_api
{
- SEService::SEService():SEServiceHelper()
+ SEService::SEService() :
+ SEServiceHelper()
{
- pid = -1;
this->context = NULL;
this->handler = NULL;
this->listener = NULL;
connected = false;
-
- pid = getpid();
}
- SEService::SEService(void *user_data, serviceConnected handler):SEServiceHelper()
+ SEService::SEService(void *user_data, serviceConnected handler)
+ throw(ErrorIO &, ErrorIllegalParameter &) :
+ SEServiceHelper()
{
- pid = -1;
- this->context = NULL;
- this->handler = NULL;
this->listener = NULL;
connected = false;
- pid = getpid();
-
initialize(user_data, handler);
}
- SEService::SEService(void *user_data, SEServiceListener *listener):SEServiceHelper()
+ SEService::SEService(void *user_data, SEServiceListener *listener)
+ throw(ErrorIO &, ErrorIllegalParameter &) :
+ SEServiceHelper()
{
- pid = -1;
- this->context = NULL;
this->handler = NULL;
- this->listener = NULL;
connected = false;
- pid = getpid();
-
initialize(user_data, listener);
}
{
uint32_t i;
- shutdownSync();
+ try
+ {
+ shutdownSync();
+ }
+ catch(ExceptionBase &e)
+ {
+ SCARD_DEBUG_ERR("EXCEPTION : %s", e.what());
+ }
+ catch(...)
+ {
+ SCARD_DEBUG_ERR("EXCEPTION!!!");
+ }
for (i = 0; i < readers.size(); i++)
{
readers.clear();
}
+ SEService *SEService::createInstance(void *user_data, SEServiceListener *listener)
+ throw(ErrorIO &, ErrorIllegalParameter &)
+ {
+ return new SEService(user_data, listener);
+ }
+
+ SEService *SEService::createInstance(void *user_data, serviceConnected handler)
+ throw(ErrorIO &, ErrorIllegalParameter &)
+ {
+ return new SEService(user_data, handler);
+ }
+
void SEService::shutdown()
{
if (connected == true)
msg.message = Message::MSG_REQUEST_SHUTDOWN;
msg.error = (unsigned int)this; /* using error to context */
msg.caller = (void *)this;
- msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
+ msg.callback = (void *)NULL;
if (ClientIPC::getInstance().sendMessage(&msg) == false)
{
}
/* send message to load se */
- int rv;
Message msg;
msg.message = Message::MSG_REQUEST_SHUTDOWN;
syncLock();
if (ClientIPC::getInstance().sendMessage(&msg) == true)
{
+ int rv;
+
rv = waitTimedCondition(0);
if (rv == 0)
#endif
}
- bool SEService::_initialize()
+ bool SEService::_initialize() throw(ErrorIO &)
{
bool result = false;
- ClientIPC *clientIPC = NULL;
- ClientDispatcher *clientDispatcher = NULL;
+ ClientIPC *clientIPC;
+ ClientDispatcher *clientDispatcher;
SCARD_BEGIN();
Message msg;
msg.message = Message::MSG_REQUEST_READERS;
- msg.error = pid; /* using error to pid */
+ msg.error = getpid(); /* using error to pid */
msg.caller = (void *)this;
msg.userParam = context;
}
bool SEService::initialize(void *context, serviceConnected handler)
+ throw(ErrorIO &, ErrorIllegalParameter &)
{
if (context == NULL)
{
- SCARD_DEBUG_ERR("invalid param");
- return false;
+ ErrorIllegalParameter e(0);
+
+ throw e;
}
this->context = context;
}
bool SEService::initialize(void *context, SEServiceListener *listener)
+ throw(ErrorIO &, ErrorIllegalParameter &)
{
if (context == NULL)
{
- SCARD_DEBUG_ERR("invalid param");
- return false;
+ ErrorIllegalParameter e(0);
+
+ throw e;
}
this->context = context;
/* copy result */
// service->error = msg->error;
-
service->signalCondition();
service->syncUnlock();
}
else
{
-// openSessionCallback cb = (openSessionCallback)msg->callback;
-//
-// /* async call */
-// cb(session, msg->error, msg->userParam);
+ /* Do nothing... */
}
break;
SCARD_DEBUG("[MSG_NOTIFY_SE_INSERTED]");
/* add readers */
- reader = new Reader(service->context, (char *)msg->data.getBuffer(), (void *)msg->param1);
+ reader = new Reader(service->context,
+ (char *)msg->data.getBuffer(), (void *)msg->param1);
if (reader != NULL)
{
service->readers.push_back(reader);
if (service->listener != NULL)
{
- service->listener->eventHandler(service, (char *)msg->data.getBuffer(), 1, service->context);
+ service->listener->eventHandler(service,
+ (char *)msg->data.getBuffer(), 1, service->context);
}
else
{
if (service->listener != NULL)
{
- service->listener->eventHandler(service, (char *)msg->data.getBuffer(), 2, service->context);
+ service->listener->eventHandler(service,
+ (char *)msg->data.getBuffer(), 2, service->context);
}
else
{
}
break;
- default:
+ default :
SCARD_DEBUG("unknown message [%s]", msg->toString());
break;
}
EXTERN_API se_service_h se_service_create_instance(void *user_data, se_service_connected_cb callback)
{
- SEService *service = new SEService(user_data, (serviceConnected)callback);
+ SEService *service;
+
+ try
+ {
+ service = new SEService(user_data, (serviceConnected)callback);
+ }
+ catch (...)
+ {
+ service = NULL;
+ }
return (se_service_h)service;
}
-EXTERN_API se_service_h se_service_create_instance_with_event_callback(void *user_data, se_service_connected_cb connected, se_service_event_cb event, se_sesrvice_error_cb error)
+EXTERN_API se_service_h se_service_create_instance_with_event_callback(void *user_data,
+ se_service_connected_cb connected, se_service_event_cb event, se_sesrvice_error_cb error)
{
- SEService *service = new SEService(user_data, (serviceConnected)connected);
+ SEService *service;
+
+ try
+ {
+ service = new SEService(user_data, (serviceConnected)connected);
+ }
+ catch (...)
+ {
+ service = NULL;
+ }
return (se_service_h)service;
}
int count = 0;
SE_SERVICE_EXTERN_BEGIN;
+
vector<ReaderHelper *> temp_readers;
temp_readers = service->getReaders();
count = temp_readers.size();
+
SE_SERVICE_EXTERN_END;
return count;
bool result = false;
SE_SERVICE_EXTERN_BEGIN;
+
vector<ReaderHelper *> temp_readers;
size_t i;
int temp = 0;
}
}
*count = temp;
+
SE_SERVICE_EXTERN_END;
return result;
bool result = false;
SE_SERVICE_EXTERN_BEGIN;
+
result = service->isConnected();
+
SE_SERVICE_EXTERN_END;
return result;
EXTERN_API void se_service_shutdown(se_service_h handle)
{
SE_SERVICE_EXTERN_BEGIN;
+
service->shutdown();
+
SE_SERVICE_EXTERN_END;
}
EXTERN_API void se_service_destroy_instance(se_service_h handle)
{
SE_SERVICE_EXTERN_BEGIN;
+
delete service;
+
SE_SERVICE_EXTERN_END;
}
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/* standard library header */
#include <stdio.h>
namespace smartcard_service_api
{
- Session::Session(void *context, Reader *reader, void *handle):SessionHelper(reader)
+ Session::Session(void *context, Reader *reader, void *handle) :
+ SessionHelper(reader)
{
this->context = NULL;
channels.clear();
}
- void Session::closeChannels()
+ void Session::closeChannels() throw (ErrorIO &, ErrorIllegalState &)
{
size_t i;
}
}
- ByteArray Session::getATRSync()
+ ByteArray Session::getATRSync() throw (ErrorIO &, ErrorIllegalState &)
{
- atr.releaseBuffer();
+ ByteArray result;
if (getReader()->isSecureElementPresent() == true)
{
- Message msg;
- int rv;
+ if (atr.isEmpty() == true)
+ {
+ Message msg;
+ int rv;
#ifdef CLIENT_IPC_THREAD
- /* request channel handle from server */
- msg.message = Message::MSG_REQUEST_GET_ATR;
- msg.param1 = (unsigned int)handle;
- msg.error = (unsigned int)context; /* using error to context */
- msg.caller = (void *)this;
- msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
-
- syncLock();
- if (ClientIPC::getInstance().sendMessage(&msg) == true)
- {
- rv = waitTimedCondition(0);
- if (rv != 0)
+ /* request channel handle from server */
+ msg.message = Message::MSG_REQUEST_GET_ATR;
+ msg.param1 = (unsigned int)handle;
+ msg.error = (unsigned int)context; /* using error to context */
+ msg.caller = (void *)this;
+ msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
+
+ syncLock();
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
{
- SCARD_DEBUG_ERR("time over");
+ rv = waitTimedCondition(0);
+ if (rv != 0)
+ {
+ SCARD_DEBUG_ERR("time over");
+ }
}
- }
- else
- {
- SCARD_DEBUG_ERR("sendMessage failed");
- }
- syncUnlock();
+ else
+ {
+ SCARD_DEBUG_ERR("sendMessage failed");
+ }
+ syncUnlock();
#endif
+ }
+
+ result = atr;
}
else
{
SCARD_DEBUG_ERR("unavailable session");
}
- return atr;
+ return result;
}
int Session::getATR(getATRCallback callback, void *userData)
if (getReader()->isSecureElementPresent() == true)
{
- Message msg;
+ if (atr.isEmpty() == true)
+ {
+ Message msg;
- /* request channel handle from server */
- msg.message = Message::MSG_REQUEST_GET_ATR;
- msg.param1 = (unsigned int)handle;
- msg.error = (unsigned int)context; /* using error to context */
- msg.caller = (void *)this;
- msg.callback = (void *)callback;
- msg.userParam = userData;
+ /* request channel handle from server */
+ msg.message = Message::MSG_REQUEST_GET_ATR;
+ msg.param1 = (unsigned int)handle;
+ msg.error = (unsigned int)context; /* using error to context */
+ msg.caller = (void *)this;
+ msg.callback = (void *)callback;
+ msg.userParam = userData;
- if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ result = 0;
+ }
+ }
+ else
{
- result = 0;
+ /* TODO : invoke callback directly */
+ callback(atr.getBuffer(), atr.getLength(), 0, userData);
}
}
else
return result;
}
- void Session::closeSync()
+ void Session::closeSync() throw (ErrorIO &, ErrorIllegalState &)
{
Message msg;
int rv;
}
Channel *Session::openChannelSync(int id, ByteArray aid)
+ throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
openedChannel = NULL;
}
Channel *Session::openBasicChannelSync(ByteArray aid)
+ throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
return openChannelSync(0, aid);
}
Channel *Session::openBasicChannelSync(unsigned char *aid, unsigned int length)
+ throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
return openBasicChannelSync(ByteArray(aid, length));
}
return openChannel(0, aid, callback, userData);
}
- int Session::openBasicChannel(unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData)
+ int Session::openBasicChannel(unsigned char *aid, unsigned int length,
+ openChannelCallback callback, void *userData)
{
return openBasicChannel(ByteArray(aid, length), callback, userData);
}
Channel *Session::openLogicalChannelSync(ByteArray aid)
+ throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
return openChannelSync(1, aid);
}
Channel *Session::openLogicalChannelSync(unsigned char *aid, unsigned int length)
+ throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
return openLogicalChannelSync(ByteArray(aid, length));
}
return openChannel(1, aid, callback, userData);
}
- int Session::openLogicalChannel(unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData)
+ int Session::openLogicalChannel(unsigned char *aid, unsigned int length,
+ openChannelCallback callback, void *userData)
{
return openLogicalChannel(ByteArray(aid, length), callback, userData);
}
if (msg->param1 != 0)
{
/* create new instance of channel */
- channel = new ClientChannel(session->context, session, msg->param2, msg->data, (void *)msg->param1);
+ channel = new ClientChannel(session->context,
+ session, msg->param2, msg->data, (void *)msg->param1);
if (channel != NULL)
{
session->channels.push_back(channel);
}
break;
- default:
+ default :
SCARD_DEBUG("unknown message : %s", msg->toString());
break;
}
reader_h reader = NULL;
SESSION_EXTERN_BEGIN;
- reader = session->getReader();
+ reader = session->getReader();
SESSION_EXTERN_END;
return reader;
int result = -1;
SESSION_EXTERN_BEGIN;
- result = session->getATR((getATRCallback)callback, userData);
+ result = session->getATR((getATRCallback)callback, userData);
SESSION_EXTERN_END;
return result;
int result = -1;
SESSION_EXTERN_BEGIN;
- result = session->close((closeSessionCallback)callback, userData);
+ result = session->close((closeSessionCallback)callback, userData);
SESSION_EXTERN_END;
return result;
bool result = false;
SESSION_EXTERN_BEGIN;
- result = session->isClosed();
+ result = session->isClosed();
SESSION_EXTERN_END;
return result;
EXTERN_API void session_close_channels(session_h handle)
{
SESSION_EXTERN_BEGIN;
- session->closeChannels();
+ session->closeChannels();
SESSION_EXTERN_END;
}
-EXTERN_API int session_open_basic_channel(session_h handle, unsigned char *aid, unsigned int length, session_open_channel_cb callback, void *userData)
+EXTERN_API int session_open_basic_channel(session_h handle, unsigned char *aid,
+ unsigned int length, session_open_channel_cb callback, void *userData)
{
int result = -1;
SESSION_EXTERN_BEGIN;
- result = session->openBasicChannel(aid, length, (openChannelCallback)callback, userData);
+ result = session->openBasicChannel(aid, length, (openChannelCallback)callback, userData);
SESSION_EXTERN_END;
return result;
}
-EXTERN_API int session_open_logical_channel(session_h handle, unsigned char *aid, unsigned int length, session_open_channel_cb callback, void *userData)
+EXTERN_API int session_open_logical_channel(session_h handle, unsigned char *aid,
+ unsigned int length, session_open_channel_cb callback, void *userData)
{
int result = -1;
SESSION_EXTERN_BEGIN;
- result = session->openLogicalChannel(aid, length, (openChannelCallback)callback, userData);
+ result = session->openLogicalChannel(aid, length, (openChannelCallback)callback, userData);
SESSION_EXTERN_END;
return result;
int result = -1;
SESSION_EXTERN_BEGIN;
- result = session->getChannelCount((getChannelCountCallback)callback, userData);
+ result = session->getChannelCount((getChannelCountCallback)callback, userData);
SESSION_EXTERN_END;
return result;
EXTERN_API void session_destroy_instance(session_h handle)
{
- SESSION_EXTERN_BEGIN;
- delete session;
- SESSION_EXTERN_END;
}
EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length)
return result;
SESSION_EXTERN_BEGIN;
- temp = session->getATRSync();
- if (temp.getLength() > 0)
- {
- *length = temp.getLength();
- *buffer = (unsigned char *)calloc(1, *length);
- memcpy(*buffer, temp.getBuffer(), *length);
+ temp = session->getATRSync();
+ if (temp.getLength() > 0)
+ {
+ *length = temp.getLength();
+ *buffer = (unsigned char *)calloc(1, *length);
+ memcpy(*buffer, temp.getBuffer(), *length);
- result = 0;
- }
- SESSION_EXTERN_END;
+ result = 0;
+ }
+ SESSION_EXTERN_END;
#endif
return result;
{
#ifdef CLIENT_IPC_THREAD
SESSION_EXTERN_BEGIN;
- session->closeSync();
+ session->closeSync();
SESSION_EXTERN_END;
#endif
}
#ifdef CLIENT_IPC_THREAD
SESSION_EXTERN_BEGIN;
- result = session->openBasicChannelSync(aid, length);
+ result = session->openBasicChannelSync(aid, length);
SESSION_EXTERN_END;
#endif
#ifdef CLIENT_IPC_THREAD
SESSION_EXTERN_BEGIN;
- result = session->openLogicalChannelSync(aid, length);
+ result = session->openLogicalChannelSync(aid, length);
SESSION_EXTERN_END;
#endif
#ifdef CLIENT_IPC_THREAD
SESSION_EXTERN_BEGIN;
- result = session->getChannelCountSync();
+ result = session->getChannelCountSync();
SESSION_EXTERN_END;
#endif
int error;
ByteArray response;
- ClientChannel(void *context, Session *session, int channelNum, ByteArray selectResponse, void *handle);
+ ClientChannel(void *context, Session *session, int channelNum,
+ ByteArray selectResponse, void *handle);
+ ~ClientChannel();
static bool dispatcherCallback(void *message);
public:
- ~ClientChannel();
-
int close(closeCallback callback, void *userParam);
- int transmit(ByteArray command, transmitCallback callback, void *userParam);
+ int transmit(ByteArray command, transmitCallback callback,
+ void *userParam);
- void closeSync();
- int transmitSync(ByteArray command, ByteArray &result);
+ void closeSync()
+ throw(ErrorIO &, ErrorIllegalState &);
+ int transmitSync(ByteArray command, ByteArray &result)
+ throw(ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &);
friend class ClientDispatcher;
friend class Session;
bool channel_is_closed(channel_h handle);
unsigned int channel_get_select_response_length(channel_h handle);
-bool channel_get_select_response(channel_h handle, unsigned char *buffer, unsigned int length);
+bool channel_get_select_response(channel_h handle, unsigned char *buffer,
+ unsigned int length);
session_h channel_get_session(channel_h handle);
-void channel_destroy_instance(channel_h handle);
+void channel_destroy_instance(channel_h handle) __attribute__((deprecated)) ;
int channel_close(channel_h handle, channel_close_cb callback, void *userParam);
-int channel_transmit(channel_h handle, unsigned char *command, unsigned int length, channel_transmit_cb callback, void *userParam);
+int channel_transmit(channel_h handle, unsigned char *command,
+ unsigned int length, channel_transmit_cb callback, void *userParam);
void channel_close_sync(channel_h handle);
-int channel_transmit_sync(channel_h handle, unsigned char *command, unsigned int cmd_len, unsigned char **response, unsigned int *resp_len);
+int channel_transmit_sync(channel_h handle, unsigned char *command,
+ unsigned int cmd_len, unsigned char **response, unsigned int *resp_len);
#ifdef __cplusplus
}
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef CLIENTDISPATCHER_H_
#define CLIENTDISPATCHER_H_
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef CLIENTIPC_H_
#define CLIENTIPC_H_
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef READER_H_
#define READER_H_
private:
void *context;
void *handle;
- ByteArray packageCert;
/* temporary data for sync function */
int error;
Session *openedSession;
Reader(void *context, const char *name, void *handle);
+ ~Reader();
void unavailable();
static bool dispatcherCallback(void *message);
- void getPackageCert();
public:
- ~Reader();
-
- void closeSessions();
+ void closeSessions()
+ throw(ErrorIO &, ErrorIllegalState &);
int openSession(openSessionCallback callback, void *userData);
- SessionHelper *openSessionSync();
+ SessionHelper *openSessionSync()
+ throw(ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &);
friend class SEService;
friend class ClientDispatcher;
};
-
} /* namespace smartcard_service_api */
#endif /* __cplusplus */
const char *reader_get_name(reader_h handle);
se_service_h reader_get_se_service(reader_h handle);
bool reader_is_secure_element_present(reader_h handle);
-int reader_open_session(reader_h handle, reader_open_session_cb callback, void *userData);
+int reader_open_session(reader_h handle, reader_open_session_cb callback,
+ void *userData);
session_h reader_open_session_sync(reader_h handle);
void reader_close_sessions(reader_h handle);
-void reader_destroy_instance(reader_h handle);
+__attribute__((deprecated)) void reader_destroy_instance(reader_h handle);
#ifdef __cplusplus
}
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef SESERVICE_H_
#define SESERVICE_H_
static bool dispatcherCallback(void *message);
bool parseReaderInformation(unsigned int count, ByteArray data);
- bool _initialize();
-
- bool initialize(void *context, serviceConnected handler);
- bool initialize(void *context, SEServiceListener *listener);
- SEService *initializeSync(void *context, serviceConnected handler);
+ bool _initialize()
+ throw(ErrorIO &);
+ bool initialize(void *context, serviceConnected handler)
+ throw(ErrorIO &, ErrorIllegalParameter &);
+ bool initialize(void *context, SEServiceListener *listener)
+ throw(ErrorIO &, ErrorIllegalParameter &);
+ SEService *initializeSync(void *context, serviceConnected handler)
+ throw(ErrorIO &, ErrorIllegalParameter &);
public:
- SEService(void *user_data, serviceConnected handler);
- SEService(void *user_data, SEServiceListener *listener);
+ SEService(void *user_data, serviceConnected handler)
+ throw(ErrorIO &, ErrorIllegalParameter &);
+ SEService(void *user_data, SEServiceListener *listener)
+ throw(ErrorIO &, ErrorIllegalParameter &);
~SEService();
+ static SEService *createInstance(void *user_data, SEServiceListener *listener)
+ throw(ErrorIO &, ErrorIllegalParameter &);
+ static SEService *createInstance(void *user_data, serviceConnected handler)
+ throw(ErrorIO &, ErrorIllegalParameter &);
+
void shutdown();
void shutdownSync();
friend class ClientDispatcher;
};
-
} /* namespace smartcard_service_api */
#endif /* __cplusplus */
#endif /* __cplusplus */
se_service_h se_service_create_instance(void *user_data, se_service_connected_cb callback);
-se_service_h se_service_create_instance_with_event_callback(void *user_data, se_service_connected_cb connected, se_service_event_cb event, se_sesrvice_error_cb error);
+se_service_h se_service_create_instance_with_event_callback(void *user_data,
+ se_service_connected_cb connected, se_service_event_cb event, se_sesrvice_error_cb error);
int se_service_get_readers_count(se_service_h handle);
bool se_service_get_readers(se_service_h handle, reader_h *readers, int *count);
bool se_service_is_connected(se_service_h handle);
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef SESERVICELISTENER_H_
#define SESERVICELISTENER_H_
class SEServiceListener
{
public:
- virtual void serviceConnected(SEServiceHelper *service, void *context) = 0;
- virtual void eventHandler(SEServiceHelper *service, char *seName, int event, void *context) = 0;
- virtual void errorHandler(SEServiceHelper *service, int error, void *context) = 0;
+ virtual void serviceConnected(SEServiceHelper *service,
+ void *context) = 0;
+ virtual void eventHandler(SEServiceHelper *service,
+ char *seName, int event, void *context) = 0;
+ virtual void errorHandler(SEServiceHelper *service, int error,
+ void *context) = 0;
};
-
} /* namespace open_mobile_api */
+
#endif /* SESERVICELISTENER_H_ */
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef SESSION_H_
#define SESSION_H_
unsigned int channelCount;
Session(void *context, Reader *reader, void *handle);
+ ~Session();
int openChannel(int id, ByteArray aid, openChannelCallback callback, void *userData);
static bool dispatcherCallback(void *message);
- Channel *openChannelSync(int id, ByteArray aid);
+ Channel *openChannelSync(int id, ByteArray aid)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
public:
- ~Session();
-
- void closeChannels();
+ void closeChannels()
+ throw(ErrorIO &, ErrorIllegalState &);
int getATR(getATRCallback callback, void *userData);
int close(closeSessionCallback callback, void *userData);
int openLogicalChannel(unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData);
int getChannelCount(getChannelCountCallback callback, void * userData);
- ByteArray getATRSync();
- void closeSync();
+ ByteArray getATRSync()
+ throw(ErrorIO &, ErrorIllegalState &);
+
+ void closeSync()
+ throw(ErrorIO &, ErrorIllegalState &);
+
+ Channel *openBasicChannelSync(ByteArray aid)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+
+ Channel *openBasicChannelSync(unsigned char *aid, unsigned int length)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+
+ Channel *openLogicalChannelSync(ByteArray aid)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+
+ Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
- Channel *openBasicChannelSync(ByteArray aid);
- Channel *openBasicChannelSync(unsigned char *aid, unsigned int length);
- Channel *openLogicalChannelSync(ByteArray aid);
- Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length);
unsigned int getChannelCountSync();
friend class ClientDispatcher;
reader_h session_get_reader(session_h handle);
bool session_is_closed(session_h handle);
-void session_destroy_instance(session_h handle);
+__attribute__((deprecated)) void session_destroy_instance(session_h handle);
void session_close_channels(session_h handle);
int session_get_atr(session_h handle, session_get_atr_cb callback, void *userData);
int session_close(session_h handle, session_close_session_cb callback, void *userData);
-int session_open_basic_channel(session_h handle, unsigned char *aid, unsigned int length, session_open_channel_cb callback, void *userData);
-int session_open_logical_channel(session_h handle, unsigned char *aid, unsigned int length, session_open_channel_cb callback, void *userData);
+int session_open_basic_channel(session_h handle, unsigned char *aid,
+ unsigned int length, session_open_channel_cb callback, void *userData);
+int session_open_logical_channel(session_h handle, unsigned char *aid,
+ unsigned int length, session_open_channel_cb callback, void *userData);
int session_get_channel_count(session_h handle, session_get_channel_count_cb callback, void * userData);
int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length);
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SMARTCARD_SERVICE_H_
+#define SMARTCARD_SERVICE_H_
+
+#include "smartcard-types.h"
+#include "Exception.h"
+#include "SEService.h"
+#include "Reader.h"
+#include "Session.h"
+#include "ClientChannel.h"
+
+#endif /* SMARTCARD_SERVICE_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Exception.h"
+
+namespace smartcard_service_api
+{
+} /* namespace smartcard_service_api */
}
#ifdef SECURITY_SERVER
- gid = security_server_get_gid(NET_NFC_MANAGER_OBJECT);
+ int gid, cookies_size;
+ char *cookies;
+
+ gid = security_server_get_gid("smartcard-service");
if(gid == 0)
{
SCARD_DEBUG("get gid from security server is failed. this object is not allowed by security server");
GIOCondition condition = (GIOCondition)(G_IO_ERR | G_IO_HUP | G_IO_IN);
#endif
int result = 0;
+ char err[200] = { 0, };
SCARD_BEGIN();
ipcSocket = socket(AF_UNIX, SOCK_STREAM, 0);
if (ipcSocket == -1)
{
- SCARD_DEBUG_ERR("get socket is failed");
+ SCARD_DEBUG_ERR("get socket is failed [%d, %s]",
+ errno, strerror_r(errno, err, sizeof(err)));
goto ERROR;
}
if ((result = connect(ipcSocket, (struct sockaddr *)&saddrun_rv, len_saddr)) < 0)
{
- SCARD_DEBUG_ERR("connect failed [%d]", result);
+ SCARD_DEBUG_ERR("connect failed [%d, %s]",
+ errno, strerror_r(errno, err, sizeof(err)));
goto ERROR;
}
#ifdef USE_IPC_EPOLL
if((fdPoll = epoll_create1(EPOLL_CLOEXEC)) == -1)
{
- SCARD_DEBUG_ERR("epoll_create1 failed");
+ SCARD_DEBUG_ERR("epoll_create1 failed [%d, %s]",
+ errno, strerror_r(errno, err, sizeof(err)));
goto ERROR;
}
stream = msg->serialize();
length = stream.getLength();
- SCARD_DEBUG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]", socket, msg->message, stream.getLength());
+ SCARD_DEBUG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]",
+ socket, msg->message, stream.getLength());
return sendMessage(socket, stream);
}
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/* standard library header */
#include <stdio.h>
namespace smartcard_service_api
{
- ReaderHelper::ReaderHelper()
+ ReaderHelper::ReaderHelper() : seService(NULL), present(false)
{
memset(name, 0, sizeof(name));
- seService = NULL;
- present = false;
}
} /* namespace smartcard_service_api */
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/* standard library header */
-#include <stdio.h>
/* SLP library header */
/* local header */
-#include "Debug.h"
-#include "SessionHelper.h"
#include "ReaderHelper.h"
namespace smartcard_service_api
{
- SessionHelper::SessionHelper(ReaderHelper *reader) : closed(true)
+ SessionHelper::SessionHelper(ReaderHelper *reader) :
+ closed(true)
{
this->reader = reader;
}
-
-// ByteArray SessionHelper::getATR()
-// {
-// return atr;
-// }
} /* namespace smartcard_service_api */
/* local header */
#include "Synchronous.h"
#include "ByteArray.h"
+#include "Exception.h"
namespace smartcard_service_api
{
SessionHelper *session;
int channelNum;
- Channel() : Synchronous()
- {
- channelNum = -1;
- }
- Channel(SessionHelper *session) : Synchronous()
- {
- this->session = session;
- }
+ Channel() : Synchronous() { channelNum = -1; }
+ Channel(SessionHelper *session) : Synchronous() { this->session = session; }
public :
virtual ~Channel() {};
- inline bool isBasicChannel() const { return (channelNum == 0); }
- inline bool isClosed() const { return (channelNum < 0); }
+ inline bool isBasicChannel() const throw() { return (channelNum == 0); }
+ inline bool isClosed() const throw() { return (channelNum < 0); }
- inline ByteArray getSelectResponse() const { return selectResponse; }
- inline SessionHelper *getSession() const { return session; }
+ inline ByteArray getSelectResponse() const throw() { return selectResponse; }
+ inline SessionHelper *getSession() const throw() { return session; }
virtual int close(closeCallback callback, void *userParam) = 0;
virtual int transmit(ByteArray command, transmitCallback callback, void *userData) = 0;
- virtual void closeSync() = 0;
- virtual int transmitSync(ByteArray command, ByteArray &result) = 0;
+ virtual void closeSync()
+ throw(ErrorIO &, ErrorIllegalState &) = 0;
+
+ virtual int transmitSync(ByteArray command, ByteArray &result)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0;
};
} /* namespace smartcard_service_api */
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXCEPTION_H_
+#define EXCEPTION_H_
+
+#include <exception>
+#include <stddef.h>
+
+#include "smartcard-types.h"
+
+namespace smartcard_service_api
+{
+ class ExceptionBase : public std::exception
+ {
+ protected :
+ int errorCode;
+
+ public :
+ ExceptionBase(int errorCode) throw()
+ : errorCode(errorCode) {}
+ virtual ~ExceptionBase() throw() {}
+
+ int getErrorCode() throw() { return errorCode; }
+ virtual const char *what() const throw()
+ {
+ return "Unknown exception";
+ }
+ };
+
+ class ErrorIO : public ExceptionBase
+ {
+ private :
+ unsigned char sw[2];
+
+ public :
+ ErrorIO(int errorCode) throw()
+ : ExceptionBase(errorCode) {}
+ ErrorIO(int errorCode, unsigned char *sw) throw()
+ : ExceptionBase(errorCode)
+ {
+ if (sw != NULL)
+ {
+ this->sw[0] = sw[0];
+ this->sw[1] = sw[1];
+ }
+ }
+ virtual ~ErrorIO() throw() {}
+
+ unsigned short getSW() throw()
+ { return (unsigned short)(sw[0] << 8 | sw[1]); }
+ unsigned char getSW1() throw() { return sw[0]; }
+ unsigned char getSW2() throw() { return sw[1]; }
+
+ virtual const char *what() const throw()
+ {
+ const char *result = NULL;
+
+ switch (errorCode)
+ {
+ case SCARD_ERROR_IPC_FAILED :
+ result = "Failed to communicate with server";
+ break;
+
+ case SCARD_ERROR_IO_FAILED :
+ result = "IO Operation failed";
+ break;
+
+ default :
+ result = ExceptionBase::what();
+ break;
+ }
+
+ return result;
+ }
+ };
+
+ class ErrorSecurity : public ExceptionBase
+ {
+ public :
+ ErrorSecurity(int errorCode) throw()
+ : ExceptionBase(errorCode) {}
+ virtual ~ErrorSecurity() throw() {}
+
+ virtual const char *what() const throw()
+ {
+ const char *result = NULL;
+
+ switch (errorCode)
+ {
+ case SCARD_ERROR_SECURITY_NOT_ALLOWED :
+ result = "Access denied";
+ break;
+
+ default :
+ result = ExceptionBase::what();
+ break;
+ }
+
+ return result;
+ }
+ };
+
+ class ErrorIllegalState : public ExceptionBase
+ {
+ public :
+ ErrorIllegalState(int errorCode) throw()
+ : ExceptionBase(errorCode) {}
+ virtual ~ErrorIllegalState() throw() {}
+
+ virtual const char *what() const throw()
+ {
+ const char *result = NULL;
+
+ switch (errorCode)
+ {
+ case SCARD_ERROR_UNAVAILABLE :
+ result = "Closed instance";
+ break;
+
+ case SCARD_ERROR_NOT_INITIALIZED :
+ result = "Need to initialize IPC";
+ break;
+
+ case SCARD_ERROR_SE_NOT_INITIALIZED :
+ result = "Need to initialize SE";
+ break;
+
+ default :
+ result = ExceptionBase::what();
+ break;
+ }
+
+ return result;
+ }
+ };
+
+ class ErrorIllegalParameter : public ExceptionBase
+ {
+ public :
+ ErrorIllegalParameter(int errorCode) throw()
+ : ExceptionBase(errorCode) {}
+ virtual ~ErrorIllegalParameter() throw() {}
+
+ virtual const char *what() const throw()
+ {
+ const char *result = NULL;
+
+ switch (errorCode)
+ {
+ case SCARD_ERROR_ILLEGAL_PARAM :
+ result = "Incorrect format of parameter";
+ break;
+
+ default :
+ result = ExceptionBase::what();
+ break;
+ }
+
+ return result;
+ }
+ };
+} /* namespace smartcard_service_api */
+
+#endif /* EXCEPTIONBASE_H_ */
bool present;
ReaderHelper();
-
- public:
virtual ~ReaderHelper() {}
+ public:
inline const char *getName() { return name; }
inline SEServiceHelper *getSEService() { return seService; }
inline bool isSecureElementPresent() { return present; }
- virtual void closeSessions() = 0;
+ virtual void closeSessions()
+ throw(ErrorIO &, ErrorIllegalState &) = 0;
virtual int openSession(openSessionCallback callback, void *userData) = 0;
- virtual SessionHelper *openSessionSync() = 0;
+ virtual SessionHelper *openSessionSync()
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)= 0;
};
} /* namespace smartcard_service_api */
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef SESSIONHELPER_H_
#define SESSIONHELPER_H_
SessionHelper(ReaderHelper *reader);
virtual ~SessionHelper() {}
- ReaderHelper *getReader() { return reader; }
- bool isClosed() { return closed; }
+ ReaderHelper *getReader() const throw() { return reader; }
+ bool isClosed() const throw() { return closed; }
- virtual void closeChannels() = 0;
+ virtual void closeChannels()
+ throw(ErrorIO &, ErrorIllegalState &) = 0;
virtual int getATR(getATRCallback callback, void *userData) = 0;
virtual int close(closeSessionCallback callback, void *userData) = 0;
virtual int openLogicalChannel(ByteArray aid, openChannelCallback callback, void *userData) = 0;
virtual int openLogicalChannel(unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData) = 0;
- virtual ByteArray getATRSync() = 0;
- virtual void closeSync() = 0;
+ virtual ByteArray getATRSync()
+ throw(ErrorIO &, ErrorIllegalState &) = 0;
+
+ virtual void closeSync()
+ throw(ErrorIO &, ErrorIllegalState &) = 0;
+
+ virtual Channel *openBasicChannelSync(ByteArray aid)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0;
+
+ virtual Channel *openBasicChannelSync(unsigned char *aid, unsigned int length)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0;
+
+ virtual Channel *openLogicalChannelSync(ByteArray aid)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0;
- virtual Channel *openBasicChannelSync(ByteArray aid) = 0;
- virtual Channel *openBasicChannelSync(unsigned char *aid, unsigned int length) = 0;
- virtual Channel *openLogicalChannelSync(ByteArray aid) = 0;
- virtual Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length) = 0;
+ virtual Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0;
};
} /* namespace smartcard_service_api */
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef SMARTCARD_TYPES_H_
#define SMARTCARD_TYPES_H_
#include <stdint.h>
#include <stdbool.h>
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
enum
{
- SCARD_ERROR_OK = 0,
+ SCARD_ERROR_OK = 0,
- SCARD_ERROR_NOT_INITIALIZED = -(0x10),
+ SCARD_ERROR_NOT_INITIALIZED = -(0x10),
SCARD_ERROR_SE_NOT_INITIALIZED = -(0x11),
SCARD_ERROR_OPERATION_NOT_SUPPORTED = -(0x12),
- SCARD_ERROR_IPC_FAILED = -(0x13),
- SCARD_ERROR_OUT_OF_MEMORY = -(0x14),
+ SCARD_ERROR_IPC_FAILED = -(0x13),
+ SCARD_ERROR_OUT_OF_MEMORY = -(0x14),
SCARD_ERROR_NOT_ENOUGH_RESOURCE = -(0x15),
SCARD_ERROR_OPERATION_TIMEOUT = -(0x16),
SCARD_ERROR_NEED_MORE_BUFFER = -(0x17),
- SCARD_ERROR_NOT_SUPPORTED = -(0x18),
- SCARD_ERROR_UNAVAILABLE = -(0x19),
+ SCARD_ERROR_NOT_SUPPORTED = -(0x18),
+ SCARD_ERROR_UNAVAILABLE = -(0x19),
- SCARD_ERROR_IO_FAILED = -(0x50),
+ SCARD_ERROR_IO_FAILED = -(0x50),
SCARD_ERROR_SECURITY_NOT_ALLOWED = -(0x51),
- SCARD_ERROR_ILLEGAL_STATE = -(0x52),
- SCARD_ERROR_ILLEGAL_PARAM = -(0x53),
+ SCARD_ERROR_ILLEGAL_STATE = -(0x52),
+ SCARD_ERROR_ILLEGAL_PARAM = -(0x53),
SCARD_ERROR_ILLEGAL_REFERENCE = -(0x54),
- SCARD_ERROR_UNKNOWN = -(0x99),
+ SCARD_ERROR_UNKNOWN = -(0x99),
};
typedef void *se_service_h;
typedef void (*channel_transmit_cb)(unsigned char *buffer, unsigned int length, int error, void *user_data);
typedef void (*channel_close_cb)(int error, void *user_data);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
#endif /* SMARTCARD_TYPES_H_ */
}
}
- void ServerChannel::closeSync()
+ void ServerChannel::closeSync() throw(ErrorIO &, ErrorIllegalState &)
{
ByteArray command, result;
APDUHelper apdu;
channelNum = -1;
}
- int ServerChannel::transmitSync(ByteArray command, ByteArray &result)
+ int ServerChannel::transmitSync(ByteArray command, ByteArray &result) throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
APDUCommand helper;
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/* standard library header */
#include <stdio.h>
namespace smartcard_service_api
{
- ServerReader::ServerReader(ServerSEService *seService, char *name, Terminal *terminal):ReaderHelper()
+ ServerReader::ServerReader(ServerSEService *seService, char *name, Terminal *terminal) :
+ ReaderHelper()
{
unsigned int length = 0;
}
void ServerReader::closeSessions()
+ throw(ErrorIO &, ErrorIllegalState &)
{
size_t i;
}
ServerSession *ServerReader::openSessionSync()
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
vector<ByteArray> temp;
return openSessionSync(temp, NULL);
}
-
ServerSession *ServerReader::openSessionSync(vector<ByteArray> &certHashes, void *caller)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
ServerSession *session = NULL;
/*
-* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/* standard library header */
switch (event)
{
case Terminal::NOTIFY_SE_AVAILABLE :
- {
- /* add right se reader */
-// if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL)
-// {
-// SCARD_DEBUG("terminal : [%s]", (char *)terminal);
+ /* add right se reader */
+// if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL)
+// {
+// SCARD_DEBUG("terminal : [%s]", (char *)terminal);
//
-// term->initialize();
-// }
-// else
-// {
-// SCARD_DEBUG("unknown terminal : [%s]", (char *)terminal);
-// }
-
- /* send all client to refresh reader */
- msg.message = msg.MSG_NOTIFY_SE_INSERTED;
- msg.data.setBuffer((unsigned char *)terminal, strlen((char *)terminal) + 1);
-
- ServerResource::getInstance().sendMessageToAllClients(msg);
- }
+// term->initialize();
+// }
+// else
+// {
+// SCARD_DEBUG("unknown terminal : [%s]", (char *)terminal);
+// }
+
+ /* send all client to refresh reader */
+ msg.message = msg.MSG_NOTIFY_SE_INSERTED;
+ msg.data.setBuffer((unsigned char *)terminal,
+ strlen((char *)terminal) + 1);
+
+ ServerResource::getInstance().sendMessageToAllClients(msg);
break;
case Terminal::NOTIFY_SE_NOT_AVAILABLE :
- {
- /* remove right se reader */
-// if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL)
-// {
-// SCARD_DEBUG("terminal : [%s]", (char *)terminal);
+ /* remove right se reader */
+// if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL)
+// {
+// SCARD_DEBUG("terminal : [%s]", (char *)terminal);
//
-// term->finalize();
-// }
-// else
-// {
-// SCARD_DEBUG("unknown terminal : [%s]", (char *)terminal);
-// }
-
- /* send all client to refresh reader */
- msg.message = msg.MSG_NOTIFY_SE_REMOVED;
- msg.data.setBuffer((unsigned char *)terminal, strlen((char *)terminal) + 1);
-
- ServerResource::getInstance().sendMessageToAllClients(msg);
- }
+// term->finalize();
+// }
+// else
+// {
+// SCARD_DEBUG("unknown terminal : [%s]", (char *)terminal);
+// }
+
+ /* send all client to refresh reader */
+ msg.message = msg.MSG_NOTIFY_SE_REMOVED;
+ msg.data.setBuffer((unsigned char *)terminal,
+ strlen((char *)terminal) + 1);
+
+ ServerResource::getInstance().sendMessageToAllClients(msg);
break;
default :
}
ByteArray ServerSession::getATRSync()
+ throw(ErrorIO &, ErrorIllegalState &)
{
/* call get atr to terminal */
return atr;
}
void ServerSession::closeSync()
+ throw(ErrorIO &, ErrorIllegalState &)
{
if (isClosed() == false)
{
}
void ServerSession::closeChannels()
+ throw(ErrorIO &, ErrorIllegalState &)
{
size_t i;
}
Channel *ServerSession::openBasicChannelSync(ByteArray aid)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
return openBasicChannelSync(aid, NULL);
}
Channel *ServerSession::openBasicChannelSync(ByteArray aid, void *caller)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
ServerChannel *channel = NULL;
#if 0
}
Channel *ServerSession::openBasicChannelSync(unsigned char *aid, unsigned int length)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
return openBasicChannelSync(ByteArray(aid, length));
}
Channel *ServerSession::openBasicChannelSync(unsigned char *aid, unsigned int length, void *caller)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
return openBasicChannelSync(ByteArray(aid, length), caller);
}
Channel *ServerSession::openLogicalChannelSync(ByteArray aid)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
return openLogicalChannelSync(aid, NULL);
}
Channel *ServerSession::openLogicalChannelSync(ByteArray aid, void *caller)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
ServerChannel *channel = NULL;
#if 0
}
Channel *ServerSession::openLogicalChannelSync(unsigned char *aid, unsigned int length)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
return openLogicalChannelSync(ByteArray(aid, length), NULL);
}
Channel *ServerSession::openLogicalChannelSync(unsigned char *aid, unsigned int length, void *caller)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
return openLogicalChannelSync(ByteArray(aid, length), caller);
}
void unsetPrivilegeMode() { this->privilege = false; }
protected:
- void closeSync();
- int transmitSync(ByteArray command, ByteArray &result);
+ void closeSync()
+ throw(ErrorIO &, ErrorIllegalState &);
+ int transmitSync(ByteArray command, ByteArray &result)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
public:
~ServerChannel();
AccessControlList *acList;
ServerReader(ServerSEService *seService, char *name, Terminal *terminal);
+ ~ServerReader();
int openSession(openSessionCallback callback, void *userData) { return -1; }
int openSession(void *caller, openSessionCallback callback, void *userData) { return -1; }
public:
- ~ServerReader();
-
- void closeSessions();
+ void closeSessions()
+ throw(ErrorIO &, ErrorIllegalState &);
AccessControlList *getAccessControlList();
- ServerSession *openSessionSync();
- ServerSession *openSessionSync(vector<ByteArray> &certHashes, void *caller);
+ ServerSession *openSessionSync()
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ ServerSession *openSessionSync(vector<ByteArray> &certHashes, void *caller)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
friend class ServerSEService;
};
public:
~ServerSession();
- ByteArray getATRSync();
- void closeSync();
-
- void closeChannels();
-
- Channel *openBasicChannelSync(ByteArray aid);
- Channel *openBasicChannelSync(unsigned char *aid, unsigned int length);
- Channel *openBasicChannelSync(ByteArray aid, void *caller);
- Channel *openBasicChannelSync(unsigned char *aid, unsigned int length, void *caller);
-
- Channel *openLogicalChannelSync(ByteArray aid);
- Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length);
- Channel *openLogicalChannelSync(ByteArray aid, void *caller);
- Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length, void *caller);
+ ByteArray getATRSync()
+ throw(ErrorIO &, ErrorIllegalState &);
+ void closeSync()
+ throw(ErrorIO &, ErrorIllegalState &);
+
+ void closeChannels()
+ throw(ErrorIO &, ErrorIllegalState &);
+
+ Channel *openBasicChannelSync(ByteArray aid)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ Channel *openBasicChannelSync(unsigned char *aid, unsigned int length)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ Channel *openBasicChannelSync(ByteArray aid, void *caller)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ Channel *openBasicChannelSync(unsigned char *aid, unsigned int length, void *caller)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+
+ Channel *openLogicalChannelSync(ByteArray aid)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ Channel *openLogicalChannelSync(ByteArray aid, void *caller)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length, void *caller)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
friend class ServerReader;
friend class ServerResource;