Implement raising exceptions
authorWonkyu Kwon <wonkyu.kwon@samsung.com>
Fri, 8 Feb 2013 08:05:02 +0000 (17:05 +0900)
committerWonkyu Kwon <wonkyu.kwon@samsung.com>
Mon, 18 Feb 2013 02:00:36 +0000 (11:00 +0900)
 - Add exception classes
 - throw exception

Change-Id: Ic331e95057ea09bb3ffc8dd0e072c77f3461fe9d

30 files changed:
client/CMakeLists.txt
client/ClientChannel.cpp
client/ClientIPC.cpp
client/Reader.cpp
client/SEService.cpp
client/Session.cpp
client/include/ClientChannel.h
client/include/ClientDispatcher.h
client/include/ClientIPC.h
client/include/Reader.h
client/include/SEService.h
client/include/SEServiceListener.h
client/include/Session.h
client/include/smartcard-service.h [new file with mode: 0644]
common/Exception.cpp [new file with mode: 0644]
common/IPCHelper.cpp
common/ReaderHelper.cpp
common/SessionHelper.cpp
common/include/Channel.h
common/include/Exception.h [new file with mode: 0644]
common/include/ReaderHelper.h
common/include/SessionHelper.h
common/include/smartcard-types.h
server/ServerChannel.cpp
server/ServerReader.cpp
server/ServerSEService.cpp
server/ServerSession.cpp
server/include/ServerChannel.h
server/include/ServerReader.h
server/include/ServerSession.h

index 08f2b32..5171d07 100644 (file)
@@ -76,6 +76,7 @@ SET(EXPORT_HEADER
        include/Reader.h
        include/Session.h
        include/ClientChannel.h
+       include/smartcard-service.h
 #      include/
 )
 
index eb2d177..b5b69a0 100644 (file)
@@ -1,18 +1,18 @@
 /*
-* 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>
@@ -34,7 +34,9 @@
 
 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;
@@ -58,7 +60,7 @@ namespace smartcard_service_api
                closeSync();
        }
 
-       void ClientChannel::closeSync()
+       void ClientChannel::closeSync() throw(ErrorIO &, ErrorIllegalState &)
        {
 #ifdef CLIENT_IPC_THREAD
                if (isClosed() == false)
@@ -75,20 +77,30 @@ namespace smartcard_service_api
                                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;
                        }
@@ -140,6 +152,7 @@ namespace smartcard_service_api
        }
 
        int ClientChannel::transmitSync(ByteArray command, ByteArray &result)
+               throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
        {
                int rv = -1;
 
@@ -169,7 +182,7 @@ namespace smartcard_service_api
                                }
                                else
                                {
-                                       SCARD_DEBUG_ERR("clientIPC is null");
+                                       SCARD_DEBUG_ERR("timeout");
 
                                        rv = -1;
                                }
@@ -184,6 +197,7 @@ namespace smartcard_service_api
                else
                {
                        SCARD_DEBUG_ERR("unavailable channel");
+                       throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
                }
 
                return rv;
@@ -326,7 +340,8 @@ EXTERN_API int channel_close(channel_h handle, channel_close_cb callback, void *
        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;
 
@@ -344,12 +359,19 @@ EXTERN_API void channel_close_sync(channel_h handle)
 {
 #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;
 
@@ -361,12 +383,20 @@ EXTERN_API int channel_transmit_sync(channel_h handle, unsigned char *command, u
        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
@@ -407,7 +437,8 @@ EXTERN_API unsigned int channel_get_select_response_length(channel_h handle)
        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;
 
@@ -443,7 +474,5 @@ EXTERN_API session_h channel_get_session(channel_h handle)
 
 EXTERN_API void channel_destroy_instance(channel_h handle)
 {
-       CHANNEL_EXTERN_BEGIN;
-       delete channel;
-       CHANNEL_EXTERN_END;
+       /* do nothing */
 }
