Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yujianwangzivayy
MaxKey
提交
3e3d8f4b
MaxKey
项目概览
yujianwangzivayy
/
MaxKey
与 Fork 源项目一致
Fork自
MaxKey单点登录官方(MaxKeyTop) / MaxKey
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3e3d8f4b
编写于
4月 13, 2020
作者:
MaxKey单点登录官方
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
短信验证码SMS
支持 腾讯云短信验证码 阿里云短信验证码 网易云信验证码
上级
710299b7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
275 addition
and
1 deletion
+275
-1
build.gradle
build.gradle
+5
-0
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/netease/SmsOtpAuthnAliyun.java
...ypto/password/opt/impl/sms/netease/SmsOtpAuthnAliyun.java
+113
-0
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/netease/SmsOtpAuthnTencentCloud.java
...assword/opt/impl/sms/netease/SmsOtpAuthnTencentCloud.java
+156
-0
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/netease/SmsOtpAuthnYunxin.java
...ypto/password/opt/impl/sms/netease/SmsOtpAuthnYunxin.java
+1
-1
未找到文件。
build.gradle
浏览文件 @
3e3d8f4b
...
...
@@ -277,6 +277,11 @@ subprojects {
compile
group:
'com.thoughtworks.xstream'
,
name:
'xstream'
,
version:
'1.4.10'
//local jars
compile
fileTree
(
dir:
"${rootDir}/maxkey-lib/"
,
include:
'*.jar'
)
//阿里云
compile
group:
'com.aliyun'
,
name:
'aliyun-java-sdk-core'
,
version:
'4.5.1'
//腾讯云
compile
group:
'com.tencentcloudapi'
,
name:
'tencentcloud-sdk-java'
,
version:
'3.1.33'
//tomcat embed
compile
group:
'org.apache.tomcat.embed'
,
name:
'tomcat-embed-core'
,
version:
'9.0.29'
compile
group:
'org.apache.tomcat.embed'
,
name:
'tomcat-embed-logging-juli'
,
version:
'8.5.2'
...
...
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/netease/SmsOtpAuthnAliyun.java
0 → 100644
浏览文件 @
3e3d8f4b
package
org.maxkey.crypto.password.opt.impl.sms.netease
;
import
com.aliyuncs.CommonRequest
;
import
com.aliyuncs.CommonResponse
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.http.MethodType
;
import
com.aliyuncs.profile.DefaultProfile
;
import
org.maxkey.crypto.password.opt.impl.SmsOtpAuthn
;
import
org.maxkey.domain.UserInfo
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* 阿里云短信验证.
* @author shimingxy
*
*/
public
class
SmsOtpAuthnAliyun
extends
SmsOtpAuthn
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SmsOtpAuthnAliyun
.
class
);
public
SmsOtpAuthnAliyun
()
{
optType
=
OptTypes
.
SMS
;
}
//请替换你在管理后台应用下申请的accessKeyId
private
String
accessKeyId
=
"94395d754eb55693043f5d6a2b772ef3"
;
//请替换你在管理后台应用下申请的accessSecret
private
String
accessSecret
=
"05d5485357bc"
;
// 短信模板ID
private
String
templateCode
=
"SMS_187590021"
;
private
String
signName
=
"MaxKey"
;
@Override
public
boolean
produce
(
UserInfo
userInfo
)
{
// 手机号
String
mobile
=
userInfo
.
getMobile
();
if
(
mobile
!=
null
&&
!
mobile
.
equals
(
""
))
{
try
{
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
accessKeyId
,
accessSecret
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
String
token
=
this
.
genToken
(
userInfo
);
CommonRequest
request
=
new
CommonRequest
();
request
.
setSysMethod
(
MethodType
.
POST
);
request
.
setSysDomain
(
"dysmsapi.aliyuncs.com"
);
request
.
setSysVersion
(
"2017-05-25"
);
request
.
setSysAction
(
"SendSms"
);
request
.
putQueryParameter
(
"RegionId"
,
"cn-hangzhou"
);
request
.
putQueryParameter
(
"PhoneNumbers"
,
mobile
);
request
.
putQueryParameter
(
"SignName"
,
signName
);
request
.
putQueryParameter
(
"TemplateCode"
,
templateCode
);
request
.
putQueryParameter
(
"TemplateParam"
,
"{\"code\":\""
+
token
+
"\"}"
);
CommonResponse
response
=
client
.
getCommonResponse
(
request
);
logger
.
debug
(
"responseString "
+
response
.
getData
());
//成功返回
if
(
response
.
getData
().
indexOf
(
"OK"
)
>
-
1
)
{
this
.
optTokenStore
.
store
(
userInfo
,
token
,
userInfo
.
getMobile
(),
OptTypes
.
SMS
);
return
true
;
}
}
catch
(
Exception
e
)
{
logger
.
error
(
" produce code error "
,
e
);
}
}
return
false
;
}
@Override
public
boolean
validate
(
UserInfo
userInfo
,
String
token
)
{
return
this
.
optTokenStore
.
validate
(
userInfo
,
token
,
OptTypes
.
SMS
,
interval
);
}
public
String
getAccessKeyId
()
{
return
accessKeyId
;
}
public
void
setAccessKeyId
(
String
accessKeyId
)
{
this
.
accessKeyId
=
accessKeyId
;
}
public
String
getAccessSecret
()
{
return
accessSecret
;
}
public
void
setAccessSecret
(
String
accessSecret
)
{
this
.
accessSecret
=
accessSecret
;
}
public
String
getTemplateCode
()
{
return
templateCode
;
}
public
void
setTemplateCode
(
String
templateCode
)
{
this
.
templateCode
=
templateCode
;
}
public
String
getSignName
()
{
return
signName
;
}
public
void
setSignName
(
String
signName
)
{
this
.
signName
=
signName
;
}
}
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/netease/SmsOtpAuthnTencentCloud.java
0 → 100644
浏览文件 @
3e3d8f4b
package
org.maxkey.crypto.password.opt.impl.sms.netease
;
import
com.tencentcloudapi.common.Credential
;
import
com.tencentcloudapi.common.profile.ClientProfile
;
import
com.tencentcloudapi.common.profile.HttpProfile
;
import
com.tencentcloudapi.sms.v20190711.SmsClient
;
import
com.tencentcloudapi.sms.v20190711.models.SendSmsRequest
;
import
com.tencentcloudapi.sms.v20190711.models.SendSmsResponse
;
import
org.maxkey.crypto.password.opt.impl.SmsOtpAuthn
;
import
org.maxkey.domain.UserInfo
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* 腾讯云短信验证.
* @author shimingxy
*
*/
public
class
SmsOtpAuthnTencentCloud
extends
SmsOtpAuthn
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SmsOtpAuthnTencentCloud
.
class
);
//
String
secretId
;
//
String
secretKey
;
//短信SDKAPPID
String
smsSdkAppid
;
//短信模板
String
templateId
;
//签名
String
sign
;
public
SmsOtpAuthnTencentCloud
()
{
optType
=
OptTypes
.
SMS
;
}
@Override
public
boolean
produce
(
UserInfo
userInfo
)
{
// 手机号
String
mobile
=
userInfo
.
getMobile
();
if
(
mobile
!=
null
&&
!
mobile
.
equals
(
""
))
{
try
{
Credential
cred
=
new
Credential
(
secretId
,
secretKey
);
HttpProfile
httpProfile
=
new
HttpProfile
();
httpProfile
.
setEndpoint
(
"sms.tencentcloudapi.com"
);
ClientProfile
clientProfile
=
new
ClientProfile
();
clientProfile
.
setHttpProfile
(
httpProfile
);
SmsClient
client
=
new
SmsClient
(
cred
,
"ap-beijing"
,
clientProfile
);
String
token
=
this
.
genToken
(
userInfo
);
String
params
=
"{\"PhoneNumberSet\":[\""
+
mobile
+
"\"],"
+
"\"TemplateID\":\""
+
templateId
+
"\",\"Sign\":\""
+
sign
+
"\","
+
"\"TemplateParamSet\":[\""
+
token
+
"\",\""
+
this
.
interval
+
"\"],"
+
"\"SmsSdkAppid\":\""
+
smsSdkAppid
+
"\"}"
;
SendSmsRequest
req
=
SendSmsRequest
.
fromJsonString
(
params
,
SendSmsRequest
.
class
);
SendSmsResponse
resp
=
client
.
SendSms
(
req
);
logger
.
debug
(
"responseString "
+
SendSmsRequest
.
toJsonString
(
resp
));
if
(
resp
.
getSendStatusSet
()[
0
].
getCode
().
equalsIgnoreCase
(
"Ok"
))
{
this
.
optTokenStore
.
store
(
userInfo
,
token
,
userInfo
.
getMobile
(),
OptTypes
.
SMS
);
return
true
;
}
}
catch
(
Exception
e
)
{
logger
.
error
(
" produce code error "
,
e
);
}
}
return
false
;
}
@Override
public
boolean
validate
(
UserInfo
userInfo
,
String
token
)
{
return
this
.
optTokenStore
.
validate
(
userInfo
,
token
,
OptTypes
.
SMS
,
interval
);
}
public
String
getSecretId
()
{
return
secretId
;
}
public
void
setSecretId
(
String
secretId
)
{
this
.
secretId
=
secretId
;
}
public
String
getSecretKey
()
{
return
secretKey
;
}
public
void
setSecretKey
(
String
secretKey
)
{
this
.
secretKey
=
secretKey
;
}
public
String
getSmsSdkAppid
()
{
return
smsSdkAppid
;
}
public
void
setSmsSdkAppid
(
String
smsSdkAppid
)
{
this
.
smsSdkAppid
=
smsSdkAppid
;
}
public
String
getTemplateId
()
{
return
templateId
;
}
public
void
setTemplateId
(
String
templateId
)
{
this
.
templateId
=
templateId
;
}
public
String
getSign
()
{
return
sign
;
}
public
void
setSign
(
String
sign
)
{
this
.
sign
=
sign
;
}
}
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/netease/SmsOtpAuthnYunxin.java
浏览文件 @
3e3d8f4b
...
...
@@ -19,7 +19,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
/**
* 网易云信
的
短信验证.
* 网易云信短信验证.
* @author shimingxy
*
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录