diff options
Diffstat (limited to 'src/server/service/include')
-rw-r--r-- | src/server/service/include/password-file.h | 8 | ||||
-rw-r--r-- | src/server/service/include/password-manager.h | 18 | ||||
-rw-r--r-- | src/server/service/include/password.h | 3 | ||||
-rw-r--r-- | src/server/service/include/policy-file.h | 94 | ||||
-rw-r--r-- | src/server/service/include/policy-manager.h | 64 |
5 files changed, 173 insertions, 14 deletions
diff --git a/src/server/service/include/password-file.h b/src/server/service/include/password-file.h index 9b18365..1ab4fcb 100644 --- a/src/server/service/include/password-file.h +++ b/src/server/service/include/password-file.h @@ -73,8 +73,11 @@ namespace AuthPasswd void setMaxHistorySize(unsigned int history); unsigned int getMaxHistorySize() const; + unsigned int getExpireTime() const; + void setExpireTime(unsigned int expireTime); + unsigned int getExpireTimeLeft() const; - void setExpireTime(time_t expireTime); + void setExpireTimeLeft(time_t expireTimeLeft); //attempt manipulating functions unsigned int getAttempt() const; @@ -122,7 +125,8 @@ namespace AuthPasswd PasswordList m_passwordHistory; unsigned int m_maxAttempt; unsigned int m_maxHistorySize; - time_t m_expireTime; + unsigned int m_expireTime; + time_t m_expireTimeLeft; bool m_passwordActive; bool m_passwordRcvActive; diff --git a/src/server/service/include/password-manager.h b/src/server/service/include/password-manager.h index 4832b57..be1075d 100644 --- a/src/server/service/include/password-manager.h +++ b/src/server/service/include/password-manager.h @@ -41,7 +41,7 @@ namespace AuthPasswd //checking functions //no const in checkPassword, attempts are update - int checkPassword(const unsigned int passwdType, const std::string& challenge, + int checkPassword(const unsigned int passwdType, const std::string &challenge, const unsigned int currentUser, unsigned int ¤tAttempt, unsigned int &maxAttempt, unsigned int &expirationTime); int isPwdValid(const unsigned int passwdType, const unsigned int currentUser, @@ -52,23 +52,19 @@ namespace AuthPasswd //setting functions int setPassword(const unsigned int passwdType, const std::string ¤tPassword, - const std::string &newPassword, const unsigned int currentUser, - const unsigned int receivedAttempts, const unsigned int receivedDays, - const unsigned int receivedHistory); + const std::string &newPassword, const unsigned int currentUser); int setPasswordRecovery(const std::string &curRcvPassword, const std::string &newPassword, - const unsigned int currentUser, const unsigned int receivedAttempts, - const unsigned int receivedDays, const unsigned int receivedHistory); + const unsigned int currentUser); //resetting functions int resetPassword(const unsigned int passwdType, const std::string &newPassword, - const unsigned int receivedUser, const unsigned int receivedAttempts, - const unsigned int receivedDays, const unsigned int receivedHistory); + const unsigned int receivedUser); //setting policy on the current passwd - int setPasswordMaxAttempts(const unsigned int receivedUser, + void setPasswordMaxAttempts(const unsigned int receivedUser, const unsigned int receivedAttempts); - int setPasswordValidity(const unsigned int receivedUser, const unsigned int receivedDays); - int setPasswordHistory(const unsigned int receivedUser, const unsigned int receivedHistory); + void setPasswordValidity(const unsigned int receivedUser, const unsigned int receivedDays); + void setPasswordHistory(const unsigned int receivedUser, const unsigned int receivedHistory); private: //managing functions diff --git a/src/server/service/include/password.h b/src/server/service/include/password.h index 1f69592..9063e07 100644 --- a/src/server/service/include/password.h +++ b/src/server/service/include/password.h @@ -34,9 +34,9 @@ #include <message-buffer.h> #include <connection-info.h> #include <protocols.h> -#include <policy.h> #include <password-manager.h> +#include <policy-manager.h> namespace AuthPasswd { @@ -81,6 +81,7 @@ namespace AuthPasswd // service attributes PasswordManager m_pwdManager; + PolicyManager m_policyManager; ConnectionInfoMap m_connectionInfoMap; }; } // namespace AuthPasswd diff --git a/src/server/service/include/policy-file.h b/src/server/service/include/policy-file.h new file mode 100644 index 0000000..f258f47 --- /dev/null +++ b/src/server/service/include/policy-file.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2016 - 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Jooseong Lee <jooseong.lee@samsung.com> + * + * 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 + */ +/* + * @file policy-file.h + * @author Jooseong Lee (jooseong.lee@samsung.com) + * @version 1.0 + * @brief Implementation of PolicyFile, used to manage policy files. + */ +#ifndef _POLICY_FILE_H_ +#define _PILICY_FILE_H_ + +#include <string> +#include <vector> +#include <list> +#include <memory> + +#include <dpl/serialization.h> + +namespace AuthPasswd +{ + class PolicyFile + { + public: + PolicyFile(const unsigned int user); + + void enable(); + void disable(); + + bool isPolicyActive() const; + + void writeMemoryToFile() const; + + bool checkMinLength(const std::string &password) const; + void setMinLength(unsigned int minLength); + + bool checkMinComplexCharNumber(const std::string &password) const; + void setMinComplexCharNumber(unsigned int minComplexCharNumber); + + bool checkMaxCharOccurrences(const std::string &password) const; + void setMaxCharOccurrences(unsigned int maxCharOccurrences); + + bool checkMaxNumSeqLength(const std::string &password) const; + void setMaxNumSeqLength(unsigned int maxNumSeqLength); + + bool checkQualityType(const std::string &password) const; + void setQualityType(unsigned int qualityType); + + bool isValidPattern(const std::string &pattern) const; + bool checkPattern(const std::string &password) const; + void setPattern(const std::string &pattern); + + bool checkForbiddenPasswds(const std::string &password) const; + void setForbiddenPasswds(std::vector<std::string> forbiddenPasswds); + + private: + void loadMemoryFromFile(); + void preparePolicyFile(); + void resetState(); + bool fileExists(const std::string &filename) const; + bool dirExists(const std::string &dirpath) const; + std::string createDir(const std::string &dir, const unsigned int user) const; + + //user name + unsigned int m_user; + + bool m_enable; + + //policy file data + unsigned int m_minLength; + unsigned int m_minComplexCharNumber; + unsigned int m_maxCharOccurrences; + unsigned int m_maxNumSeqLength; + unsigned int m_qualityType; + std::string m_pattern; + std::vector<std::string> m_forbiddenPasswds; + }; +} //namespace AuthPasswd + +#endif diff --git a/src/server/service/include/policy-manager.h b/src/server/service/include/policy-manager.h new file mode 100644 index 0000000..c83b811 --- /dev/null +++ b/src/server/service/include/policy-manager.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016 - 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Jooseong Lee <jooseong.lee@samsung.com> + * + * 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 + */ +/* + * @file policy-manager.h + * @author Jooseong Lee (jooseong.lee@samsung.com) + * @version 1.0 + * @brief Implementation of password management functions + */ + +#ifndef _POLICYMANAGER_H_ +#define _POLICYMANAGER_H_ + +#include <string> +#include <map> + +#include <policy.h> + +#include <policy-file.h> + +namespace AuthPasswd +{ + class PolicyManager + { + public: + typedef std::map<unsigned int, PolicyFile> PolicyFileMap; + + // policy checking functions + int checkPolicy(const unsigned int passwdType, + const std::string ¤tPassword, + const std::string &newPassword, + const unsigned int user); + + // policy setting functions + int setPolicy(const auth_password_policy policy); + + // policy disabling functions + int disablePolicy(const unsigned int user); + + private: + // managing functions + void addPolicy(const unsigned int user); + void removePolicy(const unsigned int user); + void existPolicy(const unsigned int user); + + PolicyFileMap m_policyFile; + }; +} //namespace AuthPasswd + +#endif |