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

com.dahuatech.icc.oauth.model.v202010.SDK.OauthPwdAuthSDK Maven / Gradle / Ivy

The newest version!
package com.dahuatech.icc.oauth.model.v202010.SDK;

import com.dahuatech.hutool.log.Log;
import com.dahuatech.hutool.log.LogFactory;
import com.dahuatech.icc.exception.ClientException;
import com.dahuatech.icc.oauth.exception.BusinessException;
import com.dahuatech.icc.oauth.http.IccClient;
import com.dahuatech.icc.oauth.model.v202010.OauthConfigBaseInfo;
import com.dahuatech.icc.oauth.model.v202010.OauthConfigUserPwdInfo;
import com.dahuatech.icc.oauth.model.v202010.OauthPwdAuthRequest;
import com.dahuatech.icc.oauth.model.v202010.OauthPwdAuthResponse;
import com.dahuatech.icc.oauth.model.v202010.oSDK.OauthParamConstant;

/**
 * program:java-sdk
 *
 * Author: 312013
 * Date:2022-07-19 13:44
 * Description: 密码认证授权
 */
public class OauthPwdAuthSDK {
    private static final Log logger = LogFactory.get();

    /**
     * 密码认证授权
     **/
    public OauthPwdAuthResponse oauthPwdAuth(OauthPwdAuthRequest request) {

        OauthPwdAuthResponse response = null;

        try{
            //基本校验
            request.valid();
            //业务校验
            request.businessValid();
            //设置url
            request.setUrl(request.getOauthConfigBaseInfo().getHttpConfigInfo().getPrefixUrl() + request.getUrl().substring(8));
            //业务逻辑处理
            response =  new IccClient().doAction(request, request.getResponseClass());
        }catch (BusinessException businessException){
            logger.error("密码认证授权:{}",businessException,businessException.getMessage());
            response = new OauthPwdAuthResponse();
            response.setCode(businessException.getCode());
            response.setErrMsg(businessException.getErrorMsg());
            response.setArgs(businessException.getArgs());
            response.setSuccess(false);
        }catch (Exception e){
            logger.error("密码认证授权:{}",e,e.getMessage());
            response = new OauthPwdAuthResponse();
            response.setErrMsg(OauthParamConstant.SYSTEME_RROR.getErrMsg());
            response.setCode(OauthParamConstant.SYSTEME_RROR.getCode());
            response.setSuccess(false);
        }
        return response;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy