/* * Copyright (C) 2014-2017 CZ.NIC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations including * the two. */ #ifndef _TASK_CHANGE_PASSWORD_H_ #define _TASK_CHANGE_PASSWORD_H_ #include "src/net/isds_session.h" #include "src/net/net_layer.h" #include "src/worker/task.h" /*! * @brief Task describing change password. */ class TaskChangePassword : public Task { public: /*! * @brief Return state describing what happened. */ enum Result { DL_SUCCESS, /*!< Operation was successful. */ DL_ISDS_ERROR, /*!< Error communicating with ISDS. */ DL_XML_ERROR, /*!< Error xml parse. */ DL_DB_INS_ERR, /*!< Error inserting into database. */ DL_ERR /*!< Other error. */ }; /*! * @brief Constructor. * * @param[in] ctx Account isds context (include username). * @param[in] netLayer Pointer to network manager. * @param[in] dbOTPType OTP login type (TOTP/HOTP). * @param[in] oldPwd Old password. * @param[in] newPwd New password. */ explicit TaskChangePassword(IsdsSession::IsdsContext &ctx, NetLayer *netLayer, const QString &dbOTPType, const QString &oldPwd, const QString &newPwd); /*! * @brief Performs actual change password. */ virtual void run(void) Q_DECL_OVERRIDE; /*! * @brief Change password. * * @param[in] ctx Account isds context (include username). * @param[in] netLayer Pointer to network manager. * @param[in] dbOTPType OTP login type (TOTP/HOTP). * @param[in] oldPwd Old password. * @param[in] newPwd New password. * @return Error state. */ static enum Result changePassword(IsdsSession::IsdsContext &ctx, NetLayer *netLayer, const QString &dbOTPType, const QString &oldPwd, const QString &newPwd); enum Result m_result; /*!< Return state. */ QString m_isdsText; /*!< Return isds result text. */ private: /*! * Disable copy and assignment. */ TaskChangePassword(const TaskChangePassword &); TaskChangePassword &operator=(const TaskChangePassword &); IsdsSession::IsdsContext m_ctx; /*!< Account isds context. */ NetLayer *m_netLayer; /*!< Pointer to network manager to send request. */ QString m_dbOTPType; /*!< OTP login type (TOTP/HOTP). */ QString m_oldPwd; /*!< Old password. */ QString m_newPwd; /*!< New password. */ }; #endif /* _TASK_CHANGE_PASSWORD_H_ */