mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-14 20:50:14 +08:00
配置文件优化,参数整合及日志优化
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
package org.maxkey.password.onetimepwd.algorithm;
|
||||
|
||||
public class KeyUriFormat {
|
||||
public class OtpKeyUriFormat {
|
||||
|
||||
public class Types {
|
||||
public static final String HOTP = "hotp";
|
||||
@@ -38,7 +38,7 @@ public class KeyUriFormat {
|
||||
|
||||
String account;
|
||||
|
||||
public KeyUriFormat() {
|
||||
public OtpKeyUriFormat() {
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class KeyUriFormat {
|
||||
* @param type
|
||||
* @param secret
|
||||
*/
|
||||
public KeyUriFormat(String type, String secret) {
|
||||
public OtpKeyUriFormat(String type, String secret) {
|
||||
this.type = type;
|
||||
this.secret = secret;
|
||||
}
|
||||
@@ -56,12 +56,35 @@ public class KeyUriFormat {
|
||||
* @param secret
|
||||
* @param issuer
|
||||
*/
|
||||
public KeyUriFormat(String type, String secret, String issuer) {
|
||||
public OtpKeyUriFormat(String type, String secret, String issuer) {
|
||||
this.type = type;
|
||||
this.secret = secret;
|
||||
this.issuer = issuer;
|
||||
}
|
||||
|
||||
public OtpKeyUriFormat(String crypto, String type, String secret, String issuer, String domain, int digits,
|
||||
Long counter, int period, String account) {
|
||||
super();
|
||||
this.crypto = crypto;
|
||||
this.type = type;
|
||||
this.secret = secret;
|
||||
this.issuer = issuer;
|
||||
this.domain = domain;
|
||||
this.digits = digits;
|
||||
this.counter = counter;
|
||||
this.period = period;
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public OtpKeyUriFormat(String type, String issuer, String domain, int digits,int period) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.issuer = issuer;
|
||||
this.domain = domain;
|
||||
this.digits = digits;
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
@@ -18,17 +18,17 @@
|
||||
package org.maxkey.password.onetimepwd.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
public class SmsOtpAuthn extends AbstractOtpAuthn {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SmsOtpAuthn.class);
|
||||
|
||||
protected Properties properties;
|
||||
protected StandardEnvironment properties;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -44,7 +44,7 @@ public class SmsOtpAuthn extends AbstractOtpAuthn {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
public void setProperties(StandardEnvironment properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,12 @@ public class TimeBasedOtpAuthn extends AbstractOtpAuthn {
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
public TimeBasedOtpAuthn(int digits , int interval) {
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
super.digits = digits;
|
||||
super.interval = interval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean produce(UserInfo userInfo) {
|
||||
return true;
|
||||
|
||||
@@ -138,10 +138,10 @@ public class SmsOtpAuthnAliyun extends SmsOtpAuthn {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.accessKeyId = this.properties.getProperty("maxkey.otp.sms.aliyun.accesskeyid");
|
||||
this.accessSecret = this.properties.getProperty("maxkey.otp.sms.aliyun.accesssecret");
|
||||
this.templateCode = this.properties.getProperty("maxkey.otp.sms.aliyun.templatecode");
|
||||
this.signName = this.properties.getProperty("maxkey.otp.sms.aliyun.signname");
|
||||
this.accessKeyId = properties.getProperty("maxkey.otp.sms.aliyun.accesskeyid");
|
||||
this.accessSecret = properties.getProperty("maxkey.otp.sms.aliyun.accesssecret");
|
||||
this.templateCode = properties.getProperty("maxkey.otp.sms.aliyun.templatecode");
|
||||
this.signName = properties.getProperty("maxkey.otp.sms.aliyun.signname");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ public class SmsOtpAuthnTencentCloud extends SmsOtpAuthn {
|
||||
otpType = OtpTypes.SMS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@@ -181,11 +180,11 @@ public class SmsOtpAuthnTencentCloud extends SmsOtpAuthn {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.secretId = this.properties.getProperty("maxkey.otp.sms.tencentcloud.secretid");
|
||||
this.secretKey = this.properties.getProperty("maxkey.otp.sms.tencentcloud.secretkey");
|
||||
this.smsSdkAppid = this.properties.getProperty("maxkey.otp.sms.tencentcloud.smssdkappid");
|
||||
this.templateId = this.properties.getProperty("maxkey.otp.sms.tencentcloud.templateid");
|
||||
this.sign = this.properties.getProperty("maxkey.otp.sms.tencentcloud.sign");
|
||||
this.secretId = properties.getProperty("maxkey.otp.sms.tencentcloud.secretid");
|
||||
this.secretKey = properties.getProperty("maxkey.otp.sms.tencentcloud.secretkey");
|
||||
this.smsSdkAppid = properties.getProperty("maxkey.otp.sms.tencentcloud.smssdkappid");
|
||||
this.templateId = properties.getProperty("maxkey.otp.sms.tencentcloud.templateid");
|
||||
this.sign = properties.getProperty("maxkey.otp.sms.tencentcloud.sign");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -212,9 +212,9 @@ public class SmsOtpAuthnYunxin extends SmsOtpAuthn {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.appKey = this.properties.getProperty("maxkey.otp.sms.yunxin.appkey");
|
||||
this.appSecret = this.properties.getProperty("maxkey.otp.sms.yunxin.appsecret");
|
||||
this.templateId = this.properties.getProperty("maxkey.otp.sms.yunxin.templateid");
|
||||
this.appKey = properties.getProperty("maxkey.otp.sms.yunxin.appkey");
|
||||
this.appSecret = properties.getProperty("maxkey.otp.sms.yunxin.appsecret");
|
||||
this.templateId = properties.getProperty("maxkey.otp.sms.yunxin.templateid");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.maxkey.otp.algorithm;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.maxkey.password.onetimepwd.algorithm.KeyUriFormat;
|
||||
import org.maxkey.password.onetimepwd.algorithm.OtpKeyUriFormat;
|
||||
import org.maxkey.util.QRCode;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
@@ -29,7 +29,7 @@ import com.google.zxing.common.BitMatrix;
|
||||
public class KeyUriFormatTest {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
KeyUriFormat kuf=new KeyUriFormat(KeyUriFormat.Types.TOTP,
|
||||
OtpKeyUriFormat kuf=new OtpKeyUriFormat(OtpKeyUriFormat.Types.TOTP,
|
||||
"GIWVWOL7EI5WLVZPDMROEPSTFBEVO77Q",
|
||||
"connsec.com");
|
||||
kuf.setPeriod(60);
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
@@ -44,26 +43,21 @@ public class SocialSignOnAutoConfiguration implements InitializingBean {
|
||||
@Bean(name = "socialSignOnProviderService")
|
||||
@ConditionalOnClass(SocialSignOnProvider.class)
|
||||
public SocialSignOnProviderService socialSignOnProviderService(
|
||||
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer) throws IOException {
|
||||
StandardEnvironment environment) throws IOException {
|
||||
SocialSignOnProviderService socialSignOnProviderService = new SocialSignOnProviderService();
|
||||
|
||||
StandardEnvironment properties = (StandardEnvironment) propertySourcesPlaceholderConfigurer
|
||||
.getAppliedPropertySources()
|
||||
.get(PropertySourcesPlaceholderConfigurer.ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME)
|
||||
.getSource();
|
||||
|
||||
List<SocialSignOnProvider> socialSignOnProviderList = new ArrayList<SocialSignOnProvider>();
|
||||
|
||||
String [] providerList =properties.getProperty("maxkey.login.socialsignon.providers").toString().split(",");
|
||||
String [] providerList =environment.getProperty("maxkey.login.socialsignon.providers").toString().split(",");
|
||||
|
||||
for(String provider : providerList) {
|
||||
String providerName = properties.getProperty("maxkey.socialsignon."+provider+".provider.name");
|
||||
String icon=properties.getProperty("maxkey.socialsignon."+provider+".icon");
|
||||
String clientId=properties.getProperty("maxkey.socialsignon."+provider+".client.id");
|
||||
String clientSecret=properties.getProperty("maxkey.socialsignon."+provider+".client.secret");
|
||||
String sortOrder = properties.getProperty("maxkey.socialsignon."+provider+".sortorder");
|
||||
String agentId = properties.getProperty("maxkey.socialsignon."+provider+".agent.id");
|
||||
String hidden = properties.getProperty("maxkey.socialsignon."+provider+".hidden");
|
||||
String providerName = environment.getProperty("maxkey.socialsignon."+provider+".provider.name");
|
||||
String icon=environment.getProperty("maxkey.socialsignon."+provider+".icon");
|
||||
String clientId=environment.getProperty("maxkey.socialsignon."+provider+".client.id");
|
||||
String clientSecret=environment.getProperty("maxkey.socialsignon."+provider+".client.secret");
|
||||
String sortOrder = environment.getProperty("maxkey.socialsignon."+provider+".sortorder");
|
||||
String agentId = environment.getProperty("maxkey.socialsignon."+provider+".agent.id");
|
||||
String hidden = environment.getProperty("maxkey.socialsignon."+provider+".hidden");
|
||||
|
||||
SocialSignOnProvider socialSignOnProvider = new SocialSignOnProvider();
|
||||
socialSignOnProvider.setProvider(provider);
|
||||
|
||||
Reference in New Issue
Block a user