index e57ab6e..de28bba 100644 (file)
@@ -1,19 +1,18 @@
 /*
-* 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>
@@ -37,7 +36,7 @@ namespace smartcard_service_api
                _launch_daemon();
 #endif
 #ifdef SECURITY_SERVER
-               int length = 0;
+               int length;
 
                if ((length = security_server_get_cookie_size()) > 0)
                {
@@ -46,9 +45,10 @@ namespace smartcard_service_api
                        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);
 
@@ -83,10 +83,8 @@ namespace smartcard_service_api
 #ifdef USE_AUTOSTART
        void ClientIPC::_launch_daemon()
        {
-               DBusGConnection *connection = NULL;
-               DBusGProxy *proxy = NULL;
+               DBusGConnection *connection;
                GError *error = NULL;
-               gint result = 0;
 
                SCARD_BEGIN();
 
@@ -97,10 +95,16 @@ namespace smartcard_service_api
                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)
@@ -130,7 +134,7 @@ namespace smartcard_service_api
        bool ClientIPC::sendMessage(Message *msg)
        {
                ByteArray stream;
-               unsigned int length = 0;
+               unsigned int length;
 
                if (ipcSocket == -1)
                        return false;
@@ -142,23 +146,24 @@ namespace smartcard_service_api
 #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
index 248c895..921d5df 100644 (file)
@@ -28,7 +28,6 @@
 #include "ClientIPC.h"
 #include "Reader.h"
 #include "Session.h"
-#include "SignatureHelper.h"
 
 #ifndef EXTERN_API
 #define EXTERN_API __attribute__((visibility("default")))
@@ -36,7 +35,7 @@
 
 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;
 
@@ -61,10 +60,6 @@ namespace smartcard_service_api
 
                present = true;
 
-#if 0
-               getPackageCert();
-#endif
-
                SCARD_END();
        }
 
@@ -83,6 +78,7 @@ namespace smartcard_service_api
        }
 
        void Reader::closeSessions()
+               throw(ErrorIO &, ErrorIllegalState &)
        {
                size_t i;
 
@@ -92,12 +88,8 @@ namespace smartcard_service_api
                }
        }
 
-       void Reader::getPackageCert()
-       {
-               packageCert = SignatureHelper::getCertificationHash(getpid());
-       }
-
        SessionHelper *Reader::openSessionSync()
+               throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
        {
                openedSession = NULL;
 
@@ -110,7 +102,6 @@ namespace smartcard_service_api
                        /* 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 */
@@ -152,9 +143,6 @@ namespace smartcard_service_api
                        /* 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;
@@ -332,7 +320,4 @@ EXTERN_API void reader_close_sessions(reader_h handle)
 
 EXTERN_API void reader_destroy_instance(reader_h handle)
 {
-       READER_EXTERN_BEGIN;
-       delete reader;
-       READER_EXTERN_END;
 }
index 366e9dc..2cb27e8 100644 (file)
@@ -1,19 +1,18 @@
 /*
-* 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);
        }
 
@@ -77,7 +68,18 @@ namespace smartcard_service_api
        {
                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++)
                {
@@ -86,6 +88,18 @@ namespace smartcard_service_api
                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)
@@ -102,7 +116,7 @@ namespace smartcard_service_api
                        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)
                        {
@@ -124,7 +138,6 @@ namespace smartcard_service_api
                        }
 
                        /* send message to load se */
-                       int rv;
                        Message msg;
 
                        msg.message = Message::MSG_REQUEST_SHUTDOWN;
@@ -135,6 +148,8 @@ namespace smartcard_service_api
                        syncLock();
                        if (ClientIPC::getInstance().sendMessage(&msg) == true)
                        {
+                               int rv;
+
                                rv = waitTimedCondition(0);
 
                                if (rv == 0)
@@ -157,11 +172,11 @@ namespace smartcard_service_api
 #endif
        }
 
-       bool SEService::_initialize()
+       bool SEService::_initialize() throw(ErrorIO &)
        {
                bool result = false;
-               ClientIPC *clientIPC = NULL;
-               ClientDispatcher *clientDispatcher = NULL;
+               ClientIPC *clientIPC;
+               ClientDispatcher *clientDispatcher;
 
                SCARD_BEGIN();
 
@@ -199,7 +214,7 @@ namespace smartcard_service_api
                        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;
 
@@ -212,11 +227,13 @@ namespace smartcard_service_api
        }
 
        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;
@@ -226,11 +243,13 @@ namespace smartcard_service_api
        }
 
        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;
@@ -324,16 +343,12 @@ namespace smartcard_service_api
 
                                /* 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;
 
@@ -344,7 +359,8 @@ namespace smartcard_service_api
                                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);
@@ -356,7 +372,8 @@ namespace smartcard_service_api
 
                                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
                                {
@@ -382,7 +399,8 @@ namespace smartcard_service_api
 
                                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
                                {
@@ -407,7 +425,7 @@ namespace smartcard_service_api
                        }
                        break;
 
-               default:
+               default :
                        SCARD_DEBUG("unknown message [%s]", msg->toString());
                        break;
                }
@@ -436,14 +454,33 @@ using namespace smartcard_service_api;
 
 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;
 }
@@ -453,10 +490,12 @@ EXTERN_API int se_service_get_readers_count(se_service_h handle)
        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;
@@ -467,6 +506,7 @@ EXTERN_API bool se_service_get_readers(se_service_h handle, reader_h *readers, i
        bool result = false;
 
        SE_SERVICE_EXTERN_BEGIN;
+
        vector<ReaderHelper *> temp_readers;
        size_t i;
        int temp = 0;
@@ -482,6 +522,7 @@ EXTERN_API bool se_service_get_readers(se_service_h handle, reader_h *readers, i
                }
        }
        *count = temp;
+
        SE_SERVICE_EXTERN_END;
 
        return result;
@@ -492,7 +533,9 @@ EXTERN_API bool se_service_is_connected(se_service_h handle)
        bool result = false;
 
        SE_SERVICE_EXTERN_BEGIN;
+
        result = service->isConnected();
+
        SE_SERVICE_EXTERN_END;
 
        return result;
@@ -501,13 +544,17 @@ EXTERN_API bool se_service_is_connected(se_service_h handle)
 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;
 }
index 2213d83..5bbe5a4 100644 (file)
@@ -1,19 +1,18 @@
 /*
-* 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>
@@ -36,7 +35,8 @@
 
 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;
 
@@ -66,7 +66,7 @@ namespace smartcard_service_api
                channels.clear();
        }
 
-       void Session::closeChannels()
+       void Session::closeChannels() throw (ErrorIO &, ErrorIllegalState &)
        {
                size_t i;
 
@@ -76,45 +76,50 @@ namespace smartcard_service_api
                }
        }
 
-       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)
@@ -123,19 +128,27 @@ namespace smartcard_service_api
 
                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
@@ -146,7 +159,7 @@ namespace smartcard_service_api
                return result;
        }
 
-       void Session::closeSync()
+       void Session::closeSync() throw (ErrorIO &, ErrorIllegalState &)
        {
                Message msg;
                int rv;
@@ -282,6 +295,7 @@ namespace smartcard_service_api
        }
 
        Channel *Session::openChannelSync(int id, ByteArray aid)
+               throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
        {
                openedChannel = NULL;
 
@@ -356,11 +370,13 @@ namespace smartcard_service_api
        }
 
        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));
        }
@@ -370,17 +386,20 @@ namespace smartcard_service_api
                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));
        }
@@ -390,7 +409,8 @@ namespace smartcard_service_api
                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);
        }
@@ -420,7 +440,8 @@ namespace smartcard_service_api
                                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);
@@ -529,7 +550,7 @@ namespace smartcard_service_api
                        }
                        break;
 
-               default:
+               default :
                        SCARD_DEBUG("unknown message : %s", msg->toString());
                        break;
                }
@@ -558,7 +579,7 @@ EXTERN_API reader_h session_get_reader(session_h handle)
        reader_h reader = NULL;
 
        SESSION_EXTERN_BEGIN;
-       reader = session->getReader();
+               reader = session->getReader();
        SESSION_EXTERN_END;
 
        return reader;
@@ -569,7 +590,7 @@ EXTERN_API int session_get_atr(session_h handle, session_get_atr_cb callback, vo
        int result = -1;
 
        SESSION_EXTERN_BEGIN;
-       result = session->getATR((getATRCallback)callback, userData);
+               result = session->getATR((getATRCallback)callback, userData);
        SESSION_EXTERN_END;
 
        return result;
@@ -580,7 +601,7 @@ EXTERN_API int session_close(session_h handle, session_close_session_cb callback
        int result = -1;
 
        SESSION_EXTERN_BEGIN;
-       result = session->close((closeSessionCallback)callback, userData);
+               result = session->close((closeSessionCallback)callback, userData);
        SESSION_EXTERN_END;
 
        return result;
@@ -591,7 +612,7 @@ EXTERN_API bool session_is_closed(session_h handle)
        bool result = false;
 
        SESSION_EXTERN_BEGIN;
-       result = session->isClosed();
+               result = session->isClosed();
        SESSION_EXTERN_END;
 
        return result;
@@ -600,27 +621,29 @@ EXTERN_API bool session_is_closed(session_h handle)
 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;
@@ -631,7 +654,7 @@ EXTERN_API int session_get_channel_count(session_h handle, session_get_channel_c
        int result = -1;
 
        SESSION_EXTERN_BEGIN;
-       result = session->getChannelCount((getChannelCountCallback)callback, userData);
+               result = session->getChannelCount((getChannelCountCallback)callback, userData);
        SESSION_EXTERN_END;
 
        return result;
@@ -639,9 +662,6 @@ EXTERN_API int session_get_channel_count(session_h handle, session_get_channel_c
 
 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)
@@ -654,16 +674,16 @@ EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, un
                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;
@@ -673,7 +693,7 @@ EXTERN_API void session_close_sync(session_h handle)
 {
 #ifdef CLIENT_IPC_THREAD
        SESSION_EXTERN_BEGIN;
-       session->closeSync();
+               session->closeSync();
        SESSION_EXTERN_END;
 #endif
 }
@@ -684,7 +704,7 @@ EXTERN_API channel_h session_open_basic_channel_sync(session_h handle, unsigned
 
 #ifdef CLIENT_IPC_THREAD
        SESSION_EXTERN_BEGIN;
-       result = session->openBasicChannelSync(aid, length);
+               result = session->openBasicChannelSync(aid, length);
        SESSION_EXTERN_END;
 #endif
 
@@ -697,7 +717,7 @@ EXTERN_API channel_h session_open_logical_channel_sync(session_h handle, unsigne
 
 #ifdef CLIENT_IPC_THREAD
        SESSION_EXTERN_BEGIN;
-       result = session->openLogicalChannelSync(aid, length);
+               result = session->openLogicalChannelSync(aid, length);
        SESSION_EXTERN_END;
 #endif
 
@@ -710,7 +730,7 @@ EXTERN_API unsigned int session_get_channel_count_sync(session_h handle)
 
 #ifdef CLIENT_IPC_THREAD
        SESSION_EXTERN_BEGIN;
-       result = session->getChannelCountSync();
+               result = session->getChannelCountSync();
        SESSION_EXTERN_END;
 #endif
 
index 53866c0..a383925 100644 (file)
@@ -41,18 +41,22 @@ namespace smartcard_service_api
                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;
@@ -71,14 +75,17 @@ bool channel_is_basic_channel(channel_h handle);
 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
 }
index 54d306a..3305b28 100644 (file)
@@ -1,18 +1,18 @@
 /*
-* 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_
index 354cd5d..4dbbc76 100644 (file)
@@ -1,18 +1,18 @@
 /*
-* 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_
index 8916bce..d80d1ed 100644 (file)
@@ -1,19 +1,18 @@
 /*
-* 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_
@@ -37,30 +36,29 @@ namespace smartcard_service_api
        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 */
 
