diff --git a/.flattened-pom.xml b/.flattened-pom.xml index 0e48b5b1..64458d8e 100644 --- a/.flattened-pom.xml +++ b/.flattened-pom.xml @@ -57,7 +57,6 @@ 0.0.4 3.14.9 - 1.0.4 2.0.23 2.0.15 1.5.30 @@ -152,8 +151,8 @@ ${aliyun.version} - com.squareup.okhttp3 okhttp + com.squareup.okhttp3 @@ -184,8 +183,8 @@ ${unisms.version} - com.squareup.okhttp3 okhttp + com.squareup.okhttp3 @@ -195,8 +194,8 @@ ${tencent.version} - com.squareup.okhttp3 okhttp + com.squareup.okhttp3 @@ -205,11 +204,6 @@ sms ${jdcloud.version} - - com.cloopen - java-sms-sdk - ${cloopen.version} - com.squareup.okhttp3 okhttp diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff01..00000000 Binary files a/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index ca5ab4ba..00000000 --- a/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/pom.xml b/pom.xml index 08a6a5ac..e565d467 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,6 @@ 3.1.622 0.0.4 1.3.3 - 1.0.4 2.0.15 3.14.9 1.5.30 @@ -240,13 +239,6 @@ ${jdcloud.version} - - - com.cloopen - java-sms-sdk - ${cloopen.version} - - com.squareup.okhttp3 diff --git a/sms4j-aliyun/.flattened-pom.xml b/sms4j-aliyun/.flattened-pom.xml index 2e927f85..60fb894e 100644 --- a/sms4j-aliyun/.flattened-pom.xml +++ b/sms4j-aliyun/.flattened-pom.xml @@ -26,15 +26,11 @@ dysmsapi20170525 - com.squareup.okhttp3 okhttp + com.squareup.okhttp3 - - com.squareup.okhttp3 - okhttp - org.dromara.sms4j sms4j-comm diff --git a/sms4j-aliyun/.mvn/wrapper/maven-wrapper.jar b/sms4j-aliyun/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff01..00000000 Binary files a/sms4j-aliyun/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/sms4j-aliyun/.mvn/wrapper/maven-wrapper.properties b/sms4j-aliyun/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index ca5ab4ba..00000000 --- a/sms4j-aliyun/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/sms4j-aliyun/pom.xml b/sms4j-aliyun/pom.xml index fe333e4c..44e522af 100644 --- a/sms4j-aliyun/pom.xml +++ b/sms4j-aliyun/pom.xml @@ -30,11 +30,6 @@ - - com.squareup.okhttp3 - okhttp - - org.dromara.sms4j sms4j-comm diff --git a/sms4j-api/.mvn/wrapper/maven-wrapper.jar b/sms4j-api/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff01..00000000 Binary files a/sms4j-api/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/sms4j-api/.mvn/wrapper/maven-wrapper.properties b/sms4j-api/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index ca5ab4ba..00000000 --- a/sms4j-api/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/sms4j-autoimmit/.mvn/wrapper/maven-wrapper.jar b/sms4j-autoimmit/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff01..00000000 Binary files a/sms4j-autoimmit/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/sms4j-autoimmit/.mvn/wrapper/maven-wrapper.properties b/sms4j-autoimmit/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index ca5ab4ba..00000000 --- a/sms4j-autoimmit/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/sms4j-cloopen/.flattened-pom.xml b/sms4j-cloopen/.flattened-pom.xml index 7c5b4d42..f1771a09 100644 --- a/sms4j-cloopen/.flattened-pom.xml +++ b/sms4j-cloopen/.flattened-pom.xml @@ -21,10 +21,6 @@ - - com.cloopen - java-sms-sdk - org.dromara.sms4j sms4j-comm diff --git a/sms4j-cloopen/.mvn/wrapper/maven-wrapper.jar b/sms4j-cloopen/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff01..00000000 Binary files a/sms4j-cloopen/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/sms4j-cloopen/.mvn/wrapper/maven-wrapper.properties b/sms4j-cloopen/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index ca5ab4ba..00000000 --- a/sms4j-cloopen/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/sms4j-cloopen/pom.xml b/sms4j-cloopen/pom.xml index ad0796b5..be20714f 100644 --- a/sms4j-cloopen/pom.xml +++ b/sms4j-cloopen/pom.xml @@ -16,12 +16,6 @@ ${revision} - - - com.cloopen - java-sms-sdk - - org.dromara.sms4j sms4j-comm diff --git a/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/api/CloopenRestApi.java b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/api/CloopenRestApi.java new file mode 100644 index 00000000..39e5d273 --- /dev/null +++ b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/api/CloopenRestApi.java @@ -0,0 +1,32 @@ +package org.dromara.sms4j.cloopen.api; + +import com.dtflys.forest.annotation.Address; +import com.dtflys.forest.annotation.BaseRequest; +import com.dtflys.forest.annotation.Body; +import com.dtflys.forest.annotation.PostRequest; + +import java.util.Map; + +/** + * 容联云 REST API + * + * @author Charles7c + * @since 2023/4/17 20:57 + */ +@Address(basePath = "{baseUrl}") +@BaseRequest(headers = { + "Accept: application/json", + "Content-Type: application/json;charset=utf-8", + "Authorization: {authorization}", +}) +public interface CloopenRestApi { + + /** + * 发送模板短信 + * + * @param paramMap 请求参数 + * @return 响应结果 + */ + @PostRequest("/Accounts/{accessKeyId}/SMS/TemplateSMS?sig={sign}") + Map sendSms(@Body Map paramMap); +} diff --git a/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/config/CloopenConfig.java b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/config/CloopenConfig.java index 271926d6..af1f02fc 100644 --- a/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/config/CloopenConfig.java +++ b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/config/CloopenConfig.java @@ -13,21 +13,46 @@ import lombok.experimental.Accessors; @Accessors(chain = true) public class CloopenConfig { - /** Access Key */ + /** + * Access Key + */ private String accessKeyId; - /** Access Key Secret */ + /** + * Access Key Secret + */ private String accessKeySecret; - /** 模板 ID */ + /** + * 模板 ID + */ private String templateId; - /** 应用 ID */ + /** + * 应用 ID + */ private String appId; - /** Rest URL 域名 */ + /** + * REST API Base URL + */ + private String baseUrl = "https://app.cloopen.com:8883/2013-12-26"; + + /** + * Rest URL 域名 + * + * @deprecated v2.0.1 + * @see baseUrl + */ + @Deprecated private String serverIp; - /** Rest URL 端口 */ + /** + * Rest URL 端口 + * + * @deprecated v2.0.1 + * @see baseUrl + */ + @Deprecated private String serverPort; } diff --git a/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/config/CloopenSmsConfig.java b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/config/CloopenSmsConfig.java index c99f48e8..31f058fa 100644 --- a/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/config/CloopenSmsConfig.java +++ b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/config/CloopenSmsConfig.java @@ -1,7 +1,7 @@ package org.dromara.sms4j.cloopen.config; -import com.cloopen.rest.sdk.BodyType; -import com.cloopen.rest.sdk.CCPRestSmsSDK; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.dromara.sms4j.cloopen.service.CloopenSmsImpl; import org.dromara.sms4j.comm.factory.BeanFactory; @@ -11,27 +11,13 @@ import org.dromara.sms4j.comm.factory.BeanFactory; * @author Charles7c * @since 2023/4/10 22:10 */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class CloopenSmsConfig { private static CloopenSmsImpl cloopenSms; private static CloopenSmsConfig cloopenSmsConfig; - /** - * 客户端对象 - * - * @param cloopenConfig 容联云短信配置属性 - * @return 客户端对象 - */ - public CCPRestSmsSDK client(CloopenConfig cloopenConfig) { - CCPRestSmsSDK sdk = new CCPRestSmsSDK(); - sdk.init(cloopenConfig.getServerIp(), cloopenConfig.getServerPort()); - sdk.setAccount(cloopenConfig.getAccessKeyId(), cloopenConfig.getAccessKeySecret()); - sdk.setAppId(cloopenConfig.getAppId()); - sdk.setBodyType(BodyType.Type_JSON); - return sdk; - } - /** * 创建容联云短信实现 */ @@ -40,12 +26,7 @@ public class CloopenSmsConfig { cloopenSmsConfig = new CloopenSmsConfig(); } if (cloopenSms == null) { - cloopenSms = new CloopenSmsImpl( - cloopenSmsConfig.client(cloopenConfig), - cloopenConfig, - BeanFactory.getExecutor(), - BeanFactory.getDelayedTime() - ); + cloopenSms = new CloopenSmsImpl(cloopenConfig, BeanFactory.getExecutor(), BeanFactory.getDelayedTime()); } return cloopenSms; } @@ -57,12 +38,7 @@ public class CloopenSmsConfig { if (cloopenSmsConfig == null) { cloopenSmsConfig = new CloopenSmsConfig(); } - cloopenSms = new CloopenSmsImpl( - cloopenSmsConfig.client(cloopenConfig), - cloopenConfig, - BeanFactory.getExecutor(), - BeanFactory.getDelayedTime() - ); + cloopenSms = new CloopenSmsImpl(cloopenConfig, BeanFactory.getExecutor(), BeanFactory.getDelayedTime()); return cloopenSms; } } diff --git a/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/service/CloopenSmsImpl.java b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/service/CloopenSmsImpl.java index 201026d6..a9899bc0 100644 --- a/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/service/CloopenSmsImpl.java +++ b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/service/CloopenSmsImpl.java @@ -1,17 +1,17 @@ package org.dromara.sms4j.cloopen.service; -import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.IdUtil; -import cn.hutool.json.JSONUtil; -import com.cloopen.rest.sdk.CCPRestSmsSDK; +import com.dtflys.forest.Forest; import lombok.extern.slf4j.Slf4j; import org.dromara.sms4j.api.SmsBlend; import org.dromara.sms4j.api.callback.CallBack; import org.dromara.sms4j.api.entity.SmsResponse; +import org.dromara.sms4j.cloopen.api.CloopenRestApi; import org.dromara.sms4j.cloopen.config.CloopenConfig; +import org.dromara.sms4j.cloopen.util.CloopenHelper; import org.dromara.sms4j.comm.annotation.Restricted; import org.dromara.sms4j.comm.delayedTime.DelayedTime; -import org.dromara.sms4j.comm.exception.SmsBlendException; import java.util.*; import java.util.concurrent.Executor; @@ -25,7 +25,7 @@ import java.util.concurrent.Executor; @Slf4j public class CloopenSmsImpl implements SmsBlend { - private final CCPRestSmsSDK client; + private final CloopenRestApi cloopenRestApi; private final CloopenConfig config; @@ -33,11 +33,11 @@ public class CloopenSmsImpl implements SmsBlend { private final DelayedTime delayed; - public CloopenSmsImpl(CCPRestSmsSDK client, CloopenConfig config, Executor pool, DelayedTime delayed) { - this.client = client; + public CloopenSmsImpl(CloopenConfig config, Executor pool, DelayedTime delayed) { this.config = config; this.pool = pool; this.delayed = delayed; + cloopenRestApi = Forest.client(CloopenRestApi.class); } @Override @@ -63,34 +63,13 @@ public class CloopenSmsImpl implements SmsBlend { @Override @Restricted public SmsResponse massTexting(List phones, String templateId, LinkedHashMap messages) { - SmsResponse smsResponse = new SmsResponse(); - Map result = null; - try { - String[] datas = messages.keySet().stream().map(messages::get).toArray(String[]::new); - result = client.sendTemplateSMS(String.join(",", phones), templateId, datas); - - String statusCode = Convert.toStr(result.get("statusCode")); - String statusMsg = Convert.toStr(result.get("statusMsg")); - smsResponse.setData(result.get("data")); - smsResponse.setCode(statusCode); - smsResponse.setMessage(statusMsg); - boolean isSuccess = "000000".equals(statusCode); - if (!isSuccess) { - smsResponse.setErrMessage(statusMsg); - smsResponse.setErrorCode(statusCode); - } else { - Object bizId = JSONUtil.getByPath(JSONUtil.parse(result.get("data")), "templateSMS.smsMessageSid"); - smsResponse.setBizId(Convert.toStr(bizId)); - } - } catch (Exception e) { - if (result != null) { - smsResponse.setErrMessage(Convert.toStr(result.get("statusMsg"))); - smsResponse.setErrorCode(Convert.toStr(result.get("statusCode"))); - } else { - throw new SmsBlendException(e.getMessage()); - } - } - return smsResponse; + CloopenHelper helper = new CloopenHelper(config); + Map paramMap = MapUtil.newHashMap(4); + paramMap.put("to", String.join(",", phones)); + paramMap.put("appId", config.getAppId()); + paramMap.put("templateId", templateId); + paramMap.put("datas", messages.keySet().stream().map(messages::get).toArray(String[]::new)); + return helper.request(cloopenRestApi::sendSms, paramMap); } @Override diff --git a/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/util/CloopenHelper.java b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/util/CloopenHelper.java new file mode 100644 index 00000000..4677681f --- /dev/null +++ b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/util/CloopenHelper.java @@ -0,0 +1,112 @@ +package org.dromara.sms4j.cloopen.util; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.json.JSONUtil; +import com.dtflys.forest.Forest; +import com.dtflys.forest.config.ForestConfiguration; +import org.dromara.sms4j.api.entity.SmsResponse; +import org.dromara.sms4j.cloopen.config.CloopenConfig; +import org.dromara.sms4j.comm.exception.SmsBlendException; + +import java.util.Collections; +import java.util.Date; +import java.util.Map; +import java.util.Optional; + +/** + * 容联云 Helper + * + * @author Charles7c + * @since 2023/4/17 20:57 + */ +public class CloopenHelper { + + private final CloopenConfig cloopenConfig; + + public CloopenHelper(CloopenConfig cloopenConfig) { + this.cloopenConfig = cloopenConfig; + } + + /** + * 发起 REST 请求 + * + * @param restApiFunction REST API 函数式接口 + * @param paramMap 请求参数 + * @param 响应类型 + * @return 响应信息 + */ + public SmsResponse request(CloopenRestApiFunction, R> restApiFunction, Map paramMap) { + SmsResponse smsResponse = new SmsResponse(); + try { + String timestamp = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN); + // 设置全局变量 + ForestConfiguration forestConfiguration = Forest.config(); + forestConfiguration.setVariableValue("baseUrl", (method) -> cloopenConfig.getBaseUrl()); + forestConfiguration.setVariableValue("accessKeyId", (method) -> cloopenConfig.getAccessKeyId()); + forestConfiguration.setVariableValue("sign", this.generateSign(cloopenConfig.getAccessKeyId(), cloopenConfig.getAccessKeySecret(), timestamp)); + forestConfiguration.setVariableValue("authorization", this.generateAuthorization(cloopenConfig.getAccessKeyId(), timestamp)); + + // 调用请求 + R response = restApiFunction.apply(paramMap); + + // 解析结果 + Map responseMap = Optional.ofNullable(response) + .map(JSONUtil::parseObj) + .map(obj -> (Map) obj) + .orElse(Collections.emptyMap()); + String statusCode = Convert.toStr(responseMap.get("statusCode")); + String statusMsg = Convert.toStr(responseMap.get("statusMsg")); + boolean isSuccess = "000000".equals(statusCode); + if (isSuccess) { + smsResponse.setCode(statusCode); + smsResponse.setMessage(statusMsg); + smsResponse.setData(response); + Object bizId = JSONUtil.getByPath(JSONUtil.parse(responseMap), "templateSMS.smsMessageSid"); + smsResponse.setBizId(Convert.toStr(bizId)); + } else { + smsResponse.setErrMessage(statusMsg); + smsResponse.setErrorCode(statusCode); + } + } catch (Exception e) { + throw new SmsBlendException(e.getMessage()); + } + return smsResponse; + } + + /** + * 生成签名 + *

+ * 1.使用 MD5 加密(账户 Id + 账户授权令牌 + 时间戳)。其中账户 Id 和账户授权令牌根据 url 的验证级别对应主账户。
+ * 时间戳是当前系统时间,格式 "yyyyMMddHHmmss"。时间戳有效时间为 24 小时,如:20140416142030
+ * 2.参数需要大写 + *

+ * + * @param accessKeyId / + * @param accessKeySecret / + * @param timestamp 时间戳 + * @return 签名 + */ + private String generateSign(String accessKeyId, String accessKeySecret, String timestamp) { + return SecureUtil.md5(accessKeyId + accessKeySecret + timestamp).toUpperCase(); + } + + /** + * 生成验证信息 + *

+ * 1.使用 Base64 编码(账户 Id + 冒号 + 时间戳)其中账户 Id 根据 url 的验证级别对应主账户
+ * 2.冒号为英文冒号
+ * 3.时间戳是当前系统时间,格式 "yyyyMMddHHmmss",需与签名中时间戳相同。 + *

+ * + * @param accessKeyId / + * @param timestamp 时间戳 + * @return 验证信息 + */ + private String generateAuthorization(String accessKeyId, String timestamp) { + return Base64.encode(accessKeyId + ":" + timestamp); + } +} diff --git a/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/util/CloopenRestApiFunction.java b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/util/CloopenRestApiFunction.java new file mode 100644 index 00000000..6a0366de --- /dev/null +++ b/sms4j-cloopen/src/main/java/org/dromara/sms4j/cloopen/util/CloopenRestApiFunction.java @@ -0,0 +1,16 @@ +package org.dromara.sms4j.cloopen.util; + +import java.io.Serializable; + +/** + * 容联云 REST API 函数式接口 + * + * @param

请求参数 + * @param 响应 + * @author Charles7c + * @since 2023/4/17 20:57 + */ +@FunctionalInterface +public interface CloopenRestApiFunction extends Serializable { + R apply(P param); +} diff --git a/sms4j-comm/.mvn/wrapper/maven-wrapper.jar b/sms4j-comm/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff01..00000000 Binary files a/sms4j-comm/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/sms4j-comm/.mvn/wrapper/maven-wrapper.properties b/sms4j-comm/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index ca5ab4ba..00000000 --- a/sms4j-comm/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/sms4j-core/src/main/java/org/dromara/sms4j/core/SupplierSqlConfig.java b/sms4j-core/src/main/java/org/dromara/sms4j/core/SupplierSqlConfig.java index 9d88abdd..d5b22666 100644 --- a/sms4j-core/src/main/java/org/dromara/sms4j/core/SupplierSqlConfig.java +++ b/sms4j-core/src/main/java/org/dromara/sms4j/core/SupplierSqlConfig.java @@ -6,6 +6,7 @@ import org.dromara.sms4j.comm.enumerate.SupplierType; import org.dromara.sms4j.comm.utils.JDBCTool; import org.dromara.sms4j.comm.utils.SmsUtil; import org.dromara.sms4j.core.config.SupplierFactory; +import org.dromara.sms4j.emay.config.EmayConfig; import org.dromara.sms4j.huawei.config.HuaweiConfig; import org.dromara.sms4j.jdcloud.config.JdCloudConfig; import org.dromara.sms4j.tencent.config.TencentConfig; @@ -40,6 +41,7 @@ public class SupplierSqlConfig { uniSms(); yunPian(); cloopen(); + emay(); } /** @@ -104,7 +106,7 @@ public class SupplierSqlConfig { /** * cloopen - *

数据库读取并设置荣联云短信 + *

数据库读取并设置容联云短信 * @author :Wind */ public static void cloopen(){ @@ -112,4 +114,12 @@ public class SupplierSqlConfig { SmsUtil.copyBean(cloopenConfig,SupplierFactory.getCloopenConfig()); } + /** + * emay + *

数据库读取并设置亿美软通短信 + */ + public static void emay() { + EmayConfig emayConfig = SmsUtil.jsonForObject(select.get(SupplierType.EMAY.getName()), EmayConfig.class); + SmsUtil.copyBean(emayConfig, SupplierFactory.getEmayConfig()); + } } diff --git a/sms4j-emay/.mvn/wrapper/maven-wrapper.jar b/sms4j-emay/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff01..00000000 Binary files a/sms4j-emay/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/sms4j-emay/.mvn/wrapper/maven-wrapper.properties b/sms4j-emay/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index ca5ab4ba..00000000 --- a/sms4j-emay/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/sms4j-huawei/.mvn/wrapper/maven-wrapper.jar b/sms4j-huawei/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff01..00000000 Binary files a/sms4j-huawei/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/sms4j-huawei/.mvn/wrapper/maven-wrapper.properties b/sms4j-huawei/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index ca5ab4ba..00000000 --- a/sms4j-huawei/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/sms4j-jdcloud/.mvn/wrapper/maven-wrapper.jar b/sms4j-jdcloud/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff01..00000000 Binary files a/sms4j-jdcloud/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/sms4j-jdcloud/.mvn/wrapper/maven-wrapper.properties b/sms4j-jdcloud/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index ca5ab4ba..00000000 --- a/sms4j-jdcloud/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar