短信验证码
This commit is contained in:
9
pom.xml
9
pom.xml
@@ -224,13 +224,6 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${pom.basedir}/src/main/resources/lib/aspose-words-22.10-jdk16.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bcloud.msg.http</groupId>
|
||||
<artifactId>bcloud.msg.http</artifactId>
|
||||
<version>http</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${pom.basedir}/src/main/resources/lib/http.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.lame</groupId>
|
||||
<artifactId>lame</artifactId>
|
||||
@@ -448,7 +441,7 @@
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
<!-- <includeSystemScope>true</includeSystemScope>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 跳过单元测试 -->
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class Base64Uploader {
|
||||
}
|
||||
|
||||
private static byte[] decode(String content) {
|
||||
return Base64.decodeBase64(content.getBytes());
|
||||
return Base64.decodeBase64(content);
|
||||
}
|
||||
|
||||
private static boolean validSize(byte[] data, long length) {
|
||||
|
||||
@@ -111,7 +111,7 @@ public class HlsDecryptService {
|
||||
*/
|
||||
private byte[] decrypt(String ciphertext) {
|
||||
DecryptKMSDataKeyResponseBody decryptKMSDataKeyResponseBody = SpdbUtil.enKMS(ciphertext);
|
||||
return Base64.decodeBase64(decryptKMSDataKeyResponseBody.getPlaintext().getBytes());
|
||||
return Base64.decodeBase64(decryptKMSDataKeyResponseBody.getPlaintext());
|
||||
// DecryptKMSDataKeyRequest request = new DecryptKMSDataKeyRequest();
|
||||
// request.setCipherText(ciphertext);
|
||||
// request.setProtocol(ProtocolType.HTTPS);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.peanut.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bcloud.msg.http.HttpSender;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
@@ -9,6 +8,7 @@ import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
@Component
|
||||
public class SmsUtil {
|
||||
@@ -31,22 +31,25 @@ public class SmsUtil {
|
||||
private String abroadContent;
|
||||
|
||||
public R sendSmsCode(String phone, String code) {
|
||||
String mobiles = phone;//手机号码,多个号码使用","分割
|
||||
boolean needstatus = true;//是否需要状态报告,需要true,不需要false
|
||||
String product = "";//产品ID
|
||||
String extno = "";//扩展码
|
||||
String respType = "json";//返回json格式响应
|
||||
boolean encrypt = true;// 密码使用时间戳加密
|
||||
try {
|
||||
String returnString = HttpSender.send(url, account, pswd, mobiles, content.replace("XXXXXX",code), needstatus, product, extno, respType, encrypt);
|
||||
//{"result":108,"ts":"20250416115415"}
|
||||
//{"result":0,"msgid":"2150416115442493200","ts":"20250416115442"}
|
||||
JSONObject object = JSONObject.parseObject(returnString);
|
||||
if ("0".equals(object.get("result").toString())){
|
||||
CloseableHttpClient client = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
StringEntity entity = new StringEntity("" +
|
||||
"account="+account+
|
||||
"&pswd="+pswd+
|
||||
"&mobile="+phone+
|
||||
"&msg="+ URLEncoder.encode(content.replace("XXXXXX",code), "UTF-8")+
|
||||
"&needstatus=false");
|
||||
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
httpPost.setEntity(entity);
|
||||
String returnString = EntityUtils.toString(client.execute(httpPost).getEntity());
|
||||
//20250416115415,0
|
||||
String[] res = returnString.split(",");
|
||||
if ("0".equals(res[1])){
|
||||
return R.ok();
|
||||
}else if ("104".equals(object.get("result").toString())){
|
||||
}else if ("104".equals(res[1])){
|
||||
return R.error("短信平台系统忙,请稍后重试。");
|
||||
}else if ("107".equals(object.get("result").toString())){
|
||||
}else if ("107".equals(res[1])){
|
||||
return R.error("错误的手机号码。");
|
||||
}else {
|
||||
return R.error("系统错误,请联系管理员");
|
||||
|
||||
@@ -31,13 +31,13 @@ public class VodAliController {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (!validRe) {
|
||||
return Base64.decodeBase64("Illegal access".getBytes());
|
||||
return Base64.decodeBase64("Illegal access");
|
||||
}
|
||||
if (null == cipherText) {
|
||||
return Base64.decodeBase64("Illegal access !".getBytes());
|
||||
return Base64.decodeBase64("Illegal access !");
|
||||
}
|
||||
DecryptKMSDataKeyResponseBody decryptKMSDataKeyResponseBody = SpdbUtil.enKMS(cipherText);
|
||||
return Base64.decodeBase64(decryptKMSDataKeyResponseBody.getPlaintext().getBytes());
|
||||
return Base64.decodeBase64(decryptKMSDataKeyResponseBody.getPlaintext());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user