private void checkOAuthParameters()

in domain/src/main/java/org/apache/rocketmq/eventbridge/domain/model/connection/ConnectionService.java [110:148]


    private void checkOAuthParameters(AuthParameters authParameters) {
        OAuthParameters oauthParameters = authParameters.getOauthParameters();
        if (AuthorizationTypeEnum.OAUTH_AUTH.getType().equals(authParameters.getAuthorizationType()) && oauthParameters == null) {
            throw new EventBridgeException(EventBridgeErrorCode.OAuthRequiredParameterIsEmpty);
        }
        if (oauthParameters != null && AuthorizationTypeEnum.OAUTH_AUTH.getType().equals(authParameters.getAuthorizationType())) {
            if (StringUtils.isBlank(oauthParameters.getAuthorizationEndpoint()) || StringUtils.isBlank(oauthParameters.getHttpMethod())) {
                throw new EventBridgeException(EventBridgeErrorCode.OAuthRequiredParameterIsEmpty);
            }
            if (oauthParameters.getAuthorizationEndpoint().length() > EventBridgeConstants.MAX_LENGTH_CONSTANT || oauthParameters.getAuthorizationEndpoint().length() < EventBridgeConstants.MIN_LENGTH_CONSTANT) {
                throw new EventBridgeException(EventBridgeErrorCode.AuthorizationEndpointLengthExceed);
            }
            if (oauthParameters.getClientParameters() != null) {
                OAuthParameters.ClientParameters clientParameters = oauthParameters.getClientParameters();
                if (StringUtils.isNotBlank(clientParameters.getClientID())
                        && (clientParameters.getClientID().length() > EventBridgeConstants.MAX_LENGTH_CONSTANT
                        || clientParameters.getClientID().length() < EventBridgeConstants.MIN_LENGTH_CONSTANT)) {
                    throw new EventBridgeException(EventBridgeErrorCode.ClientIDLengthExceed);
                }
                if (StringUtils.isNotBlank(clientParameters.getClientSecret())
                        && (clientParameters.getClientSecret().length() > EventBridgeConstants.MAX_LENGTH_CONSTANT
                        || clientParameters.getClientSecret().length() < EventBridgeConstants.MIN_LENGTH_CONSTANT)) {
                    throw new EventBridgeException(EventBridgeErrorCode.ClientSecretLengthExceed);
                }
            }
            OAuthHttpParameters oauthHttpParameters = oauthParameters.getOauthHttpParameters();
            if (oauthHttpParameters == null) {
                throw new EventBridgeException(EventBridgeErrorCode.OauthHttpParametersEmpty);
            }
            List<BodyParameter> bodyParameters = oauthHttpParameters.getBodyParameters();
            List<QueryStringParameter> queryStringParameters = oauthHttpParameters.getQueryStringParameters();
            List<HeaderParameter> headerParameters = oauthHttpParameters.getHeaderParameters();
            if (CollectionUtils.isEmpty(bodyParameters)
                    && CollectionUtils.isEmpty(queryStringParameters)
                    && CollectionUtils.isEmpty(headerParameters)) {
                throw new EventBridgeException(EventBridgeErrorCode.OauthHttpParametersEmpty);
            }
        }
    }