Apply tizen 2.4 smartcard-service 05/41905/1 accepted/tizen/mobile/20150619.083137 accepted/tizen/tv/20150619.083147 accepted/tizen/wearable/20150619.083201 submit/tizen/20150619.055208
authorJihoon Jung <jh8801.jung@samsung.com>
Fri, 19 Jun 2015 05:46:00 +0000 (14:46 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Fri, 19 Jun 2015 05:46:48 +0000 (14:46 +0900)
Signed-off-by: Ji-hoon Jung <jh8801.jung@samsung.com>
Change-Id: I5a74d30399eb77fb1b6426c373c437b6ca1d7d94

133 files changed:
CMakeLists.txt
client/CMakeLists.txt
client/ClientChannel.cpp
client/ClientGDBus.cpp
client/Reader.cpp
client/SEService.cpp
client/Session.cpp
client/include/ClientChannel.h
client/include/ClientGDBus.h
client/include/Reader.h
client/include/SEService.h
client/include/SEServiceListener.h
client/include/Session.h
client/include/smartcard-service.h
client/smartcard-service.pc [new file with mode: 0644]
client/smartcard-service.pc.in [deleted file]
common/APDUHelper.cpp
common/AccessCondition.cpp
common/AccessControlList.cpp
common/ByteArray.cpp
common/CMakeLists.txt
common/EFDIR.cpp
common/FCI.cpp
common/FileObject.cpp
common/GPACE.cpp
common/GPARAACL.cpp
common/GPARAM.cpp
common/GPARFACL.cpp
common/ISO7816BERTLV.cpp
common/OpensslHelper.cpp
common/PKCS15.cpp
common/PKCS15CDF.cpp [new file with mode: 0644]
common/PKCS15DODF.cpp
common/PKCS15ODF.cpp
common/PKCS15OID.cpp
common/PKCS15Object.cpp
common/PKCS15Path.cpp
common/PKCS15TokenInfo.cpp
common/Serializable.cpp
common/SignatureHelper.cpp
common/include/APDUHelper.h
common/include/AccessCondition.h
common/include/AccessControlList.h
common/include/ByteArray.h
common/include/Channel.h
common/include/Debug.h
common/include/EFDIR.h
common/include/Exception.h
common/include/FCI.h
common/include/FileObject.h
common/include/GDBusHelper.h
common/include/GPACE.h
common/include/GPARAACL.h
common/include/GPARAM.h
common/include/GPARFACL.h
common/include/ISO7816BERTLV.h
common/include/Lock.h
common/include/NumberStream.h
common/include/OpensslHelper.h
common/include/PKCS15.h
common/include/PKCS15CDF.h [new file with mode: 0644]
common/include/PKCS15DODF.h
common/include/PKCS15ODF.h
common/include/PKCS15OID.h
common/include/PKCS15Object.h
common/include/PKCS15Path.h
common/include/PKCS15TokenInfo.h
common/include/ProviderHelper.h
common/include/ReaderHelper.h
common/include/SEServiceHelper.h
common/include/Serializable.h
common/include/SessionHelper.h
common/include/SignatureHelper.h
common/include/Synchronous.h
common/include/Terminal.h
common/include/TerminalInterface.h
common/smartcard-service-common.pc [new file with mode: 0644]
common/smartcard-service-common.pc.in [deleted file]
common/smartcard-service-gdbus.xml
common/smartcard-service.xml [deleted file]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/smartcard-service-common-dev.dirs [new file with mode: 0644]
debian/smartcard-service-common-dev.install [new file with mode: 0644]
debian/smartcard-service-common.dirs [new file with mode: 0644]
debian/smartcard-service-common.install [new file with mode: 0644]
debian/smartcard-service-dev.dirs [new file with mode: 0644]
debian/smartcard-service-dev.install [new file with mode: 0644]
debian/smartcard-service-server.dirs [new file with mode: 0644]
debian/smartcard-service-server.init [new file with mode: 0755]
debian/smartcard-service-server.install [new file with mode: 0644]
debian/smartcard-service.dirs [new file with mode: 0644]
debian/smartcard-service.install [new file with mode: 0644]
packaging/smartcard-service [new file with mode: 0644]
packaging/smartcard-service-common [new file with mode: 0644]
packaging/smartcard-service-common-devel.manifest [deleted file]
packaging/smartcard-service-common.manifest [deleted file]
packaging/smartcard-service-devel.manifest [deleted file]
packaging/smartcard-service-server [new file with mode: 0644]
packaging/smartcard-service-server.manifest [deleted file]
packaging/smartcard-service.changes [deleted file]
packaging/smartcard-service.manifest [deleted file]
packaging/smartcard-service.spec
server/CMakeLists.txt
server/ClientInstance.cpp
server/ServerChannel.cpp
server/ServerGDBus.cpp
server/ServerResource.cpp
server/ServerSEService.cpp
server/ServerSession.cpp
server/include/ClientInstance.h
server/include/ServerChannel.h
server/include/ServerGDBus.h
server/include/ServerResource.h
server/include/ServerSEService.h
server/include/ServerSession.h
server/include/SmartcardDbus.h
server/org.tizen.SmartcardService.service [new file with mode: 0644]
server/org.tizen.smartcard_service.service [deleted file]
server/private/AccessControl.cpp [new file with mode: 0644]
server/private/PKCS15CDFACL.cpp [new file with mode: 0644]
server/private/PKCS15CDFACL.h [new file with mode: 0644]
server/private/access-control-gdbus.xml [new file with mode: 0755]
server/smartcard-daemon.cpp
server/smartcard-service-server.xml
smartcard-service-common-devel.manifest [new file with mode: 0644]
smartcard-service-common.manifest [new file with mode: 0644]
smartcard-service-devel.manifest [new file with mode: 0644]
smartcard-service-server.manifest [new file with mode: 0644]
smartcard-service.manifest [new file with mode: 0644]
test-client/CMakeLists.txt

index 6e59a80..ee5ffee 100644 (file)
@@ -1,44 +1,31 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(smartcard-service CXX C)
 
 MESSAGE("build smartcard-service")
 
-IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
-       SET(CMAKE_BUILD_TYPE "Release")
-ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+SET(CMAKE_VERBOSE_MAKEFILE OFF)
 
-MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
-
-INCLUDE(FindPkgConfig)
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
-
-SET(CMAKE_SHARED_LINKER_FLAGS " -Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
-SET(CMAKE_EXE_LINKER_FLAGS " -Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
-
-FIND_PROGRAM(UNAME NAMES uname)
-EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
-IF("${ARCH}" MATCHES "^arm.*")
-       ADD_DEFINITIONS("-DTARGET")
-       MESSAGE("add -DTARGET")
-       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mabi=aapcs-linux -fno-common")
-ENDIF("${ARCH}" MATCHES "^arm.*")
-
-# names
-SET(CLIENT_LIB ${PROJECT_NAME})
-SET(COMMON_LIB "smartcard-service-common")
-SET(DAEMON "smartcard-daemon")
-
-# For *.pc files
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+# apply smack
+ADD_DEFINITIONS("-DUSER_SPACE_SMACK")
 
-# Defines
 IF(DEFINED USE_AUTOSTART)
        ADD_DEFINITIONS("-DUSE_AUTOSTART")
 ENDIF()
 
-# apply smack
-##ADD_DEFINITIONS("-DUSER_SPACE_SMACK")
+# make string from entire content of byte array
+ADD_DEFINITIONS("-DTO_STRING_ALL")
+
+SET(GC_SECTIONS_FLAGS "-fdata-sections -ffunction-sections -Wl,--gc-sections")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GC_SECTIONS_FLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GC_SECTIONS_FLAGS}")
+
+FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
+EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
+       " \\
+       --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service-gdbus \\
+       --c-namespace SmartcardService\\
+       --interface-prefix org.tizen.SmartcardService. \\
+       ${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service-gdbus.xml \\
+       ")
 
 ADD_SUBDIRECTORY(common)
 ADD_SUBDIRECTORY(client)
index d00cf10..e0fb961 100644 (file)
@@ -1,24 +1,67 @@
-INCLUDE_DIRECTORIES(include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/server/include)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(smartcard-service CXX)
+
+SET(LIB_NAME "smartcard-service")
+SET(VERSION_MAJOR 1)
+SET(VERSION ${VERSION_MAJOR}.0.0)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../server/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SRCS)
 
-pkg_check_modules(pkgs_client REQUIRED  glib-2.0 dlog)
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+# pkg config
+INCLUDE(FindPkgConfig)
+
+SET(PKG_MODULE glib-2.0 dlog)
+
+pkg_check_modules(pkgs_client REQUIRED ${PKG_MODULE})
+
+MESSAGE("${LIB_NAME} ld flag : ${pkgs_client_LDFLAGS}")
+
 FOREACH(flag ${pkgs_client_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
        SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
 ENDFOREACH(flag)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -finstrument-functions -fPIC")
+#SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+#SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -finstrument-functions -std=c++0x")
+#SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+#SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+MESSAGE("CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
 ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_CLIENT\"")
 
-ADD_LIBRARY(${CLIENT_LIB} SHARED ${SRCS})
-SET_TARGET_PROPERTIES(${CLIENT_LIB} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER})
-TARGET_LINK_LIBRARIES(${CLIENT_LIB} ${pkgs_client_LDFLAGS})
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
 
-SET(EXPORT_HEADER
+SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${VERSION})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_client_LDFLAGS})
+
+SET(EXPORT_HEADER 
        ../common/include/smartcard-types.h
        ../common/include/ByteArray.h
        ../common/include/Debug.h
@@ -41,11 +84,8 @@ SET(EXPORT_HEADER
 #      include/
 )
 
-CONFIGURE_FILE(${CLIENT_LIB}.pc.in ${CLIENT_LIB}.pc @ONLY)
-
-INSTALL(FILES ${CLIENT_LIB}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(TARGETS ${CLIENT_LIB} DESTINATION ${LIB_INSTALL_DIR})
-
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
 FOREACH(hfile ${EXPORT_HEADER})
-       INSTALL(FILES ${hfile} DESTINATION include/${CLIENT_LIB})
+       INSTALL(FILES ${hfile} DESTINATION include/${LIB_NAME})
 ENDFOREACH(hfile)
index 7ecab0f..4102925 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
 #include <glib.h>
 
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "ClientChannel.h"
 #include "ReaderHelper.h"
@@ -167,6 +171,7 @@ namespace smartcard_service_api
                                gint ret;
                                GError *error = NULL;
 
+
                                if (proxy == NULL) {
                                        _ERR("dbus proxy is not initialized yet");
                                        throw ErrorIllegalState(SCARD_ERROR_NOT_INITIALIZED);
@@ -177,7 +182,9 @@ namespace smartcard_service_api
                                        GPOINTER_TO_UINT(context),
                                        GPOINTER_TO_UINT(handle),
                                        &ret, NULL, &error) == true) {
-                                       if (ret != SCARD_ERROR_OK) {
+                                       if (ret == SCARD_ERROR_OK) {
+                                               channelNum = -1;
+                                       } else {
                                                _ERR("smartcard_service_channel_call_close_channel_sync failed, [%d]", ret);
                                                THROW_ERROR(ret);
                                        }
@@ -246,13 +253,14 @@ namespace smartcard_service_api
                                NULL, &error) == true) {
 
                                if (rv == SCARD_ERROR_OK) {
-                                       GDBusHelper::convertVariantToByteArray(var_response, result);
+                                       GDBusHelper::convertVariantToByteArray(var_response, transmitResponse);
+                                       result = transmitResponse;
                                } else {
-                                       _ERR("smartcard_service_session_call_get_atr_sync failed, [%d]", rv);
+                                       _ERR("smartcard_service_session_call_transmit failed, [%d]", rv);
                                        THROW_ERROR(rv);
                                }
                        } else {
-                               _ERR("smartcard_service_session_call_get_atr_sync failed, [%s]", error->message);
+                               _ERR("smartcard_service_session_call_transmit failed, [%s]", error->message);
                                g_error_free(error);
 
                                throw ErrorIO(SCARD_ERROR_IPC_FAILED);
@@ -316,94 +324,258 @@ namespace smartcard_service_api
 
 using namespace smartcard_service_api;
 
-EXTERN_API int channel_close(channel_h handle, channel_close_cb callback, void *userParam)
+EXTERN_API int channel_close_sync(channel_h handle)
 {
-       int result = -1;
+       int result = SCARD_ERROR_OK;
 
        CHANNEL_EXTERN_BEGIN;
-       result = channel->close((closeChannelCallback)callback, userParam);
+
+       try
+       {
+               channel->closeSync();
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+       }
+
        CHANNEL_EXTERN_END;
 
        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_sync(channel_h handle, unsigned char *command,
+       unsigned int cmd_len, unsigned char **response, unsigned int *resp_len)
 {
-       int result = -1;
+       int result = SCARD_ERROR_OK;
+
+       if (command == NULL || cmd_len == 0 || response == NULL || resp_len == NULL)
+               return SCARD_ERROR_UNKNOWN;
 
        CHANNEL_EXTERN_BEGIN;
-       ByteArray temp;
 
-       temp.assign(command, length);
-       result = channel->transmit(temp, (transmitCallback)callback, userParam);
+       try
+       {
+               ByteArray temp, resp;
+
+               temp.assign(command, cmd_len);
+               channel->transmitSync(temp, resp);
+
+               if (resp.size() > 0)
+               {
+                       *response = (unsigned char *)calloc(resp.size(), sizeof(unsigned char));
+                       *resp_len = resp.size();
+                       memcpy(*response, resp.getBuffer(), *resp_len);
+               }
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+               *resp_len = 0;
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+               *resp_len = 0;
+       }
+
        CHANNEL_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API void channel_close_sync(channel_h handle)
+EXTERN_API int channel_is_basic_channel(channel_h handle, bool* is_basic_channel)
 {
+       int result = SCARD_ERROR_OK;
+
        CHANNEL_EXTERN_BEGIN;
+
        try
        {
-               channel->closeSync();
+               *is_basic_channel = channel->isBasicChannel();
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
        }
        catch (...)
        {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
        }
+
        CHANNEL_EXTERN_END;
+
+       return result;
 }
 
-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_is_closed(channel_h handle, bool* is_closed)
 {
-       int result = -1;
+       int result = SCARD_ERROR_OK;
 
-       if (command == NULL || cmd_len == 0 || response == NULL || resp_len == NULL)
-               return result;
+       CHANNEL_EXTERN_BEGIN;
+
+       try
+       {
+               *is_closed = channel->isClosed();
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+       }
+
+       CHANNEL_EXTERN_END;
+
+       return result;
+}
+
+EXTERN_API int channel_get_select_response(channel_h handle,
+       unsigned char **buffer, size_t *length)
+{
+       int result = SCARD_ERROR_OK;
 
        CHANNEL_EXTERN_BEGIN;
-       ByteArray temp, resp;
 
-       temp.assign(command, cmd_len);
+       try
+       {
+               ByteArray response = channel->getSelectResponse();
+               uint8_t* get_buffer = response.getBuffer();
+
+               *length = response.size();
+
+               if (*length > 0)
+               {
+                       *buffer = (unsigned char *)calloc(*length, sizeof(unsigned char));
+                       if(*buffer == NULL || get_buffer == NULL)
+                       {
+                               *length = 0;
+                               return SCARD_ERROR_NOT_ENOUGH_RESOURCE;
+                       }
+
+                       memcpy(*buffer, get_buffer, *length);
+               }
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+               *length = 0;
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+               *length = 0;
+       }
+
+       CHANNEL_EXTERN_END;
+
+       return result;
+}
+
+EXTERN_API int channel_get_transmit_response(channel_h handle,
+       unsigned char **buffer, size_t *length)
+{
+       int result = SCARD_ERROR_OK;
+
+       CHANNEL_EXTERN_BEGIN;
 
        try
        {
-               result = channel->transmitSync(temp, resp);
-               if (resp.size() > 0)
+               ByteArray response;
+
+               response = channel->getTransmitResponse();
+
+               *length = response.size();
+
+               if (*length > 0)
                {
-                       *resp_len = resp.size();
-                       *response = (unsigned char *)calloc(1, *resp_len);
-                       memcpy(*response, resp.getBuffer(), *resp_len);
+                       *buffer = (unsigned char *)calloc(*length, sizeof(unsigned char));
+                       memcpy(*buffer, response.getBuffer(), *length);
                }
        }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+               *length = 0;
+       }
        catch (...)
        {
-               result = -1;
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+               *length = 0;
        }
+
        CHANNEL_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API bool channel_is_basic_channel(channel_h handle)
+EXTERN_API int channel_get_session(channel_h handle, int *session_handle)
 {
-       bool result = false;
+       int result = SCARD_ERROR_OK;
+       session_h session = NULL;
 
        CHANNEL_EXTERN_BEGIN;
-       result = channel->isBasicChannel();
+
+       try
+       {
+               session = channel->getSession();
+               //*session_handle = (int)session;
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+       }
+
        CHANNEL_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API bool channel_is_closed(channel_h handle)
+EXTERN_API int channel_select_next(channel_h handle, bool *pSuccess)
 {
-       bool result = false;
+       int result = SCARD_ERROR_OK;
 
        CHANNEL_EXTERN_BEGIN;
-       result = channel->isClosed();
+
+       try
+       {
+               *pSuccess = channel->selectNext();
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+       }
+
        CHANNEL_EXTERN_END;
 
        return result;
@@ -420,39 +592,30 @@ 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 int channel_close(channel_h handle, channel_close_cb callback, void *userParam)
 {
-       bool result = false;
-
-       if (buffer == NULL || length == 0)
-       {
-               return result;
-       }
+       int result = -1;
 
        CHANNEL_EXTERN_BEGIN;
-       ByteArray response;
-
-       response = channel->getSelectResponse();
-       if (response.size() > 0)
-       {
-               memcpy(buffer, response.getBuffer(), MIN(length, response.size()));
-               result = true;
-       }
+       result = channel->close((closeChannelCallback)callback, userParam);
        CHANNEL_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API session_h channel_get_session(channel_h handle)
+EXTERN_API int channel_transmit(channel_h handle, unsigned char *command,
+       unsigned int length, channel_transmit_cb callback, void *userParam)
 {
-       session_h session = NULL;
+       int result = -1;
 
        CHANNEL_EXTERN_BEGIN;
-       session = channel->getSession();
+       ByteArray temp;
+
+       temp.assign(command, length);
+       result = channel->transmit(temp, (transmitCallback)callback, userParam);
        CHANNEL_EXTERN_END;
 
-       return session;
+       return result;
 }
 
 EXTERN_API void channel_destroy_instance(channel_h handle)
index f2c572e..eb1eb2f 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <glib.h>
 
+/* SLP library header */
+
+/* local header */
 #include "smartcard-types.h"
 #include "Debug.h"
 #include "ByteArray.h"
 
 using namespace std;
 
+/* below functions will be called when dlopen or dlclose is called */
+void __attribute__ ((constructor)) lib_init()
+{
+       g_type_init();
+}
+
+void __attribute__ ((destructor)) lib_fini()
+{
+}
+
 namespace smartcard_service_api
 {
 } /* namespace smartcard_service_api */
index 1b1d0e5..2a9cac1 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "Reader.h"
 #include "Session.h"
@@ -235,66 +239,130 @@ namespace smartcard_service_api
 
 using namespace smartcard_service_api;
 
-EXTERN_API const char *reader_get_name(reader_h handle)
+EXTERN_API int reader_get_name(reader_h handle, char** reader_name)
 {
-       const char *name = NULL;
+       int result = SCARD_ERROR_OK;
 
        READER_EXTERN_BEGIN;
-       name = reader->getName();
+
+       try
+       {
+               *reader_name = g_strdup(reader->getName());
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+       }
+
        READER_EXTERN_END;
 
-       return name;
+       return result;
 }
 
-EXTERN_API se_service_h reader_get_se_service(reader_h handle)
+EXTERN_API  int reader_is_secure_element_present(reader_h handle, bool* is_present)
 {
-       se_service_h service = NULL;
+       int result = SCARD_ERROR_OK;
 
        READER_EXTERN_BEGIN;
-       service = (se_service_h)reader->getSEService();
+
+       try
+       {
+               *is_present = reader->isSecureElementPresent();
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+       }
+
        READER_EXTERN_END;
 
-       return service;
+       return result;
 }
 
-EXTERN_API bool reader_is_secure_element_present(reader_h handle)
+EXTERN_API int reader_open_session_sync(reader_h handle, int *session_handle)
 {
-       bool result = false;
+       session_h session;
+       int result = SCARD_ERROR_OK;
 
        READER_EXTERN_BEGIN;
-       result = reader->isSecureElementPresent();
+
+       try
+       {
+               session = (session_h)reader->openSessionSync();
+               //*session_handle = (int)session;
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+               *session_handle = 0;
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+               *session_handle = 0;
+       }
+
        READER_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API int reader_open_session(reader_h handle, reader_open_session_cb callback, void *userData)
+EXTERN_API int reader_close_sessions(reader_h handle)
 {
-       int result = -1;
+       int result = SCARD_ERROR_OK;
 
        READER_EXTERN_BEGIN;
-       result = reader->openSession((openSessionCallback)callback, userData);
+
+       try
+       {
+               reader->closeSessions();
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+       }
+
        READER_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API session_h reader_open_session_sync(reader_h handle)
+
+EXTERN_API se_service_h reader_get_se_service(reader_h handle)
 {
-       session_h result = NULL;
+       se_service_h service = NULL;
 
        READER_EXTERN_BEGIN;
-       result = (session_h)reader->openSessionSync();
+       service = (se_service_h)reader->getSEService();
        READER_EXTERN_END;
 
-       return result;
+       return service;
 }
 
-EXTERN_API void reader_close_sessions(reader_h handle)
+EXTERN_API int reader_open_session(reader_h handle, reader_open_session_cb callback, void *userData)
 {
+       int result = -1;
+
        READER_EXTERN_BEGIN;
-       reader->closeSessions();
+       result = reader->openSession((openSessionCallback)callback, userData);
        READER_EXTERN_END;
+
+       return result;
 }
 
 EXTERN_API void reader_destroy_instance(reader_h handle)
index 60a6336..3ebee77 100644 (file)
 #include <glib.h>
 #include <glib-object.h>
 
-/* SLP library header */
-
 /* local header */
 #include "Debug.h"
 #include "SEService.h"
+#include "ClientChannel.h"
 #include "Reader.h"
 #include "ClientGDBus.h"
 
 #endif
 
 #define SHUTDOWN_DELAY         500000 /* us */
+#define VERSION "3.0"
 
 namespace smartcard_service_api
 {
        SEService::SEService() : SEServiceHelper(),
-               handle(-1), context(NULL), handler(NULL), listener(NULL)
+               handle(-1), context(NULL), handler(NULL), listener(NULL),
+               version(VERSION)
        {
                proxy = NULL;
        }
@@ -45,7 +46,7 @@ namespace smartcard_service_api
        SEService::SEService(void *user_data, serviceConnected handler)
                throw(ErrorIO &, ErrorIllegalParameter &) :
                SEServiceHelper(), handle(-1),
-               listener(NULL)
+               listener(NULL), version(VERSION)
        {
                initialize(user_data, handler);
        }
@@ -53,33 +54,42 @@ namespace smartcard_service_api
        SEService::SEService(void *user_data, SEServiceListener *listener)
                throw(ErrorIO &, ErrorIllegalParameter &) :
                SEServiceHelper(), handle(-1),
-               handler(NULL)
+               handler(NULL), version(VERSION)
        {
                initialize(user_data, listener);
        }
 
-       SEService::~SEService()
+       SEService::SEService(void *user_data)
+               throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &) :
+               SEServiceHelper(), handle(-1),
+               handler(NULL), version(VERSION)
        {
-               uint32_t i;
+               initializeSync(user_data);
+       }
 
+       SEService::~SEService()
+       {
                try
                {
+                       size_t i;
+
                        shutdownSync();
+
+                       for (i = 0; i < readers.size(); i++)
+                       {
+                               delete (Reader *)readers[i];
+                       }
+
+                       readers.clear();
                }
-               catch(ExceptionBase &e)
+               catch (ExceptionBase &e)
                {
                        _ERR("EXCEPTION : %s", e.what());
                }
-               catch(...)
+               catch (...)
                {
                        _ERR("EXCEPTION!!!");
                }
-
-               for (i = 0; i < readers.size(); i++)
-               {
-                       delete (Reader *)readers[i];
-               }
-               readers.clear();
        }
 
        SEService *SEService::createInstance(void *user_data,
@@ -293,6 +303,64 @@ namespace smartcard_service_api
                return result;
        }
 
+       int SEService::_initialize_sync() throw(ErrorIO &, ExceptionBase &)
+       {
+               gint result;
+               guint handle;
+               GError *error = NULL;
+               GVariant *readers = NULL;
+               SEService *service = (SEService *)this;
+
+               _BEGIN();
+
+               /* init default context */
+
+               proxy = smartcard_service_se_service_proxy_new_for_bus_sync(
+                       G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
+                       "org.tizen.SmartcardService",
+                       "/org/tizen/SmartcardService/SeService",
+                       NULL, &error);
+               if (proxy == NULL)
+               {
+                       _ERR("Can not create proxy : %s", error->message);
+                       g_error_free(error);
+                       return false;
+               }
+
+               g_signal_connect(proxy, "reader-inserted",
+                               G_CALLBACK(&SEService::reader_inserted), this);
+
+               g_signal_connect(proxy, "reader-removed",
+                               G_CALLBACK(&SEService::reader_removed), this);
+
+               /* request reader */
+               if(smartcard_service_se_service_call_se_service_sync(
+                       (SmartcardServiceSeService *)proxy, &result, &handle, &readers, NULL, &error) == true)
+               {
+                       if (result == SCARD_ERROR_OK)
+                       {
+                               service->connected = true;
+                               service->handle = handle;
+                               service->parseReaderInformation(readers);
+                       }
+                       else
+                       {
+                               throw ExceptionBase(result);
+                       }
+               }
+               else
+               {
+                       _ERR("smartcard_service_se_service_call_se_service failed, [%s]", error->message);
+                       g_error_free(error);
+
+                       result = SCARD_ERROR_IPC_FAILED;
+               }
+
+               _END();
+
+               return result;
+       }
+
        bool SEService::initialize(void *context, serviceConnected handler)
                throw(ErrorIO &, ErrorIllegalParameter &)
        {
@@ -321,20 +389,29 @@ namespace smartcard_service_api
                return _initialize();
        }
 
+       bool SEService::initializeSync(void *context)
+               throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &)
+       {
+               this->context = context;
+
+               _initialize_sync();
+               return true;
+       }
+
        bool SEService::parseReaderInformation(GVariant *variant)
        {
                Reader *reader = NULL;
 
                GVariantIter *iter;
-               gsize count;
                guint handle;
                gchar *name;
 
                g_variant_get(variant, "a(us)", &iter);
 
-               count = g_variant_iter_n_children(iter);
                while (g_variant_iter_loop(iter, "(us)", &handle, &name) == true)
                {
+                       SECURE_LOGD("Reader : name [%s], handle [%08x]", name, handle);
+
                        /* add readers */
                        reader = new Reader((void *)this->handle, name, GUINT_TO_POINTER(handle));
                        if (reader == NULL)
@@ -360,20 +437,36 @@ namespace smartcard_service_api
                void *handle = NULL;
                Reader *reader = NULL;
                char name[100];
+               const uint8_t *buffer = NULL;
+
 
                for (i = 0; i < count && offset < data.size(); i++)
                {
                        memset(name, 0, sizeof(name));
 
-                       memcpy(&len, data.getBuffer(offset), sizeof(len));
+                       buffer = data.getBuffer(offset);
+                       if(buffer == NULL)
+                               continue;
+
+                       memcpy(&len, buffer, sizeof(len));
                        offset += sizeof(len);
 
-                       memcpy(name, data.getBuffer(offset), len);
+                       buffer = data.getBuffer(offset);
+                       if(buffer == NULL)
+                               return false;
+
+                       memcpy(name, buffer, len);
                        offset += len;
 
-                       memcpy(&handle, data.getBuffer(offset), sizeof(handle));
+                       buffer = data.getBuffer(offset);
+                       if(buffer == NULL)
+                               return false;
+
+                       memcpy(&handle, buffer, sizeof(handle));
                        offset += sizeof(handle);
 
+                       SECURE_LOGD("Reader [%d] : name [%s], handle [%p]", i, name, handle);
+
                        /* add readers */
                        reader = new Reader(context, name, handle);
                        if (reader == NULL)
@@ -404,7 +497,8 @@ namespace smartcard_service_api
 
 using namespace smartcard_service_api;
 
-EXTERN_API se_service_h se_service_create_instance(void *user_data, se_service_connected_cb callback)
+EXTERN_API se_service_h se_service_create_instance(void *user_data,
+       se_service_connected_cb callback)
 {
        SEService *service;
 
@@ -420,8 +514,9 @@ EXTERN_API se_service_h se_service_create_instance(void *user_data, se_service_c
        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;
 
@@ -437,6 +532,46 @@ EXTERN_API se_service_h se_service_create_instance_with_event_callback(void *use
        return (se_service_h)service;
 }
 
+EXTERN_API se_service_h se_service_create_instance_sync(void *user_data,
+       int *result)
+{
+       SEService *service;
+
+       try
+       {
+               service = new SEService(user_data);
+       }
+       catch (ExceptionBase &e)
+       {
+               *result = e.getErrorCode();
+               service = NULL;
+       }
+       catch (...)
+       {
+               *result = SCARD_ERROR_UNKNOWN;
+               service = NULL;
+       }
+
+       return (se_service_h)service;
+}
+
+EXTERN_API int se_service_get_version(se_service_h handle, char **version_str)
+{
+       int ret = 0;
+
+       if (version_str == NULL) {
+               return SCARD_ERROR_ILLEGAL_PARAM;
+       }
+
+       SE_SERVICE_EXTERN_BEGIN;
+
+       *version_str = g_strdup(service->getVersion());
+
+       SE_SERVICE_EXTERN_END;
+
+       return ret;
+}
+
 EXTERN_API int se_service_get_readers_count(se_service_h handle)
 {
        int count = 0;
@@ -453,9 +588,9 @@ EXTERN_API int se_service_get_readers_count(se_service_h handle)
        return count;
 }
 
-EXTERN_API bool se_service_get_readers(se_service_h handle, reader_h *readers, int *count)
+EXTERN_API int se_service_get_readers(se_service_h handle, int **readers, int *count)
 {
-       bool result = false;
+       int result = 0;
 
        SE_SERVICE_EXTERN_BEGIN;
 
@@ -464,16 +599,26 @@ EXTERN_API bool se_service_get_readers(se_service_h handle, reader_h *readers, i
        int temp = 0;
 
        temp_readers = service->getReaders();
-
-       for (i = 0; i < temp_readers.size() && i < (size_t)*count; i++)
+       if(temp_readers.size() > 0)
        {
-               if (temp_readers[i]->isSecureElementPresent())
+               *readers = (int *)calloc(temp_readers.size(), sizeof(int));
+
+               if(*readers == NULL)
+               {
+                       *count = 0;
+                       return SCARD_ERROR_NOT_ENOUGH_RESOURCE;
+               }
+
+               for (i = 0; i < temp_readers.size(); i++)
                {
-                       readers[i] = (reader_h)temp_readers[i];
-                       temp++;
+                       if (temp_readers[i]->isSecureElementPresent())
+                       {
+                               //(*readers)[i] = (int)temp_readers[i];
+                               temp++;
+                       }
                }
+               *count = temp;
        }
-       *count = temp;
 
        SE_SERVICE_EXTERN_END;
 
@@ -502,11 +647,15 @@ EXTERN_API void se_service_shutdown(se_service_h handle)
        SE_SERVICE_EXTERN_END;
 }
 
-EXTERN_API void se_service_destroy_instance(se_service_h handle)
+EXTERN_API int se_service_destroy_instance(se_service_h handle)
 {
+       int result = 0;
+
        SE_SERVICE_EXTERN_BEGIN;
 
        delete service;
 
        SE_SERVICE_EXTERN_END;
+
+       return result;
 }
index 88fb349..ca5624f 100644 (file)
@@ -144,11 +144,12 @@ namespace smartcard_service_api
                CallbackParam *param = (CallbackParam *)user_data;
                Session *session;
                openChannelCallback callback;
-               gint result;
+               gint result = SCARD_ERROR_UNKNOWN;
+               gint channel_number;
                guint channel_id;
                GVariant *var_response;
                GError *error = NULL;
-               Channel *channel;
+               Channel *channel = NULL;
 
                _INFO("MSG_REQUEST_OPEN_CHANNEL");
 
@@ -162,7 +163,7 @@ namespace smartcard_service_api
 
                if (smartcard_service_session_call_open_channel_finish(
                        SMARTCARD_SERVICE_SESSION(source_object),
-                       &result, &channel_id, &var_response,
+                       &result, &channel_id, &channel_number, &var_response,
                        res, &error) == true) {
                        if (result == SCARD_ERROR_OK) {
                                ByteArray response;
@@ -400,11 +401,17 @@ namespace smartcard_service_api
 
                return count;
        }
-
        Channel *Session::openChannelSync(int id, const ByteArray &aid)
                throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                        ErrorIllegalParameter &, ErrorSecurity &)
        {
+               return openChannelSync(id, aid, 0x00);
+       }
+
+       Channel *Session::openChannelSync(int id, const ByteArray &aid, unsigned char P2)
+               throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                       ErrorIllegalParameter &, ErrorSecurity &)
+       {
                Channel *channel = NULL;
 
                if (getReader()->isSecureElementPresent() == true)
@@ -412,6 +419,7 @@ namespace smartcard_service_api
                        gint ret;
                        GVariant *var_aid = NULL, *var_response = NULL;
                        guint channel_id;
+                       gint channel_number;
                        GError *error = NULL;
 
                        var_aid = GDBusHelper::convertByteArrayToVariant(aid);
@@ -420,7 +428,7 @@ namespace smartcard_service_api
                                (SmartcardServiceSession *)proxy,
                                GPOINTER_TO_UINT(context),
                                GPOINTER_TO_UINT(handle),
-                               (guint)id, var_aid, &ret, &channel_id,
+                               (guint)id, var_aid, (guint8)P2, &ret, &channel_id, &channel_number,
                                &var_response, NULL, &error) == true) {
                                if (ret == SCARD_ERROR_OK && channel_id != 0) {
                                        ByteArray response;
@@ -430,7 +438,7 @@ namespace smartcard_service_api
 
                                        /* create new instance of channel */
                                        channel = new ClientChannel(context,
-                                               this, channel_id,
+                                               this, channel_number,
                                                response, (void *)channel_id);
                                        if (channel != NULL)
                                        {
@@ -484,7 +492,7 @@ namespace smartcard_service_api
                                (SmartcardServiceSession *)proxy,
                                GPOINTER_TO_UINT(context),
                                GPOINTER_TO_UINT(handle),
-                               (guint)id, var_aid, NULL,
+                               (guint)id, var_aid, 0, NULL,
                                &Session::session_open_channel_cb, param);
 
                        result = SCARD_ERROR_OK;
@@ -502,7 +510,14 @@ namespace smartcard_service_api
                throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                        ErrorIllegalParameter &, ErrorSecurity &)
        {
-               return openChannelSync(0, aid);
+               return openChannelSync(0, aid, 0x00);
+       }
+
+       Channel *Session::openBasicChannelSync(const ByteArray &aid, unsigned char P2)
+               throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                       ErrorIllegalParameter &, ErrorSecurity &)
+       {
+               return openChannelSync(0, aid, P2);
        }
 
        Channel *Session::openBasicChannelSync(const unsigned char *aid, unsigned int length)
@@ -511,7 +526,16 @@ namespace smartcard_service_api
        {
                ByteArray temp(aid, length);
 
-               return openBasicChannelSync(temp);
+               return openBasicChannelSync(temp, 0x00);
+       }
+
+       Channel *Session::openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+               throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                       ErrorIllegalParameter &, ErrorSecurity &)
+       {
+               ByteArray temp(aid, length);
+
+               return openBasicChannelSync(temp, P2);
        }
 
        int Session::openBasicChannel(const ByteArray &aid, openChannelCallback callback, void *userData)
@@ -531,7 +555,14 @@ namespace smartcard_service_api
                throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                        ErrorIllegalParameter &, ErrorSecurity &)
        {
-               return openChannelSync(1, aid);
+               return openChannelSync(1, aid, 0x00);
+       }
+
+       Channel *Session::openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
+               throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                       ErrorIllegalParameter &, ErrorSecurity &)
+       {
+               return openChannelSync(1, aid, P2);
        }
 
        Channel *Session::openLogicalChannelSync(const unsigned char *aid, unsigned int length)
@@ -540,7 +571,16 @@ namespace smartcard_service_api
        {
                ByteArray temp(aid, length);
 
-               return openLogicalChannelSync(temp);
+               return openLogicalChannelSync(temp, 0x00);
+       }
+
+       Channel *Session::openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+               throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                       ErrorIllegalParameter &, ErrorSecurity &)
+       {
+               ByteArray temp(aid, length);
+
+               return openLogicalChannelSync(temp, P2);
        }
 
        int Session::openLogicalChannel(const ByteArray &aid, openChannelCallback callback, void *userData)
@@ -572,132 +612,261 @@ namespace smartcard_service_api
 
 using namespace smartcard_service_api;
 
-EXTERN_API reader_h session_get_reader(session_h handle)
+EXTERN_API int session_get_reader(session_h handle, int* reader_handle)
 {
+       int result = SCARD_ERROR_OK;
        reader_h reader = NULL;
 
        SESSION_EXTERN_BEGIN;
+
+       try
+       {
                reader = session->getReader();
+               //*reader_handle = (int)reader;
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+               *reader_handle = 0;
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+               *reader_handle = 0;
+       }
+
        SESSION_EXTERN_END;
 
-       return reader;
+       return result;
 }
 
-EXTERN_API int session_get_atr(session_h handle, session_get_atr_cb callback, void *userData)
+EXTERN_API int session_is_closed(session_h handle, bool* is_closed)
 {
-       int result = -1;
+       int result = SCARD_ERROR_OK;
 
        SESSION_EXTERN_BEGIN;
-               result = session->getATR((getATRCallback)callback, userData);
+
+       try
+       {
+               *is_closed = session->isClosed();
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+       }
+
        SESSION_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API int session_close(session_h handle, session_close_session_cb callback, void *userData)
+EXTERN_API int session_close_channels(session_h handle)
 {
-       int result = -1;
+       int result = SCARD_ERROR_OK;
 
        SESSION_EXTERN_BEGIN;
-               result = session->close((closeSessionCallback)callback, userData);
+
+       try
+       {
+               session->closeChannels();
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+       }
+
        SESSION_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API bool session_is_closed(session_h handle)
+EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length)
 {
-       bool result = false;
+       ByteArray temp;
+       int result = SCARD_ERROR_OK;
 
        SESSION_EXTERN_BEGIN;
-               result = session->isClosed();
+
+       try
+       {
+               temp = session->getATRSync();
+
+               if (temp.size() > 0)
+               {
+                       *buffer = (unsigned char *)calloc(temp.size(), sizeof(char));
+                       *length = temp.size();
+
+                       memcpy(*buffer, temp.getBuffer(), *length);
+               }
+       }
+       catch (ErrorIllegalState &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+
+               if(result == SCARD_ERROR_OPERATION_NOT_SUPPORTED)
+               {
+                       *length = 0;
+                       result = SCARD_ERROR_OK;
+               }
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+               *length = 0;
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+               *length = 0;
+       }
+
        SESSION_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API void session_close_channels(session_h handle)
+EXTERN_API int session_close_sync(session_h handle)
 {
+       int result = SCARD_ERROR_OK;
+
        SESSION_EXTERN_BEGIN;
-               session->closeChannels();
+
+       try
+       {
+               session->closeSync();
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+       }
+
        SESSION_EXTERN_END;
+
+       return result;
 }
 
-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_sync(session_h handle, unsigned char *aid,
+       unsigned int length, unsigned char P2, int* channel_handle)
 {
-       int result = -1;
+       int result = SCARD_ERROR_OK;
 
        SESSION_EXTERN_BEGIN;
-               result = session->openBasicChannel(aid, length, (openChannelCallback)callback, userData);
+
+       try
+       {
+               //*channel_handle = (int)session->openBasicChannelSync(aid, length, P2);
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+               *channel_handle = 0;
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+               *channel_handle = 0;
+       }
+
        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_sync(session_h handle, unsigned char *aid,
+       unsigned int length, unsigned char P2, int* channel_handle)
 {
-       int result = -1;
+       int result = SCARD_ERROR_OK;
 
        SESSION_EXTERN_BEGIN;
-               result = session->openLogicalChannel(aid, length, (openChannelCallback)callback, userData);
+
+       try
+       {
+               //*channel_handle = (int)session->openLogicalChannelSync(aid, length, P2);
+       }
+       catch (ExceptionBase &e)
+       {
+               _ERR("Error occur : %s\n", e.what());
+               result = e.getErrorCode();
+               *channel_handle = 0;
+       }
+       catch (...)
+       {
+               _ERR("Error occur : unknown error\n");
+               result = SCARD_ERROR_UNKNOWN;
+               *channel_handle = 0;
+       }
+
        SESSION_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API void session_destroy_instance(session_h handle)
-{
-}
-
-EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length)
+EXTERN_API int session_get_atr(session_h handle, session_get_atr_cb callback, void *userData)
 {
-       ByteArray temp;
        int result = -1;
 
-       if (buffer == NULL || length == NULL)
-               return result;
-
        SESSION_EXTERN_BEGIN;
-               temp = session->getATRSync();
-               if (temp.size() > 0)
-               {
-                       *length = temp.size();
-                       *buffer = (unsigned char *)calloc(1, *length);
-                       memcpy(*buffer, temp.getBuffer(), *length);
-
-                       result = 0;
-               }
+               result = session->getATR((getATRCallback)callback, userData);
        SESSION_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API void session_close_sync(session_h handle)
+EXTERN_API int session_close(session_h handle, session_close_session_cb callback, void *userData)
 {
+       int result = -1;
+
        SESSION_EXTERN_BEGIN;
-               session->closeSync();
+               result = session->close((closeSessionCallback)callback, userData);
        SESSION_EXTERN_END;
+
+       return result;
 }
 
-EXTERN_API channel_h session_open_basic_channel_sync(session_h handle, unsigned char *aid, unsigned int length)
+EXTERN_API int session_open_basic_channel(session_h handle, unsigned char *aid,
+       unsigned int length, session_open_channel_cb callback, void *userData)
 {
-       channel_h result = NULL;
+       int result = -1;
 
        SESSION_EXTERN_BEGIN;
-               result = session->openBasicChannelSync(aid, length);
+               result = session->openBasicChannel(aid, length, (openChannelCallback)callback, userData);
        SESSION_EXTERN_END;
 
        return result;
 }
 
-EXTERN_API channel_h session_open_logical_channel_sync(session_h handle, unsigned char *aid, unsigned int length)
+EXTERN_API int session_open_logical_channel(session_h handle, unsigned char *aid,
+       unsigned int length, session_open_channel_cb callback, void *userData)
 {
-       channel_h result = NULL;
+       int result = -1;
 
        SESSION_EXTERN_BEGIN;
-               result = session->openLogicalChannelSync(aid, length);
+               result = session->openLogicalChannel(aid, length, (openChannelCallback)callback, userData);
        SESSION_EXTERN_END;
 
        return result;
@@ -713,3 +882,8 @@ EXTERN_API size_t session_get_channel_count(session_h handle)
 
        return result;
 }
+
+EXTERN_API void session_destroy_instance(session_h handle)
+{
+}
+
index 9b94394..a4e75ee 100644 (file)
 #ifndef CLIENTCHANNEL_H_
 #define CLIENTCHANNEL_H_
 
-#ifdef USE_AUTOSTART
+/* standard library header */
 #include <gio/gio.h>
-#endif
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
 #include "smartcard-types.h"
 #ifdef __cplusplus
 #include "Channel.h"
@@ -31,7 +32,7 @@
 #ifdef __cplusplus
 namespace smartcard_service_api
 {
-       class EXPORT ClientChannel: public Channel
+       class ClientChannel: public Channel
        {
        private:
                void *context;
@@ -41,16 +42,17 @@ namespace smartcard_service_api
                ClientChannel(void *context, Session *session, int channelNum,
                        const ByteArray &selectResponse, void *handle);
                ~ClientChannel();
-#ifdef USE_AUTOSTART
+
                static void channel_transmit_cb(GObject *source_object,
                        GAsyncResult *res, gpointer user_data);
                static void channel_close_cb(GObject *source_object,
                        GAsyncResult *res, gpointer user_data);
-#endif
+
        public:
                int close(closeChannelCallback callback, void *userParam);
                int transmit(const ByteArray &command,
                        transmitCallback callback, void *userParam);
+               bool selectNext(){ return false; }
 
                void closeSync()
                        throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
@@ -59,6 +61,8 @@ namespace smartcard_service_api
                        throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                                ErrorIllegalParameter &, ErrorSecurity &);
 
+               void *getHandle(){ return handle; }
+
                friend class Session;
        };
 } /* namespace smartcard_service_api */
@@ -70,21 +74,25 @@ extern "C"
 {
 #endif /* __cplusplus */
 
-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);
-session_h channel_get_session(channel_h handle);
-void channel_destroy_instance(channel_h handle) __attribute__((deprecated));
+int channel_is_basic_channel(channel_h handle, bool* is_basic_channel);
+int channel_is_closed(channel_h handle, bool* is_closed );
+int channel_get_session(channel_h handle, int *session_handle);
+int 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_get_select_response(channel_h handle,
+       unsigned char **buffer, size_t* length);
+int channel_get_transmit_response(channel_h handle,
+       unsigned char **buffer, size_t* length);
+int channel_select_next(channel_h hChannel, bool *pSuccess);
+////
 
 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);
-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);
+unsigned int channel_get_select_response_length(channel_h handle);
+void channel_destroy_instance(channel_h handle) __attribute__((deprecated));
+
 
 #ifdef __cplusplus
 }
index 6630d14..c111874 100644 (file)
 #ifndef CLIENTGDBUS_H_
 #define CLIENTGDBUS_H_
 
+/* standard library header */
 #include <glib.h>
 
+/* SLP library header */
+
+/* local header */
 #include "GDBusHelper.h"
 #include "smartcard-service-gdbus.h"
 
index f2f0103..876d0b8 100644 (file)
 #ifndef READER_H_
 #define READER_H_
 
-#ifdef USE_AUTOSTART
+/* standard library header */
 #include <glib.h>
 #include <gio/gio.h>
-#endif
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
 #include "smartcard-types.h"
 #ifdef __cplusplus
 #include "ReaderHelper.h"
@@ -32,7 +33,7 @@
 #ifdef __cplusplus
 namespace smartcard_service_api
 {
-       class EXPORT Reader: public ReaderHelper
+       class Reader: public ReaderHelper
        {
        private:
                void *context;
@@ -43,10 +44,8 @@ namespace smartcard_service_api
                ~Reader();
 
                inline void unavailable() { present = false; }
-#ifdef USE_AUTOSTART
                static void reader_open_session_cb(GObject *source_object,
                        GAsyncResult *res, gpointer user_data);
-#endif
 
        public:
                void closeSessions()
@@ -57,6 +56,8 @@ namespace smartcard_service_api
                        throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                                ErrorIllegalParameter &, ErrorSecurity &);
 
+               void *getHandle(){ return handle; }
+
                friend class SEService;
        };
 } /* namespace smartcard_service_api */
@@ -68,13 +69,15 @@ extern "C"
 {
 #endif /* __cplusplus */
 
-const char *reader_get_name(reader_h handle);
-se_service_h reader_get_se_service(reader_h handle);
-bool reader_is_secure_element_present(reader_h handle);
+int reader_get_name(reader_h handle, char** reader_name);
+int reader_is_secure_element_present(reader_h handle, bool* is_present);
+int reader_open_session_sync(reader_h handle, int *session_handle);
+int reader_close_sessions(reader_h handle);
+///
+
 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);
+se_service_h reader_get_se_service(reader_h handle);
 __attribute__((deprecated)) void reader_destroy_instance(reader_h handle);
 
 #ifdef __cplusplus
index ade4068..cb7672d 100644 (file)
 #ifndef SESERVICE_H_
 #define SESERVICE_H_
 
-#ifdef USE_AUTOSTART
+/* standard library header */
 #include <glib.h>
 #include <gio/gio.h>
-#endif
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
 #include "smartcard-types.h"
 #ifdef __cplusplus
 #include "SEServiceListener.h"
@@ -36,7 +37,7 @@ namespace smartcard_service_api
 {
        typedef void (*serviceConnected)(SEServiceHelper *service, void *context);
 
-       class EXPORT SEService : public SEServiceHelper
+       class SEService : public SEServiceHelper
        {
        private:
                unsigned int handle;
@@ -44,22 +45,25 @@ namespace smartcard_service_api
                serviceConnected handler;
                SEServiceListener *listener;
                void *proxy;
+               const char *version;
+
                SEService();
 
                void addReader(unsigned int handle, const char *name);
                bool parseReaderInformation(unsigned int count, const ByteArray &data);
-#ifdef USE_AUTOSTART
                bool parseReaderInformation(GVariant *variant);
-#endif
+
                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 &);
-#ifdef USE_AUTOSTART
+               int _initialize_sync()
+                       throw(ErrorIO &, ExceptionBase &);
+               bool initializeSync(void *context)
+                       throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &);
+
                static void reader_inserted(GObject *source_object,
                        guint reader_id, gchar *reader_name,
                        gpointer user_data);
@@ -70,12 +74,14 @@ namespace smartcard_service_api
                        GAsyncResult *res, gpointer user_data);
                static void se_service_cb(GObject *source_object,
                        GAsyncResult *res, gpointer user_data);
-#endif
+
        public:
                SEService(void *user_data, serviceConnected handler)
                        throw(ErrorIO &, ErrorIllegalParameter &);
                SEService(void *user_data, SEServiceListener *listener)
                        throw(ErrorIO &, ErrorIllegalParameter &);
+               SEService(void *user_data)
+                       throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &);
                ~SEService();
 
                static SEService *createInstance(void *user_data, SEServiceListener *listener)
@@ -85,6 +91,7 @@ namespace smartcard_service_api
 
                void shutdown();
                void shutdownSync();
+               const char *getVersion() const { return version; }
        };
 } /* namespace smartcard_service_api */
 #endif /* __cplusplus */
@@ -100,11 +107,16 @@ se_service_h se_service_create_instance(void *user_data,
 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_sync(void *user_data, int* result);
+int se_service_get_version(se_service_h handle, char **version_str);
 int se_service_get_readers_count(se_service_h handle);
-bool se_service_get_readers(se_service_h handle, reader_h *readers, int *count);
+int se_service_get_readers(se_service_h handle, int **readers, int *count);
+
 bool se_service_is_connected(se_service_h handle);
 void se_service_shutdown(se_service_h handle);
-void se_service_destroy_instance(se_service_h handle);
+int se_service_destroy_instance(se_service_h handle);
+
 
 #ifdef __cplusplus
 }
index 886b918..9cfc01b 100644 (file)
 #ifndef SESERVICELISTENER_H_
 #define SESERVICELISTENER_H_
 
-#include "Debug.h"
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 
 namespace smartcard_service_api
 {
        class SEServiceHelper;
 
-       class EXPORT SEServiceListener
+       class SEServiceListener
        {
        public:
                virtual void serviceConnected(SEServiceHelper *service,
index 5eff455..7d530e3 100644 (file)
 #ifndef SESSION_H_
 #define SESSION_H_
 
-#ifdef USE_AUTOSTART
+/* standard library header */
 #include <gio/gio.h>
-#endif
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
 #include "smartcard-types.h"
 #ifdef __cplusplus
 #include "SessionHelper.h"
@@ -32,7 +33,7 @@ namespace smartcard_service_api
 {
        class Reader;
 
-       class EXPORT Session : public SessionHelper
+       class Session : public SessionHelper
        {
        private:
                void *context;
@@ -43,18 +44,21 @@ namespace smartcard_service_api
                ~Session();
 
                int openChannel(int id, const ByteArray &aid, openChannelCallback callback, void *userData);
+               
                Channel *openChannelSync(int id, const ByteArray &aid)
                        throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                                ErrorIllegalParameter &, ErrorSecurity &);
 
-#ifdef USE_AUTOSTART
+               Channel *openChannelSync(int id, const ByteArray &aid, unsigned char P2)
+                       throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                               ErrorIllegalParameter &, ErrorSecurity &);
+
                static void session_get_atr_cb(GObject *source_object,
                        GAsyncResult *res, gpointer user_data);
                static void session_open_channel_cb(GObject *source_object,
                        GAsyncResult *res, gpointer user_data);
                static void session_close_cb(GObject *source_object,
                        GAsyncResult *res, gpointer user_data);
-#endif
 
        public:
                void closeChannels()
@@ -90,9 +94,26 @@ namespace smartcard_service_api
 
                Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length)
                        throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                               ErrorIllegalParameter &, ErrorSecurity &);      
+
+               Channel *openBasicChannelSync(const ByteArray &aid, unsigned char P2)
+                       throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                               ErrorIllegalParameter &, ErrorSecurity &);
+
+               Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+                       throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                               ErrorIllegalParameter &, ErrorSecurity &);
+
+               Channel *openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
+                       throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                               ErrorIllegalParameter &, ErrorSecurity &);
+
+               Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+                       throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                                ErrorIllegalParameter &, ErrorSecurity &);
 
                size_t getChannelCount() const;
