#pragma once

#include <cstring>
#include <experimental/filesystem>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
#include <xyz/openbmc_project/User/Password/server.hpp>
namespace phosphor
{
namespace user
{

using CryptAlgo = std::string;

namespace fs = std::experimental::filesystem;
namespace Base = sdbusplus::xyz::openbmc_project::User::server;
using Interface = sdbusplus::server::object::object<Base::Password>;

/** @class User
 *  @brief Responsible for managing a specific user account.
 *         It is implementing just the Password interface
 *         for now.
 */
class User : public Interface
{
  public:
    User() = delete;
    ~User() = default;
    User(const User&) = delete;
    User& operator=(const User&) = delete;
    User(User&&) = delete;
    User& operator=(User&&) = delete;

    /** @brief Constructs User object.
     *
     *  @param[in] bus  - sdbusplus handler
     *  @param[in] path - D-Bus path
     */
    User(sdbusplus::bus::bus& bus, const char* path) :
        Interface(bus, path), bus(bus), path(path),
        user(fs::path(path).filename())
    {
        // Do nothing
    }

    /** @brief user password set method. If this is called for
     *         a user ID that already has the password, the password
     *         would be updated, else password would be created.
     *         Since this needs an already authenticated session,
     *         old password is not needed.
     *
     *  @param[in] newPassword - New password
     */
    void setPassword(std::string newPassword) override;

  private:
    /** @brief sdbusplus handler */
    sdbusplus::bus::bus& bus;

    /** @brief object path */
    const std::string& path;

    /** @brief User id extracted from object path */
    const std::string user;

    /** @brief Returns a random string from set [A-Za-z0-9./]
     *         of length size
     *
     *  @param[in] numChars - length of string
     */
    static const std::string randomString(int length);

    /** @brief Returns password hash created with crypt algo,
     *         salt and password
     *
     *  @param[in] spPwdp   - sp_pwdp of struct spwd
     *  @param[in] password - clear text password
     *  @param[in] salt     - Random salt
     */
    std::string hashPassword(char* spPwdp, const std::string& password,
                             const std::string& salt);

    /** @brief Extracts crypto number from the shadow entry for user
     *
     *  @param[in] spPwdp - sp_pwdp of struct spwd
     */
    static CryptAlgo getCryptField(char* spPwdp);

    /** @brief Generates one-way hash based on salt and password
     *
     *  @param[in] password - clear text password
     *  @param[in] salt     - Combination of crypto method and salt
     *                        Eg: $1$HELLO$, where in 1 is crypto method
     *                        and HELLO is salt
     */
    static std::string generateHash(const std::string& password,
                                    const std::string& salt);

    /** @brief Returns salt string with $ delimiter.
     *         Eg: If crypt is 1 and salt is HELLO, returns $1$HELLO$
     *
     *  @param[in] crypt - Crypt number in string
     *  @param[in] salt  - salt
     */
    static std::string getSaltString(const std::string& crypt,
                                     const std::string& salt);

    /** @brief Applies the password for a given user.
     *         Writes shadow entries into a temp file
     *
     *  @param[in] shadowFile - shadow password file
     *  @param[in] password   - clear text password
     *  @param[in] salt       - salt
     */
    void applyPassword(const std::string& shadowFile,
                       const std::string& password, const std::string& salt);

    /** @brief Wrapper for raising exception
     *
     *  @param[in] errNo  - errno
     *  @param[in] errMsg - Error message
     */
    void raiseException(int errNo, const std::string& errMsg);

    /** @brief For enabling test cases */
    friend class UserTest;
};

} // namespace user
} // namespace phosphor