@@ -73,10 +71,11 @@ extern "C"
 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
 }
index 18bdd35..0070fe3 100644 (file)
@@ -1,19 +1,18 @@
 /*
-* 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_
@@ -49,23 +48,32 @@ namespace smartcard_service_api
                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 */
 
@@ -76,7 +84,8 @@ extern "C"
 #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);
index 1b8d4ea..9cfc01b 100644 (file)
@@ -1,18 +1,18 @@
 /*
-* 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_
@@ -30,10 +30,13 @@ namespace smartcard_service_api
        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_ */
index e4ec77f..ad91ce8 100644 (file)
@@ -1,19 +1,18 @@
 /*
-* 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_
@@ -44,16 +43,17 @@ namespace smartcard_service_api
                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);
@@ -64,13 +64,24 @@ namespace smartcard_service_api
                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;
@@ -88,14 +99,16 @@ extern "C"
 
 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);
diff --git a/client/include/smartcard-service.h b/client/include/smartcard-service.h
new file mode 100644 (file)
index 0000000..a79163d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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_ */
diff --git a/common/Exception.cpp b/common/Exception.cpp
new file mode 100644 (file)
index 0000000..53a6b0e
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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 */
index 3302fcb..48cf3ee 100644 (file)
@@ -160,7 +160,10 @@ 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");
@@ -313,6 +316,7 @@ ERROR :
                GIOCondition condition = (GIOCondition)(G_IO_ERR | G_IO_HUP | G_IO_IN);
 #endif
                int result = 0;
