Modify logging method of PrivilegeHandler on osp-installer
authorhb.min <hb.min@samsung.com>
Mon, 18 Feb 2013 04:11:48 +0000 (13:11 +0900)
committerhb.min <hb.min@samsung.com>
Mon, 18 Feb 2013 04:11:48 +0000 (13:11 +0900)
Change-Id: Ia5e44fdb25bad28fcab979a66789b76785710582
Signed-off-by: hb.min <hb.min@samsung.com>
src/XmlHandler/PrivilegeHandler.cpp

index b1940ea..bddb1e3 100755 (executable)
@@ -22,7 +22,7 @@
 #include <stdlib.h>
 
 #include <FBaseString.h>
-#include <FBaseSysLog.h>
+#include <FBaseLog.h>
 #include <FSecCryptoAesCipher.h>
 #include <FSecCryptoSha1Hash.h>
 #include <FBase_StringConverter.h>
@@ -49,8 +49,6 @@ PrivilegeHandler::GenerateCipherPrivilege(const AppId& appId, const IList& privi
        byte* pBitwisePrivilege = null;
        int count = 0;
 
-       SysLog(NID_SEC, "Enter.");
-
        encryptedPrivileges.Clear();
        checksum.Clear();
 
@@ -61,13 +59,13 @@ PrivilegeHandler::GenerateCipherPrivilege(const AppId& appId, const IList& privi
        }
 
        pBitwisePrivilege = PackPrivilegeN(privilegeList);
-       SysTryReturnResult(NID_SEC, pBitwisePrivilege != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       TryReturnResultTag(OSP_INSTALLER, pBitwisePrivilege != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
        r = GetEncryptedBitwise(pBitwisePrivilege, encryptedPrivileges);
-       SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        r = GetChecksum(appId, pBitwisePrivilege, checksum);
-       SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        // fall through
 
@@ -78,7 +76,6 @@ CATCH:
                free(pBitwisePrivilege);
        }
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -89,8 +86,6 @@ PrivilegeHandler::GenerateCipherPrivilege(const AppId& appId, const IList& privi
        byte* pBitwisePrivilege = null;
        int count = 0;
 
-       SysLog(NID_SEC, "Enter.");
-
        encryptedPrivileges.Clear();
        checksum.Clear();
 
@@ -101,13 +96,13 @@ PrivilegeHandler::GenerateCipherPrivilege(const AppId& appId, const IList& privi
        }
 
        r = PackPrivilegeN(privilegeList, visibilityLevel, &pBitwisePrivilege);
-       SysTryReturnResult(NID_SEC,   r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+       TryReturnResultTag(OSP_INSTALLER, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        r = GetEncryptedBitwise(pBitwisePrivilege, encryptedPrivileges);
-       SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        r = GetChecksum(appId, pBitwisePrivilege, checksum);
-       SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        // fall through
 
@@ -118,7 +113,6 @@ CATCH:
                free(pBitwisePrivilege);
        }
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -136,16 +130,15 @@ PrivilegeHandler::PackPrivilegeN(const IList& privilegeList)
        byte* pBitwisePrivilege = null;
        IEnumerator* pEnum = null;
 
-       SysLog(NID_SEC, "Enter.");
        ClearLastResult();
 
        pResult = (byte*) malloc(sizeof(byte) * MAX_BITWISE_PRIV_SIZE);
-       SysTryReturn(NID_SEC, pResult != null, null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+       TryReturnResultTag(OSP_INSTALLER, pResult != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        memset(pResult, 0, MAX_BITWISE_PRIV_SIZE);
 
        pEnum = privilegeList.GetEnumeratorN();
-       SysTryCatch(NID_SEC, pEnum != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatch(pEnum != null, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        while (pEnum->MoveNext() == E_SUCCESS)
        {
@@ -156,8 +149,7 @@ PrivilegeHandler::PackPrivilegeN(const IList& privilegeList)
 
                if ((pTempString->GetLength()) < (privilegeURI.GetLength()))
                {
-                       SysLogException(NID_SEC, E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", pTempString->GetPointer());
-                       AppLog("[Privilege] PackPrivilegeN(1): length error[%ls]", pTempString->GetPointer());
+                       AppLogExceptionTag(OSP_INSTALLER, "[E_INVALID_ARG] Invalid privilege string (Length error): [%ls]", pTempString->GetPointer());
                        resultFlag = false;
                        continue;
                }
@@ -167,8 +159,7 @@ PrivilegeHandler::PackPrivilegeN(const IList& privilegeList)
 
                if (!(uriString.Equals(privilegeURI, true)))
                {
-                       SysLogException(NID_SEC, E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", pTempString->GetPointer());
-                       AppLog("[Privilege] PackPrivilegeN(1): uri error[%ls]", pTempString->GetPointer());
+                       AppLogExceptionTag(OSP_INSTALLER, "[E_INVALID_ARG] Invalid privilege string (URI error): [%ls]", pTempString->GetPointer());
                        resultFlag = false;
                        continue;
                }
@@ -192,19 +183,17 @@ PrivilegeHandler::PackPrivilegeN(const IList& privilegeList)
 
                if (validStringFlag == false)
                {
-                       SysLogException(NID_SEC, E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", pTempString->GetPointer());
-                       AppLog("[Privilege] PackPrivilegeN(1): validStringFlag is false[%ls]", pTempString->GetPointer());
+                       AppLogExceptionTag(OSP_INSTALLER, "[E_INVALID_ARG] Invalid privilege string: [%ls]", pTempString->GetPointer());
                        resultFlag = false;
                }
        }
 
-       SysTryCatch(NID_SEC, resultFlag == true, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] One of privilege string is invalid.");
+       TryCatchTag(OSP_INSTALLER, resultFlag == true, r = E_INVALID_ARG, "[E_INVALID_ARG] One of privilege string is invalid.");
 
        pBitwisePrivilege = pResult;
 
        delete pEnum;
 
-       SysLog(NID_SEC, "Exit.");
        return pBitwisePrivilege;
 
 CATCH:
@@ -212,7 +201,8 @@ CATCH:
        delete pEnum;
        free(pResult);
 
-       SysLog(NID_SEC, "Exit.");
+       SetLastResult(r);
+
        return null;
 }
 
@@ -230,16 +220,15 @@ PrivilegeHandler::PackPrivilegeN(const IList& privilegeList, int visibilityLevel
        byte* pResult = null;
        IEnumerator* pEnum = null;
 
-       SysLog(NID_SEC, "Enter.");
        ClearLastResult();
 
        pResult = (byte*) malloc(sizeof(byte) * MAX_BITWISE_PRIV_SIZE);
-       SysTryReturn(NID_SEC, pResult != null, null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+       TryReturnResultTag(OSP_INSTALLER, pResult != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        memset(pResult, 0, MAX_BITWISE_PRIV_SIZE);
 
        pEnum = privilegeList.GetEnumeratorN();
-       SysTryCatch(NID_SEC, pEnum != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, pEnum != null, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        while (pEnum->MoveNext() == E_SUCCESS)
        {
@@ -252,8 +241,7 @@ PrivilegeHandler::PackPrivilegeN(const IList& privilegeList, int visibilityLevel
 
                if ((pTempString->GetLength()) < (privilegeURI.GetLength()))
                {
-                       SysLogException(NID_SEC, E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", pTempString->GetPointer());
-                       AppLog("[Privilege] PackPrivilegeN(3): length error[%ls]", pTempString->GetPointer());
+                       AppLogExceptionTag(OSP_INSTALLER, "[E_INVALID_ARG] Invalid privilege string (Length error): [%ls]", pTempString->GetPointer());
                        resultFlag = false;
                        continue;
                }
@@ -263,8 +251,7 @@ PrivilegeHandler::PackPrivilegeN(const IList& privilegeList, int visibilityLevel
 
                if (!(uriString.Equals(privilegeURI, true)))
                {
-                       SysLogException(NID_SEC, E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", pTempString->GetPointer());
-                       AppLog("[Privilege] PackPrivilegeN(3): uri error[%ls]", pTempString->GetPointer());
+                       AppLogExceptionTag(OSP_INSTALLER, "[E_INVALID_ARG] Invalid privilege string (URI error): [%ls]", pTempString->GetPointer());
                        resultFlag = false;
                        continue;
                }
@@ -297,26 +284,23 @@ PrivilegeHandler::PackPrivilegeN(const IList& privilegeList, int visibilityLevel
 
                if (validStringFlag == false)
                {
-                       SysLogException(NID_SEC, E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", pTempString->GetPointer());
-                       AppLog("[Privilege] PackPrivilegeN(3): privilege string error[%ls]", pTempString->GetPointer());
+                       AppLogExceptionTag(OSP_INSTALLER, "[E_INVALID_ARG] Invalid privilege string: [%ls]", pTempString->GetPointer());
                        resultFlag = false;
                }
 
                if (validLevelFlag == false)
                {
-                       SysLogException(NID_SEC, E_INVALID_ARG, "[E_INVALID_ARG] The application does not have the visibility to register %ls", pTempString->GetPointer());
-                       AppLog("[Privilege] PackPrivilegeN(3): validLevelFlag is false[%ls]", pTempString->GetPointer());
+                       AppLogExceptionTag(OSP_INSTALLER, "[E_INVALID_ARG] The application does not have the visibility to register [%ls]", pTempString->GetPointer());
                        resultFlag = false;
                }
        }
 
-       SysTryCatch(NID_SEC, resultFlag == true, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] One of privilege string is invalid.");
+       TryCatchTag(OSP_INSTALLER, resultFlag == true, r = E_INVALID_ARG, "[E_INVALID_ARG] One of privilege string is invalid.");
 
        *ppBitwisePrivilege = pResult;
 
        delete pEnum;
 
-       SysLog(NID_SEC, "Exit.");;
        return r;
 
 CATCH:
@@ -324,7 +308,6 @@ CATCH:
        delete pEnum;
        free(pResult);
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -335,20 +318,18 @@ PrivilegeHandler::GetEncryptedBitwise(byte* pBitwisePrivilege, String& encrypted
        result r = E_SUCCESS;
        ByteBuffer* pTempBitwisePrivilege = null;
 
-       SysLog(NID_SEC, "Enter.");
-
        pTempBitwisePrivilege = new (std::nothrow) ByteBuffer();
-       SysTryReturnResult(NID_SEC, pTempBitwisePrivilege != null, E_OUT_OF_MEMORY, "Memory allocation is failed.");
+       TryReturnResultTag(OSP_INSTALLER, pTempBitwisePrivilege != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
 
        r = pTempBitwisePrivilege->Construct(MAX_BITWISE_PRIV_SIZE);
-       SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        r = pTempBitwisePrivilege->SetArray(pBitwisePrivilege, 0, MAX_BITWISE_PRIV_SIZE);
-       SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
        pTempBitwisePrivilege->Flip();
 
        r = StringUtil::EncodeToBase64String(*pTempBitwisePrivilege, encryptedPrivileges);
-       SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        // fall through
 
@@ -356,7 +337,6 @@ CATCH:
 
        delete pTempBitwisePrivilege;
 
-       SysLog(NID_SEC, "Exit.");
        return r;
 }
 
@@ -372,7 +352,7 @@ PrivilegeHandler::GetChecksum(AppId appId, byte* pBitwisePrivilege, String& chec
        char* pAppId = null;
 
        pAppId = (char*) _StringConverter::CopyToCharArrayN(appId);
-       SysTryCatch(NID_SEC, pAppId != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, pAppId != null, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        memcpy(tempChecksumString, pAppId, MAX_APP_ID_SIZE);
        memcpy(tempChecksumString + MAX_APP_ID_SIZE, pBitwisePrivilege, MAX_BITWISE_PRIV_SIZE);
@@ -381,20 +361,20 @@ PrivilegeHandler::GetChecksum(AppId appId, byte* pBitwisePrivilege, String& chec
        pAppId = null;
 
        r = input.Construct(MAX_APP_ID_SIZE + MAX_BITWISE_PRIV_SIZE);
-       SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        r = input.SetArray(tempChecksumString, 0, MAX_APP_ID_SIZE + MAX_BITWISE_PRIV_SIZE);
-       SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
        input.Flip();
 
        pHash = new (std::nothrow) Sha1Hash();
-       SysTryCatch(NID_SEC, pHash != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
+       TryCatchTag(OSP_INSTALLER, pHash != null, r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
 
        pChecksumByteBuffer = pHash->GetHashN(input);
-       SysTryCatch(NID_SEC, pChecksumByteBuffer != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, pChecksumByteBuffer != null, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        r = StringUtil::EncodeToBase64String(*pChecksumByteBuffer, checksum);
-       SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+       TryCatchTag(OSP_INSTALLER, r == E_SUCCESS, r = E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
        // fall through