Fix doc related to exportable flag
authoryuseok.jeon <yuseok.jeon@samsung.com>
Wed, 6 Aug 2014 02:27:26 +0000 (11:27 +0900)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Fri, 12 Sep 2014 12:59:27 +0000 (14:59 +0200)
Signed-off-by: yuseok.jeon <yuseok.jeon@samsung.com>
src/include/ckmc/ckmc-error.h
src/include/ckmc/ckmc-manager.h
src/manager/client-capi/ckmc-error.cpp
src/manager/client-capi/ckmc-type-converter.h
src/manager/client-capi/ckmc-type.cpp
src/manager/client/client-error.cpp

index 8a65d61..089612f 100644 (file)
@@ -16,7 +16,7 @@
  * @file    ckmc-error.h
  * @version 1.0
  * @brief   This file contains error codes of the Key Manager
-*/
+ */
 #ifndef __TIZEN_CORE_CKMC_ERROR_H_
 #define __TIZEN_CORE_CKMC_ERROR_H_
 
@@ -31,14 +31,13 @@ extern "C" {
  * @{
  */
 
-
 #define KEY_MANAGER_ERROR_CLASS          0x0FFF0000
 
-
 /**
  * @brief Enumeration for Key Manager Errors.
  * @since_tizen 2.3
  */
+
 typedef enum{
        CKMC_ERROR_NONE                     = TIZEN_ERROR_NONE,               /**< Successful */
        CKMC_ERROR_INVALID_PARAMETER        = TIZEN_ERROR_INVALID_PARAMETER,  /**< Invalid function parameter */
@@ -60,11 +59,10 @@ typedef enum{
        CKMC_ERROR_VERIFICATION_FAILED      = KEY_MANAGER_ERROR_CLASS | 0x0D, /**< CA certificate(s) were unknown and chain could not be created */
        CKMC_ERROR_INVALID_FORMAT           = KEY_MANAGER_ERROR_CLASS | 0x0E, /**< A provided file or binary has not a valid format */
        CKMC_ERROR_FILE_ACCESS_DENIED       = KEY_MANAGER_ERROR_CLASS | 0x0F, /**< A provided file or binary has not a valid format */
-    CKMC_ERROR_NOT_EXPORTABLE           = KEY_MANAGER_ERROR_CLASS | 0x10, /**< Key is not exportable. It could not be returned to client */
-       CKMC_ERROR_UNKNOWN                  = KEY_MANAGER_ERROR_CLASS | 0x11, /**< A provided file or binary has not a valid format */
+       CKMC_ERROR_NOT_EXPORTABLE           = KEY_MANAGER_ERROR_CLASS | 0x10, /**< Key is not exportable. It could not be returned to client */
+       CKMC_ERROR_UNKNOWN                  = KEY_MANAGER_ERROR_CLASS | 0xFF, /**< A provided file or binary has not a valid format */
 } key_manager_error_e;
 
-
 /**
  * @}
  */
index 3be5a5a..bb7c9ad 100644 (file)
@@ -122,7 +122,7 @@ int ckmc_remove_key(const char *alias);
  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
- *
+ * @retval #CKMC_ERROR_NOT_EXPORTABLE a key is not exportable and could not be returned to client
  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
  *
  * @see ckmc_save_key()
@@ -239,6 +239,7 @@ int ckmc_remove_cert(const char *alias);
  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
+ * @retval #CKMC_ERROR_NOT_EXPORTABLE a certification is not exportable and could not be returned to client
  *
  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
  *
@@ -355,6 +356,7 @@ int ckmc_remove_data(const char *alias);
  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
+ * @retval #CKMC_ERROR_NOT_EXPORTABLE data is not exportable and could not be returned to client
  *
  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
  *
index 67f240c..715bb2b 100644 (file)
@@ -22,7 +22,8 @@
 
 #include <ckmc/ckmc-error.h>
 #include <ckm/ckm-type.h>
+#include <ckmc-type-converter.h>
 
 const char * ckmc_error_to_string(int error) {
-       return CKM::ErrorToString(error);
+       return CKM::ErrorToString(to_ckm_error(error));
 }
index 435a0df..661d913 100644 (file)
@@ -31,6 +31,7 @@ extern "C" {
 #endif
 
 int to_ckmc_error(int ckm_error);
+int to_ckm_error(int ckmc_error);
 
 #ifdef __cplusplus
 }
index c02bf7f..584a585 100644 (file)
@@ -510,6 +510,33 @@ int _ckmc_load_cert_from_x509(X509 *xCert, ckmc_cert_s **cert)
        return ckmc_cert_new(output.data(), output.size(), CKMC_FORM_DER, cert);
 }
 
+int to_ckm_error(int ckmc_error) {
+       switch(ckmc_error) {
+       case CKMC_ERROR_NONE:                  return CKM_API_SUCCESS;
+       case CKMC_ERROR_SOCKET:                return CKM_API_ERROR_SOCKET;
+       case CKMC_ERROR_BAD_REQUEST:           return CKM_API_ERROR_BAD_REQUEST;
+       case CKMC_ERROR_BAD_RESPONSE:          return CKM_API_ERROR_BAD_RESPONSE;
+       case CKMC_ERROR_SEND_FAILED:           return CKM_API_ERROR_SEND_FAILED;
+       case CKMC_ERROR_RECV_FAILED:           return CKM_API_ERROR_RECV_FAILED;
+       case CKMC_ERROR_AUTHENTICATION_FAILED: return CKM_API_ERROR_AUTHENTICATION_FAILED;
+       case CKMC_ERROR_INVALID_PARAMETER:     return CKM_API_ERROR_INPUT_PARAM;
+       case CKMC_ERROR_BUFFER_TOO_SMALL:      return CKM_API_ERROR_BUFFER_TOO_SMALL;
+       case CKMC_ERROR_OUT_OF_MEMORY:         return CKM_API_ERROR_OUT_OF_MEMORY;
+       case CKMC_ERROR_PERMISSION_DENIED:     return CKM_API_ERROR_ACCESS_DENIED;
+       case CKMC_ERROR_SERVER_ERROR:          return CKM_API_ERROR_SERVER_ERROR;
+       case CKMC_ERROR_DB_LOCKED:             return CKM_API_ERROR_DB_LOCKED;
+       case CKMC_ERROR_DB_ERROR:              return CKM_API_ERROR_DB_ERROR;
+       case CKMC_ERROR_DB_ALIAS_EXISTS:       return CKM_API_ERROR_DB_ALIAS_EXISTS;
+       case CKMC_ERROR_DB_ALIAS_UNKNOWN:      return CKM_API_ERROR_DB_ALIAS_UNKNOWN;
+       case CKMC_ERROR_VERIFICATION_FAILED:   return CKM_API_ERROR_VERIFICATION_FAILED;
+       case CKMC_ERROR_INVALID_FORMAT:        return CKM_API_ERROR_INVALID_FORMAT;
+       case CKMC_ERROR_FILE_ACCESS_DENIED:    return CKM_API_ERROR_FILE_ACCESS_DENIED;
+       case CKMC_ERROR_NOT_EXPORTABLE:        return CKM_API_ERROR_NOT_EXPORTABLE;
+       case CKMC_ERROR_UNKNOWN:               return CKM_API_ERROR_UNKNOWN;
+       }
+       return CKMC_ERROR_UNKNOWN;
+}
+
 int to_ckmc_error(int ckm_error) {
        switch(ckm_error) {
        case CKM_API_SUCCESS:                     return CKMC_ERROR_NONE;
index 079417b..4f41236 100644 (file)
@@ -46,6 +46,7 @@ const char * ErrorToString(int error) {
         ERRORDESCRIBE(CKM_API_ERROR_VERIFICATION_FAILED);
         ERRORDESCRIBE(CKM_API_ERROR_INVALID_FORMAT);
         ERRORDESCRIBE(CKM_API_ERROR_FILE_ACCESS_DENIED);
+        ERRORDESCRIBE(CKM_API_ERROR_NOT_EXPORTABLE);
         ERRORDESCRIBE(CKM_API_ERROR_UNKNOWN);
     default:
         return "Error not defined";