package com.huimv.video.dhicc.test.config;

import com.dahuatech.icc.oauth.profile.GrantType;
import com.huimv.video.dhicc.test.schedule.UpdateTokenSchedule;

import java.util.Map;

/**
 * 用户密码模式配置信息
 */
public class OauthConfigUserPwdInfoTest02 extends OauthConfigBaseInfo02{
    /** 密码认证用户名 */
    public String username;//登录平台的用户名，
    /** 认证密码 明文 */
    public String password;

    public OauthConfigUserPwdInfoTest02(){}
    /**
     * 使用默认端口、默认协议构造
     * @param host
     * @param clientId
     * @param clientSecret
     */
    public OauthConfigUserPwdInfoTest02(String host, String clientId, String clientSecret, String username, String password){
        super(host,clientId,clientSecret, GrantType.password);
        this.username = username;
        this.password = password;
        //创建用户名密码模式信息时，将客户端信息进行缓存
        cacheClientInfo();
    }

    /**
     * 使用指定端口、指定协议构造
     * @param host
     * @param clientId
     * @param clientSecret
     */
    public OauthConfigUserPwdInfoTest02(String host, String clientId, String clientSecret, String username, String password, boolean isEnableHttpTest, String httpsPort, String httpPort){
        super(host,clientId,clientSecret, GrantType.password,isEnableHttpTest,httpsPort,httpPort);
        this.username = username;
        this.password = password;
        cacheClientInfo();
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void cacheClientInfo(){
        Map<String, OauthConfigBaseInfo02> clientInfoMap =  UpdateTokenSchedule.httpConfigMap2;
        String clientKey = UpdateTokenSchedule.getKey2(this);
        //缓存客户端信息
        clientInfoMap.put(clientKey, this);
    }
}