+               void *getHandle(){ return handle; }
 
                friend class Reader;
        };
@@ -105,31 +126,29 @@ extern "C"
 {
 #endif /* __cplusplus */
 
-reader_h session_get_reader(session_h handle);
-bool session_is_closed(session_h handle);
-__attribute__((deprecated)) void session_destroy_instance(session_h handle);
-void session_close_channels(session_h handle);
+int session_get_reader(session_h handle, int* reader_handle);
+int session_is_closed(session_h handle, bool* is_closed);
+int session_close_channels(session_h handle);
+int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length);
+int session_close_sync(session_h handle);
+int session_open_basic_channel_sync(session_h handle, unsigned char *aid,
+       unsigned int length, unsigned char P2, int* channel_handle);
+int session_open_logical_channel_sync(session_h handle, unsigned char *aid,
+       unsigned int length, unsigned char P2, int* channel_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);
+size_t session_get_channel_count(session_h handle);
+__attribute__((deprecated)) void session_destroy_instance(session_h handle);
 
-int session_get_atr_sync(session_h handle, unsigned char **buffer,
-       unsigned int *length);
-void session_close_sync(session_h handle);
-
-channel_h session_open_basic_channel_sync(session_h handle,
-       unsigned char *aid, unsigned int length);
-channel_h session_open_logical_channel_sync(session_h handle,
-       unsigned char *aid, unsigned int length);
 
-size_t session_get_channel_count(session_h handle);
 
 #ifdef __cplusplus
 }
index a79163d..354e11f 100644 (file)
@@ -18,7 +18,9 @@
 #define SMARTCARD_SERVICE_H_
 
 #include "smartcard-types.h"
