This commit is contained in:
MaxKey 2021-02-16 08:55:11 +08:00
parent 69325ee6e5
commit 0f19da93f4
11 changed files with 28 additions and 28 deletions

View File

@ -44,9 +44,9 @@ public abstract class AbstractOtpAuthn {
StringGenerator stringGenerator; StringGenerator stringGenerator;
protected String optType = OptTypes.TIMEBASED_OPT; protected String otpType = OtpTypes.TIMEBASED_OTP;
public static final class OptTypes { public static final class OtpTypes {
// 手机 // 手机
public static String MOBILE = "MOBILE"; public static String MOBILE = "MOBILE";
// 短信 // 短信
@ -54,13 +54,13 @@ public abstract class AbstractOtpAuthn {
// 邮箱 // 邮箱
public static String EMAIL = "EMAIL"; public static String EMAIL = "EMAIL";
//TIMEBASED_OPT //TIMEBASED_OPT
public static String TIMEBASED_OPT = "TOPT"; public static String TIMEBASED_OTP = "TOPT";
// HmacOTP // HmacOTP
public static String HOTP_OPT = "HOTP"; public static String HOTP_OTP = "HOTP";
public static String RSA_OPT = "RSA"; public static String RSA_OTP = "RSA";
public static String CAP_OPT = "CAP"; public static String CAP_OTP = "CAP";
} }
@ -134,12 +134,12 @@ public abstract class AbstractOtpAuthn {
this.crypto = crypto; this.crypto = crypto;
} }
public String getOptType() { public String getOtpType() {
return optType; return otpType;
} }
public void setOptType(String optType) { public void setOtpType(String optType) {
this.optType = optType; this.otpType = optType;
} }
public void setOptTokenStore(AbstractOtpTokenStore optTokenStore) { public void setOptTokenStore(AbstractOtpTokenStore optTokenStore) {

View File

@ -35,7 +35,7 @@ public class CapOtpAuthn extends AbstractOtpAuthn {
public CapOtpAuthn() { public CapOtpAuthn() {
optType = OptTypes.CAP_OPT; otpType = OtpTypes.CAP_OTP;
} }
@Override @Override

View File

@ -30,7 +30,7 @@ public class CounterBasedOtpAuthn extends AbstractOtpAuthn {
public CounterBasedOtpAuthn() { public CounterBasedOtpAuthn() {
optType = OptTypes.HOTP_OPT; otpType = OtpTypes.HOTP_OTP;
} }
@Override @Override

View File

@ -34,7 +34,7 @@ public class HotpOtpAuthn extends AbstractOtpAuthn {
int truncation = -1; int truncation = -1;
public HotpOtpAuthn() { public HotpOtpAuthn() {
optType = OptTypes.HOTP_OPT; otpType = OtpTypes.HOTP_OTP;
} }
@Override @Override

View File

@ -38,7 +38,7 @@ public class MailOtpAuthn extends AbstractOtpAuthn {
String messageTemplate = "{0} You Token is {1} , it validity in {2} minutes."; String messageTemplate = "{0} You Token is {1} , it validity in {2} minutes.";
public MailOtpAuthn() { public MailOtpAuthn() {
optType = OptTypes.EMAIL; otpType = OtpTypes.EMAIL;
} }
@Override @Override
@ -68,7 +68,7 @@ public class MailOtpAuthn extends AbstractOtpAuthn {
userInfo, userInfo,
token, token,
userInfo.getMobile(), userInfo.getMobile(),
OptTypes.EMAIL); OtpTypes.EMAIL);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -78,7 +78,7 @@ public class MailOtpAuthn extends AbstractOtpAuthn {
@Override @Override
public boolean validate(UserInfo userInfo, String token) { public boolean validate(UserInfo userInfo, String token) {
return this.optTokenStore.validate(userInfo, token, OptTypes.EMAIL, interval); return this.optTokenStore.validate(userInfo, token, OtpTypes.EMAIL, interval);
} }
public void setEmailConfig(EmailConfig emailConfig) { public void setEmailConfig(EmailConfig emailConfig) {

View File

@ -25,7 +25,7 @@ public class MobileOtpAuthn extends AbstractOtpAuthn {
public MobileOtpAuthn() { public MobileOtpAuthn() {
optType = OptTypes.SMS; otpType = OtpTypes.SMS;
} }
@Override @Override

View File

@ -35,7 +35,7 @@ public class RsaOtpAuthn extends AbstractOtpAuthn {
public RsaOtpAuthn() { public RsaOtpAuthn() {
optType = OptTypes.RSA_OPT; otpType = OtpTypes.RSA_OTP;
} }
@Override @Override

View File

@ -42,7 +42,7 @@ public class SmsOtpAuthnAliyun extends SmsOtpAuthn {
private static final Logger logger = LoggerFactory.getLogger(SmsOtpAuthnAliyun.class); private static final Logger logger = LoggerFactory.getLogger(SmsOtpAuthnAliyun.class);
public SmsOtpAuthnAliyun() { public SmsOtpAuthnAliyun() {
optType = OptTypes.SMS; otpType = OtpTypes.SMS;
} }
//请替换你在管理后台应用下申请的accessKeyId //请替换你在管理后台应用下申请的accessKeyId
@ -83,7 +83,7 @@ public class SmsOtpAuthnAliyun extends SmsOtpAuthn {
userInfo, userInfo,
token, token,
userInfo.getMobile(), userInfo.getMobile(),
OptTypes.SMS); OtpTypes.SMS);
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {
@ -95,7 +95,7 @@ public class SmsOtpAuthnAliyun extends SmsOtpAuthn {
@Override @Override
public boolean validate(UserInfo userInfo, String token) { public boolean validate(UserInfo userInfo, String token) {
return this.optTokenStore.validate(userInfo, token, OptTypes.SMS, interval); return this.optTokenStore.validate(userInfo, token, OtpTypes.SMS, interval);
} }
public String getAccessKeyId() { public String getAccessKeyId() {

View File

@ -52,7 +52,7 @@ public class SmsOtpAuthnTencentCloud extends SmsOtpAuthn {
String sign; String sign;
public SmsOtpAuthnTencentCloud() { public SmsOtpAuthnTencentCloud() {
optType = OptTypes.SMS; otpType = OtpTypes.SMS;
} }
@ -89,7 +89,7 @@ public class SmsOtpAuthnTencentCloud extends SmsOtpAuthn {
userInfo, userInfo,
token, token,
userInfo.getMobile(), userInfo.getMobile(),
OptTypes.SMS); OtpTypes.SMS);
return true; return true;
} }
@ -102,7 +102,7 @@ public class SmsOtpAuthnTencentCloud extends SmsOtpAuthn {
@Override @Override
public boolean validate(UserInfo userInfo, String token) { public boolean validate(UserInfo userInfo, String token) {
return this.optTokenStore.validate(userInfo, token, OptTypes.SMS, interval); return this.optTokenStore.validate(userInfo, token, OtpTypes.SMS, interval);
} }

View File

@ -45,7 +45,7 @@ public class SmsOtpAuthnYunxin extends SmsOtpAuthn {
private static final Logger logger = LoggerFactory.getLogger(SmsOtpAuthnYunxin.class); private static final Logger logger = LoggerFactory.getLogger(SmsOtpAuthnYunxin.class);
public SmsOtpAuthnYunxin() { public SmsOtpAuthnYunxin() {
optType = OptTypes.SMS; otpType = OtpTypes.SMS;
} }
//发送验证码的请求路径URL //发送验证码的请求路径URL
@ -122,7 +122,7 @@ public class SmsOtpAuthnYunxin extends SmsOtpAuthn {
userInfo, userInfo,
yunxinSms.getObj(), yunxinSms.getObj(),
userInfo.getMobile(), userInfo.getMobile(),
OptTypes.SMS); OtpTypes.SMS);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.error(" produce code error ", e); logger.error(" produce code error ", e);
@ -137,7 +137,7 @@ public class SmsOtpAuthnYunxin extends SmsOtpAuthn {
@Override @Override
public boolean validate(UserInfo userInfo, String token) { public boolean validate(UserInfo userInfo, String token) {
return this.optTokenStore.validate(userInfo, token, OptTypes.SMS, interval); return this.optTokenStore.validate(userInfo, token, OtpTypes.SMS, interval);
} }

View File

@ -151,7 +151,7 @@ public class LoginEndpoint {
modelAndView.addObject("isKerberos", applicationConfig.getLoginConfig().isKerberos()); modelAndView.addObject("isKerberos", applicationConfig.getLoginConfig().isKerberos());
modelAndView.addObject("isMfa", applicationConfig.getLoginConfig().isMfa()); modelAndView.addObject("isMfa", applicationConfig.getLoginConfig().isMfa());
if(applicationConfig.getLoginConfig().isMfa()) { if(applicationConfig.getLoginConfig().isMfa()) {
modelAndView.addObject("optType", tfaOptAuthn.getOptType()); modelAndView.addObject("optType", tfaOptAuthn.getOtpType());
modelAndView.addObject("optInterval", tfaOptAuthn.getInterval()); modelAndView.addObject("optInterval", tfaOptAuthn.getInterval());
} }