Add GetPasswordStatus API to Password Policy 73/84573/2
authorSungjun, Lee <sjun221.lee@samsung.com>
Fri, 19 Aug 2016 09:43:35 +0000 (18:43 +0900)
committerSungjun, Lee <sjun221.lee@samsung.com>
Mon, 22 Aug 2016 02:48:36 +0000 (11:48 +0900)
Change-Id: I74f7967aa4ba3e1c3e6b4b3728cabed0b4774cad
Signed-off-by: Sungjun, Lee <sjun221.lee@samsung.com>
libs/dpm/password.cpp [changed mode: 0755->0644]
libs/dpm/password.h
libs/password.cpp
policy/password.hxx
server/password.cpp

old mode 100755 (executable)
new mode 100644 (file)
index aaabef0..909edec
@@ -273,6 +273,24 @@ EXPORT_API int dpm_password_set_status(device_policy_manager_h handle, dpm_passw
        return password.setPasswordPolicyStatus(status);
 }
 
+EXPORT_API int dpm_password_get_status(device_policy_manager_h handle, dpm_password_status_e *status)
+{
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(status, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+
+       int ret = password.getPasswordPolicyStatus();
+       if (ret < 0) {
+               return -1;
+       }
+
+       *status = (dpm_password_status_e)ret;
+
+       return DPM_ERROR_NONE;
+}
+
 EXPORT_API int dpm_password_delete_pattern(device_policy_manager_h handle)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
index 665f26f..2225df1 100644 (file)
@@ -406,6 +406,22 @@ int dpm_password_get_max_inactivity_time_device_lock(device_policy_manager_h han
 int dpm_password_set_status(device_policy_manager_h handle, dpm_password_status_e status);
 
 /**
+ * @brief       Gets password status
+ * @details     An administrator can know password status for this API.
+ * @since_tizen 3.0
+ * @param[in]   handle Device policy manager handle
+ * @param[out]   status Password status
+ * @return      #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval      #DPM_ERROR_NONE Successful
+ * @retval      #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval      #DPM_ERROR_TIMED_OUT Time out
+ * @pre         The handle must be created by dpm_manager_create().
+ * @see         dpm_manager_create()
+ */
+int dpm_password_get_status(device_policy_manager_h handle, dpm_password_status_e *status);
+
+
+/**
  * @partner
  * @brief       Removes all password patterns.
  * @details     An administrator can remove all password patterns.
index c6950a1..49f2b3d 100644 (file)
@@ -187,6 +187,15 @@ int PasswordPolicy::setPasswordPolicyStatus(const int status)
        }
 }
 
+int PasswordPolicy::getPasswordPolicyStatus()
+{
+       try {
+               return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyStatus");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
+}
+
 int PasswordPolicy::deletePasswordPolicyPattern()
 {
        try {
index ccb5454..832a568 100644 (file)
@@ -63,6 +63,7 @@ public:
        int getMaxInactivityTimeDeviceLock();
        std::string getPasswordPolicyPolicy();
        int setPasswordPolicyStatus(const int status);
+       int getPasswordPolicyStatus();
        int deletePasswordPolicyPattern();
        std::string getPasswordPolicyPattern();
        int setMaximumCharacterOccurrences(const int value);
index 5e21d88..7400d22 100644 (file)
@@ -200,6 +200,7 @@ PasswordPolicy::PasswordPolicy(PolicyControlContext &ctxt) :
        ctxt.registerParametricMethod(this, DPM_PRIVILEGE_PASSWORD, (int)(PasswordPolicy::setMaxInactivityTimeDeviceLock)(int));
        ctxt.registerNonparametricMethod(this, "", (int)(PasswordPolicy::getMaxInactivityTimeDeviceLock));
        ctxt.registerParametricMethod(this, DPM_PRIVILEGE_PASSWORD, (int)(PasswordPolicy::setPasswordPolicyStatus)(int));
+       ctxt.registerNonparametricMethod(this, "", (int)(PasswordPolicy::getPasswordPolicyStatus));
        ctxt.registerNonparametricMethod(this, DPM_PRIVILEGE_PASSWORD, (int)(PasswordPolicy::deletePasswordPolicyPattern));
        ctxt.registerNonparametricMethod(this, "", (std::string)(PasswordPolicy::getPasswordPolicyPattern));
        ctxt.registerParametricMethod(this, DPM_PRIVILEGE_PASSWORD, (int)(PasswordPolicy::setMaximumCharacterOccurrences)(int));
@@ -211,15 +212,15 @@ PasswordPolicy::PasswordPolicy(PolicyControlContext &ctxt) :
 
        ctxt.createNotification("password");
 
-    DefineUintMaxPolicy(ctxt, "password-history");
+       DefineUintMaxPolicy(ctxt, "password-history");
        DefineUintMaxPolicy(ctxt, "password-minimum-length");
-    DefineUintMaxPolicy(ctxt, "password-minimum-complexity");
-    DefineUintMaxPolicy(ctxt, "password-inactivity-timeout", 1000);
+       DefineUintMaxPolicy(ctxt, "password-minimum-complexity");
+       DefineUintMaxPolicy(ctxt, "password-inactivity-timeout", 1000);
 
-    DefineUintMinPolicy(ctxt, "password-expired");
-    DefineUintMinPolicy(ctxt, "password-maximum-failure-count");
-    DefineUintMinPolicy(ctxt, "password-numeric-sequences-length");
-    DefineUintMinPolicy(ctxt, "password-maximum-character-occurrences");
+       DefineUintMinPolicy(ctxt, "password-expired");
+       DefineUintMinPolicy(ctxt, "password-maximum-failure-count");
+       DefineUintMinPolicy(ctxt, "password-numeric-sequences-length");
+       DefineUintMinPolicy(ctxt, "password-maximum-character-occurrences");
 
        DefineLastPolicy(ctxt, "password-status", "0");
        DefineLastPolicy(ctxt, "password-quality", "");
@@ -377,13 +378,13 @@ int PasswordPolicy::setMaximumFailedPasswordPolicyForWipe(const int value)
 
        auth_passwd_free_policy(p_policy);
 
-       return SetUintPolicy(__context, "password-maximum-failure-count", (value == 0)? UINT_MAX : value);
+       return SetUintPolicy(__context, "password-maximum-failure-count", (value == 0) ? UINT_MAX : value);
 }
 
 int PasswordPolicy::getMaximumFailedPasswordPolicyForWipe()
 {
        unsigned int result = GetUintPolicy(__context, "password-maximum-failure-count");
-       return (result == UINT_MAX)? 0 : result;
+       return (result == UINT_MAX) ? 0 : result;
 }
 
 int PasswordPolicy::setPasswordPolicyExpires(const int value)
@@ -411,13 +412,13 @@ int PasswordPolicy::setPasswordPolicyExpires(const int value)
 
        auth_passwd_free_policy(p_policy);
 
-       return SetUintPolicy(__context, "password-expired", (value == 0)? UINT_MAX : value);
+       return SetUintPolicy(__context, "password-expired", (value == 0) ? UINT_MAX : value);
 }
 
 int PasswordPolicy::getPasswordPolicyExpires()
 {
        unsigned int result = GetUintPolicy(__context, "password-expired");
-       return (result == UINT_MAX)? 0 : result;
+       return (result == UINT_MAX) ? 0 : result;
 }
 
 int PasswordPolicy::setPasswordPolicyHistory(const int value)
@@ -559,6 +560,12 @@ int PasswordPolicy::setPasswordPolicyStatus(const int status)
        return -1;
 }
 
+int PasswordPolicy::getPasswordPolicyStatus()
+{
+       int status = std::stoi(GetPolicy(__context, "password-status"));
+       return status;
+}
+
 int PasswordPolicy::deletePasswordPolicyPattern()
 {
        policy_h *p_policy;
@@ -622,14 +629,14 @@ int PasswordPolicy::setMaximumCharacterOccurrences(const int value)
 
        auth_passwd_free_policy(p_policy);
 
-       return SetUintPolicy(__context, "password-maximum-character-occurrences", (value == 0)? UINT_MAX : value);
+       return SetUintPolicy(__context, "password-maximum-character-occurrences", (value == 0) ? UINT_MAX : value);
 }
 
 int PasswordPolicy::getMaximumCharacterOccurrences()
 {
 
-    unsigned int result = GetUintPolicy(__context, "password-maximum-character-occurrences");
-       return (result == UINT_MAX)? 0 : result;
+       unsigned int result = GetUintPolicy(__context, "password-maximum-character-occurrences");
+       return (result == UINT_MAX) ? 0 : result;
 }
 
 int PasswordPolicy::setMaximumNumericSequenceLength(const int value)
@@ -657,13 +664,13 @@ int PasswordPolicy::setMaximumNumericSequenceLength(const int value)
 
        auth_passwd_free_policy(p_policy);
 
-       return SetUintPolicy(__context, "password-numeric-sequences-length", (value == 0)? UINT_MAX : value);
+       return SetUintPolicy(__context, "password-numeric-sequences-length", (value == 0) ? UINT_MAX : value);
 }
 
 int PasswordPolicy::getMaximumNumericSequenceLength()
 {
        unsigned int result = GetUintPolicy(__context, "password-numeric-sequences-length");
-       return (result == UINT_MAX)? 0 : result;
+       return (result == UINT_MAX) ? 0 : result;
 }
 
 int PasswordPolicy::setForbiddenStrings(const std::vector<std::string> &forbiddenStrings)