+#ifdef __cplusplus
 #include "Exception.h"
+#endif
 #include "SEService.h"
 #include "Reader.h"
 #include "Session.h"
diff --git a/client/smartcard-service.pc b/client/smartcard-service.pc
new file mode 100644 (file)
index 0000000..fb0b732
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=/usr
+exec_prefix=${prefix}/bin
+includedir=${prefix}/include
+libdir=${prefix}/lib
+
+Name: smartcard-service
+Description: Make flags of Common library of Smartcard service
+Version: 1.0
+Requires: glib-2.0 dlog
+Libs: -L${libdir} -lsmartcard-service
+Cflags: -I${includedir}/smartcard-service
\ No newline at end of file
diff --git a/client/smartcard-service.pc.in b/client/smartcard-service.pc.in
deleted file mode 100644 (file)
index 3590877..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@PREFIX@
-exec_prefix=${prefix}/bin
-libdir=@LIB_INSTALL_DIR@
-includedir=@INCLUDE_INSTALL_DIR@/@PROJECT_NAME@
-
-Name: @PROJECT_NAME@
-Description: library of Smartcard service
-Version: @FULLVER@
-Requires: glib-2.0 dlog
-Libs: -L${libdir} -l@PROJECT_NAME@
-Cflags: -I${includedir}
index ae5589c..d962e21 100644 (file)
@@ -80,6 +80,68 @@ namespace smartcard_service_api
                case (unsigned char)0x92 : /* extra information */
                        break;
 
+               /* Warning processing */
+               case (unsigned char)0x62 : /* State of non-volatile memory is unchanged (further qualification in SW2) */
+                       break;
+
+               case (unsigned char)0x63 : /* State of non-volatile memory has changed (further qualification in SW2) */
+                       break;
+
+#if 0
+               case (unsigned char)0x61 : /* SW2 encodes the number of data bytes still available */
+                       break;
+
+
+               /* Execution error */
+               case (unsigned char)0x64 : /* State of non-volatile memory is unchanged (further qualification in SW2) */
+                       result = -1;
+                       break;
+
+               case (unsigned char)0x65 : /* State of non-volatile memory has changed (further qualification in SW2) */
+                       result = -1;
+                       break;
+
+               case (unsigned char)0x66 : /* Security-related issues */
+                       result = -1;
+                       break;
+
+               /* Checking error */
+               case (unsigned char)0x67 : /* SW2:00, Wrong length; no further indication */
+                       result = -1;
+                       break;
+
+               case (unsigned char)0x68 : /* Functions in CLA not supported (further qualification in SW2) */
+                       result = -1;
+                       break;
+
+               case (unsigned char)0x69 : /* Command not allowed (further qualification in SW2) */
+                       result = -1;
+                       break;
+
+               case (unsigned char)0x6A : /* Wrong parameters P1-P2 (further qualification in SW2) */
+                       result = -1;
+                       break;
+
+               case (unsigned char)0x6B : /* SW2:00, Wrong parameters P1-P2 */
+                       result = -1;
+                       break;
+
+               case (unsigned char)0x6C : /* Wrong Le field; SW2 encodes the exact number of available data bytes */
+                       result = -1;
+                       break;
+
+               case (unsigned char)0x6D : /* SW2:00, Instruction code not supported or invalid */
+                       result = -1;
+                       break;
+
+               case (unsigned char)0x6E : /* SW2:00, Class not supported */
+                       result = -1;
+                       break;
+
+               case (unsigned char)0x6F : /* SW2:00, No precise diagnosis */
+                       result = -1;
+                       break;
+#endif
                default :
                        result *= -1;
                        break;
@@ -94,7 +156,9 @@ namespace smartcard_service_api
 
                if (response.size() >= 2)
                {
-                       status = ResponseHelper::parseStatusWord(response.getBuffer((response.size() - 2)));
+                       const uint8_t* buffer = response.getBuffer((response.size() - 2));
+                       if(buffer != NULL)
+                               status = ResponseHelper::parseStatusWord(buffer);
                }
 
                return status;
@@ -142,6 +206,7 @@ namespace smartcard_service_api
        bool APDUCommand::setCommand(const ByteArray &command)
        {
                bool result = false;
+               const uint8_t *buffer;
                uint32_t offset = 0;
                uint32_t lengthSize = 1;
 
@@ -150,7 +215,13 @@ namespace smartcard_service_api
                        return false;
                }
 
-               memcpy(&header, command.getBuffer(offset), sizeof(header));
+               buffer = command.getBuffer(offset);
+               if(buffer == NULL)
+               {
+                       return false;
+               }
+
+               memcpy(&header, buffer, sizeof(header));
                offset += sizeof(header);
 
                if (isExtendedLength)
@@ -171,6 +242,9 @@ namespace smartcard_service_api
                        else
                        {
                                length = command.at(offset);
+                               if (length == 0) {
+                                       length = 256;
+                               }
                                offset += 1;
                        }
 
@@ -197,7 +271,7 @@ namespace smartcard_service_api
                        else
                        {
                                if (command.at(offset) == 0)
-                                       setMaxResponseSize(APDUCommand::LE_MAX);
+                                       setMaxResponseSize(256);
                                else
                                        setMaxResponseSize(command.at(offset));
 
@@ -228,7 +302,6 @@ namespace smartcard_service_api
                        {
                        case INS_TERMINAL_PROFILE :
                        case INS_FETCH :
-                       case INS_ENVELOPE :
                        case INS_TERMINAL_RESPONSE :
                                result = true;
                                break;
@@ -450,7 +523,7 @@ namespace smartcard_service_api
                switch (command)
                {
                case COMMAND_OPEN_LOGICAL_CHANNEL :
-                       apdu.setCommand(0, APDUCommand::INS_MANAGE_CHANNEL, 0, 0, ByteArray::EMPTY, APDUCommand::LE_MAX);
+                       apdu.setCommand(0, APDUCommand::INS_MANAGE_CHANNEL, 0, 0, ByteArray::EMPTY, 1);
                        apdu.getBuffer(result);
                        break;
 
@@ -470,7 +543,7 @@ namespace smartcard_service_api
                        break;
 
                case COMMAND_SELECT_BY_DF_NAME :
-                       apdu.setCommand(0, APDUCommand::INS_SELECT_FILE, APDUCommand::P1_SELECT_BY_DF_NAME, APDUCommand::P2_SELECT_GET_FCP, data, 0);
+                       apdu.setCommand(0, APDUCommand::INS_SELECT_FILE, APDUCommand::P1_SELECT_BY_DF_NAME, APDUCommand::P2_SELECT_GET_FCI, data, 0);
                        apdu.getBuffer(result);
                        break;
 
index 563da7d..d68f028 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <stdio.h>
 
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "SimpleTLV.h"
 #include "AccessControlList.h"
@@ -46,8 +50,17 @@ namespace smartcard_service_api
                        cmd = *(unsigned int *)command.getBuffer();
                        for (item = listFilters.begin(); item != listFilters.end(); item++)
                        {
-                               mask = *(unsigned int *)item->second.getBuffer();
-                               rule = *(unsigned int *)item->first.getBuffer();
+                               unsigned int *temp1 = NULL;
+                               unsigned int *temp2 = NULL;
+
+                               temp1 = (unsigned int *)item->second.getBuffer();
+                               temp2 = (unsigned int *)item->first.getBuffer();
+
+                               if(temp1 == NULL || temp2 == NULL)
+                                       continue;
+
+                               mask = *temp1;
+                               rule = *temp2;
 
                                if ((cmd & mask) == rule)
                                {
@@ -65,6 +78,27 @@ namespace smartcard_service_api
                return result;
        }
 
+       void AccessRule::printAccessRules() const
+       {
+               if (listFilters.size() > 0)
+               {
+                       vector<pair<ByteArray, ByteArray> >::const_iterator item;
+
+                       _DBG("         +---- Granted APDUs");
+
+                       for (item = listFilters.begin(); item != listFilters.end(); item++)
+                       {
+                               _DBG("         +----- APDU : %s, Mask : %s", item->first.toString().c_str(), item->second.toString().c_str());
+                       }
+               }
+               else
+               {
+                       _DBG("         +---- APDU Access ALLOW : %s", apduRule ? "ALWAYS" : "NEVER");
+               }
+
+               _DBG("         +---- NFC  Access ALLOW : %s", nfcRule ? "ALWAYS" : "NEVER");
+       }
+
        bool AccessRule::isAuthorizedNFCAccess(void) const
        {
                return nfcRule;
@@ -133,6 +167,28 @@ namespace smartcard_service_api
                return result;
        }
 
+       void AccessCondition::printAccessConditions() const
+       {
+               _DBG("   +-- Access Condition");
+
+               if (mapRules.size() > 0)
+               {
+                       map<ByteArray, AccessRule>::const_iterator item;
+
+                       for (item = mapRules.begin(); item != mapRules.end(); item++)
+                       {
+                               ByteArray temp = item->first;
+
+                               _DBG("   +--- hash : %s", (temp == AccessControlList::ALL_DEVICE_APPS) ? "All device applications" : temp.toString().c_str());
+                               item->second.printAccessRules();
+                       }
+               }
+               else
+               {
+                       _DBG("   +--- no rule found");
+               }
+       }
+
        void AccessCondition::setAPDUAccessRule(const ByteArray &certHash,
                bool rule)
        {
index 2122eed..40121d8 100644 (file)
@@ -166,6 +166,15 @@ namespace smartcard_service_api
                                result = rule->isAuthorizedAPDUAccess(command);
                        }
                        _INFO("rule found (%s): [%s:%s]", result ? "accept" : "deny", "All SE Applications", "All device applications");
+                       goto END;
+               }
+
+               size_t i;
+
+               _INFO("no rule found, aid     [%s]", aid.toString().c_str());
+
+               for (i = 0; i < certHashes.size(); i++) {
+                       _INFO("               hash[%d] [%s]", i, certHashes[i].toString().c_str());
                }
 
 END :
@@ -216,9 +225,35 @@ END :
                if (rule != NULL) {
                        result = rule->isAuthorizedNFCAccess();
                        _INFO("rule found (%s): [%s:%s]", result ? "accept" : "deny", "All SE Applications", "All device applications");
+                       goto END;
                }
 
+               size_t i;
+
+               _INFO("no rule found, aid     [%s]", aid.toString().c_str());
+
+               for (i = 0; i < certHashes.size(); i++) {
+                       _INFO("               hash[%d] [%s]", i, certHashes[i].toString().c_str());
+               }
 END :
                return result;
        }
+
+       void AccessControlList::printAccessControlList() const
+       {
+               ByteArray temp;
+               map<ByteArray, AccessCondition>::const_iterator iterMap;
+
+               _DBG("========================== Access Control Rules ============================");
+               for (iterMap = mapConditions.begin(); iterMap != mapConditions.end(); iterMap++)
+               {
+                       temp = iterMap->first;
+
+                       _DBG("+ aid : %s", (temp == DEFAULT_SE_APP) ? "Default Application" : (temp == ALL_SE_APPS) ? "All SE Applications" : temp.toString().c_str());
+
+                       iterMap->second.printAccessConditions();
+               }
+               _DBG("============================================================================");
+       }
+
 } /* namespace smartcard_service_api */
index 181125c..95ac12b 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <cstdio>
 #include <cstring>
 #include <cerrno>
 #include <sstream>
 
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "ByteArray.h"
 
@@ -296,8 +300,18 @@ namespace smartcard_service_api
 
                return buffer[index];
        }
+
        const string ByteArray::toString() const
        {
+#ifdef TO_STRING_ALL
+               return toString(true);
+#else
+               return toString(false);
+#endif
+       }
+
+       const string ByteArray::toString(bool entire) const
+       {
                stringstream ss;
 
                if (length > 0)
@@ -308,7 +322,7 @@ namespace smartcard_service_api
                        bool ellipsis = false;
 
                        count = length;
-                       if (count > 20)
+                       if (entire == false && count > 20)
                        {
                                count = 20;
                                ellipsis = true;
@@ -349,6 +363,8 @@ namespace smartcard_service_api
                        fwrite(buffer, 1, length, file);
                        fflush(file);
                        fclose(file);
+
+                       SECURE_LOGD("file has written, file [%s], length[%d]", filePath, length);
                }
                else
                {
@@ -357,4 +373,3 @@ namespace smartcard_service_api
        }
 
 } /* namespace smartcard_service_api */
-
index 1b5fc13..6469fb2 100644 (file)
@@ -1,44 +1,72 @@
-INCLUDE_DIRECTORIES(include)
-
-FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
-EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
-       " --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/smartcard-service-gdbus"
-       " --c-namespace SmartcardService"
-       " --interface-prefix org.tizen.SmartcardService."
-       " ${CMAKE_CURRENT_SOURCE_DIR}/smartcard-service-gdbus.xml"
-)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(smartcard-service-common CXX)
+
+SET(LIB_NAME "smartcard-service-common")
+SET(VERSION_MAJOR 1)
+SET(VERSION ${VERSION_MAJOR}.0.0)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} COMMON_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SRCS)
 
+#IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+#      SET(CMAKE_BUILD_TYPE "Debug")
+#ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+#MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs_common REQUIRED glib-2.0 gio-unix-2.0 dlog aul libssl pkgmgr pkgmgr-info)
+
+MESSAGE("${LIB_NAME} ld flag : ${pkgs_common_LDFLAGS}")
+
 FOREACH(flag ${pkgs_common_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
        SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
 ENDFOREACH(flag)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
 
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -finstrument-functions -fPIC")
+#SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+#SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -finstrument-functions -std=c++0x")
+#SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+#SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS("-DUSE_UNIX_DOMAIN")
 ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_COMMON\"")
 
-SET(CMAKE_C_FLAGS "${EXTRA_CXXFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+
+SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${VERSION})
 
-ADD_LIBRARY(${COMMON_LIB} SHARED ${COMMON_SRCS})
-SET_TARGET_PROPERTIES(${COMMON_LIB} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER})
-TARGET_LINK_LIBRARIES(${COMMON_LIB} ${pkgs_common_LDFLAGS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_common_LDFLAGS})
 
-SET(EXPORT_HEADER
+SET(EXPORT_HEADER 
        include/smartcard-types.h
        include/Debug.h
        include/Exception.h
        include/ByteArray.h
        include/Lock.h
-       include/Synchronous.h
+       include/Synchronous.h   
        include/TerminalInterface.h
        include/Terminal.h
        include/SignatureHelper.h
 )
 
-CONFIGURE_FILE(${COMMON_LIB}.pc.in ${COMMON_LIB}.pc @ONLY)
-INSTALL(FILES ${COMMON_LIB}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(TARGETS ${COMMON_LIB} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
 FOREACH(hfile ${EXPORT_HEADER})
-       INSTALL(FILES ${hfile} DESTINATION include/${COMMON_LIB})
+       INSTALL(FILES ${hfile} DESTINATION include/${LIB_NAME})
 ENDFOREACH(hfile)
index 3735d75..e6035e5 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <stdio.h>
 
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "EFDIR.h"
 #include "APDUHelper.h"
index d4d1bf2..253f05e 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <cstdio>
 #include <cstring>
 #include <sstream>
 
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "FCI.h"
 #include "SimpleTLV.h"
@@ -77,7 +81,7 @@ namespace smartcard_service_api
                }
 
                /* parse... */
-               tlv.setTLVBuffer(fcpBuffer.getBuffer(), fcpBuffer.size());
+               tlv.setTLVBuffer(fcpBuffer);
 
                if (tlv.decodeTLV())
                {
@@ -130,6 +134,7 @@ namespace smartcard_service_api
 
                                case 0x84 : /* DF name */
                                        {
+                                               SECURE_LOGD("0x%02X : DF name : %s", tlv.getTag(), tlv.getValue().toString().c_str());
        //                                      ByteArray value = tlv.getValue();
                                        }
                                        break;
@@ -143,6 +148,7 @@ namespace smartcard_service_api
 
                                case 0x86 : /* Security attribute in proprietary format */
                                        {
+                                               SECURE_LOGD("0x%02X : Security attribute in proprietary format : %s", tlv.getTag(), tlv.getValue().toString().c_str());
        //                                      ByteArray value = tlv.getValue();
                                        }
                                        break;
@@ -185,36 +191,42 @@ namespace smartcard_service_api
 
                                case 0x8B : /* Security attribute referencing the expanded format */
                                        {
+                                               SECURE_LOGD("0x%02X : Security attribute referencing the expanded format : %s", tlv.getTag(), tlv.getValue().toString().c_str());
        //                                      ByteArray value = tlv.getValue();
                                        }
                                        break;
 
                                case 0x8C : /* Security attribute in compact format */
                                        {
+                                               SECURE_LOGD("0x%02X : Security attribute in compact format : %s", tlv.getTag(), tlv.getValue().toString().c_str());
        //                                      ByteArray value = tlv.getValue();
                                        }
                                        break;
 
                                case 0x8D : /* Identifier of an EF containing security environment templates */
                                        {
+                                               SECURE_LOGD("0x%02X : Identifier of an EF containing security environment templates : %s", tlv.getTag(), tlv.getValue().toString().c_str());
        //                                      ByteArray value = tlv.getValue();
                                        }
                                        break;
 
                                case 0x8E : /* Channel security attribute */
                                        {
+                                               SECURE_LOGD("0x%02X : Channel security attribute : %s", tlv.getTag(), tlv.getValue().toString().c_str());
        //                                      ByteArray value = tlv.getValue();
                                        }
                                        break;
 
                                case 0xA0 : /* Security attribute template for data objects */
                                        {
+                                               SECURE_LOGD("0x%02X : Security attribute template for data objects : %s", tlv.getTag(), tlv.getValue().toString().c_str());
        //                                      ByteArray value = tlv.getValue();
                                        }
                                        break;
 
                                case 0xA1 : /* Security attribute template in proprietary format */
                                        {
+                                               SECURE_LOGD("0x%02X : Security attribute template in proprietary format : %s", tlv.getTag(), tlv.getValue().toString().c_str());
        //                                      ByteArray value = tlv.getValue();
                                        }
                                        break;
@@ -235,6 +247,7 @@ namespace smartcard_service_api
 
                                case 0xAB : /* Security attribute template in expanded format */
                                        {
+                                               SECURE_LOGD("0x%02X : Security attribute template in expanded format : %s", tlv.getTag(), tlv.getValue().toString().c_str());
        //                                      ByteArray value = tlv.getValue();
                                        }
                                        break;
@@ -248,6 +261,7 @@ namespace smartcard_service_api
 
                                case 0xC6 : /* PIN status template DO */
                                        {
+                                               SECURE_LOGD("0x%02X : PIN status template DO : %s", tlv.getTag(), tlv.getValue().toString().c_str());
        //                                      ByteArray value = tlv.getValue();
                                        }
                                        break;
index b56c696..efbc110 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <stdio.h>
+#include <glib.h>
 
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "FileObject.h"
 #include "APDUHelper.h"
@@ -101,10 +106,7 @@ namespace smartcard_service_api
 
                        ret = resp.getStatus();
 
-                       if (setSelectResponse(result) == true)
-                       {
-                               opened = true;
-                       }
+                       setSelectResponse(result);
                }
                else
                {
@@ -238,13 +240,19 @@ namespace smartcard_service_api
                return 0;
        }
 
+#define MAX_SINGLE_LEN 256
+
        int FileObject::readBinary(unsigned int sfi, unsigned int offset, unsigned int length, ByteArray &result)
        {
                ByteArray command, response;
                APDUCommand apdu;
                int ret;
 
-               apdu.setCommand(0, APDUCommand::INS_READ_BINARY, offset, 0, ByteArray::EMPTY, length);
+               /* FIXME : fix calculating length */
+               apdu.setCommand(0, APDUCommand::INS_READ_BINARY,
+                       (offset >> 8) & 0x7F, offset & 0x00FF,
+                       ByteArray::EMPTY, (length > MAX_SINGLE_LEN - 1) ? 0 : length);
+
                apdu.getBuffer(command);
 
                ret = channel->transmitSync(command, response);
@@ -273,6 +281,23 @@ namespace smartcard_service_api
                return ret;
        }
 
+       int FileObject::readBinary(unsigned int sfi, unsigned int length, ByteArray &result)
+       {
+               int ret;
+               size_t offset = 0;
+               ByteArray temp;
+
+               do {
+                       ret = readBinary(sfi, offset, length - offset, temp);
+                       if (ret >= SCARD_ERROR_OK) {
+                               result += temp;
+                               offset += temp.size();
+                       }
+               } while (ret >= SCARD_ERROR_OK && offset < length);
+
+               return ret;
+       }
+
        int FileObject::writeBinary(unsigned int sfi, const ByteArray &data, unsigned int offset, unsigned int length)
        {
                ByteArray command, response;
@@ -305,4 +330,32 @@ namespace smartcard_service_api
 
                return ret;
        }
+
+       int FileObject::writeBinary(unsigned int sfi, const ByteArray &data)
+       {
+               int result;
+               size_t offset = 0, len;
+               ByteArray temp;
+
+               do {
+                       len = MIN(data.size() - offset, MAX_SINGLE_LEN);
+                       temp.setBuffer(data.getBuffer(offset), len);
+                       result = writeBinary(sfi, temp, offset, len);
+                       if (result >= SCARD_ERROR_OK) {
+                               offset += len;
+                       }
+               } while (result >= SCARD_ERROR_OK && offset < data.size());
+
+               return result;
+       }
+
+       int FileObject::readBinaryAll(unsigned int sfi, ByteArray &result)
+       {
+               int ret;
+
+               ret = readBinary(sfi, getFCP()->getFileSize(), result);
+
+               return ret;
+       }
+
 } /* namespace smartcard_service_api */
index ca1d0d7..3aa3ba7 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "GPACE.h"
 #include "GPARAACL.h"
index 0f3b8fc..95a9f65 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "GPARAACL.h"
 #include "GPARAM.h"
@@ -287,6 +292,8 @@ namespace smartcard_service_api
                        {
                                _INFO("access rules are not changed. skip update");
                        }
+
+                       printAccessControlList();
                } else {
                        _ERR("transmitSync failed, %x", result);
                }
index 2990cf9..2c81baf 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+#include <glib.h>
+
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "GPARAM.h"
 #include "APDUHelper.h"
@@ -29,7 +35,7 @@
 
 namespace smartcard_service_api
 {
-       static unsigned char aid_aram[] = { 0xA0, 0x00, 0x00, 0x01, 0x51, 0x41, 0x43, 0x4C, 00 };
+       static unsigned char aid_aram[] = { 0xA0, 0x00, 0x00, 0x01, 0x51, 0x41, 0x43, 0x4C, 0x00 };
        static ByteArray AID_ARAM(ARRAY_AND_SIZE(aid_aram));
 
 #define GET_DATA_ALL           0
@@ -132,6 +138,49 @@ namespace smartcard_service_api
                return result;
        }
 
+       int getLengthAndValue(const ByteArray &data, ByteArray &value)
+       {
+               int result = -1;
+               int offset = 0;
+
+               if (data.isEmpty() == true) {
+                       return result;
+               }
+
+               if (data.at(offset) == 0xFF && data.at(offset + 1) == 0x40) {
+                       uint8_t count;
+
+                       offset += 2;
+                       count = data.at(offset);
+
+                       offset += 1;
+                       if (count & 0x80) {
+                               int i;
+
+                               count &= ~0x80;
+                               result = 0;
+
+                               for (i = 0; i < count; i++) {
+                                       result = (result << 8) | data.at(offset + i);
+                               }
+
+                               offset += i;
+                       } else {
+                               result = count;
+                       }
+
+                       if (result > 0) {
+                               value.assign(data.getBuffer(offset),
+                                       MIN((uint32_t)result,
+                                               data.size() - offset));
+                       }
+               } else {
+                       _ERR("invalid tag");
+               }
+
+               return result;
+       }
+
        int GPARAM::getDataAll(ByteArray &data)
        {
                int result;
@@ -141,37 +190,31 @@ namespace smartcard_service_api
 
                result = doCommand(channel, GET_DATA_ALL, response);
                if (result >= SCARD_ERROR_OK) {
-                       ISO7816BERTLV tlv(response);
-
-                       if (tlv.decodeTLV() == true &&
-                               tlv.getTag() == ARAM_TAG_ALL_AR) {
-                               unsigned int length = tlv.size();
-
-                               if (length > 0){
-                                       data = tlv.getValue();
-
-                                       while (length > data.size()) {
-                                               result = doCommand(channel, GET_DATA_NEXT, response);
-                                               if (result >= SCARD_ERROR_OK) {
-                                                       data += response;
-                                               } else {
-                                                       _ERR("generateCommand failed, [%d]", result);
-                                                       data.clear();
-                                                       break;
-                                               }
+                       int length;
+
+                       length = getLengthAndValue(response, data);
+                       if (length > 0){
+                               while (length > (int)data.size()) {
+                                       result = doCommand(channel, GET_DATA_NEXT, response);
+                                       if (result >= SCARD_ERROR_OK) {
+                                               data += response;
+                                       } else {
+                                               _ERR("generateCommand failed, [%d]", result);
+                                               data.clear();
+                                               break;
                                        }
-
-                                       _DBG("data[%d] : %s", data.size(), data.toString().c_str());
-                               } else {
-                                       _INFO("Response-ALL-AR-DO is empty");
-                                       data.clear();
                                }
+
+                               _DBG("data[%d] : %s", data.size(), data.toString().c_str());
+                       } else if (length == 0) {
+                               _INFO("Response-ALL-AR-DO is empty");
+                               data.clear();
                        } else {
-                               _ERR("decodeTLV failed, %s", response.toString().c_str());
-                               result = SCARD_ERROR_ILLEGAL_PARAM;
+                               _ERR("invalid result, %s", response.toString().c_str());
+                               result = SCARD_ERROR_UNAVAILABLE;
                        }
                } else {
-                       _ERR("generateCommand failed, [%d]", result);
+                       _ERR("doCommand failed, [%d]", result);
                }
 
                _END();
index 1f45cb2..84b3938 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "GPARFACL.h"
 #include "PKCS15ODF.h"
@@ -53,7 +58,12 @@ namespace smartcard_service_api
                PKCS15 pkcs15(channel);
 
                /* basically, all requests will be accepted when PKCS #15 doesn't exist or global platform OID is not placed */
+#if 1 /* FOR ORANGE */
+               /* for Orange, every requests will be denied in same cases */
                allGranted = false;
+#else
+               allGranted = true;
+#endif
 
                result = pkcs15.select();
                if (result >= SCARD_ERROR_OK)
@@ -61,7 +71,6 @@ namespace smartcard_service_api
                        PKCS15ODF *odf;
 
                        result = SCARD_ERROR_OK;
-                       allGranted = true;
 
                        if ((odf = pkcs15.getODF()) != NULL)
                        {
@@ -72,26 +81,43 @@ namespace smartcard_service_api
                                        result = loadAccessControl(channel, dodf);
                                        if (result == SCARD_ERROR_OK)
                                        {
+                                               printAccessControlList();
                                        }
                                        else
                                        {
+#if 1 /* FOR ORANGE */
+                                               _ERR("loadAccessControl failed, every request will be denied.");
+#else
                                                _INFO("loadAccessControl failed, every request will be accepted.");
+#endif
                                                result = SCARD_ERROR_OK;
                                        }
                                }
                                else
                                {
+#if 1 /* FOR ORANGE */
+                                       _ERR("dodf null, every request will be denied.");
+#else
                                        _INFO("dodf null, every request will be accepted.");
+#endif
                                }
                        }
                        else
                        {
+#if 1 /* FOR ORANGE */
+                               _ERR("odf null, every request will be denied.");
+#else
                                _INFO("odf null, every request will be accepted.");
+#endif
                        }
                }
                else
                {
-                       _ERR("failed to open PKCS15, every request will be denied.");
+#if 1 /* FOR ORANGE */
+                       _ERR("failed to open PKCS#15, every request will be denied.");
+#else
+                       _INFO("failed to open PKCS#15, every request will be accepted.");
+#endif
                }
 
                _END();
@@ -112,7 +138,7 @@ namespace smartcard_service_api
                        _DBG("oid path : %s", path.toString().c_str());
 
                        file.select(NumberStream::getLittleEndianNumber(path));
-                       file.readBinary(0, 0, file.getFCP()->getFileSize(), data);
+                       file.readBinaryAll(0, data);
 
                        _DBG("data : %s", data.toString().c_str());
 
@@ -182,7 +208,7 @@ namespace smartcard_service_api
                ByteArray data, aid;
 
                file.select(NumberStream::getLittleEndianNumber(path));
-               file.readBinary(0, 0, file.getFCP()->getFileSize(), data);
+               file.readBinaryAll(0, data);
 
                _DBG("data : %s", data.toString().c_str());
 
@@ -380,9 +406,10 @@ namespace smartcard_service_api
                                }
                                else
                                {
-                                       _INFO("access denied for all applications, aid : %s", condition.getAID().toString().c_str());
+                                       /* empty rule, it means allow for all application */
+                                       _INFO("access allowed for all applications, aid : %s", condition.getAID().toString().c_str());
 
-                                       condition.setAccessCondition(false);
+                                       condition.setAccessCondition(true);
                                        break;
                                }
                        }
@@ -402,7 +429,7 @@ namespace smartcard_service_api
                ByteArray data;
 
                file.select(NumberStream::getLittleEndianNumber(path));
-               file.readBinary(0, 0, file.getFCP()->getFileSize(), data);
+               file.readBinaryAll(0, data);
 
                _DBG("data : %s", data.toString().c_str());
 
index babd635..afe1933 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <stdio.h>
 #include <string.h>
 
+/* SLP library header */
+
+/* local header */
 #include "ISO7816BERTLV.h"
 
 namespace smartcard_service_api
@@ -89,34 +93,38 @@ namespace smartcard_service_api
 
        int ISO7816BERTLV::decodeLength(const unsigned char *buffer)
        {
-               if (buffer[0] & 0x80)
+               uint8_t offset = 0;
+               uint8_t count = buffer[offset];
+
+               offset++;
+
+               if (count & 0x80)
                {
-                       uint8_t count = (buffer[0] & 0x7F);
                        uint8_t i;
 
+                       count &= ~0x80;
+
                        /* count will be less than 5 */
                        if (count > 4)
                                return -1;
 
-                       count++;
-
-                       for (i = 1; i < count; i++)
+                       for (i = 0; i < count; i++)
                        {
                                /* if big endian */
-                               currentL = (currentL << 8) | buffer[i];
+                               currentL = (currentL << 8) | buffer[offset + i];
 
                                /* if little endian */
-                               /* currentL = currentL | (buffer[i] << (8 * (i - 1))); */
+                               /* currentL = currentL | (buffer[offset + i] << (8 * (i - 1))); */
                        }
 
-                       return count;
+                       offset += i;
                }
                else
                {
-                       currentL = buffer[0];
-
-                       return 1;
+                       currentL = count;
                }
+
+               return offset;
        }
 
        int ISO7816BERTLV::decodeValue(const unsigned char *buffer)
index 17f485d..9712d60 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <stdio.h>
 #include <string.h>
 #include <openssl/evp.h>
 #include <openssl/bio.h>
 #include <openssl/buffer.h>
 
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "ByteArray.h"
 #include "OpensslHelper.h"
@@ -38,6 +42,9 @@ namespace smartcard_service_api
                }
 
                b64 = BIO_new(BIO_f_base64());
+               if(b64 == NULL)
+                       return false;
+
                bmem = BIO_new(BIO_s_mem());
 
                if (newLineChar == false)
@@ -88,6 +95,12 @@ namespace smartcard_service_api
                        memset(temp, 0, length);
 
                        b64 = BIO_new(BIO_f_base64());
+                       if(b64 == NULL)
+                       {
+                               delete []temp;
+                               return false;
+                       }
+
                        bmem = BIO_new_mem_buf((void *)buffer.getBuffer(), length);
                        if (newLineChar == false)
                                BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
@@ -96,12 +109,17 @@ namespace smartcard_service_api
                        length = BIO_read(bmem, temp, length);
 
                        BIO_free_all(bmem);
-
-                       result.assign((unsigned char *)temp, length);
+                       if(length > 0)
+                       {
+                               result.assign((unsigned char *)temp, length);
+                               ret = true;
+                       }
+                       else
+                       {
+                               ret = false;
+                       }
 
                        delete []temp;
-
-                       ret = true;
                }
                else
                {
index 674c684..613e58a 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "APDUHelper.h"
 #include "EFDIR.h"
@@ -23,7 +28,7 @@ namespace smartcard_service_api
 {
        static unsigned char aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x63, 0x50,
                0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 };
-       ByteArray PKCS15::PKCS15_AID(ARRAY_AND_SIZE(aid));
+       const ByteArray PKCS15::PKCS15_AID(ARRAY_AND_SIZE(aid));
 
        PKCS15::PKCS15(Channel *channel) :
                PKCS15Object(channel), odf(NULL)
@@ -48,7 +53,7 @@ namespace smartcard_service_api
        {
                int ret;
 
-               ret = PKCS15Object::select(PKCS15::PKCS15_AID);
+               ret = PKCS15Object::select(PKCS15_AID);
                if (ret >= SCARD_ERROR_OK)
                {
                        _DBG("response : %s", selectResponse.toString().c_str());
diff --git a/common/PKCS15CDF.cpp b/common/PKCS15CDF.cpp
new file mode 100644 (file)
index 0000000..7664d0d
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * 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 */
+
+/* SLP library header */
+
+/* local header */
+#include "Debug.h"
+#include "NumberStream.h"
+#include "PKCS15CDF.h"
+#include "SimpleTLV.h"
+
+namespace smartcard_service_api
+{
+       PKCS15CDF::PKCS15CDF(unsigned int fid, Channel *channel) :
+               PKCS15Object(channel)
+       {
+               int ret = 0;
+
+               if ((ret = select(fid)) >= SCARD_ERROR_OK)
+               {
+                       ByteArray cdfData, extra;
+
+                       _DBG("response : %s", selectResponse.toString().c_str());
+
+                       ret = readBinaryAll(0, cdfData);
+                       if (ret == SCARD_ERROR_OK)
+                       {
+                               _DBG("cdfData : %s", cdfData.toString().c_str());
+
+                               parseData(cdfData);
+                       }
+                       else
+                       {
+                               _ERR("readBinary failed, [%d]", ret);
+                       }
+               }
+               else
+               {
+                       _ERR("select failed, [%d]", ret);
+               }
+       }
+
+       PKCS15CDF::PKCS15CDF(const ByteArray &path, Channel *channel) :
+               PKCS15Object(channel)
+       {
+               int ret = 0;
+
+               if ((ret = select(path)) >= SCARD_ERROR_OK)
+               {
+                       ByteArray cdfData, extra;
+
+                       _DBG("response : %s", selectResponse.toString().c_str());
+
+                       ret = readBinaryAll(0, cdfData);
+                       if (ret == SCARD_ERROR_OK)
+                       {
+                               _DBG("cdfData : %s", cdfData.toString().c_str());
+
+                               parseData(cdfData);
+                       }
+                       else
+                       {
+                               _ERR("readBinary failed, [%d]", ret);
+                       }
+               }
+               else
+               {
+                       _ERR("select failed, [%d]", ret);
+               }
+       }
+
+       PKCS15CDF::~PKCS15CDF()
+       {
+       }
+
+       bool PKCS15CDF::parseData(const ByteArray &data)
+       {
+               int result;
+               char* buffer;
+               SimpleTLV tlv(data);
+
+               while (tlv.decodeTLV())
+               {
+                       CertificateType *cert;
+
+                       _DBG("0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+
+                       cert = new CertificateType();
+
+                       tlv.enterToValueTLV();
+                       if (tlv.decodeTLV())
+                       {
+                               _DBG("Common Object Attributes");
+
+                               /* Common Object Attributes */
+                               tlv.enterToValueTLV();
+                               while (tlv.decodeTLV())
+                               {
+                                       switch (tlv.getTag())
+                                       {
+                                       case (unsigned int)0x0C : /* label : OCTET STRING */
+                                               buffer = (char *)tlv.getValue().getBuffer();
+                                               if(buffer != NULL)
+                                               {
+                                                       _DBG("label : %s", buffer);
+                                                       cert->label.assign(buffer, tlv.getValue().getLength());
+                                               }
+                                               break;
+
+                                       case (unsigned int)0x03 : /* flags : BIT STRING */
+                                               /* 0 : private, 1 : modifiable */
+                                               _DBG("flag : %s", tlv.getValue()[0] ? "modifiable" : "private");
+                                               cert->modifiable = (tlv.getValue()[0] == 1);
+                                               break;
+
+                                       default :
+                                               _DBG("0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+                                               break;
+                                       }
+                               }
+                               tlv.returnToParentTLV();
+                       }
+
+                       if (tlv.decodeTLV())
+                       {
+                               _DBG("Common Certificate Attributes");
+
+                               /* Common Certificate Attributes */
+                               tlv.enterToValueTLV();
+                               while (tlv.decodeTLV())
+                               {
+                                       switch (tlv.getTag())
+                                       {
+                                       case (unsigned int)0x04 : /* iD : OCTET STRING */
+                                               _DBG("id : %s", tlv.getValue().toString().c_str());
+                                               cert->id = tlv.getValue();
+                                               break;
+
+                                       case (unsigned int)0x01 : /* Authority : BOOLEAN */
+                                               _DBG("authority : %s", tlv.getValue().toString().c_str());
+                                               cert->authority = tlv.getValue()[0];
+                                               break;
+
+                                       case (unsigned int)0xA1 : /* ??? : ??? */
+                                               tlv.enterToValueTLV();
+                                               if (tlv.decodeTLV()) {
+                                                       _DBG("    0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+                                                       tlv.enterToValueTLV();
+                                                       if (tlv.decodeTLV()) {
+                                                               _DBG("      0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+                                                               tlv.enterToValueTLV();
+                                                               if (tlv.decodeTLV()) {
+                                                                       _DBG("        0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+                                                                       tlv.enterToValueTLV();
+                                                                       if (tlv.decodeTLV()) {
+                                                                               _DBG("          0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+                                                                       }
+                                                                       tlv.returnToParentTLV();
+                                                               }
+                                                               if (tlv.decodeTLV()) {
+                                                                       _DBG("        0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+                                                               }
+                                                               tlv.returnToParentTLV();
+                                                       }
+                                                       tlv.returnToParentTLV();
+                                               }
+                                               tlv.returnToParentTLV();
+                                               break;
+
+                                       default :
+                                               _DBG("0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+                                               break;
+                                       }
+                               }
+                               tlv.returnToParentTLV();
+                       }
+
+                       if (tlv.decodeTLV())
+                       {
+                               _DBG("Certificate Attributes");
+
+                               /* Path or Object */
+                               tlv.enterToValueTLV();
+                               if (tlv.decodeTLV())
+                               {
+                                       tlv.enterToValueTLV();
+                                       if (tlv.decodeTLV())
+                                       {
+                                               /* PATH */
+                                               tlv.enterToValueTLV();
+                                               while (tlv.decodeTLV())
+                                               {
+                                                       switch (tlv.getTag())
+                                                       {
+                                                       case (unsigned int)0x04 : /* path : OCTET STRING */
+                                                               cert->path = tlv.getValue();
+                                                               _DBG("path : %s", cert->path.toString().c_str());
+                                                               break;
+
+                                                       case (unsigned int)0x02 : /* index : INTEGER */
+                                                               cert->index = NumberStream::getBigEndianNumber(tlv.getValue());
+                                                               _DBG("index : %d", cert->index);
+                                                               break;
+
+                                                       case (unsigned int)0x80 : /* length : INTEGER */
+                                                               cert->length = NumberStream::getBigEndianNumber(tlv.getValue());
+                                                               _DBG("length : %d", cert->length);
+                                                               break;
+                                                       }
+                                               }
+                                               tlv.returnToParentTLV();
+
+                                               FileObject file(channel);
+
+                                               result = file.select(cert->path, true);
+                                               if (result >= SCARD_ERROR_OK) {
+                                                       result = file.readBinary(0, cert->length, cert->certificate);
+                                                       if (result >= SCARD_ERROR_OK) {
+                                                               _DBG("certificate[%d] : %s", cert->certificate.size(), cert->certificate.toString().c_str());
+                                                       } else {
+                                                               _ERR("readBinary failed, [%x]", result);
+                                                       }
+                                               } else {
+                                                       _ERR("select failed, [%x]", result);
+                                               }
+
+                                       }
+                                       tlv.returnToParentTLV();
+                               }
+                               tlv.returnToParentTLV();
+                       }
+                       tlv.returnToParentTLV();
+
+                       listCertType.push_back(cert);
+               }
+
+               _INFO("listCertType.size() = %d", listCertType.size());
+
+               return (listCertType.size() > 0);
+       }
+
+       const CertificateType *PKCS15CDF::getCertificateType(int index) const
+       {
+               if (index < 0 || index >= (int)listCertType.size())
+                       return NULL;
+
+               return listCertType[index];
+       }
+} /* namespace smartcard_service_api */
index 50cf11a..ea1cde6 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "PKCS15DODF.h"
 #include "SimpleTLV.h"
@@ -31,9 +36,9 @@ namespace smartcard_service_api
 
                        _DBG("response : %s", selectResponse.toString().c_str());
 
-                       if ((ret = readBinary(0, 0, getFCP()->getFileSize(), dodfData)) == 0)
+                       if ((ret = readBinaryAll(0, dodfData)) == 0)
                        {
-                               _DBG("odfData : %s", dodfData.toString().c_str());
+                               _DBG("dodfData : %s", dodfData.toString().c_str());
 
                                parseData(dodfData);
                        }
@@ -59,7 +64,7 @@ namespace smartcard_service_api
 
                        _DBG("response : %s", selectResponse.toString().c_str());
 
-                       if ((ret = readBinary(0, 0, getFCP()->getFileSize(), dodfData)) == 0)
+                       if ((ret = readBinaryAll(0, dodfData)) == 0)
                        {
                                _DBG("dodfData : %s", dodfData.toString().c_str());
 
index a0beb7c..53ff3d7 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "PKCS15ODF.h"
 #include "SimpleTLV.h"
 
 namespace smartcard_service_api
 {
+       static const unsigned int ODF_FID = 0x3150;
+
+       static const unsigned int TAG_DODF = (unsigned int)0xA7;
+       static const unsigned int TAG_CDF = (unsigned int)0xA5;
+
        PKCS15ODF::PKCS15ODF(Channel *channel) :
-               PKCS15Object(channel), dodf(NULL)
+               PKCS15Object(channel), cdf(NULL), dodf(NULL)
        {
                int ret = 0;
 
-               if ((ret = select(PKCS15ODF::ODF_FID)) >= SCARD_ERROR_OK)
+               if ((ret = select(ODF_FID)) >= SCARD_ERROR_OK)
                {
                        ByteArray odfData, extra;
 
                        _DBG("response : %s", selectResponse.toString().c_str());
 
-                       if ((ret = readBinary(0, 0, getFCP()->getFileSize(), odfData)) == 0)
+                       if ((ret = readBinaryAll(0, odfData)) == 0)
                        {
                                _DBG("odfData : %s", odfData.toString().c_str());
 
@@ -55,7 +65,7 @@ namespace smartcard_service_api
                int ret = 0;
                ByteArray odfData;
 
-               if ((ret = readBinary(0, 0, 0, odfData)) == 0)
+               if ((ret = readBinaryAll(0, odfData)) == 0)
                {
                        _DBG("odfData : %s", odfData.toString().c_str());
 
@@ -85,7 +95,7 @@ namespace smartcard_service_api
                {
                        switch (tlv.getTag())
                        {
-                       case (unsigned int)0xA7 ://PKCS15ODF::TAG_DODF :
+                       case TAG_DODF :
                                {
                                        ByteArray dodf;
 
@@ -100,11 +110,11 @@ namespace smartcard_service_api
                                }
                                break;
 
-                       case (unsigned int)0xA5 ://PKCS15ODF::TAG_TOKENINFO :
+                       case TAG_CDF :
                                {
                                        ByteArray tokeninfo;
 
-                                       _DBG("TAG_TOKENINFO");
+                                       _DBG("TAG_CDF");
 
                                        tokeninfo = PKCS15Object::getOctetStream(tlv.getValue());
 
@@ -134,13 +144,13 @@ namespace smartcard_service_api
 
                if (dodf == NULL)
                {
-                       item = dataList.find((unsigned int)0xA7/*PKCS15ODF::TAG_DODF*/);
+                       item = dataList.find(TAG_DODF);
                        if (item != dataList.end())
                        {
                                NumberStream num(item->second);
                                unsigned int fid = num.getLittleEndianNumber();
 
-                               _DBG("fid [%X]", fid);
+                               _DBG("dodf fid [%X]", fid);
 
                                dodf = new PKCS15DODF(fid, channel);
                                if (dodf != NULL && dodf->isClosed() == true)
@@ -162,4 +172,37 @@ namespace smartcard_service_api
                return dodf;
        }
 
+       PKCS15CDF *PKCS15ODF::getCDF()
+       {
+               map<unsigned int, ByteArray>::iterator item;
+
+               if (cdf == NULL)
+               {
+                       item = dataList.find(TAG_CDF);
+                       if (item != dataList.end())
+                       {
+                               NumberStream num(item->second);
+                               unsigned int fid = num.getLittleEndianNumber();
+
+                               _DBG("cdf fid [%X]", fid);
+
+                               cdf = new PKCS15CDF(fid, channel);
+                               if (cdf != NULL && cdf->isClosed() == true)
+                               {
+                                       _ERR("failed to open CDF");
+
+                                       delete cdf;
+                                       cdf = NULL;
+                               }
+                       }
+                       else
+                       {
+                               _ERR("[%02X] is not found. total [%d]", TAG_CDF, dataList.size());
+                       }
+               }
+
+               _DBG("cdf [%p]", cdf);
+
+               return cdf;
+       }
 } /* namespace smartcard_service_api */
index a927fd8..2c46c24 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "PKCS15.h"
 #include "PKCS15OID.h"
@@ -49,6 +54,7 @@ namespace smartcard_service_api
                                        if (tlv.decodeTLV() == true && tlv.getTag() == 0x0C) /* ?? */
                                        {
                                                name = tlv.getValue();
+                                               SECURE_LOGD("name : %s", name.toString().c_str());
                                        }
                                        tlv.returnToParentTLV();
                                }
index 8559aa7..6c4c790 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "SimpleTLV.h"
 #include "PKCS15Object.h"
index a219c3d..0e28b13 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "PKCS15Path.h"
 
 namespace smartcard_service_api
index 37722b8..259d939 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "PKCS15TokenInfo.h"
 
 namespace smartcard_service_api
index b5ac3ed..f4daec8 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Serializable.h"
 
 namespace smartcard_service_api
index d0c97ba..62bdc1e 100644 (file)
 #include <list>
 #include <string>
 #include <vector>
-#include <sys/stat.h>
 
 /* SLP library header */
-#include "package-manager.h"
 #include "pkgmgr-info.h"
 #include "aul.h"
 
 
 namespace smartcard_service_api
 {
-       uid_t ProcGetUsrBypid(int pid)
-       {
-               char buf[255];
-               int ret;
-               uid_t uid;
-               struct stat dir_stats;
-               snprintf(buf, sizeof(buf), "/proc/%d", pid);
-               ret = stat(buf, &dir_stats);
-               if (ret < 0)
-                       uid = (uid_t) - 1;
-               else
-                       uid = dir_stats.st_uid;
-               return uid;
-       }
-
        int SignatureHelper::getPackageName(int pid, char *package, size_t length)
        {
                return aul_app_get_pkgname_bypid(pid, package, length);
        }
 
-       const ByteArray SignatureHelper::getCertificationHash(const char *packageName, uid_t uid)
+       const ByteArray SignatureHelper::getCertificationHash(const char *packageName)
        {
                ByteArray result;
                int ret = 0;
-               pkgmgr_certinfo_h handle = NULL;
+               pkgmgrinfo_certinfo_h handle = NULL;
                pkgmgrinfo_appinfo_h handle_appinfo;
                char *pkgid = NULL;
 
@@ -82,17 +65,19 @@ namespace smartcard_service_api
                }
                pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
 
-               if ((ret = pkgmgr_pkginfo_create_certinfo(&handle)) == 0)
+               SECURE_LOGD("package name : %s, package id : %s", packageName, pkgid);
+
+               if ((ret = pkgmgrinfo_pkginfo_create_certinfo(&handle)) == 0)
                {
-                       if ((ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle, uid)) == 0)
+                       if (0)
                        {
                                int type;
 
-                               for (type = (int)PM_AUTHOR_ROOT_CERT; type <= (int)PM_DISTRIBUTOR2_SIGNER_CERT; type++)
+                               for (type = (int)PMINFO_AUTHOR_ROOT_CERT; type <= (int)PMINFO_DISTRIBUTOR2_SIGNER_CERT; type++)
                                {
                                        const char *value = NULL;
 
-                                       if ((ret = pkgmgr_pkginfo_get_cert_value(handle, (pkgmgr_cert_type)type, &value)) == 0)
+                                       if ((ret = pkgmgrinfo_pkginfo_get_cert_value(handle, (pkgmgrinfo_cert_type)type, &value)) == 0)
                                        {
                                                if (value != NULL && strlen(value) > 0)
                                                {
@@ -111,7 +96,7 @@ namespace smartcard_service_api
                                _ERR("pkgmgr_pkginfo_load_certinfo failed [%d]", ret);
                        }
 
-                       pkgmgr_pkginfo_destroy_certinfo(handle);
+                       pkgmgrinfo_pkginfo_destroy_certinfo(handle);
                }
                else
                {
@@ -126,11 +111,10 @@ namespace smartcard_service_api
                ByteArray result;
                int error = 0;
                char pkgName[256] = { 0, };
-               uid_t uid = ProcGetUsrBypid(pid);
 
                if ((error = aul_app_get_pkgname_bypid(pid, pkgName, sizeof(pkgName))) == 0)
                {
-                       result = getCertificationHash(pkgName, uid);
+                       result = getCertificationHash(pkgName);
                }
                else
                {
@@ -145,11 +129,10 @@ namespace smartcard_service_api
                bool result = false;
                int error = 0;
                char pkgName[256] = { 0, };
-               uid_t uid = ProcGetUsrBypid(pid);
 
                if ((error = aul_app_get_pkgname_bypid(pid, pkgName, sizeof(pkgName))) == 0)
                {
-                       result = getCertificationHashes(pkgName, certHashes, uid);
+                       result = getCertificationHashes(pkgName, certHashes);
                }
                else
                {
@@ -159,38 +142,40 @@ namespace smartcard_service_api
                return result;
        }
 
-       bool SignatureHelper::getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes, uid_t uid)
+       bool SignatureHelper::getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes)
        {
                bool result = false;
                int ret = 0;
-               pkgmgr_certinfo_h handle = NULL;
+               pkgmgrinfo_certinfo_h handle = NULL;
                pkgmgrinfo_appinfo_h handle_appinfo;
                char *pkgid = NULL;
 
-               if(pkgmgrinfo_appinfo_get_appinfo(packageName, &handle_appinfo) != PMINFO_R_OK)
+               if (pkgmgrinfo_appinfo_get_appinfo(packageName, &handle_appinfo) != PMINFO_R_OK)
                {
                        _ERR("pkgmgrinfo_appinfo_get_appinfo fail");
                        return result;
                }
 
-               if(pkgmgrinfo_appinfo_get_pkgid(handle_appinfo, &pkgid) != PMINFO_R_OK)
+               if (pkgmgrinfo_appinfo_get_pkgid(handle_appinfo, &pkgid) != PMINFO_R_OK)
                {
                        pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
                        _ERR("pkgmgrinfo_appinfo_get_pkgid fail");
                        return result;
                }
 
-               if ((ret = pkgmgr_pkginfo_create_certinfo(&handle)) == 0)
+               SECURE_LOGD("package name : %s, package id : %s", packageName, pkgid);
+
+               if ((ret = pkgmgrinfo_pkginfo_create_certinfo(&handle)) == 0)
                {
-                       if ((ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle, uid)) == 0)
+                       if (0)
                        {
                                int type;
 
-                               for (type = (int)PM_AUTHOR_ROOT_CERT; type <= (int)PM_DISTRIBUTOR2_SIGNER_CERT; type++)
+                               for (type = (int)PMINFO_AUTHOR_ROOT_CERT; type <= (int)PMINFO_DISTRIBUTOR2_SIGNER_CERT; type++)
                                {
                                        const char *value = NULL;
 
-                                       if ((ret = pkgmgr_pkginfo_get_cert_value(handle, (pkgmgr_cert_type)type, &value)) == 0)
+                                       if ((ret = pkgmgrinfo_pkginfo_get_cert_value(handle, (pkgmgrinfo_cert_type)type, &value)) == 0)
                                        {
                                                if (value != NULL && strlen(value) > 0)
                                                {
@@ -219,7 +204,7 @@ namespace smartcard_service_api
 
                        pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
 
-                       pkgmgr_pkginfo_destroy_certinfo(handle);
+                       pkgmgrinfo_pkginfo_destroy_certinfo(handle);
                }
                else
                {
@@ -236,12 +221,15 @@ using namespace smartcard_service_api;
 certiHash *__signature_helper_vector_to_linked_list(vector<ByteArray> &certHashes)
 {
        vector<ByteArray>::iterator item;
-       certiHash *head, *tail, *tmp;
+       certiHash *head, *tail;
+       uint8_t* buffer = NULL;
 
        head = tail = NULL;
 
        for (item = certHashes.begin(); item != certHashes.end(); item++)
        {
+               certiHash *tmp = NULL;
+
                if ((tmp = (certiHash *)calloc(1, sizeof(certiHash))) == NULL)
                        goto ERROR;
 
@@ -253,7 +241,15 @@ certiHash *__signature_helper_vector_to_linked_list(vector<ByteArray> &certHashe
                        goto ERROR;
                }
 
-               memcpy(tmp->value, (*item).getBuffer(), tmp->length);
+               buffer = (*item).getBuffer();
+               if(buffer == NULL)
+               {
+                       free(tmp->value);
+                       free(tmp);
+                       continue;
+               }
+
+               memcpy(tmp->value, buffer, tmp->length);
                tmp->next = NULL;
 
                if (head == NULL)
@@ -266,11 +262,14 @@ certiHash *__signature_helper_vector_to_linked_list(vector<ByteArray> &certHashe
                        tail = tmp;
                }
        }
+
        return head;
 
 ERROR :
        _ERR("alloc fail");
 
+       certiHash *tmp;
+
        while (head)
        {
                tmp = head;
@@ -283,7 +282,7 @@ ERROR :
        return NULL;
 }
 
-EXTERN_API int signature_helper_get_certificate_hashes(const char *packageName, uid_t uid, certiHash **hash)
+EXTERN_API int signature_helper_get_certificate_hashes(const char *packageName, certiHash **hash)
 {
        int ret = -1;
        vector<ByteArray> hashes;
@@ -291,7 +290,7 @@ EXTERN_API int signature_helper_get_certificate_hashes(const char *packageName,
        if (packageName == NULL)
                return ret;
 
-       if (SignatureHelper::getCertificationHashes(packageName, hashes, uid) == true)
+       if (SignatureHelper::getCertificationHashes(packageName, hashes) == true)
        {
                *hash = __signature_helper_vector_to_linked_list(hashes);
                ret = 0;
index 94ffd0a..8b44a71 100644 (file)
 #ifndef APDUHELPER_H_
 #define APDUHELPER_H_
 
-#include "Debug.h"
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "ByteArray.h"
 
 namespace smartcard_service_api
 {
-       class EXPORT ResponseHelper
+       class ResponseHelper
        {
        private:
                ByteArray response;
@@ -71,7 +75,7 @@ namespace smartcard_service_api
 //             static char *getErrorString();
        };
 
-       class EXPORT APDUCommand
+       class APDUCommand
        {
        private:
                typedef struct _command_header_t
@@ -130,6 +134,7 @@ namespace smartcard_service_api
 //             static const unsigned char P1_ = (unsigned char)0x;
 
                static const unsigned char P2_SELECT_GET_FCP = (unsigned char)0x04;
+               static const unsigned char P2_SELECT_GET_FCI = (unsigned char)0x00;
 //             static const unsigned char P2_ = (unsigned char)0x;
 
                static const unsigned char CLA_CHANNEL_STANDARD = (unsigned char)0x00;
@@ -167,7 +172,7 @@ namespace smartcard_service_api
                bool getBuffer(ByteArray &array) const;
        };
 
-       class EXPORT APDUHelper
+       class APDUHelper
        {
        public:
                static const int COMMAND_OPEN_LOGICAL_CHANNEL = 1;
index 689eacd..6f33cca 100644 (file)
 #ifndef ACCESSCONDITION_H_
 #define ACCESSCONDITION_H_
 
+/* standard library header */
 #include <map>
 #include <vector>
 
+/* SLP library header */
+
+/* local header */
 #include "ByteArray.h"
 
 using namespace std;
@@ -33,6 +37,8 @@ namespace smartcard_service_api
                bool nfcRule;
                vector<pair<ByteArray, ByteArray> > listFilters;
 
+               void printAccessRules() const;
+
        public :
                AccessRule() : apduRule(true), nfcRule(true) {}
 
@@ -58,6 +64,8 @@ namespace smartcard_service_api
                ByteArray aid;
                map<ByteArray, AccessRule> mapRules;
 
+               void printAccessConditions() const;
+
        public :
                AccessCondition() {}
 
@@ -82,6 +90,7 @@ namespace smartcard_service_api
                AccessRule *getAccessRule(const ByteArray &certHash);
                const AccessRule *getAccessRule(const ByteArray &certHash) const;
 
+
                friend class AccessControlList;
        };
 
index 6f2b56f..77a90ba 100644 (file)
 #ifndef ACCESSCONTROLLIST_H_
 #define ACCESSCONTROLLIST_H_
 
+/* standard library header */
 #include <vector>
 #include <map>
 
+/* SLP library header */
+
+/* local header */
 #include "ByteArray.h"
 #include "Channel.h"
 #include "AccessCondition.h"
@@ -38,6 +42,8 @@ namespace smartcard_service_api
                        const ByteArray &hash) const;
                AccessCondition &getAccessCondition(const ByteArray &aid);
 
+               void printAccessControlList() const;
+
        public:
                static ByteArray ALL_SE_APPS;
                static ByteArray DEFAULT_SE_APP;
@@ -51,6 +57,9 @@ namespace smartcard_service_api
                int updateACL(Channel *channel) { return loadACL(channel); }
                void releaseACL();
 
+               /* FIXME ??? */
+               inline bool hasConditions() const { return mapConditions.size() > 0; }
+
                virtual bool isAuthorizedAccess(const ByteArray &aid,
                        const ByteArray &certHash) const;
                virtual bool isAuthorizedAccess(const unsigned char *aidBuffer,
index c6e1052..84a8c8f 100644 (file)
 #ifndef BYTEARRAY_H_
 #define BYTEARRAY_H_
 
+/* standard library header */
 #include <string>
 #include <stdint.h>
 #include <stddef.h>
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
+//#include "Serializable.h"
 
 #define ARRAY_AND_SIZE(x) (uint8_t *)(&x), sizeof(x)
 
@@ -29,7 +33,7 @@ using namespace std;
 
 namespace smartcard_service_api
 {
-       class EXPORT ByteArray //: public Serializable
+       class ByteArray //: public Serializable
        {
        protected:
                uint8_t *buffer;
@@ -78,6 +82,7 @@ namespace smartcard_service_api
                uint8_t operator [](size_t index) const;
 
                inline bool isEmpty() const { return (buffer == (void *)0 || length == 0); }
+               const string toString(bool entire) const;
                const string toString() const;
        };
 
index da0b472..8358142 100644 (file)
 #ifndef CHANNEL_H_
 #define CHANNEL_H_
 
-#include "Debug.h"
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Synchronous.h"
 #include "ByteArray.h"
 #include "Exception.h"
@@ -30,10 +34,11 @@ namespace smartcard_service_api
                unsigned int length, int error, void *userParam);
        typedef void (*closeChannelCallback)(int error, void *userParam);
 
-       class EXPORT Channel : public Synchronous
+       class Channel : public Synchronous
        {
        protected :
                ByteArray selectResponse;
+               ByteArray transmitResponse;
                SessionHelper *session;
                int channelNum;
 
@@ -49,6 +54,7 @@ namespace smartcard_service_api
                inline bool isClosed() const throw() { return (channelNum < 0); }
 
                inline const ByteArray getSelectResponse() const throw() { return selectResponse; }
+               inline const ByteArray getTransmitResponse() const throw() { return transmitResponse; }
                inline SessionHelper *getSession() const throw() { return session; }
 
                virtual int close(closeChannelCallback callback, void *userParam) = 0;
index edcf921..bb829ef 100644 (file)
 #ifndef DEBUG_H_
 #define DEBUG_H_
 
+/* standard library header */
 #include <iostream>
 
+/* SLP library header */
 #include "dlog.h"
 
-#ifndef EXPORT
-#define EXPORT __attribute__((visibility("default")))
-#endif
+/* local header */
 
 #define COLOR_BLACK    "\033[0;30m"
 #define COLOR_RED      "\033[0;31m"
 #define _BEGIN() \
        do \
        { \
-               LOGD(COLOR_BLUE"BEGIN >>>>"COLOR_END); \
+               LOGD(COLOR_BLUE "BEGIN >>>>" COLOR_END); \
        } \
        while (0)
 
 #define _END() \
        do \
        { \
-               LOGD(COLOR_BLUE"END <<<<"COLOR_END); \
+               LOGD(COLOR_BLUE "END <<<<" COLOR_END); \
        } \
        while (0)
 
index 9314fe4..c19eec9 100644 (file)
 #ifndef EFDIR_H_
 #define EFDIR_H_
 
+/* standard library header */
 #include <vector>
 
+/* SLP library header */
+
+/* local header */
 #include "FileObject.h"
 
 using namespace std;
index 8b33ae2..cb59d1d 100644 (file)
@@ -20,7 +20,6 @@
 #include <exception>
 #include <stddef.h>
 
-#include "Debug.h"
 #include "smartcard-types.h"
 
 #define THROW_ERROR(errorCode) \
@@ -67,7 +66,7 @@
 
 namespace smartcard_service_api
 {
-       class EXPORT ExceptionBase : public std::exception
+       class ExceptionBase : public std::exception
        {
        protected :
                int errorCode;
@@ -84,7 +83,7 @@ namespace smartcard_service_api
                }
        };
 
-       class EXPORT ErrorIO : public ExceptionBase
+       class ErrorIO : public ExceptionBase
        {
        private :
                unsigned char sw[2];
@@ -131,7 +130,7 @@ namespace smartcard_service_api
                }
        };
 
-       class EXPORT ErrorSecurity : public ExceptionBase
+       class ErrorSecurity : public ExceptionBase
        {
        public :
                ErrorSecurity(int errorCode) throw()
@@ -157,7 +156,7 @@ namespace smartcard_service_api
                }
        };
 
-       class EXPORT ErrorIllegalState : public ExceptionBase
+       class ErrorIllegalState : public ExceptionBase
        {
        public :
                ErrorIllegalState(int errorCode) throw()
@@ -191,7 +190,7 @@ namespace smartcard_service_api
                }
        };
 
-       class EXPORT ErrorIllegalParameter : public ExceptionBase
+       class ErrorIllegalParameter : public ExceptionBase
        {
        public :
                ErrorIllegalParameter(int errorCode) throw()
@@ -217,7 +216,7 @@ namespace smartcard_service_api
                }
        };
 
-       class EXPORT ThrowError
+       class ThrowError
        {
        public :
                static void throwError(int errorCode)
index a0e6d8a..1b303e5 100644 (file)
 #ifndef FCI_H_
 #define FCI_H_
 
+/* standard library header */
 #include <string>
 
+/* SLP library header */
+
+/* local header */
 #include "ByteArray.h"
 
 namespace smartcard_service_api
index 3f879bb..c377dbf 100644 (file)
 #ifndef FILEOBJECT_H_
 #define FILEOBJECT_H_
 
+/* standard library header */
 #include <vector>
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
 #include "ProviderHelper.h"
 #include "ByteArray.h"
 #include "FCI.h"
@@ -29,7 +32,7 @@ using namespace std;
 
 namespace smartcard_service_api
 {
-       class EXPORT FileObject : public ProviderHelper
+       class FileObject : public ProviderHelper
        {
        private:
                FCI fci;
@@ -76,7 +79,11 @@ namespace smartcard_service_api
                int searchRecord(unsigned int sfi, const ByteArray &searchParam, vector<int> &result);
 
                int readBinary(unsigned int sfi, unsigned int offset, unsigned int length, ByteArray &result);
+               int readBinary(unsigned int sfi, unsigned int length, ByteArray &result);
                int writeBinary(unsigned int sfi, const ByteArray &data, unsigned int offset, unsigned int length);
+               int writeBinary(unsigned int sfi, const ByteArray &data);
+
+               int readBinaryAll(unsigned int sfi, ByteArray &result);
        };
 
 } /* namespace smartcard_service_api */
index 73edb10..a32c269 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <glib.h>
 
-#include "Debug.h"
 #include "ByteArray.h"
 
 namespace smartcard_service_api
@@ -32,7 +31,7 @@ namespace smartcard_service_api
                void *user_param;
        };
 
-       class EXPORT GDBusHelper
+       class GDBusHelper
        {
        public :
                static void convertVariantToByteArray(GVariant *var,
index c69f59f..5300dfd 100644 (file)
 #ifndef GPACE_H_
 #define GPACE_H_
 
-#include "Debug.h"
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "smartcard-types.h"
 #ifdef __cplusplus
 #include "AccessControlList.h"
@@ -26,7 +30,7 @@
 #ifdef __cplusplus
 namespace smartcard_service_api
 {
-       class EXPORT GPACE : public AccessControlList
+       class GPACE : public AccessControlList
        {
        private :
                AccessControlList *acl;
index dbfb5f3..4038b41 100644 (file)
 #ifndef GPARAACL_H_
 #define GPARAACL_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "smartcard-types.h"
 #ifdef __cplusplus
 #include "AccessControlList.h"
index 2cf6621..d4b3116 100644 (file)
 #ifndef GPARAM_H_
 #define GPARAM_H_
 
+/* standard library header */
 #include <vector>
 
+/* SLP library header */
+
+/* local header */
 #include "FileObject.h"
 
 using namespace std;
index c612e22..396adbe 100644 (file)
 #ifndef GPARFACL_H_
 #define GPARFACL_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "smartcard-types.h"
 #ifdef __cplusplus
 #include "AccessControlList.h"
index 82cb043..d5a0cd7 100644 (file)
 #ifndef ISO7816BERTLV_H_
 #define ISO7816BERTLV_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "ByteArray.h"
 #include "TLVHelper.h"
 
index 0339d08..6328016 100644 (file)
 #ifndef LOCK_H_
 #define LOCK_H_
 
-#include <pthread.h>
+/* standard library header */
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
+#include "pthread.h"
 
 namespace smartcard_service_api
 {
-       class EXPORT Lock
+       class Lock
        {
        public:
                virtual ~Lock() {};
@@ -46,9 +49,9 @@ namespace smartcard_service_api
 #define TOKENPASTE(x, y) x ## y
 #define TOKENPASTE2(x, y) TOKENPASTE(x, y)
 #define SCOPE_LOCK(X) \
-       if (const AutoLockHelper& TOKENPASTE2(lock_, __LINE__) = makeAutoLock(X))
+       if (AutoLockHelper TOKENPASTE2(lock_, __LINE__) = makeAutoLock(X))
 
-       class EXPORT AutoLockHelper
+       class AutoLockHelper
        {
        public:
                inline operator bool() const
@@ -58,7 +61,7 @@ namespace smartcard_service_api
        };
 
        template<typename T>
-       class EXPORT AutoLock : public AutoLockHelper
+       class AutoLock : public AutoLockHelper
        {
        private:
                T *lock;
index 26f10e3..74b1f8b 100644 (file)
 #ifndef NUMBERSTREAM_H_
 #define NUMBERSTREAM_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "ByteArray.h"
 
 namespace smartcard_service_api
index 87b55b0..05cd2c2 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <stdint.h>
 
+/* SLP library header */
+
+/* local header */
 #include "ByteArray.h"
 
 #ifndef OPENSSLHELPER_H_
index e7bbb7c..568036e 100644 (file)
 #ifndef PKCS15_H_
 #define PKCS15_H_
 
+/* standard library header */
 #include <map>
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
 #include "PKCS15Object.h"
 #include "PKCS15ODF.h"
 
@@ -27,7 +30,7 @@ using namespace std;
 
 namespace smartcard_service_api
 {
-       class EXPORT PKCS15: public PKCS15Object
+       class PKCS15: public PKCS15Object
        {
        private:
                map<unsigned int, ByteArray> recordElement;
@@ -36,7 +39,7 @@ namespace smartcard_service_api
                int selectFromEFDIR();
 
        public:
-               static ByteArray PKCS15_AID;
+               static const ByteArray PKCS15_AID;
 
                PKCS15(Channel *channel);
                PKCS15(Channel *channel, const ByteArray &selectResponse);
diff --git a/common/include/PKCS15CDF.h b/common/include/PKCS15CDF.h
new file mode 100644 (file)
index 0000000..aa9e336
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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 PKCS15CDF_H_
+#define PKCS15CDF_H_
+
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
+#include "PKCS15Object.h"
+#include "PKCS15OID.h"
+
+namespace smartcard_service_api
+{
+       class CertificateType
+       {
+       public :
+               /* Common Object Attributes */
+               string label;
+               bool modifiable;
+
+               /* Common Certificate Attributes */
+               ByteArray id;
+               int authority;
+
+               /* Certificate Attributes */
+               ByteArray path;
+               int index;
+               size_t length;
+               ByteArray certificate;
+       };
+
+       class PKCS15CDF : public PKCS15Object
+       {
+       private:
+               vector<CertificateType *> listCertType;
+
+               bool parseData(const ByteArray &data);
+
+       public:
+               PKCS15CDF(unsigned int fid, Channel *channel);
+               PKCS15CDF(const ByteArray &path, Channel *channel);
+               ~PKCS15CDF();
+
+               inline size_t getCount() const { return listCertType.size(); }
+               const CertificateType *getCertificateType(int index) const;
+       };
+
+} /* namespace smartcard_service_api */
+#endif /* PKCS15DODF_H_ */
index 7dfb5ea..9364245 100644 (file)
 #ifndef PKCS15DODF_H_
 #define PKCS15DODF_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "PKCS15Object.h"
 #include "PKCS15OID.h"
 
index 27a1b18..a886f33 100644 (file)
 #ifndef PKCS15ODF_H_
 #define PKCS15ODF_H_
 
+/* standard library header */
 #include <map>
 
+/* SLP library header */
+
+/* local header */
 #include "FileObject.h"
+#include "PKCS15CDF.h"
 #include "PKCS15DODF.h"
 
 using namespace std;
@@ -29,16 +34,12 @@ namespace smartcard_service_api
        class PKCS15ODF : public PKCS15Object
        {
        private:
-               bool parseData(const ByteArray &data);
+               PKCS15CDF *cdf;
                PKCS15DODF *dodf;
 
-       public:
-               static const unsigned int ODF_FID = 0x3150;
-
-               static const unsigned int TAG_DODF = (unsigned int)0xA7;
-               static const unsigned int TAG_TOKENINFO = (unsigned int)0xA5;
+               bool parseData(const ByteArray &data);
 
-//             PKCS15ODF();
+       public:
                PKCS15ODF(Channel *channel);
                PKCS15ODF(Channel *channel, const ByteArray &selectResponse);
                ~PKCS15ODF();
@@ -46,9 +47,10 @@ namespace smartcard_service_api
                int getPuKDFPath(ByteArray &path);
                int getPrKDFPath(ByteArray &path);
                int getAODFPath(ByteArray &path);
-               int getCDFFPath(ByteArray &path);
+               int getCDFPath(ByteArray &path);
                int getDODFPath(ByteArray &path);
 
+               PKCS15CDF *getCDF();
                PKCS15DODF *getDODF();
        };
 
index 9ba3073..248150b 100644 (file)
 #ifndef PKCS15OID_H_
 #define PKCS15OID_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "ByteArray.h"
 
 namespace smartcard_service_api
index e5d78d2..df76f72 100644 (file)
 #ifndef PKCS15OBJECT_H_
 #define PKCS15OBJECT_H_
 
+/* standard library header */
 #include <map>
 #include <vector>
 
+/* SLP library header */
+
+/* local header */
 #include "FileObject.h"
 #include "PKCS15Path.h"
 
index b5a964b..52f3894 100644 (file)
 #ifndef PKCS15Path_H_
 #define PKCS15Path_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "ByteArray.h"
 
 namespace smartcard_service_api
index 5ebba70..9f3ff80 100644 (file)
 #ifndef PKCS15TOKENINFO_H_
 #define PKCS15TOKENINFO_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "PKCS15Object.h"
 
 namespace smartcard_service_api
index 2c004ea..7418b6c 100644 (file)
 #ifndef PROVIDERHELPER_H_
 #define PROVIDERHELPER_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Channel.h"
 
 namespace smartcard_service_api
index e3c0b8d..259044a 100644 (file)
 #ifndef READERHELPER_H_
 #define READERHELPER_H_
 
+/* standard library header */
 #include <vector>
 #include <string>
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
 #include "Synchronous.h"
 #include "SessionHelper.h"
 
@@ -33,7 +36,7 @@ namespace smartcard_service_api
        typedef void (*openSessionCallback)(SessionHelper *session, int error,
                void *userData);
 
-       class EXPORT ReaderHelper : public Synchronous
+       class ReaderHelper : public Synchronous
        {
        protected:
                SEServiceHelper *seService;
index 999c293..4afbfcb 100644 (file)
 #ifndef SESERVICEHELPER_H_
 #define SESERVICEHELPER_H_
 
+/* standard library header */
 #include <vector>
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
 #include "Synchronous.h"
 #include "ReaderHelper.h"
 
@@ -27,7 +30,7 @@ using namespace std;
 
 namespace smartcard_service_api
 {
-       class EXPORT SEServiceHelper : public Synchronous
+       class SEServiceHelper : public Synchronous
        {
        protected:
                vector<ReaderHelper *> readers;
index 98ada48..a138cd6 100644 (file)
 #ifndef SERIALIZABLE_H_
 #define SERIALIZABLE_H_
 
-#include "Debug.h"
 #include "ByteArray.h"
 
 namespace smartcard_service_api
 {
-       class EXPORT Serializable
+       class Serializable
        {
                virtual const ByteArray serialize() const = 0;
                virtual void deserialize(const ByteArray &buffer) = 0;
index 513790e..3e220e6 100644 (file)
 #ifndef SESSIONHELPER_H_
 #define SESSIONHELPER_H_
 
+/* standard library header */
 #include <vector>
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
 #include "Synchronous.h"
 #include "ByteArray.h"
 #include "Channel.h"
@@ -35,7 +38,7 @@ namespace smartcard_service_api
        typedef void (*closeSessionCallback)(int error, void *userData);
        typedef void (*getChannelCountCallback)(unsigned count, int error, void *userData);
 
-       class EXPORT SessionHelper : public Synchronous
+       class SessionHelper : public Synchronous
        {
        protected:
                ReaderHelper *reader;
@@ -85,6 +88,22 @@ namespace smartcard_service_api
                virtual Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length)
                        throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                                ErrorIllegalParameter &, ErrorSecurity &) = 0;
+
+               virtual Channel *openBasicChannelSync(const ByteArray &aid, unsigned char P2)
+                       throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                               ErrorIllegalParameter &, ErrorSecurity &) = 0;
+
+               virtual Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+                       throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                               ErrorIllegalParameter &, ErrorSecurity &) = 0;
+
+               virtual Channel *openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
+                       throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                               ErrorIllegalParameter &, ErrorSecurity &) = 0;
+
+               virtual Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+                       throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+                               ErrorIllegalParameter &, ErrorSecurity &) = 0;
        };
 
 } /* namespace smartcard_service_api */
index 65e9b26..f65844c 100644 (file)
 #ifndef SIGNATUREHELPER_H_
 #define SIGNATUREHELPER_H_
 
+/* standard library header */
 #ifdef __cplusplus
 #include <vector>
-#include "ByteArray.h"
 #endif /* __cplusplus */
 
-#include <sys/types.h>
+/* SLP library header */
 
-#include "Debug.h"
+/* local header */
 #include "smartcard-types.h"
+#ifdef __cplusplus
+#include "ByteArray.h"
+#endif /* __cplusplus */
 
 #ifdef __cplusplus
 using namespace std;
 
 namespace smartcard_service_api
 {
-       class EXPORT SignatureHelper
+       class SignatureHelper
        {
        public:
                static int getPackageName(int pid, char *package, size_t length);
-               static const ByteArray getCertificationHash(const char *packageName, uid_t uid);
+               static const ByteArray getCertificationHash(const char *packageName);
                static const ByteArray getCertificationHash(int pid);
                static bool getCertificationHashes(int pid, vector<ByteArray> &certHashes);
-               static bool getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes, uid_t uid);
+               static bool getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes);
        };
 
 } /* namespace smartcard_service_api */
index c228171..479b902 100644 (file)
 #ifndef SYNCHRONOUS_H_
 #define SYNCHRONOUS_H_
 
+/* standard library header */
 #include <pthread.h>
 
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
 
 namespace smartcard_service_api
 {
-       class EXPORT Synchronous
+       class Synchronous
        {
        protected:
                pthread_mutex_t syncMutex;
index 0e3db4a..c26003a 100644 (file)
 #ifndef TERMINAL_H_
 #define TERMINAL_H_
 
-#include "Debug.h"
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "ByteArray.h"
 #include "Synchronous.h"
 
@@ -28,7 +32,7 @@ namespace smartcard_service_api
        typedef void (*terminalTransmitCallback)(const unsigned char *buffer, unsigned int length, int error, void *userParam);
        typedef void (*terminalGetATRCallback)(const unsigned char *buffer, unsigned int length, int error, void *userParam);
 
-       class EXPORT Terminal : public Synchronous
+       class Terminal : public Synchronous
        {
        protected:
                terminalNotificationCallback statusCallback;
index 47d7171..311b43a 100644 (file)
 #ifndef TERMINALINTERFACE_H_
 #define TERMINALINTERFACE_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
+
 //typedef unsigned int terminal_handle_h;
 //
 //typedef enum
diff --git a/common/smartcard-service-common.pc b/common/smartcard-service-common.pc
new file mode 100644 (file)
index 0000000..0c1c83a
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=/usr
+exec_prefix=${prefix}/bin
+includedir=${prefix}/include
+libdir=${prefix}/lib
+
+Name: smartcard-service-common
+Description: Make flags of Common library of Smartcard service
+Version: 1.0
+Requires: glib-2.0 dlog
+Libs: -L${libdir} -lsmartcard-service-common
+Cflags: -I${includedir}/smartcard-service-common
\ No newline at end of file
diff --git a/common/smartcard-service-common.pc.in b/common/smartcard-service-common.pc.in
deleted file mode 100644 (file)
index 7eba9e2..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@PREFIX@
-exec_prefix=${prefix}/bin
-libdir=@LIB_INSTALL_DIR@
-includedir=@INCLUDE_INSTALL_DIR@/@COMMON_LIB@
-
-Name: @COMMON_LIB@
-Description: Common library of Smartcard service
-Version: @FULLVER@
-Requires: glib-2.0 dlog
-Libs: -L${libdir} -l@COMMON_LIB@
-Cflags: -I${includedir}
index cc8b21a..e98e9d0 100755 (executable)
       <arg type="u" name="session_id" direction="in" />
       <arg type="u" name="type" direction="in" />
       <arg type="a(y)" name="aid" direction="in" />
+      <arg type="y" name="P2" direction="in" />
       <arg type="i" name="result" direction="out" />
       <arg type="u" name="handle" direction="out" />
+      <arg type="i" name="channel_number" direction="out" />
       <arg type="a(y)" name="select_response" direction="out" />
     </method>
     <!--
diff --git a/common/smartcard-service.xml b/common/smartcard-service.xml
deleted file mode 100644 (file)
index 50e031d..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/org/tizen/smartcard_service">
-       <interface name="org.tizen.smartcard_service">
-               <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="smartcard_service"/>
-               <method name="launch">
-                       <arg type="i" name="result" direction="out"/>
-               </method>
-       </interface>
-</node>
-
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..c7c2e9a
--- /dev/null
@@ -0,0 +1,55 @@
+smartcard-service (0.1.0-3) unstable; urgency=low
+
+  * add an exceptional case when is openning client channel (nfc-manager)
+  * Git: slp/pkgs/s/smartcard-service
+  * Tag: smartcard-service_0.1.0-3
+
+ -- Wonkyu Kwon <wonkyu.kwon@samsung.com>  Fri, 20 Apr 2012 11:00:00 +0900
+
+smartcard-service (0.1.0-2) unstable; urgency=low
+
+  * add helpers for openssl and package signature
+  * Git: slp/pkgs/s/smartcard-service
+  * Tag: smartcard-service_0.1.0-2
+
+ -- Wonkyu Kwon <wonkyu.kwon@samsung.com>  Fri, 23 Mar 2012 12:40:00 +0900
+
+smartcard-service (0.1.0-1) unstable; urgency=low
+
+  * Upload package
+  * Git: slp/pkgs/s/smartcard-service
+  * Tag: smartcard-service_0.1.0-1
+
+ -- Wonkyu Kwon <wonkyu.kwon@samsung.com>  Wed, 14 Mar 2012 13:30:00 +0900
+
+smartcard-service (0.0.0-4) unstable; urgency=low
+
+  * Upload package
+  * Git: slp/pkgs/s/smartcard-service
+  * Tag: smartcard-service_0.0.0-4
+
+ -- Wonkyu Kwon <wonkyu.kwon@samsung.com>  Tue, 13 Mar 2012 13:10:00 +0900
+
+smartcard-service (0.0.0-3) unstable; urgency=low
+
+  * namespace and macro name change
+  * Git: slp/pkgs/s/smartcard-service
+  * Tag: smartcard-service_0.0.0-3
+
+ -- Sangsoo Lee <constant.lee@samsung.com>  Wed, 07 Mar 2012 19:26:46 +0900
+
+smartcard-service (0.0.0-2) unstable; urgency=low
+
+  * getChannelCount api add
+  * Git: slp/pkgs/s/smartcard-service
+  * Tag: smartcard-service_0.0.0-2
+
+ -- Sangsoo Lee <constant.lee@samsung.com>  Thu, 23 Feb 2012 21:10:42 +0900
+
+smartcard-service (0.0.0-1) unstable; urgency=low
+
+  * Initial release
+  * Git: slp/pkgs/s/smartcard-service
+  * Tag: smartcard-service_0.0.0-1
+
+ -- Wonkyu Kwon <wonkyu.kwon@samsung.com>  Thu, 31 Jan 2012 00:00:00 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..45a4fb7
--- /dev/null
@@ -0,0 +1 @@
+8
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..f0eabd9
--- /dev/null
@@ -0,0 +1,65 @@
+Source: smartcard-service
+Priority: extra
+Maintainer: Wonkyu Kwon <wonkyu.kwon@samsung.com>, Sangsoo Lee <constant.lee@samsung.com>, Sungjae Lim <sungjae.lim@samsung.com>, Junyong Sim <junyong.sim@samsung.com>, Sechang Sohn <sc.sohn@samsung.com>
+Build-Depends: debhelper (>= 8.0.0), libglib2.0-dev, libvconf-dev, libsecurity-server-client-dev, dlog-dev, wrt-commons-dev, libaul-1-dev, libssl-dev
+#Build-Depends: debhelper (>= 8.0.0), libglib2.0-dev, libvconf-dev, libsecurity-server-client-dev, dlog-dev, libpkcs11-helper1-dev, wrt-commons, libaul-dev, libssl-dev
+#Standards-Version: 3.9.2
+Section: mixed
+Homepage: <insert the upstream URL, if relevant>
+#Vcs-Git: git://git.debian.org/collab-maint/smartcard-service.git
+#Vcs-Browser: http://git.debian.org/?p=collab-maint/smartcard-service.git;a=summary
+
+Package: smartcard-service-common
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Common library of Smart card service
+ Common library of Smart card service
+
+Package: smartcard-service-common-dev
+Section: libdevel
+Architecture: any
+Depends: smartcard-service-common (= ${binary:Version})
+Description: Common library of Smart card service
+ Common library of Smart card service
+
+Package: smartcard-service-common-dbg
+Section: debug
+Architecture: any
+Depends: smartcard-service-common (= ${binary:Version})
+Description: Common library of Smart card service (unstripped)
+ Common library of Smart card service (unstripped)
+
+Package: smartcard-service-server
+Architecture: any
+Depends: smartcard-service-common-dev (= ${binary:Version})
+Description: Main process of Smart card service
+ Main process of Smart card service
+
+Package: smartcard-service-server-dbg
+Section: debug
+Architecture: any
+Depends: smartcard-service-server (= ${binary:Version})
+Description: Main process of Smart card service (unstripped)
+ Main process of Smart card service (unstripped)
+
+Package: smartcard-service
+Section: libs
+Architecture: any
+Depends: smartcard-service-common-dev (= ${binary:Version})
+Description: User library of Smart card service 
+ User library of Smart card service
+
+Package: smartcard-service-dev
+Section: libdevel
+Architecture: any
+Depends: smartcard-service (= ${binary:Version})
+Description: User library of Smart card service
+ User library of Smart card service
+
+Package: smartcard-service-dbg
+Section: debug
+Architecture: any
+Depends: smartcard-service (= ${binary:Version})
+Description: User library of Smart card service (unstripped)
+ User library of Smart card service (unstripped)
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..d6ef688
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+override_dh_auto_build:
+
+       cd $(CMAKE_BINARY_DIR)
+       dh_auto_build
+
+override_dh_install:
+       
+       mkdir -p $(CURDIR)/debian/tmp/etc/init.d
+       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/
+       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/
+       
+       cp -af $(CURDIR)/debian/smartcard-service-server.init $(CURDIR)/debian/tmp/etc/init.d/smartcard-service-server
+       ln -s ../init.d/smartcard-service-server $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S79smartcard-service-server
+       ln -s ../init.d/smartcard-service-server $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/S79smartcard-service-server
+       
+       dh_install
+       
+override_dh_installinit:
+
+%:
+       dh $@ 
+
diff --git a/debian/smartcard-service-common-dev.dirs b/debian/smartcard-service-common-dev.dirs
new file mode 100644 (file)
index 0000000..4418816
--- /dev/null
@@ -0,0 +1,2 @@
+usr/lib
+usr/include
diff --git a/debian/smartcard-service-common-dev.install b/debian/smartcard-service-common-dev.install
new file mode 100644 (file)
index 0000000..2d332a5
--- /dev/null
@@ -0,0 +1,5 @@
+usr/include/smartcard-service-common/*
+#usr/lib/lib*.a
+usr/lib/libsmartcard-service-common.so
+usr/lib/pkgconfig/smartcard-service-common.pc
+#usr/share/pkgconfig/*
diff --git a/debian/smartcard-service-common.dirs b/debian/smartcard-service-common.dirs
new file mode 100644 (file)
index 0000000..6845771
--- /dev/null
@@ -0,0 +1 @@
+usr/lib
diff --git a/debian/smartcard-service-common.install b/debian/smartcard-service-common.install
new file mode 100644 (file)
index 0000000..3b87046
--- /dev/null
@@ -0,0 +1 @@
+usr/lib/libsmartcard-service-common.so.*
diff --git a/debian/smartcard-service-dev.dirs b/debian/smartcard-service-dev.dirs
new file mode 100644 (file)
index 0000000..4418816
--- /dev/null
@@ -0,0 +1,2 @@
+usr/lib
+usr/include
diff --git a/debian/smartcard-service-dev.install b/debian/smartcard-service-dev.install
new file mode 100644 (file)
index 0000000..a547e24
--- /dev/null
@@ -0,0 +1,5 @@
+usr/include/smartcard-service/*
+#usr/lib/lib*.a
+usr/lib/libsmartcard-service.so
+usr/lib/pkgconfig/smartcard-service.pc
+#usr/share/pkgconfig/*
diff --git a/debian/smartcard-service-server.dirs b/debian/smartcard-service-server.dirs
new file mode 100644 (file)
index 0000000..2d445a0
--- /dev/null
@@ -0,0 +1,2 @@
+usr/bin
+etc
\ No newline at end of file
diff --git a/debian/smartcard-service-server.init b/debian/smartcard-service-server.init
new file mode 100755 (executable)
index 0000000..ffc409b
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          smartcard-service-server
+# Required-Start:    $network $local_fs
+# Required-Stop:
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: <Enter a short description of the sortware>
+# Description:       <Enter a long description of the software>
+#                    <...>
+#                    <...>
+### END INIT INFO
+
+# Author: Wonkyu Kwon <wonkyu.kwon@samsung.com>
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/usr/bin
+DESC=smartcard-daemon      # Introduce a short description here
+NAME=smartcard-daemon      # Introduce the short server's name here
+DAEMON=/usr/bin/smartcard-daemon # Introduce the server's location here
+DAEMON_ARGS=""             # Arguments to run the daemon with
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x $DAEMON ] || exit 0
+
+$DAEMON $DAEMON_ARGS &
\ No newline at end of file
diff --git a/debian/smartcard-service-server.install b/debian/smartcard-service-server.install
new file mode 100644 (file)
index 0000000..8a71c41
--- /dev/null
@@ -0,0 +1,2 @@
+usr/bin/smartcard-daemon
+etc/*
\ No newline at end of file
diff --git a/debian/smartcard-service.dirs b/debian/smartcard-service.dirs
new file mode 100644 (file)
index 0000000..6845771
--- /dev/null
@@ -0,0 +1 @@
+usr/lib
diff --git a/debian/smartcard-service.install b/debian/smartcard-service.install
new file mode 100644 (file)
index 0000000..05b76e3
--- /dev/null
@@ -0,0 +1 @@
+usr/lib/libsmartcard-service.so.*
diff --git a/packaging/smartcard-service b/packaging/smartcard-service
new file mode 100644 (file)
index 0000000..ec68963
--- /dev/null
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+\r
+\r
diff --git a/packaging/smartcard-service-common b/packaging/smartcard-service-common
new file mode 100644 (file)
index 0000000..ec68963
--- /dev/null
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+\r
+\r
diff --git a/packaging/smartcard-service-common-devel.manifest b/packaging/smartcard-service-common-devel.manifest
deleted file mode 100644 (file)
index c00c25b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-        <request>
-                <domain name="_" />
-        </request>
-</manifest>
diff --git a/packaging/smartcard-service-common.manifest b/packaging/smartcard-service-common.manifest
deleted file mode 100644 (file)
index c00c25b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-        <request>
-                <domain name="_" />
-        </request>
-</manifest>
diff --git a/packaging/smartcard-service-devel.manifest b/packaging/smartcard-service-devel.manifest
deleted file mode 100644 (file)
index c00c25b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-        <request>
-                <domain name="_" />
-        </request>
-</manifest>
diff --git a/packaging/smartcard-service-server b/packaging/smartcard-service-server
new file mode 100644 (file)
index 0000000..ec68963
--- /dev/null
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+\r
+\r
diff --git a/packaging/smartcard-service-server.manifest b/packaging/smartcard-service-server.manifest
deleted file mode 100644 (file)
index c00c25b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-        <request>
-                <domain name="_" />
-        </request>
-</manifest>
diff --git a/packaging/smartcard-service.changes b/packaging/smartcard-service.changes
deleted file mode 100644 (file)
index b8b843d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-* Sun Aug 25 2013 Chengwei Yang <chengwei.yang@intel.com>
-- Remove debian packaging stuff
-
-* Wed May 29 2013 Baptiste DURAND <baptiste.durand@eurogiciel.fr> accepted/tizen/20130523.160330@6952ac6
-- Fix compatibility for x64 arch
-
-* Wed May 22 2013 Rusty Lynch <rusty.lynch@intel.com> accepted/tizen/20130520.101306@173a4a8
-- Cleanup the package spec
-- Fix build for Tizen 3.0
diff --git a/packaging/smartcard-service.manifest b/packaging/smartcard-service.manifest
deleted file mode 100644 (file)
index c00c25b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-        <request>
-                <domain name="_" />
-        </request>
-</manifest>
index d79a255..c9a9970 100644 (file)
@@ -2,24 +2,23 @@
 %global use_autostart "-DUSE_AUTOSTART=1"
 #%%global test_client "-DTEST_CLIENT=1"
 
+################################################################################
+# package : smartcard-service                                                  #
+################################################################################
 Name:       smartcard-service
-Summary:    Smartcard Service
-Version:    0.1.30
+Summary:    Smartcard Service FW
+Version:    0.1.43
 Release:    0
-Group:      Network & Connectivity/Service
+Group:      libs
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 %if 0%{!?use_autostart:1}
-Source1:    smartcard-service-server.init
+Source1:    %{name}-server.init
 %endif
 BuildRequires: cmake
-Source1001:    %{name}.manifest
-Source1002:    %{name}-devel.manifest
-Source1003:    smartcard-service-common.manifest
-Source1004:    smartcard-service-common-devel.manifest
-Source1005:    smartcard-service-server.manifest
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(gio-unix-2.0)
+BuildRequires: pkgconfig(security-server)
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(libssl)
@@ -27,132 +26,183 @@ BuildRequires: pkgconfig(pkgmgr)
 BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: python
 BuildRequires: python-xml
+BuildRequires: hash-signer
 
 Requires(post):   /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
-Requires:         smartcard-service-common = %{version}-%{release}
+Requires:         %{name}-common = %{version}-%{release}
 
 
 %description
-A library for Smartcard applications.
+Smartcard Service FW.
 
 
-%prep
-%setup -q
-cp %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} %{SOURCE1005} .
+%files
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%{_libdir}/lib%{name}.so.*
+%{_datadir}/license/%{name}
+
+
+%post
+/sbin/ldconfig
 
 
+%postun
+/sbin/ldconfig
+
+
+################################################################################
+# package : smartcard-service-devel                                            #
+################################################################################
 %package    devel
-Summary:    Smartcard service
-Group:      Network & Connectivity/Development
+Summary:    smartcard service devel
+Group:      Development/Libraries
 Requires:   %{name} = %{version}-%{release}
 
-%description devel
-For developing Smartcard applications.
 
+%description devel
+smartcard service.
 
-%package -n smartcard-service-common
-Summary:    Common smartcard service
-Group:      Network & Connectivity/Service
 
-%description -n smartcard-service-common
-Common smartcard service for developing internally
+%files  devel
+%manifest %{name}-devel.manifest
+%defattr(-,root,root,-)
+%{_includedir}/%{name}/*
+%{_libdir}/lib%{name}.so
+%{_libdir}/pkgconfig/%{name}.pc
 
 
-%package -n smartcard-service-common-devel
-Summary:    Common smartcard service
-Group:      Network & Connectivity/Development
-Requires:   smartcard-service-common = %{version}-%{release}
+################################################################################
+# package : smartcard-service-common                                           #
+################################################################################
+%package    common
+Summary:    common smartcard service
+Group:      Development/Libraries
 
-%description -n smartcard-service-common-devel
-For developing smartcard services internally.
 
+%description common
+common smartcard service.
 
-%package -n smartcard-service-server
-Summary:    Smartcard service server
-Group:      Network & Connectivity/Service
-Requires:   smartcard-service-common = %{version}-%{release}
 
-%description -n smartcard-service-server
-Server for smartcard service
+%files common
+%manifest %{name}-common.manifest
+%defattr(-,root,root,-)
+%{_libdir}/lib%{name}-common.so.*
+%{_datadir}/license/%{name}-common
 
 
-%build
-MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . %{?use_autostart} %{?test_client} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+################################################################################
+# package : smartcard-service-common-devel                                     #
+################################################################################
+%package    common-devel
+Summary:    common smartcard service
+Group:      Development/Libraries
+Requires:   %{name}-common = %{version}-%{release}
 
-%install
-%make_install
-%if 0%{!?use_autostart:1}
-       %__mkdir -p  %{buildroot}/etc/init.d/
-       %__mkdir -p  %{buildroot}/etc/rc.d/rc3.d/
-       %__mkdir -p  %{buildroot}/etc/rc.d/rc5.d/
-       %__cp -af %SOURCE1 %{buildroot}/etc/init.d/smartcard-service-server
-       chmod 755 %{buildroot}/etc/init.d/smartcard-service-server
-%endif
 
-%post
-/sbin/ldconfig
-%if 0%{!?use_autostart:1}
-       ln -sf /etc/init.d/smartcard-service-server /etc/rc.d/rc3.d/S79smartcard-service-server
-       ln -sf /etc/init.d/smartcard-service-server /etc/rc.d/rc5.d/S79smartcard-service-server
-%endif
+%description common-devel
+common smartcard service.
 
-%postun
-/sbin/ldconfig
-%if 0%{!?use_autostart:1}
-       rm -f /etc/rc.d/rc3.d/S79smartcard-service-server
-       rm -f /etc/rc.d/rc5.d/S79smartcard-service-server
-%endif
 
-%post -n smartcard-service-common
-/sbin/ldconfig
+%files common-devel
+%manifest %{name}-common-devel.manifest
+%defattr(-,root,root,-)
+%{_includedir}/%{name}-common/*
+%{_libdir}/lib%{name}-common.so
+%{_libdir}/pkgconfig/%{name}-common.pc
 
-%postun -n smartcard-service-common
-/sbin/ldconfig
 
+################################################################################
+# package : smartcard-service-server                                           #
+################################################################################
+%global bindir /usr/apps/%{name}-server
 
-%files
-%manifest %{name}.manifest
-%defattr(-,root,root,-)
-%{_libdir}/libsmartcard-service.so.*
-%license LICENSE.APLv2
+%package          server
+Summary:          server smartcard service
+Group:            Development/Libraries
+Requires:         %{name}-common = %{version}-%{release}
 
 
-%files  devel
-%manifest smartcard-service-devel.manifest
-%defattr(-,root,root,-)
-%{_includedir}/%{name}/*
-%{_libdir}/libsmartcard-service.so
-%{_libdir}/pkgconfig/%{name}.pc
+%description server
+smartcard service server
 
 
-%files -n smartcard-service-common
-%manifest smartcard-service-common.manifest
-%defattr(-,root,root,-)
-%{_libdir}/libsmartcard-service-common.so.*
-%license LICENSE.APLv2
+%post server
+/usr/bin/signing-client/hash-signer-client.sh -a -d -p platform %{bindir}
+%if 0%{!?use_autostart:1}
+       ln -sf /etc/init.d/%{name}-server /etc/rc.d/rc3.d/S79%{name}-server
+       ln -sf /etc/init.d/%{name}-server /etc/rc.d/rc5.d/S79%{name}-server
+%endif
+ln -sf /usr/apps/%{name}-server/bin/smartcard-daemon /usr/bin/smartcard-daemon
+%if 0%{?test_client:1}
+       ln -sf /usr/apps/%{name}-server/bin/smartcard-test-client /usr/bin/smartcard-test-client
+%endif
 
 
-%files -n smartcard-service-common-devel
-%manifest smartcard-service-common-devel.manifest
-%defattr(-,root,root,-)
-%{_includedir}/smartcard-service-common/*
-%{_libdir}/libsmartcard-service-common.so
-%{_libdir}/pkgconfig/smartcard-service-common.pc
+%postun server
+%if 0%{!?use_autostart:1}
+       rm -f /etc/rc.d/rc3.d/S79%{name}-server
+       rm -f /etc/rc.d/rc5.d/S79%{name}-server
+%endif
+rm -f /usr/bin/smartcard-daemon
 
 
-%files -n smartcard-service-server
-%manifest smartcard-service-server.manifest
+%files server
+%manifest %{name}-server.manifest
 %defattr(-,root,root,-)
-%{_bindir}/smartcard-daemon
-%{_datadir}/packages/smartcard-service-server.xml
+%{bindir}/bin/smartcard-daemon
+%{_datadir}/packages/%{name}-server.xml
 %if 0%{?test_client:1}
-       %{_bindir}/smartcard-test-client
+       %{bindir}/bin/smartcard-test-client
 %endif
 %if 0%{?use_autostart:1}
-       %{_datadir}/dbus-1/system-services/org.tizen.smartcard_service.service
+       %{_datadir}/dbus-1/system-services/org.tizen.SmartcardService.service
 %else
-       %{_sysconfdir}/init.d/smartcard-service-server
+       %{_sysconfdir}/init.d/%{name}-server
+%endif
+%{bindir}/%{name}-server
+%{bindir}/author-signature.xml
+%{bindir}/signature1.xml
+
+
+################################################################################
+# common...                                                                    #
+################################################################################
+%prep
+%setup -q
+
+
+%build
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
+export LDFLAGS+="-Wl,-Bsymbolic-functions"
+mkdir obj-arm-limux-qnueabi
+cd obj-arm-limux-qnueabi
+%cmake .. -DCMAKE_INSTALL_PREFIX=%{_prefix} %{?use_autostart} %{?use_gdbus} %{?test_client}
+#make %{?jobs:-j%jobs}
+
+
+%install
+cd obj-arm-limux-qnueabi
+%make_install
+%if 0%{!?use_autostart:1}
+       %__mkdir -p  %{buildroot}/etc/init.d/
+       %__mkdir -p  %{buildroot}/etc/rc.d/rc3.d/
+       %__mkdir -p  %{buildroot}/etc/rc.d/rc5.d/
+       %__cp -af %SOURCE1 %{buildroot}/etc/init.d/%{name}-server
+       chmod 755 %{buildroot}/etc/init.d/%{name}-server
 %endif
-%license LICENSE.APLv2
+mkdir -p %{buildroot}/usr/share/license
+cp -af %{_builddir}/%{name}-%{version}/packaging/%{name} %{buildroot}/usr/share/license/
+cp -af %{_builddir}/%{name}-%{version}/packaging/%{name}-common %{buildroot}/usr/share/license/
+cp -af %{_builddir}/%{name}-%{version}/packaging/%{name}-server %{buildroot}%{bindir}
+
+%define tizen_sign 1
+%define tizen_sign_base %{bindir}
+%define tizen_sign_level platform
+%define tizen_author_sign 1
+%define tizen_dist_sign 1
index a287198..d5c068b 100644 (file)
@@ -1,23 +1,75 @@
-LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
-INCLUDE_DIRECTORIES(include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/include)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(smartcard-daemon CXX)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ SRCS)
 
-pkg_check_modules(pkgs_server REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 dlog)
+### for private
+ADD_DEFINITIONS("-D__PRIVATE")
+
+FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
+EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
+       " \\
+       --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/private/access-control-gdbus \\
+       --c-namespace SmartcardService\\
+       --interface-prefix org.tizen.SmartcardService. \\
+       ${CMAKE_CURRENT_SOURCE_DIR}/private/access-control-gdbus.xml \\
+       ")
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/private SRCS)
+##############
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+
+# pkg config
+INCLUDE(FindPkgConfig)
+
+SET(PKG_MODULE glib-2.0 gio-2.0 gio-unix-2.0 security-server dlog)
+
+pkg_check_modules(pkgs_server REQUIRED ${PKG_MODULE})
+
 FOREACH(flag ${pkgs_server_CFLAGS})
        SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
 
+MESSAGE("CHECK MODULE in ${PROJECT_NAME} ${pkgs_server_LDFLAGS}")
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pipe -fomit-frame-pointer -Wall -Wno-trigraphs  -fno-strict-aliasing -Wl,-zdefs -fvisibility=hidden")
+SET(ARM_CFLAGS "${ARM_CLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fpic")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -pipe -fomit-frame-pointer -Wall -Wno-trigraphs  -fno-strict-aliasing -Wl,-zdefs -fvisibility=hidden -std=c++0x")
+SET(ARM_CXXFLAGS "${ARM_CXXLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fpic")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -fPIC")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" MATCHES "^arm.*")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM_CXXFLAGS}")
+       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM_CFLAGS}")
+ENDIF()
+
+ADD_DEFINITIONS("-DPREFIX=\"/usr/apps/smartcard-service-server\"")
 ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_SERVER\"")
 
-ADD_EXECUTABLE(${DAEMON} ${SRCS})
-TARGET_LINK_LIBRARIES(${DAEMON} ${pkgs_server_LDFLAGS} ${COMMON_LIB} dl)
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_server_LDFLAGS} "-L../common" "-lsmartcard-service-common" "-pie -ldl")
 
-INSTALL(TARGETS ${DAEMON} DESTINATION bin)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/apps/smartcard-service-server/bin)
 IF("${USE_AUTOSTART}" STREQUAL "1")
-       INSTALL(FILES org.tizen.smartcard_service.service DESTINATION share/dbus-1/system-services)
+       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.tizen.SmartcardService.service DESTINATION share/dbus-1/system-services)
 ENDIF()
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/smartcard-service-server.xml DESTINATION share/packages)
index 730948f..4e60be7 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
 #include <pthread.h>
 
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "ClientInstance.h"
 #include "ServerResource.h"
index daedefc..07842de 100644 (file)
  * limitations under the License.
  */
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Debug.h"
 #include "ServerChannel.h"
 #include "APDUHelper.h"
@@ -47,6 +52,9 @@ namespace smartcard_service_api
                {
                        /* close channel */
                        command = apdu.generateAPDU(APDUHelper::COMMAND_CLOSE_LOGICAL_CHANNEL, channelNum, ByteArray::EMPTY);
+
+                       _DBG("command [%d] : %s", command.size(), command.toString().c_str());
+
                        rv = terminal->transmitSync(command, result);
 
                        if (rv == 0 && result.size() >= 2)
index 1a6a787..44e6b54 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+/* standard library header */
 #include <unistd.h>
 #include <glib.h>
 #include <gio/gio.h>
 #include <string>
 #include <sys/socket.h>
 
+/* SLP library header */
+#ifdef USER_SPACE_SMACK
+#include "security-server.h"
+#endif
+
+/* local header */
 #include "smartcard-types.h"
 #include "Debug.h"
 #include "ByteArray.h"
 
 using namespace std;
 
+#ifdef __PRIVATE
+extern "C" bool smartcard_service_init_access_control(void *connection);
+extern "C" void smartcard_service_deinit_access_control();
+#endif
+
 namespace smartcard_service_api
 {
        GDBusDispatcher::GDBusDispatcher() : Synchronous()
@@ -226,12 +238,17 @@ namespace smartcard_service_api
                initReader();
                initSession();
                initChannel();
-
+#ifdef __PRIVATE
+               smartcard_service_init_access_control(connection);
+#endif
                return true;
        }
 
        void ServerGDBus::deinit()
        {
+#ifdef __PRIVATE
+               smartcard_service_deinit_access_control();
+#endif
                deinitChannel();
                deinitSession();
                deinitReader();
@@ -283,7 +300,25 @@ namespace smartcard_service_api
                const char *rights)
        {
                bool result = true;
-               /*TODO : apply cynara api */
+#ifdef USER_SPACE_SMACK
+               pid_t pid;
+               const char *name;
+               ClientInstance *instance;
+
+               name = g_dbus_method_invocation_get_sender(invocation);
+
+               instance = ServerResource::getInstance().getClient(name);
+               if (instance != NULL) {
+                       pid = instance->getPID();
+               } else {
+                       pid = ServerGDBus::getInstance().getPID(name);
+               }
+
+               result = (security_server_check_privilege_by_pid(
+                       pid,
+                       "smartcard-service",
+                       rights) == SECURITY_SERVER_API_SUCCESS);
+#endif
                return result;
        }
 
@@ -444,7 +479,7 @@ namespace smartcard_service_api
 
        static gboolean __process_shutdown(SmartcardServiceSeService *object,
                GDBusMethodInvocation *invocation,
-               intptr_t handle, void *user_data)
+               guint handle, void *user_data)
        {
                const char *name;
 
@@ -470,7 +505,7 @@ namespace smartcard_service_api
        {
                SmartcardServiceSeService *object;
                GDBusMethodInvocation *invocation;
-               intptr_t handle;
+               guint handle;
                void *user_data;
 
                if (params.size() != 4) {
@@ -481,7 +516,7 @@ namespace smartcard_service_api
 
                object = (SmartcardServiceSeService *)params[0];
                invocation = (GDBusMethodInvocation *)params[1];
-               handle = (intptr_t)params[2];
+               handle = 0;//(guint)params[2];
                user_data = params[3];
 
                __process_shutdown(object, invocation, handle, user_data);
@@ -492,7 +527,7 @@ namespace smartcard_service_api
 
        static gboolean _handle_shutdown(SmartcardServiceSeService *object,
                GDBusMethodInvocation *invocation,
-               intptr_t handle,
+               guint handle,
                void *user_data)
        {
                vector<void *> params;
@@ -583,8 +618,8 @@ namespace smartcard_service_api
         *
         */
        static gboolean __process_open_session(SmartcardServiceReader *object,
-               GDBusMethodInvocation *invocation, intptr_t service_id,
-               intptr_t reader_id, void *user_data)
+               GDBusMethodInvocation *invocation, guint service_id,
+               guint reader_id, void *user_data)
        {
                unsigned int handle = IntegerHandle::INVALID_HANDLE;
                int result;
@@ -628,8 +663,8 @@ namespace smartcard_service_api
        {
                SmartcardServiceReader *object;
                GDBusMethodInvocation *invocation;
-               intptr_t service_id;
-               intptr_t reader_id;
+               guint service_id;
+               guint reader_id;
                void *user_data;
 
                if (params.size() != 5) {
@@ -640,8 +675,8 @@ namespace smartcard_service_api
 
                object = (SmartcardServiceReader *)params[0];
                invocation = (GDBusMethodInvocation *)params[1];
-               service_id = (intptr_t)params[2];
-               reader_id = (intptr_t)params[3];
+               service_id = 0;//(guint)params[2];
+               reader_id = 0;//(guint)params[3];
                user_data = params[4];
 
                __process_open_session(object, invocation, service_id,
@@ -653,8 +688,8 @@ namespace smartcard_service_api
 
        static gboolean _handle_open_session(SmartcardServiceReader *object,
                GDBusMethodInvocation *invocation,
-               intptr_t service_id,
-               intptr_t reader_id, void *user_data)
+               guint service_id,
+               guint reader_id, void *user_data)
        {
                vector<void *> params;
 
@@ -726,8 +761,8 @@ namespace smartcard_service_api
         *
         */
        static gboolean __process_close_session(SmartcardServiceSession *object,
-               GDBusMethodInvocation *invocation, intptr_t service_id,
-               intptr_t session_id, void *user_data)
+               GDBusMethodInvocation *invocation, guint service_id,
+               guint session_id, void *user_data)
        {
                const char *name;
 
@@ -756,8 +791,8 @@ namespace smartcard_service_api
        {
                SmartcardServiceSession *object;
                GDBusMethodInvocation *invocation;
-               intptr_t service_id;
-               intptr_t session_id;
+               guint service_id;
+               guint session_id;
                void *user_data;
 
                if (params.size() != 5) {
@@ -768,8 +803,8 @@ namespace smartcard_service_api
 
                object = (SmartcardServiceSession *)params[0];
                invocation = (GDBusMethodInvocation *)params[1];
-               service_id = (intptr_t)params[2];
-               session_id = (intptr_t)params[3];
+               service_id = 0;//(guint)params[2];
+               session_id = 0;//(guint)params[3];
                user_data = params[4];
 
                __process_close_session(object, invocation, service_id,
@@ -781,8 +816,8 @@ namespace smartcard_service_api
 
        static gboolean _handle_close_session(SmartcardServiceSession *object,
                GDBusMethodInvocation *invocation,
-               intptr_t service_id,
-               intptr_t session_id, void *user_data)
+               guint service_id,
+               guint session_id, void *user_data)
        {
                vector<void *> params;
 
@@ -811,8 +846,8 @@ namespace smartcard_service_api
        }
 
        static gboolean __process_get_atr(SmartcardServiceSession *object,
-               GDBusMethodInvocation *invocation, intptr_t service_id,
-               intptr_t session_id, void *user_data)
+               GDBusMethodInvocation *invocation, guint service_id,
+               guint session_id, void *user_data)
        {
                int result;
                ByteArray resp;
@@ -832,14 +867,10 @@ namespace smartcard_service_api
 
                        terminal = client->getTerminal(session_id);
                        if (terminal != NULL) {
-                               int rv;
-
                                if (terminal->open() == true) {
-                                       rv = terminal->getATRSync(resp);
-                                       if (rv < SCARD_ERROR_OK) {
+                                       result = terminal->getATRSync(resp);
+                                       if (result < SCARD_ERROR_OK) {
                                                _ERR("getATRSync failed : name [%s], service_id [%d], session_id [%d]", name, service_id, session_id);
-
-                                               result = rv;
                                        }
 
                                        terminal->close();
@@ -872,8 +903,8 @@ namespace smartcard_service_api
        {
                SmartcardServiceSession *object;
                GDBusMethodInvocation *invocation;
-               intptr_t service_id;
-               intptr_t session_id;
+               guint service_id;
+               guint session_id;
                void *user_data;
 
                if (params.size() != 5) {
@@ -884,8 +915,8 @@ namespace smartcard_service_api
 
                object = (SmartcardServiceSession *)params[0];
                invocation = (GDBusMethodInvocation *)params[1];
-               service_id = (intptr_t)params[2];
-               session_id = (intptr_t)params[3];
+               service_id = 0;//(guint)params[2];
+               session_id = 0;//(guint)params[3];
                user_data = params[4];
 
                __process_get_atr(object, invocation, service_id,
@@ -897,8 +928,8 @@ namespace smartcard_service_api
 
        static gboolean _handle_get_atr(SmartcardServiceSession *object,
                GDBusMethodInvocation *invocation,
-               intptr_t service_id,
-               intptr_t session_id, void *user_data)
+               guint service_id,
+               guint session_id, void *user_data)
        {
                vector<void *> params;
 
@@ -932,9 +963,10 @@ namespace smartcard_service_api
        }
 
        static gboolean __process_open_channel(SmartcardServiceSession *object,
-               GDBusMethodInvocation *invocation, intptr_t service_id,
-               intptr_t session_id, intptr_t type, GVariant *aid, void *user_data)
+               GDBusMethodInvocation *invocation, guint service_id,
+               guint session_id, guint type, GVariant *aid, guint8 P2, void *user_data)
        {
+               int channelNum = -1;
                int result = SCARD_ERROR_UNKNOWN;
                ByteArray resp;
                GVariant *response = NULL;
@@ -942,6 +974,7 @@ namespace smartcard_service_api
                const char *name;
 
                _INFO("[MSG_REQUEST_OPEN_CHANNEL]");
+               _INFO("P2 is %x", P2);
 
                ServerResource &resource = ServerResource::getInstance();
 
@@ -963,9 +996,13 @@ namespace smartcard_service_api
                                        name, service_id, channelID);
                                if (temp != NULL) {
                                        resp = temp->getSelectResponse();
-
+                                       channelNum = temp->getChannelNumber();
                                        result = SCARD_ERROR_OK;
                                }
+                               else{
+                                       _ERR("getChannel is failed");
+                                       result = SCARD_ERROR_UNAVAILABLE;
+                               }
                        } else {
                                _ERR("channel is null.");
 
@@ -982,7 +1019,7 @@ namespace smartcard_service_api
 
                /* response to client */
                smartcard_service_session_complete_open_channel(object,
-                       invocation, result, channelID, response);
+                       invocation, result, channelID, channelNum, response);
 
                return true;
        }
@@ -991,13 +1028,14 @@ namespace smartcard_service_api
        {
                SmartcardServiceSession *object;
                GDBusMethodInvocation *invocation;
-               intptr_t service_id;
-               intptr_t session_id;
-               intptr_t type;
+               guint service_id;
+               guint session_id;
+               guint type;
+               guint8 P2;
                GVariant *aid;
                void *user_data;
 
-               if (params.size() != 7) {
+               if (params.size() != 8) {
                        _ERR("invalid parameter");
 
                        return;
@@ -1005,24 +1043,25 @@ namespace smartcard_service_api
 
                object = (SmartcardServiceSession *)params[0];
                invocation = (GDBusMethodInvocation *)params[1];
-               service_id = (intptr_t)params[2];
-               session_id = (intptr_t)params[3];
-               type = (intptr_t)params[4];
+               service_id = 0;//(guint)params[2];
+               session_id = 0;//(guint)params[3];
+               type = 0;//(guint)params[4];
                aid = (GVariant *)params[5];
-               user_data = params[6];
+               P2 = 0;//(guint8)((int)params[6]);
+               user_data = params[7];
 
                __process_open_channel(object, invocation, service_id,
-                       session_id, type, aid, user_data);
+                       session_id, type, aid, P2, user_data);
 
                g_object_unref(object);
                g_object_unref(invocation);
-               g_object_unref(aid);
+               g_variant_unref(aid);
        }
 
        static gboolean _handle_open_channel(SmartcardServiceSession *object,
                GDBusMethodInvocation *invocation,
-               intptr_t service_id,
-               intptr_t session_id, intptr_t type, GVariant *aid, void *user_data)
+               guint service_id,
+               guint session_id, guint type, GVariant *aid, guint8 P2, void *user_data)
        {
                vector<void *> params;
 
@@ -1038,8 +1077,9 @@ namespace smartcard_service_api
                        params.push_back((void *)session_id);
                        params.push_back((void *)type);
 
-                       g_object_ref(aid);
+                       g_variant_ref(aid);
                        params.push_back((void *)aid);
+                       params.push_back((void *)((int)P2));
                        params.push_back(user_data);
 
                        GDBusDispatcher::push(_process_open_channel, params);
@@ -1053,6 +1093,7 @@ namespace smartcard_service_api
                                invocation,
                                SCARD_ERROR_SECURITY_NOT_ALLOWED,
                                IntegerHandle::INVALID_HANDLE,
+                               -1,
                                GDBusHelper::convertByteArrayToVariant(resp));
                }
 
@@ -1111,8 +1152,8 @@ namespace smartcard_service_api
         *
         */
        static gboolean __process_close_channel(SmartcardServiceChannel *object,
-               GDBusMethodInvocation *invocation, intptr_t service_id,
-               intptr_t channel_id, void *user_data)
+               GDBusMethodInvocation *invocation, guint service_id,
+               guint channel_id, void *user_data)
        {
                int result;
                const char *name;
@@ -1138,8 +1179,8 @@ namespace smartcard_service_api
        {
                SmartcardServiceChannel *object;
                GDBusMethodInvocation *invocation;
-               intptr_t service_id;
-               intptr_t channel_id;
+               guint service_id;
+               guint channel_id;
                void *user_data;
 
                if (params.size() != 5) {
@@ -1150,8 +1191,8 @@ namespace smartcard_service_api
 
                object = (SmartcardServiceChannel *)params[0];
                invocation = (GDBusMethodInvocation *)params[1];
-               service_id = (intptr_t)params[2];
-               channel_id = (intptr_t)params[3];
+               service_id = 0;//(guint)params[2];
+               channel_id = 0;//(guint)params[3];
                user_data = params[4];
 
                __process_close_channel(object, invocation, service_id,
@@ -1163,7 +1204,7 @@ namespace smartcard_service_api
 
        static gboolean _handle_close_channel(SmartcardServiceChannel *object,
                GDBusMethodInvocation *invocation,
-               intptr_t service_id, intptr_t channel_id, void *user_data)
+               guint service_id, guint channel_id, void *user_data)
        {
                vector<void *> params;
 
@@ -1195,8 +1236,8 @@ namespace smartcard_service_api
 
        static gboolean __process_transmit(SmartcardServiceChannel *object,
                GDBusMethodInvocation *invocation,
-               intptr_t service_id,
-               intptr_t channel_id,
+               guint service_id,
+               guint channel_id,
                GVariant *command,
                void *user_data)
        {
@@ -1246,8 +1287,8 @@ namespace smartcard_service_api
        {
                SmartcardServiceChannel *object;
                GDBusMethodInvocation *invocation;
-               intptr_t service_id;
-               intptr_t channel_id;
+               guint service_id;
+               guint channel_id;
                GVariant *command;
                void *user_data;
 
@@ -1259,8 +1300,8 @@ namespace smartcard_service_api
 
                object = (SmartcardServiceChannel *)params[0];
                invocation = (GDBusMethodInvocation *)params[1];
-               service_id = (intptr_t)params[2];
-               channel_id = (intptr_t)params[3];
+               service_id = 0;//(guint)params[2];
+               channel_id = 0;//(guint)params[3];
                command = (GVariant *)params[4];
                user_data = params[5];
 
@@ -1274,8 +1315,8 @@ namespace smartcard_service_api
 
        static gboolean _handle_transmit(SmartcardServiceChannel *object,
                GDBusMethodInvocation *invocation,
-               intptr_t service_id,
-               intptr_t channel_id,
+               guint service_id,
+               guint channel_id,
                GVariant *command,
                void *user_data)
        {
index 9b72607..b25b5ce 100644 (file)
@@ -288,6 +288,13 @@ namespace smartcard_service_api
                return (((instance = getService(name, handle)) != NULL) && (instance->isVaildSessionHandle(session)));
        }
 
+       bool ServerResource::isValidChannelHandle(const char *name, unsigned int handle, unsigned int channel)
+       {
+               ServiceInstance *instance = NULL;
+
+               return (((instance = getService(name, handle)) != NULL) && (instance->isVaildChannelHandle(channel)));
+       }
+
        unsigned int ServerResource::getChannelCount(const char *name, unsigned int handle, unsigned int sessionID)
        {
                unsigned int result = -1;
@@ -571,6 +578,9 @@ namespace smartcard_service_api
 
                /* open channel */
                command = APDUHelper::generateAPDU(APDUHelper::COMMAND_OPEN_LOGICAL_CHANNEL, 0, ByteArray::EMPTY);
+
+               _DBG("command [%d] : %s", command.size(), command.toString().c_str());
+
                rv = terminal->transmitSync(command, response);
                if (rv == 0 && response.size() >= 2)
                {
@@ -602,6 +612,9 @@ namespace smartcard_service_api
 
                /* open channel */
                command = APDUHelper::generateAPDU(APDUHelper::COMMAND_CLOSE_LOGICAL_CHANNEL, channelNum, ByteArray::EMPTY);
+
+               _DBG("command [%d] : %s", command.size(), command.toString().c_str());
+
                rv = terminal->transmitSync(command, response);
                if (rv == 0 && response.size() >= 2)
                {
@@ -664,6 +677,12 @@ namespace smartcard_service_api
                }
 
                channel = service->getChannel(result);
+               if(channel == NULL)
+               {
+                       _ERR("channel is null.");
+
+                        throw ExceptionBase(SCARD_ERROR_OUT_OF_MEMORY);
+               }
 
                /* check */
                if (_isAuthorizedAccess(channel, aid,
@@ -864,13 +883,14 @@ namespace smartcard_service_api
                                                strncmp(entry->d_name, "..", 2) != 0)
                                        {
                                                char fullPath[1024];
-
                                                /* TODO : need additional name rule :) */
 
                                                /* append each files */
                                                snprintf(fullPath, sizeof(fullPath),
                                                        "%s/%s", OMAPI_SE_PATH, entry->d_name);
 
+                                               SECURE_LOGD("se name [%s]", fullPath);
+
                                                result = appendSELibrary(fullPath);
                                        }
                                }
@@ -1107,56 +1127,128 @@ namespace smartcard_service_api
                }
        }
 
+       ServerChannel *ServerResource::createInternalChannel(Terminal *terminal,
+               int channelType)
+       {
+               int channelNum = 0;
+               ServerChannel *channel = NULL;
+
+               /* open logical channel */
+               if (channelType == 1)
+               {
+                       channelNum = _openLogicalChannel(terminal);
+                       if (channelNum > 0)
+                       {
+                               _DBG("channelNum [%d]", channelNum);
+                       }
+                       else
+                       {
+                               _ERR("_openLogicalChannel failed [%d]", channelNum);
+                               throw ExceptionBase(SCARD_ERROR_NOT_ENOUGH_RESOURCE);
+                       }
+               }
+
+               /* create channel instance */
+               channel = new ServerChannel(NULL, NULL, channelNum, terminal);
+
+               return channel;
+       }
+
        bool ServerResource::isAuthorizedNFCAccess(Terminal *terminal,
                const ByteArray &aid, const vector<ByteArray> &hashes)
        {
                bool result = false;
+               ServerChannel *channel;
 
                if (terminal == NULL) {
                        return result;
                }
 
-               int num = _openLogicalChannel(terminal);
-               if (num > 0) {
-                       /* create channel instance */
-                       ServerChannel *channel = new ServerChannel(NULL, NULL, num, terminal);
-                       if (channel != NULL) {
-                               AccessControlList *acl = getAccessControlList(channel);
-                               if (acl == NULL) {
-
-                                       /* load access control defined by Global Platform */
-                                       acl = new GPACE();
-                                       if (acl != NULL) {
-                                               int ret;
-
-                                               ret = acl->loadACL(channel);
-                                               if (ret >= SCARD_ERROR_OK) {
-                                                       addAccessControlList(channel, acl);
-                                               } else {
-                                                       _ERR("unknown error, 0x%x", -ret);
-
-                                                       delete acl;
-                                                       acl = NULL;
-                                               }
+               channel = createInternalChannel(terminal, 1);
+               if (channel != NULL) {
+                       AccessControlList *acl = getAccessControlList(channel);
+                       if (acl == NULL) {
+
+                               /* load access control defined by Global Platform */
+                               acl = new GPACE();
+                               if (acl != NULL) {
+                                       int ret;
+
+                                       ret = acl->loadACL(channel);
+                                       if (ret >= SCARD_ERROR_OK) {
+                                               addAccessControlList(channel, acl);
                                        } else {
-                                               _ERR("alloc failed");
+                                               _ERR("unknown error, 0x%x", -ret);
+
+                                               delete acl;
+                                               acl = NULL;
                                        }
                                } else {
-                                       acl->updateACL(channel);
+                                       _ERR("alloc failed");
                                }
+                       } else {
+                               acl->updateACL(channel);
+                       }
+
+                       if (acl != NULL) {
+                               result = acl->isAuthorizedNFCAccess(aid, hashes);
+                       } else {
+                               _ERR("acl is null");
+                       }
+
+                       delete channel;
+               } else {
+                       _ERR("alloc failed");
+               }
+
+               return result;
+       }
+
+       bool ServerResource::isAuthorizedAccess(Terminal *terminal,
+               const ByteArray &aid, const vector<ByteArray> &hashes)
+       {
+               bool result = false;
+               ServerChannel *channel;
+
+               if (terminal == NULL) {
+                       return result;
+               }
 
+               channel = createInternalChannel(terminal, 1);
+               if (channel != NULL) {
+                       AccessControlList *acl = getAccessControlList(channel);
+                       if (acl == NULL) {
+
+                               /* load access control defined by Global Platform */
+                               acl = new GPACE();
                                if (acl != NULL) {
-                                       result = acl->isAuthorizedNFCAccess(aid, hashes);
+                                       int ret;
+
+                                       ret = acl->loadACL(channel);
+                                       if (ret >= SCARD_ERROR_OK) {
+                                               addAccessControlList(channel, acl);
+                                       } else {
+                                               _ERR("unknown error, 0x%x", -ret);
+
+                                               delete acl;
+                                               acl = NULL;
+                                       }
                                } else {
-                                       _ERR("acl is null");
+                                       _ERR("alloc failed");
                                }
+                       } else {
+                               acl->updateACL(channel);
+                       }
 
-                               delete channel;
+                       if (acl != NULL) {
+                               result = acl->isAuthorizedAccess(aid, hashes);
                        } else {
-                               _ERR("alloc failed");
+                               _ERR("acl is null");
                        }
+
+                       delete channel;
                } else {
-                       _ERR("_openLogicalChannel failed");
+                       _ERR("alloc failed");
                }
 
                return result;
index f7d4bcf..a80d54c 100644 (file)
@@ -136,7 +136,6 @@ namespace smartcard_service_api
        int ServerSEService::openSELibraries()
        {
                int result;
-               void *libHandle;
                DIR *dir = NULL;
                struct dirent *entry = NULL;
 
@@ -150,10 +149,11 @@ namespace smartcard_service_api
 
                                        /* need additional name rule :) */
                                        /* open each files */
-                                       libHandle = NULL;
 
                                        snprintf(fullPath, sizeof(fullPath), "%s/%s", OMAPI_SE_PATH, entry->d_name);
 
+                                       SECURE_LOGD("se name [%s]", fullPath);
+
                                        result = appendSELibrary(fullPath);
                                }
                        }
@@ -184,19 +184,58 @@ namespace smartcard_service_api
                }
        }
 
+#if 0
+       bool ServerSEService::isValidReaderHandle(void *handle)
+       {
+               bool result = false;
+               size_t i;
+
+               for (i = 0; i < readers.size(); i++)
+               {
+                       if ((void *)readers[i] == handle)
+                       {
+                               result =  true;
+                               break;
+                       }
+               }
+
+               return false;
+       }
+#endif
+
        void ServerSEService::terminalCallback(const void *terminal, int event, int error, void *user_param)
        {
                switch (event)
                {
                case Terminal::NOTIFY_SE_AVAILABLE :
                        {
-                               // TODO: add right se reader
+                               /* add right se reader */
+//                             if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL)
+//                             {
+//                                     _DBG("terminal : [%s]", (char *)terminal);
+//
+//                                     term->initialize();
+//                             }
+//                             else
+//                             {
+//                                     _DBG("unknown terminal : [%s]", (char *)terminal);
+//                             }
                        }
                        break;
 
                case Terminal::NOTIFY_SE_NOT_AVAILABLE :
                        {
-                               // TODO: remove right se reader
+                               /* remove right se reader */
+//                             if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL)
+//                             {
+//                                     _DBG("terminal : [%s]", (char *)terminal);
+//
+//                                     term->finalize();
+//                             }
+//                             else
+//                             {
+//                                     _DBG("unknown terminal : [%s]", (char *)terminal);
+//                             }
                        }
                        break;
 
index 0c73fe8..6a2df89 100644 (file)
@@ -105,22 +105,91 @@ namespace smartcard_service_api
        Channel *ServerSession::openBasicChannelSync(const ByteArray &aid)
                throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
        {
-               return openBasicChannelSync(aid, NULL);
+               return openBasicChannelSync(aid, (void *)NULL);
+       }
+
+       Channel *ServerSession::openBasicChannelSync(const ByteArray &aid, unsigned char P2)
+               throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
+       {
+               return openBasicChannelSync(aid, (void *)NULL);
        }
 
        Channel *ServerSession::openBasicChannelSync(const ByteArray &aid, void *caller)
                throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
        {
                ServerChannel *channel = NULL;
+#if 0
+               AccessControlList *acList = NULL;
+               ByteArray command, result;
+               int channelID = 0;
+               int rv = 0;
+
+               _BEGIN();
+
+               acList = ((ServerReader *)reader)->getAccessControlList();
+               if (acList == NULL)
+               {
+                       _ERR("acList is null");
+
+                       return channel;
+               }
+
+               if (acList->isAuthorizedAccess(aid, certHashes) == false)
+               {
+                       _ERR("unauthorized access, aid : %s", aid.toString().c_str());
+
+                       return channel;
+               }
+
+               /* select aid */
+               command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_DF_NAME, channelID, aid);
+               rv = terminal->transmitSync(command, result);
+               if (rv == 0 && result.size() >= 2)
+               {
+                       ResponseHelper resp(result);
+
+                       if (resp.getStatus() == 0)
+                       {
+                               channel = new ServerChannel(this, caller, channelID, terminal);
+                               if (channel != NULL)
+                               {
+                                       channel->selectResponse = result;
+
+                                       channels.push_back(channel);
+                               }
+                               else
+                               {
+                                       _ERR("alloc failed");
+                               }
+                       }
+                       else
+                       {
+                               _ERR("status word [ %02X %02X ]", resp.getSW1(), resp.getSW2());
+                       }
+               }
+               else
+               {
+                       _ERR("select apdu is failed, rv [%d], length [%d]", rv, result.size());
+               }
+#endif
                return channel;
        }
 
        Channel *ServerSession::openBasicChannelSync(const unsigned char *aid, unsigned int length)
                throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
        {
+               unsigned char P2 = 0x00;
+               ByteArray temp(aid, length);
+
+               return openBasicChannelSync(temp, P2);
+       }
+
+       Channel *ServerSession::openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+               throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
+       {
                ByteArray temp(aid, length);
 
-               return openBasicChannelSync(temp);
+               return openBasicChannelSync(temp, P2);
        }
 
        Channel *ServerSession::openBasicChannelSync(const unsigned char *aid, unsigned int length, void *caller)
@@ -134,22 +203,118 @@ namespace smartcard_service_api
        Channel *ServerSession::openLogicalChannelSync(const ByteArray &aid)
                throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
        {
-               return openLogicalChannelSync(aid, NULL);
+               void* caller;
+               return openLogicalChannelSync(aid, caller);
+       }
+
+       Channel *ServerSession::openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
+               throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
+       {
+               void* caller;
+               return openLogicalChannelSync(aid, caller);
        }
 
        Channel *ServerSession::openLogicalChannelSync(const ByteArray &aid, void *caller)
                throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
        {
                ServerChannel *channel = NULL;
+#if 0
+               AccessControlList *acList = NULL;
+               ByteArray command, result;
+               int channelID = 1;
+               int rv;
+
+               acList = ((ServerReader *)reader)->getAccessControlList();
+               if (acList == NULL)
+               {
+                       _ERR("unauthorized access, aid %s, hash %s");
+
+                       return channel;
+               }
+
+               if (acList->isAuthorizedAccess(aid, certHashes) == false)
+               {
+                       _ERR("unauthorized access, aid : %s", aid.toString().c_str());
+
+                       return channel;
+               }
+
+               /* open channel */
+               command = APDUHelper::generateAPDU(APDUHelper::COMMAND_OPEN_LOGICAL_CHANNEL, 0, ByteArray::EMPTY);
+               rv = terminal->transmitSync(command, result);
+
+               if (rv == 0 && result.size() >= 2)
+               {
+                       ResponseHelper resp(result);
+
+                       if (resp.getStatus() == 0)
+                       {
+                               channelID = resp.getDataField()[0];
+                       }
+                       else
+                       {
+                               _ERR("status word [ %02X %02X ]", resp.getSW1(), resp.getSW2());
+
+                               return channel;
+                       }
+               }
+               else
+               {
+                       _ERR("select apdu is failed, rv [%d], length [%d]", rv, result.size());
+
+                       return channel;
+               }
+
+               /* select aid */
+               command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_DF_NAME, channelID, aid);
+               rv = terminal->transmitSync(command, result);
+
+               if (rv == 0 && result.size() >= 2)
+               {
+                       ResponseHelper resp(result);
+
+                       if (resp.getStatus() == 0)
+                       {
+                               channel = new ServerChannel(this, caller, channelID, terminal);
+                               if (channel == NULL)
+                               {
+                                       _ERR("alloc failed");
+
+                                       return NULL;
+                               }
+
+                               channel->selectResponse = result;
+
+                               channels.push_back(channel);
+                       }
+                       else
+                       {
+                               _ERR("status word [ %02X %02X ]", resp.getSW1(), resp.getSW2());
+                       }
+               }
+               else
+               {
+                       _ERR("select apdu is failed, rv [%d], length [%d]", rv, result.size());
+               }
+#endif
                return channel;
        }
 
        Channel *ServerSession::openLogicalChannelSync(const unsigned char *aid, unsigned int length)
                throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
        {
+               unsigned char P2 = 0x00;
+               ByteArray temp(aid, length);
+
+               return openLogicalChannelSync(temp, P2);
+       }
+
+       Channel *ServerSession::openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+               throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
+       {
                ByteArray temp(aid, length);
 
-               return openLogicalChannelSync(temp, NULL);
+               return openLogicalChannelSync(temp, P2);
        }
 
        Channel *ServerSession::openLogicalChannelSync(const unsigned char *aid, unsigned int length, void *caller)
index ca777fb..25a0bfc 100644 (file)
 #ifndef CLIENTINSTANCE_H_
 #define CLIENTINSTANCE_H_
 
+/* standard library header */
 #include <map>
 #include <vector>
 #include <string>
 
+/* SLP library header */
+
+/* local header */
 #include "ServiceInstance.h"
 
 namespace smartcard_service_api
index 6102f2a..1df1576 100644 (file)
 #ifndef SERVERCHANNEL_H_
 #define SERVERCHANNEL_H_
 
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
 #include "Channel.h"
 #include "Terminal.h"
 #include "ServerSession.h"
index 96def07..9a29246 100644 (file)
 #ifndef SERVERGDBUS_H_
 #define SERVERGDBUS_H_
 
+/* standard library header */
 #include <glib.h>
 #include <queue>
 #include <vector>
 
+/* SLP library header */
+
+/* local header */
 #include "Synchronous.h"
 #include "GDBusHelper.h"
 #include "smartcard-service-gdbus.h"
index 6609575..35b5de2 100644 (file)
@@ -115,6 +115,7 @@ namespace smartcard_service_api
                unsigned int getChannelCount(const char *name, unsigned int handle, unsigned int sessionID);
                void removeSession(const char *name, unsigned int handle, unsigned int session);
                bool isValidSessionHandle(const char *name, unsigned int handle, unsigned int sessionID);
+               bool isValidChannelHandle(const char *name, unsigned int handle, unsigned int channelID);
 
                unsigned int createChannel(const char *name, unsigned int handle,
                        unsigned int sessionID, int channelType, ByteArray aid)
@@ -127,9 +128,15 @@ namespace smartcard_service_api
                AccessControlList *getAccessControlList(ServerChannel *channel);
                bool isAuthorizedNFCAccess(Terminal *terminal, const ByteArray &aid,
                        const vector<ByteArray> &hashes);
+               bool isAuthorizedAccess(Terminal *terminal,
+                       const ByteArray &aid, const vector<ByteArray> &hashes);
 
                void finish();
 
+               /* FIXME ??? */
+               ServerChannel *createInternalChannel(Terminal *terminal,
+                       int channelType);
+
                friend void terminalCallback(void *terminal, int event, int error, void *user_param);
        };
 
index fd0c471..b5c8d5e 100644 (file)
@@ -52,6 +52,10 @@ namespace smartcard_service_api
        public:
                static ServerSEService &getInstance();
 
+#if 0
+               bool isValidReaderHandle(void *handle);
+#endif
+
                void shutdown() {}
                void shutdownSync() {}
 
index a2f66df..4f9ec46 100644 (file)
@@ -67,6 +67,10 @@ namespace smartcard_service_api
                        throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
                Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length)
                        throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+               Channel *openBasicChannelSync(const ByteArray &aid, unsigned char P2)
+                       throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+               Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+                       throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
                Channel *openBasicChannelSync(const ByteArray &aid, void *caller)
                        throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
                Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, void *caller)
@@ -76,6 +80,10 @@ namespace smartcard_service_api
                        throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
                Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length)
                        throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+               Channel *openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
+                       throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+               Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+                       throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
                Channel *openLogicalChannelSync(const ByteArray &aid, void *caller)
                        throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
                Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, void *caller)
index 55e9e29..e9154f6 100644 (file)
@@ -27,8 +27,8 @@
 typedef struct _Smartcard_Service Smartcard_Service;
 typedef struct _Smartcard_ServiceClass Smartcard_ServiceClass;
 
-#define SMARTCARD_SERVICE_NAME "org.tizen.smartcard_service"
-#define SMARTCARD_SERVICE_PATH "/org/tizen/smartcard_service"
+#define SMARTCARD_SERVICE_NAME "org.tizen.SmartcardService"
+#define SMARTCARD_SERVICE_PATH "/org/tizen/SmartcardService"
 
 GType smartcard_service_get_type(void);
 
diff --git a/server/org.tizen.SmartcardService.service b/server/org.tizen.SmartcardService.service
new file mode 100644 (file)
index 0000000..0233f2e
--- /dev/null
@@ -0,0 +1,5 @@
+[D-BUS Service]
+Name=org.tizen.SmartcardService
+Exec=/usr/apps/smartcard-service-server/bin/smartcard-daemon
+MemoryLimit=10M
+User=root
\ No newline at end of file
diff --git a/server/org.tizen.smartcard_service.service b/server/org.tizen.smartcard_service.service
deleted file mode 100644 (file)
index d909599..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-[D-BUS Service]
-Name=org.tizen.SmartcardService
-Exec=/usr/bin/smartcard-daemon
-User=root
diff --git a/server/private/AccessControl.cpp b/server/private/AccessControl.cpp
new file mode 100644 (file)
index 0000000..4b78232
--- /dev/null
@@ -0,0 +1,601 @@
+/*
+ * 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 <glib.h>
+#include <gio/gio.h>
+#include <map>
+
+/* SLP library header */
+#ifdef USER_SPACE_SMACK
+#include "security-server.h"
+#endif
+
+/* local header */
+#include "Debug.h"
+#include "APDUHelper.h"
+#include "ServerResource.h"
+#include "SignatureHelper.h"
+#include "ServerGDBus.h"
+#include "PKCS15CDFACL.h"
+#include "access-control-gdbus.h"
+
+using namespace std;
+using namespace smartcard_service_api;
+
+static SmartcardServiceAccessControl *access_control;
+static map<string, ByteArray> mapGranted;
+static PKCS15CDFACL cdfAcl;
+
+static void _load_granted_package_info()
+{
+       mapGranted.clear();
+
+       /* TODO : load information form file */
+       mapGranted.insert(make_pair("nfc-manager", ByteArray::EMPTY));
+}
+
+static gboolean _compare_hash(char *package, ByteArray &hash)
+{
+       gboolean result = false;
+       vector<ByteArray> hashes;
+
+       /* get certificate hashes by pid */
+       if (SignatureHelper::getCertificationHashes(package, hashes) == true) {
+               vector<ByteArray>::iterator item;
+
+               for (item = hashes.begin(); item != hashes.end(); item++) {
+                       if (*item == hash) {
+                               result = true;
+                               break;
+                       }
+               }
+       } else {
+               _ERR("getCertificationHashes failed, [%s]", package);
+       }
+
+       return result;
+}
+
+static gboolean _check_permission(pid_t pid)
+{
+       gboolean result = false;
+       char package[1024];
+
+       if (SignatureHelper::getPackageName(pid,
+               package, sizeof(package)) == 0) {
+               map<string, ByteArray>::iterator item;
+
+               item = mapGranted.find(package);
+               if (item != mapGranted.end()) {
+                       /* TODO : check privilege */
+                       if (false) {
+                               result = _compare_hash(package, item->second);
+                       } else {
+                               result = true;
+                       }
+               }
+       } else {
+               _ERR("aul_app_get_pkgname_bypid failed");
+       }
+
+       return result;
+}
+
+static bool _get_se_name(unsigned int se_type, char *buf, size_t len)
+{
+       bool result = false;
+
+       switch ((se_type >> 4) & 0x0F) {
+       case 1 :
+               snprintf(buf, len, "SIM%d", (se_type & 0x0F) + 1);
+               result = true;
+               break;
+
+       case 2 :
+               snprintf(buf, len, "eSE");
+               result = true;
+               break;
+
+       default :
+               break;
+       }
+
+       return result;
+}
+
+static bool _is_authorized_request(GDBusMethodInvocation *invocation,
+       const char *rights)
+{
+       bool result = true;
+#ifdef USER_SPACE_SMACK
+       pid_t pid;
+       const char *name;
+
+       name = g_dbus_method_invocation_get_sender(invocation);
+
+       pid = ServerGDBus::getInstance().getPID(name);
+
+       result = (security_server_check_privilege_by_pid(
+               pid,
+               "smartcard-service::priv",
+               rights) == SECURITY_SERVER_API_SUCCESS);
+#endif
+       return result;
+}
+
+static gboolean __process_is_authorized_nfc_access(
+       SmartcardServiceAccessControl *object,
+       GDBusMethodInvocation *invocation,
+       guint se_type,
+       const gchar *package,
+       GVariant *aid,
+       void *user_data)
+{
+       bool result = false;
+       const char *error;
+       const char *name;
+       char se[10];
+       pid_t pid;
+
+       ByteArray temp;
+       Terminal *terminal;
+       vector<ByteArray> hashes;
+
+       _INFO("[MSG_IS_AUTHORIZED_NFC_ACCESS]");
+
+       ServerResource &resource = ServerResource::getInstance();
+
+       name = g_dbus_method_invocation_get_sender(invocation);
+
+       pid = ServerGDBus::getInstance().getPID(name);
+
+       _INFO("service requested, pid [%d]", pid);
+
+       if (pid < 0) {
+               error = "invalid pid";
+
+               _ERR("%s, [%d]", error, pid);
+
+               goto ERR;
+       }
+
+       /* check process permission */
+       if (_check_permission(pid) == false) {
+               error = "permission denied";
+
+               _ERR("%s, [%d]", error, pid);
+
+               goto ERR;
+       }
+
+       /* load secure elements */
+       resource.loadSecureElements();
+
+       if (_get_se_name(se_type, se, sizeof(se)) == false) {
+               error = "unknown SE type";
+
+               _ERR("%s, [%d]", error, se_type);
+
+               goto ERR;
+       }
+
+       _INFO("SE : [%s]", se);
+
+       terminal = resource.getTerminal(se);
+       if (terminal == NULL) {
+               error = "failed getting terminal";
+
+               _ERR("%s, [%d]", error, se_type);
+
+               goto ERR;
+       }
+
+       if (terminal->isSecureElementPresence() == false) {
+               error = "terminal is not available now";
+
+               _ERR("%s, [%d]", error, se_type);
+
+               goto ERR;
+       }
+
+       /* get certificate hashes */
+       if (SignatureHelper::getCertificationHashes(package, hashes) == false) {
+               error = "failed getting certificates";
+
+               _ERR("%s, [%s]", error, package);
+
+               goto ERR;
+       }
+
+       /* convert AID */
+       GDBusHelper::convertVariantToByteArray(aid, temp);
+
+       result = resource.isAuthorizedNFCAccess(terminal, temp, hashes);
+
+       /* response to client */
+       smartcard_service_access_control_complete_is_authorized_nfc_access(
+               object, invocation, result);
+
+       return true;
+
+ERR :
+       g_dbus_method_invocation_return_dbus_error(
+               invocation,
+               "org.tizen.SmartcardService.AccessControl.Error",
+               error);
+
+       return false;
+}
+
+static void _process_is_authorized_nfc_access(vector<void *> &params)
+{
+       SmartcardServiceAccessControl *object;
+       GDBusMethodInvocation *invocation;
+       guint se_type;
+       gchar *package;
+       GVariant *aid;
+       void *user_data;
+
+       if (params.size() != 6) {
+               _ERR("invalid parameter");
+
+               return;
+       }
+
+       object = (SmartcardServiceAccessControl *)params[0];
+       invocation = (GDBusMethodInvocation *)params[1];
+       se_type = 0;//(guint)params[2];
+       package = (gchar *)params[3];
+       aid = (GVariant *)params[4];
+       user_data = params[5];
+
+       __process_is_authorized_nfc_access(object, invocation, se_type,
+               package, aid, user_data);
+
+       g_variant_unref(aid);
+
+       g_free(package);
+
+       g_object_unref(invocation);
+       g_object_unref(object);
+
+       /* FIXME : disable killing process code */
+//     ServerResource::getInstance().finish();
+}
+
+static gboolean _handle_is_authorized_nfc_access(
+       SmartcardServiceAccessControl *object,
+       GDBusMethodInvocation *invocation,
+       guint se_type,
+       const gchar *package,
+       GVariant *aid,
+       void *user_data)
+{
+       vector<void *> params;
+
+       /* apply user space smack */
+       if (_is_authorized_request(invocation, "r") == true) {
+               g_object_ref(object);
+               params.push_back((void *)object);
+
+               g_object_ref(invocation);
+               params.push_back((void *)invocation);
+
+               params.push_back((void *)se_type);
+               params.push_back((void *)g_strdup(package));
+
+               g_variant_ref(aid);
+               params.push_back((void *)aid);
+
+               params.push_back((void *)user_data);
+
+               GDBusDispatcher::getInstance().push(
+                       _process_is_authorized_nfc_access,
+                       params);
+       } else {
+               _ERR("access denied");
+
+               g_dbus_method_invocation_return_dbus_error(
+                       invocation,
+                       "org.tizen.SmartcardService.AccessControl.Error",
+                       "access denied");
+
+       /* FIXME : disable killing process code */
+//             ServerResource::getInstance().finish();
+       }
+
+       return true;
+}
+
+static bool __load_cdf_acl(Terminal *terminal)
+{
+       bool result = false;
+       ServerResource &resource = ServerResource::getInstance();
+       ServerChannel *channel;
+
+       if (terminal == NULL) {
+               return result;
+       }
+
+//     if (terminal->open() == SCARD_ERROR_OK) {
+               channel = resource.createInternalChannel(terminal, 1);
+               if (channel != NULL) {
+                       int ret;
+
+                       ret = cdfAcl.updateACL(channel);
+                       if (ret == 0) {
+                               result = true;
+                       } else {
+                               _ERR("acl is null");
+                               result = false;
+                       }
+
+                       delete channel;
+               } else {
+                       _ERR("alloc failed");
+               }
+//
+//             terminal->close();
+//     } else {
+//             _ERR("terminal open failed");
+//     }
+
+       return result;
+}
+
+static gboolean __process_is_authorized_extra_access(
+       SmartcardServiceAccessControl *object,
+       GDBusMethodInvocation *invocation,
+       guint se_type,
+       const gchar *package,
+       void *user_data)
+{
+       bool result = false;
+       const char *error;
+       const char *name;
+       char se[10];
+       pid_t pid;
+
+       ByteArray temp;
+       Terminal *terminal;
+       vector<ByteArray> hashes;
+
+       _INFO("[MSG_IS_AUTHORIZED_EXTRA_ACCESS]");
+
+       ServerResource &resource = ServerResource::getInstance();
+
+       name = g_dbus_method_invocation_get_sender(invocation);
+
+       pid = ServerGDBus::getInstance().getPID(name);
+
+       _INFO("service requested, pid [%d]", pid);
+
+       if (pid < 0) {
+               error = "invalid pid";
+
+               _ERR("%s, [%d]", error, pid);
+
+               goto ERR;
+       }
+
+       /* check process permission */
+       if (_check_permission(pid) == false) {
+               error = "permission denied";
+
+               _ERR("%s, [%d]", error, pid);
+
+               goto ERR;
+       }
+
+       /* load secure elements */
+       resource.loadSecureElements();
+
+       if (_get_se_name(se_type, se, sizeof(se)) == false) {
+               error = "unknown SE type";
+
+               _ERR("%s, [%d]", error, se_type);
+
+               goto ERR;
+       }
+
+       _INFO("SE : [%s]", se);
+
+       terminal = resource.getTerminal(se);
+       if (terminal == NULL) {
+               error = "failed getting terminal";
+
+               _ERR("%s, [%d]", error, se_type);
+
+               goto ERR;
+       }
+
+       if (terminal->isSecureElementPresence() == false) {
+               error = "terminal is not available now";
+
+               _ERR("%s, [%d]", error, se_type);
+
+               goto ERR;
+       }
+
+       /* get certificate hashes */
+       if (SignatureHelper::getCertificationHashes(package, hashes) == false) {
+               error = "failed getting certificates";
+
+               _ERR("%s, [%s]", error, package);
+
+               goto ERR;
+       }
+
+       if ((se_type & 0xF0) == 0x10/* SIM */) {
+               /* load CDF */
+               if (cdfAcl.hasConditions() == false) {
+                       _ERR("cdf rule doesn't be load");
+                       __load_cdf_acl(terminal);
+               }
+
+               /* check access */
+               result = cdfAcl.isAuthorizedAccess(
+                       AccessControlList::ALL_SE_APPS, hashes);
+       } else if ((se_type & 0xF0) == 0x20/* eSE */) {
+               if (terminal->open() == true) {
+                       result = resource.isAuthorizedAccess(terminal,
+                               AccessControlList::ALL_SE_APPS, hashes);
+
+                       terminal->close();
+               }
+       }
+
+       /* response to client */
+       smartcard_service_access_control_complete_is_authorized_extra_access(
+               object, invocation, result);
+
+       return true;
+
+ERR :
+       g_dbus_method_invocation_return_dbus_error(
+               invocation,
+               "org.tizen.SmartcardService.AccessControl.Error",
+               error);
+
+       return false;
+}
+
+static void _process_is_authorized_extra_access(vector<void *> &params)
+{
+       SmartcardServiceAccessControl *object;
+       GDBusMethodInvocation *invocation;
+       guint se_type;
+       gchar *package;
+       void *user_data;
+
+       if (params.size() != 5) {
+               _ERR("invalid parameter");
+
+               return;
+       }
+
+       object = (SmartcardServiceAccessControl *)params[0];
+       invocation = (GDBusMethodInvocation *)params[1];
+       se_type = 0;//(guint)params[2];
+       package = (gchar *)params[3];
+       user_data = params[4];
+
+       __process_is_authorized_extra_access(object, invocation, se_type,
+               package, user_data);
+
+       g_free(package);
+
+       g_object_unref(invocation);
+       g_object_unref(object);
+
+       /* FIXME : disable killing process code */
+//     ServerResource::getInstance().finish();
+}
+
+static gboolean _handle_is_authorized_extra_access(
+       SmartcardServiceAccessControl *object,
+       GDBusMethodInvocation *invocation,
+       guint se_type,
+       const gchar *package,
+       void *user_data)
+{
+       vector<void *> params;
+
+       /* apply user space smack */
+       if (_is_authorized_request(invocation, "r") == true) {
+               g_object_ref(object);
+               params.push_back((void *)object);
+
+               g_object_ref(invocation);
+               params.push_back((void *)invocation);
+
+               params.push_back((void *)se_type);
+               params.push_back((void *)g_strdup(package));
+
+               params.push_back((void *)user_data);
+
+               GDBusDispatcher::getInstance().push(
+                       _process_is_authorized_extra_access,
+                       params);
+       } else {
+               _ERR("access denied");
+
+               g_dbus_method_invocation_return_dbus_error(
+                       invocation,
+                       "org.tizen.SmartcardService.AccessControl.Error",
+                       "access denied");
+
+               /* FIXME : disable killing process code */
+//             ServerResource::getInstance().finish();
+       }
+
+       return true;
+}
+
+static bool _init_access_control(void *connection)
+{
+       GError *error = NULL;
+
+       access_control = smartcard_service_access_control_skeleton_new();
+
+       g_signal_connect(access_control,
+               "handle-is-authorized-nfc-access",
+               G_CALLBACK(_handle_is_authorized_nfc_access),
+               NULL);
+
+       g_signal_connect(access_control,
+               "handle-is-authorized-extra-access",
+               G_CALLBACK(_handle_is_authorized_extra_access),
+               NULL);
+
+       if (g_dbus_interface_skeleton_export(
+               G_DBUS_INTERFACE_SKELETON(access_control),
+               (GDBusConnection *)connection,
+               "/org/tizen/SmartcardService/AccessControl",
+               &error) == false)
+       {
+               _ERR("Can not skeleton_export %s", error->message);
+
+               g_error_free(error);
+               g_object_unref(access_control);
+               access_control = NULL;
+
+               return false;
+       }
+
+       return true;
+}
+
+static void _deinit_access_control()
+{
+       if (access_control != NULL) {
+               g_object_unref(access_control);
+               access_control = NULL;
+       }
+}
+
+extern "C" bool smartcard_service_init_access_control(void *connection)
+{
+       _load_granted_package_info();
+
+       return _init_access_control(connection);
+}
+
+extern "C" void smartcard_service_deinit_access_control()
+{
+       _deinit_access_control();
+}
diff --git a/server/private/PKCS15CDFACL.cpp b/server/private/PKCS15CDFACL.cpp
new file mode 100644 (file)
index 0000000..f124a8a
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * 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 */
+
+/* SLP library header */
+
+/* local header */
+#include "Debug.h"
+#include "PKCS15CDFACL.h"
+#include "PKCS15ODF.h"
+#include "OpensslHelper.h"
+#include "AccessCondition.h"
+
+#ifndef EXTERN_API
+#define EXTERN_API __attribute__((visibility("default")))
+#endif
+
+namespace smartcard_service_api
+{
+       PKCS15CDFACL::PKCS15CDFACL() : AccessControlList()
+       {
+       }
+
+       PKCS15CDFACL::~PKCS15CDFACL()
+       {
+       }
+
+       int PKCS15CDFACL::loadACL(Channel *channel)
+       {
+               int result = SCARD_ERROR_OK;
+
+               _BEGIN();
+
+               if (channel == NULL)
+               {
+                       return SCARD_ERROR_ILLEGAL_PARAM;
+               }
+
+               releaseACL();
+
+               PKCS15 pkcs15(channel);
+
+               result = pkcs15.select();
+               if (result >= SCARD_ERROR_OK)
+               {
+                       PKCS15ODF *odf;
+
+                       result = SCARD_ERROR_OK;
+
+                       if ((odf = pkcs15.getODF()) != NULL)
+                       {
+                               PKCS15CDF *cdf;
+
+                               cdf = odf->getCDF();
+                               if (cdf != NULL)
+                               {
+                                       result = loadRules(channel, cdf);
+                                       if (result == SCARD_ERROR_OK)
+                                       {
+                                               printAccessControlList();
+                                       }
+                                       else
+                                       {
+                                               result = SCARD_ERROR_OK;
+                                       }
+                               }
+                               else
+                               {
+                                       _ERR("dodf null, every request will be denied.");
+                               }
+                       }
+                       else
+                       {
+                               _ERR("odf null, every request will be denied.");
+                       }
+               }
+               else
+               {
+                       _ERR("failed to open PKCS#15, every request will be denied.");
+               }
+
+               _END();
+
+               return result;
+       }
+
+       int PKCS15CDFACL::loadRules(Channel *channel, PKCS15CDF *cdf)
+       {
+               int result = 0;
+               size_t i;
+               ByteArray hash;
+               const CertificateType *type;
+               AccessCondition condition;
+
+               condition.setAID(AccessControlList::ALL_SE_APPS);
+
+               for (i = 0; i < cdf->getCount(); i++) {
+                       type = cdf->getCertificateType(i);
+                       if(type == NULL)
+                               continue;
+
+                       OpensslHelper::digestBuffer("SHA1", type->certificate, hash);
+
+                       _INFO("cdf[%d] = %s", i, hash.toString().c_str());
+
+                       condition.addAccessRule(hash);
+               }
+
+               pair<ByteArray, AccessCondition> newItem(
+                       AccessControlList::ALL_SE_APPS, condition);
+
+               mapConditions.insert(newItem);
+
+               return result;
+       }
+} /* namespace smartcard_service_api */
diff --git a/server/private/PKCS15CDFACL.h b/server/private/PKCS15CDFACL.h
new file mode 100644 (file)
index 0000000..93c18b9
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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 PKCS15CDFACL_H_
+#define PKCS15CDFACL_H_
+
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
+#include "smartcard-types.h"
+#ifdef __cplusplus
+#include "AccessControlList.h"
+#include "PKCS15.h"
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
+namespace smartcard_service_api
+{
+       class PKCS15CDFACL : public AccessControlList
+       {
+       private:
+               int loadRules(Channel *channel, PKCS15CDF *cdf);
+
+       public:
+               PKCS15CDFACL();
+               ~PKCS15CDFACL();
+
+               int loadACL(Channel *channel);
+       };
+
+} /* namespace smartcard_service_api */
+#endif /* __cplusplus */
+#endif /* PKCS15CDFACL_H_ */
diff --git a/server/private/access-control-gdbus.xml b/server/private/access-control-gdbus.xml
new file mode 100755 (executable)
index 0000000..f5a0c37
--- /dev/null
@@ -0,0 +1,26 @@
+<!--
+  org.tizen.SmartcardService
+-->
+
+<node>
+  <interface name="org.tizen.SmartcardService.AccessControl">
+    <!--
+      isAuthorizedExtraAccess
+    -->
+    <method name="isAuthorizedExtraAccess">
+      <arg type="u" name="se_type" direction="in" />
+      <arg type="s" name="package" direction="in" />
+      <arg type="b" name="result" direction="out" />
+    </method>
+
+    <!--
+      isAuthorizedNfcAccess
+    -->
+    <method name="isAuthorizedNfcAccess">
+      <arg type="u" name="se_type" direction="in" />
+      <arg type="s" name="package" direction="in" />
+      <arg type="a(y)" name="aid" direction="in" />
+      <arg type="b" name="result" direction="out" />
+    </method>
+  </interface>
+</node>
index cb9c75f..3c2890a 100644 (file)
@@ -123,6 +123,12 @@ int main(int argc, char *argv[])
        daemonize();
 #endif
 
+       if (!g_thread_supported()) {
+               g_thread_init(NULL);
+       }
+
+       g_type_init();
+
        main_loop = g_main_new(TRUE);
 
        id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
index 82c673a..fe64adb 100644 (file)
@@ -1,15 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<manifest xmlns="http://tizen.org/ns/packages"
-       package="smartcard-service-server"
-       version="0.1.20"
-       install-location="internal-only"
-       type="rpm">
+<manifest xmlns="http://tizen.org/ns/packages" package="smartcard-service-server" version="0.1.20" install-location="internal-only" type="rpm">
        <label>Smartcard Service Server</label>
        <author email="constant.lee@samsung.com" href="www.samsung.com">Sangsoo Lee</author>
        <author email="wonkyu.kwon@samsung.com" href="www.samsung.com">Wonkyu Kwon</author>
        <description>Smartcard Service Server</description>
        <ui-application appid="smartcard-service-server"
-               exec="/usr/bin/smartcard-daemon"
+               exec="/usr/apps/smartcard-service-server/bin/smartcard-daemon"
                nodisplay="true"
                multiple="false"
                type="capp"
diff --git a/smartcard-service-common-devel.manifest b/smartcard-service-common-devel.manifest
new file mode 100644 (file)
index 0000000..ca37499
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
+
diff --git a/smartcard-service-common.manifest b/smartcard-service-common.manifest
new file mode 100644 (file)
index 0000000..ca37499
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
+
diff --git a/smartcard-service-devel.manifest b/smartcard-service-devel.manifest
new file mode 100644 (file)
index 0000000..ca37499
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
+
diff --git a/smartcard-service-server.manifest b/smartcard-service-server.manifest
new file mode 100644 (file)
index 0000000..8a64a46
--- /dev/null
@@ -0,0 +1,23 @@
+<manifest>
+       <define>
+               <domain name="smartcard-service" />
+               <provide>
+                       <label name="smartcard-service::priv" />
+               </provide>
+               <request>
+                       <smack request="sys-assert::core" type="rwxat" />
+                       <smack request="nfc-manager" type="rwx" />
+                       <smack request="csc-feature" type="r" />
+                       <smack request="security-server::api-privilege-by-pid" type="w" />
+               </request>
+       </define>
+       <assign>
+               <filesystem path="/usr/apps/smartcard-service-server/bin/smartcard-daemon" exec_label="smartcard-service" />
+               <!-- <filesystem path="/usr/apps/smartcard-service-server/bin/smartcard-test-client" exec_label="smartcard-service" /> -->
+               <filesystem path="/usr/share/dbus-1/services/smartcard-service.service" label="_" />
+       </assign>
+       <request>
+               <domain name="smartcard-service" />
+       </request>
+</manifest>
+
diff --git a/smartcard-service.manifest b/smartcard-service.manifest
new file mode 100644 (file)
index 0000000..ca37499
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
+
index 05b2d24..434f147 100644 (file)
@@ -1,23 +1,48 @@
-LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
-INCLUDE_DIRECTORIES(include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT(smartcard-test-client CXX)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../client/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 #AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ SRCS)
 SET(SRCS "${CMAKE_CURRENT_SOURCE_DIR}/test-client-sync.cpp")
 #SET(SRCS "${CMAKE_CURRENT_SOURCE_DIR}/test-client.cpp")
 
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+
+INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs_test_client REQUIRED glib-2.0 dlog)
+
 FOREACH(flag ${pkgs_test_client_CFLAGS})
        SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
 ENDFOREACH(flag)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
 
 MESSAGE("CHECK MODULE in ${PROJECT_NAME} ${pkgs_test_client_LDFLAGS}")
 
+# this for NFC flag
+
+SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -pipe -fomit-frame-pointer -Wall -Wno-trigraphs  -fno-strict-aliasing -Wl,-zdefs -fvisibility=hidden -std=c++0x")
+SET(ARM_CXXFLAGS "${ARM_CXXLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fpic")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" MATCHES "^arm.*")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM_CXXFLAGS}")
+ENDIF()
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+#ADD_DEFINITIONS("-DSLP_DEBUG")
 ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_TEST\"")
 
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_test_client_LDFLAGS} ${COMMON_LIB} ${CLIENT_LIB})
-
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_test_client_LDFLAGS} "-L../common" "-lsmartcard-service-common" "-L../client" "-lsmartcard-service" "-pie -ldl")
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/apps/smartcard-service-server/bin)