+               char err[200] = { 0, };
 
                SCARD_BEGIN();
 
@@ -329,7 +333,8 @@ ERROR :
                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;
                }
 
@@ -344,7 +349,8 @@ 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;
                }
 
@@ -352,7 +358,8 @@ 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;
                }
 
@@ -509,7 +516,8 @@ 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);
        }
index bf625e8..1583a9b 100644 (file)
@@ -1,19 +1,18 @@
 /*
-* 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 */
index dec604e..fde6560 100644 (file)
@@ -1,39 +1,31 @@
 /*
-* 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 */
index 5813165..38f694d 100644 (file)
@@ -25,6 +25,7 @@
 /* local header */
 #include "Synchronous.h"
 #include "ByteArray.h"
+#include "Exception.h"
 
 namespace smartcard_service_api
 {
@@ -40,29 +41,26 @@ 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 */
diff --git a/common/include/Exception.h b/common/include/Exception.h
new file mode 100644 (file)
index 0000000..2ff91d8
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * 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_ */
index 84e5e7a..4e49116 100644 (file)
@@ -44,18 +44,19 @@ namespace smartcard_service_api
                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 */
index 8a9e0f1..8599612 100644 (file)
@@ -1,19 +1,18 @@
 /*
-* 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_
@@ -51,10 +50,11 @@ namespace smartcard_service_api
                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;
@@ -64,13 +64,23 @@ namespace smartcard_service_api
                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 */
index 055756d..6b03bd0 100644 (file)
@@ -1,19 +1,18 @@
 /*
-* 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;
@@ -64,4 +68,8 @@ typedef void (*session_get_channel_count_cb)(unsigned count, int error, void *us
 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_ */
index 2bac293..2836e13 100644 (file)
@@ -41,7 +41,7 @@ namespace smartcard_service_api
                }
        }
 
-       void ServerChannel::closeSync()
+       void ServerChannel::closeSync() throw(ErrorIO &, ErrorIllegalState &)
        {
                ByteArray command, result;
                APDUHelper apdu;
@@ -75,7 +75,7 @@ namespace smartcard_service_api
                channelNum = -1;
        }
 
-       int ServerChannel::transmitSync(ByteArray command, ByteArray &result)
+       int ServerChannel::transmitSync(ByteArray command, ByteArray &result) throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
        {
                APDUCommand helper;
 
index 2aace13..fa51f1a 100644 (file)
@@ -1,18 +1,18 @@
 /*
-* 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>
@@ -30,7 +30,8 @@
 
 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;
 
@@ -76,6 +77,7 @@ namespace smartcard_service_api
        }
 
        void ServerReader::closeSessions()
+               throw(ErrorIO &, ErrorIllegalState &)
        {
                size_t i;
 
@@ -108,14 +110,15 @@ namespace smartcard_service_api
        }
 
        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;
 
index 4b3b5bc..3ab859c 100644 (file)
@@ -1,18 +1,18 @@
 /*
-* 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 */
@@ -345,47 +345,45 @@ namespace smartcard_service_api
                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 :
index da1e044..c9bc7f3 100644 (file)
@@ -54,12 +54,14 @@ namespace smartcard_service_api
        }
 
        ByteArray ServerSession::getATRSync()
+               throw(ErrorIO &, ErrorIllegalState &)
        {
                /* call get atr to terminal */
                return atr;
        }
 
        void ServerSession::closeSync()
+               throw(ErrorIO &, ErrorIllegalState &)
        {
                if (isClosed() == false)
                {
@@ -69,6 +71,7 @@ namespace smartcard_service_api
        }
 
        void ServerSession::closeChannels()
+               throw(ErrorIO &, ErrorIllegalState &)
        {
                size_t i;
 
@@ -82,11 +85,13 @@ namespace smartcard_service_api
        }
 
        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
@@ -147,21 +152,25 @@ namespace smartcard_service_api
        }
 
        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
@@ -247,11 +256,13 @@ namespace smartcard_service_api
        }
 
        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);
        }
index bcb8bd6..b777891 100644 (file)
@@ -41,8 +41,10 @@ namespace smartcard_service_api
                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();
index 523300f..709282e 100644 (file)
@@ -44,19 +44,21 @@ namespace smartcard_service_api
                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;
        };
index 45b6368..1dd3fca 100644 (file)
@@ -55,20 +55,31 @@ namespace smartcard_service_api
        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;