Organize the error type into hal_security_auth_error_e type. 86/322986/9
authorDongsun Lee <ds73.lee@samsung.com>
Mon, 21 Apr 2025 02:24:42 +0000 (11:24 +0900)
committerDongik Lee <dongik.lee@samsung.com>
Fri, 25 Apr 2025 05:36:51 +0000 (14:36 +0900)
Change-Id: I97d1d2601c804fcb01e47539a0786c3e812b00e2

src/include/auth-passwd-error.h
src/server/service/password-manager.cpp

index 31654e1609bb6ec3af3c5f4bf9884d5700a6e4ff..84ecd73f0bc372d5d08bb7636c6ff397e9f863f7 100644 (file)
  * result codes begin with the start error code and extend into negative direction.
  * @{
 */
-#define AUTH_PASSWD_API_SUCCESS 0
+
 
 /*! \brief   indicating the result of the one specific API is successful */
+#define AUTH_PASSWD_API_SUCCESS 0
+
+/*! \brief   indicating the socket error happened */
 #define AUTH_PASSWD_API_ERROR_SOCKET -1
 
 /*! \brief   indicating the API's input parameter is malformed */
 /*! \brief   indicating password does not meet pattern policy */
 #define AUTH_PASSWD_API_ERROR_INVALID_PATTERN -24
 
+/*! \brief   indicating status does not meet the required condition or threshold */
+#define AUTH_PASSWD_API_ERROR_STATUS -25
+
+/*! \brief   indicating there is a failure during HAL initialization */
+#define AUTH_PASSWD_API_ERROR_HAL_INIT_FAIL -26
+
 /*! \brief   indicating the error with unknown reason */
 #define AUTH_PASSWD_API_ERROR_UNKNOWN -255
 /** @}*/
index c9b269eb03faab3f5ed1c8cb03b2050208a17ff7..4399b5bfb0aef81ffa305faa932a01d56c2fbaca 100644 (file)
@@ -150,12 +150,12 @@ int PasswordManager::checkPassword(unsigned int passwdType,
        LogSecureDebug("Inside checkPassword function.");
        existPassword(passwdType, currentUser, false);
 
-       if(hal_security_auth_is_ignore_period(currentUser) == AUTH_PASSWD_API_SUCCESS){
+       if(hal_security_auth_is_ignore_period(currentUser) == HAL_SECURITY_AUTH_ERROR_NONE){
                LogError("Retry timeout occurred.");
                return AUTH_PASSWD_API_ERROR_PASSWORD_RETRY_TIMER;
        }
 
-       if ((hal_security_auth_is_password_active(currentUser) != AUTH_PASSWD_API_SUCCESS)
+       if ((hal_security_auth_is_password_active(currentUser) != HAL_SECURITY_AUTH_ERROR_NONE)
                                                                                                && !challenge.empty()) {
                LogError("Password not active.");
                return AUTH_PASSWD_API_ERROR_NO_PASSWORD;
@@ -166,7 +166,7 @@ int PasswordManager::checkPassword(unsigned int passwdType,
        hal_security_auth_get_max_attempt(currentUser, &maxAttempt);
        hal_security_auth_get_expire_time_left(currentUser,&expirationTime);
 
-       if (hal_security_auth_check_attempt_exceeded(currentUser) != AUTH_PASSWD_API_SUCCESS) {
+       if (hal_security_auth_check_attempt_exceeded(currentUser) != HAL_SECURITY_AUTH_ERROR_NONE) {
                LogError("Too many tries.");
                return AUTH_PASSWD_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED;
        }
@@ -175,7 +175,7 @@ int PasswordManager::checkPassword(unsigned int passwdType,
                return AUTH_PASSWD_API_ERROR_PASSWORD_MISMATCH;
 
        const char* ch_challenge = challenge.data();
-       if (hal_security_auth_check_password(currentUser, ch_challenge) != AUTH_PASSWD_API_SUCCESS) {
+       if (hal_security_auth_check_password(currentUser, ch_challenge) != HAL_SECURITY_AUTH_ERROR_NONE) {
                LogError("Wrong password.");
                return AUTH_PASSWD_API_ERROR_PASSWORD_MISMATCH;
        }
@@ -203,7 +203,7 @@ int PasswordManager::isPwdValid(unsigned int passwdType, unsigned int currentUse
        }
        existPassword(passwdType, currentUser, false);
 
-       if (hal_security_auth_is_password_active(currentUser) != AUTH_PASSWD_API_SUCCESS) {
+       if (hal_security_auth_is_password_active(currentUser) != HAL_SECURITY_AUTH_ERROR_NONE) {
                LogError("Current password not active.");
                return AUTH_PASSWD_API_ERROR_NO_PASSWORD;
        }
@@ -226,9 +226,9 @@ int PasswordManager::isPwdReused(unsigned int passwdType, const std::string &pas
        }
 
        // check history, however only if history is active and password is not empty
-       if (hal_security_auth_is_history_active(currentUser) == AUTH_PASSWD_API_SUCCESS && !passwd.empty()){
+       if (hal_security_auth_is_history_active(currentUser) == HAL_SECURITY_AUTH_ERROR_NONE && !passwd.empty()){
                const char* ch_passwd = passwd.data();
-               if(hal_security_auth_is_password_reused(currentUser, ch_passwd) == AUTH_PASSWD_API_SUCCESS){
+               if(hal_security_auth_is_password_reused(currentUser, ch_passwd) == HAL_SECURITY_AUTH_ERROR_NONE){
                        isReused = true;
                }
        }
@@ -250,7 +250,7 @@ int PasswordManager::setPasswordWithTypeRestore(unsigned int initTypeBackup, uns
                LogError("setPassword Not supported new password type: " << newPasswdType);
                return AUTH_PASSWD_API_ERROR_INPUT_PARAM;
        }
-       if (hal_security_auth_is_ignore_period(currentUser) == AUTH_PASSWD_API_SUCCESS) {
+       if (hal_security_auth_is_ignore_period(currentUser) == HAL_SECURITY_AUTH_ERROR_NONE) {
                LogError("Retry timeout occured.");
 
                return AUTH_PASSWD_API_ERROR_PASSWORD_RETRY_TIMER;
@@ -258,7 +258,7 @@ int PasswordManager::setPasswordWithTypeRestore(unsigned int initTypeBackup, uns
 
        // check delivered currentPassword
        // when m_passwordActive flag is false, current password should be empty
-       if (!currentPassword.empty() && hal_security_auth_is_password_active(currentUser) != AUTH_PASSWD_API_SUCCESS) {
+       if (!currentPassword.empty() && hal_security_auth_is_password_active(currentUser) != HAL_SECURITY_AUTH_ERROR_NONE) {
                LogError("Password not active.");
                return AUTH_PASSWD_API_ERROR_NO_PASSWORD;
        }
@@ -277,7 +277,7 @@ int PasswordManager::setPasswordWithTypeRestore(unsigned int initTypeBackup, uns
                return AUTH_PASSWD_API_ERROR_PASSWORD_MISMATCH;
        }
        const char* ch_currentPassword = currentPassword.data();
-       if (hal_security_auth_check_password(currentUser, ch_currentPassword) != AUTH_PASSWD_API_SUCCESS) {
+       if (hal_security_auth_check_password(currentUser, ch_currentPassword) != HAL_SECURITY_AUTH_ERROR_NONE) {
                LogError("Wrong password.");
                return AUTH_PASSWD_API_ERROR_PASSWORD_MISMATCH;
        }
@@ -287,9 +287,9 @@ int PasswordManager::setPasswordWithTypeRestore(unsigned int initTypeBackup, uns
        hal_security_auth_write_attempt_to_file(currentUser);
 
        // check history, however only if history is active and new password is not empty
-       if (hal_security_auth_is_history_active(currentUser) == AUTH_PASSWD_API_SUCCESS && !newPassword.empty()) {
+       if (hal_security_auth_is_history_active(currentUser) == HAL_SECURITY_AUTH_ERROR_NONE && !newPassword.empty()) {
                const char* ch_newPassword = newPassword.data();
-               if (hal_security_auth_is_password_reused(currentUser, ch_newPassword) == AUTH_PASSWD_API_SUCCESS) {
+               if (hal_security_auth_is_password_reused(currentUser, ch_newPassword) == HAL_SECURITY_AUTH_ERROR_NONE) {
                        LogError("Password reused.");
                        return AUTH_PASSWD_API_ERROR_PASSWORD_REUSED;
                }
@@ -322,7 +322,7 @@ int PasswordManager::setPassword(unsigned int curPasswdType,
        existPassword(newPasswdType, currentUser, true);
 
        int result = setPasswordWithTypeRestore(passwdUnitType, curPasswdType, currentPassword,newPasswdType, newPassword,currentUser);
-       if(result != AUTH_PASSWD_API_SUCCESS){
+       if(result != HAL_SECURITY_AUTH_ERROR_NONE){
                existPassword(passwdUnitType, currentUser, true);
        }
        return result;
@@ -379,7 +379,7 @@ void PasswordManager::setPasswordValidity(unsigned int passwdType, unsigned int
        existPassword(passwdType, receivedUser, false);
        calculateExpiredTime(receivedDays, valid_secs);
 
-       if (hal_security_auth_is_password_active(receivedUser) == AUTH_PASSWD_API_SUCCESS){
+       if (hal_security_auth_is_password_active(receivedUser) == HAL_SECURITY_AUTH_ERROR_NONE){
                LogError("setPasswordValidity is not password active : " << receivedDays << " validSecs : " << valid_secs);
                hal_security_auth_set_expire_time_left(receivedUser ,valid_secs);
        }