All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dahuatech.icc.oauth.model.v202010.OauthPwdAuthRequest Maven / Gradle / Ivy

There is a newer version: 1.0.13.7
Show newest version
package com.dahuatech.icc.oauth.model.v202010;

import com.dahuatech.hutool.http.Method;
import com.dahuatech.icc.common.ParamValidEnum;
import com.dahuatech.icc.exception.ClientException;
import com.dahuatech.icc.oauth.constant.OauthConstant;
import com.dahuatech.icc.oauth.exception.BusinessException;
import com.dahuatech.icc.oauth.http.AbstractIccRequest;
import com.dahuatech.icc.oauth.model.v202010.oSDK.OauthParamConstant;
import com.dahuatech.icc.util.StringUtils;

/**
 * 密码认证授权
 *
 * @author 232676
 * @since 1.0.0 2020-10-24 20:59:11
 */
public class OauthPwdAuthRequest extends AbstractIccRequest {

  private String grant_type;
  private String username;
  private String password;
  private String client_id;
  private String client_secret;
  private String public_key;

  public OauthPwdAuthRequest() {
    super(OauthConstant.url(OauthConstant.OAUTH_URL_PWD_AUTH_POST), Method.POST, Boolean.FALSE);
  }

  @Override
  public Class getResponseClass() {
    return OauthPwdAuthResponse.class;
  }

  public String getGrant_type() {
    return grant_type;
  }

  public void setGrant_type(String grant_type) {
    this.grant_type = grant_type;
    putBodyParameter("grant_type", grant_type);
  }

  public String getUsername() {
    return username;
  }

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

  public String getPassword() {
    return password;
  }

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

  public String getClient_id() {
    return client_id;
  }

  public void setClient_id(String client_id) {
    this.client_id = client_id;
    putBodyParameter("client_id", client_id);
  }

  public String getClient_secret() {
    return client_secret;
  }

  public void setClient_secret(String client_secret) {
    this.client_secret = client_secret;
    putBodyParameter("client_secret", client_secret);
  }

  public String getPublic_key() {
    return public_key;
  }

  public void setPublic_key(String public_key) {
    this.public_key = public_key;
    putBodyParameter("public_key", public_key);
  }

    public void businessValid() {
        if(StringUtils.isEmpty(grant_type)){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "clientType");
        }
        if(StringUtils.isEmpty(username)){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "username");
        }
        if(StringUtils.isEmpty(password)){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "password");
        }
        if(StringUtils.isEmpty(client_id)){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "client_id");
        }
        if(StringUtils.isEmpty(client_secret)){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "client_secret");
        }
        if(StringUtils.isEmpty(public_key)){
            throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(), ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getErrMsg(), "public_key");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy