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;
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";
// 短信
@ -54,13 +54,13 @@ public abstract class AbstractOtpAuthn {
// 邮箱
public static String EMAIL = "EMAIL";
//TIMEBASED_OPT
public static String TIMEBASED_OPT = "TOPT";
public static String TIMEBASED_OTP = "TOPT";
// 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;
}
public String getOptType() {
return optType;
public String getOtpType() {
return otpType;
}
public void setOptType(String optType) {
this.optType = optType;
public void setOtpType(String optType) {
this.otpType = optType;
}
public void setOptTokenStore(AbstractOtpTokenStore optTokenStore) {

View File

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

View File

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

View File

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

View File

@ -38,7 +38,7 @@ public class MailOtpAuthn extends AbstractOtpAuthn {
String messageTemplate = "{0} You Token is {1} , it validity in {2} minutes.";
public MailOtpAuthn() {
optType = OptTypes.EMAIL;
otpType = OtpTypes.EMAIL;
}
@Override
@ -68,7 +68,7 @@ public class MailOtpAuthn extends AbstractOtpAuthn {
userInfo,
token,
userInfo.getMobile(),
OptTypes.EMAIL);
OtpTypes.EMAIL);
return true;
} catch (Exception e) {
e.printStackTrace();
@ -78,7 +78,7 @@ public class MailOtpAuthn extends AbstractOtpAuthn {
@Override
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) {

View File

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

View File

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

View File

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

View File

@ -52,7 +52,7 @@ public class SmsOtpAuthnTencentCloud extends SmsOtpAuthn {
String sign;
public SmsOtpAuthnTencentCloud() {
optType = OptTypes.SMS;
otpType = OtpTypes.SMS;
}
@ -89,7 +89,7 @@ public class SmsOtpAuthnTencentCloud extends SmsOtpAuthn {
userInfo,
token,
userInfo.getMobile(),
OptTypes.SMS);
OtpTypes.SMS);
return true;
}
@ -102,7 +102,7 @@ public class SmsOtpAuthnTencentCloud extends SmsOtpAuthn {
@Override
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);
public SmsOtpAuthnYunxin() {
optType = OptTypes.SMS;
otpType = OtpTypes.SMS;
}
//发送验证码的请求路径URL
@ -122,7 +122,7 @@ public class SmsOtpAuthnYunxin extends SmsOtpAuthn {
userInfo,
yunxinSms.getObj(),
userInfo.getMobile(),
OptTypes.SMS);
OtpTypes.SMS);
return true;
} catch (Exception e) {
logger.error(" produce code error ", e);
@ -137,7 +137,7 @@ public class SmsOtpAuthnYunxin extends SmsOtpAuthn {
@Override
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("isMfa", applicationConfig.getLoginConfig().isMfa());
if(applicationConfig.getLoginConfig().isMfa()) {
modelAndView.addObject("optType", tfaOptAuthn.getOptType());
modelAndView.addObject("optType", tfaOptAuthn.getOtpType());
modelAndView.addObject("optInterval", tfaOptAuthn.getInterval());
}