mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
separate common
This commit is contained in:
parent
d1d8924b60
commit
647d899771
1
.gitignore
vendored
1
.gitignore
vendored
@ -45,3 +45,4 @@ classpath-data.json
|
|||||||
/.gradle/*
|
/.gradle/*
|
||||||
/build/
|
/build/
|
||||||
setEnvVars.bat
|
setEnvVars.bat
|
||||||
|
/bin/
|
||||||
|
|||||||
14
build.gradle
14
build.gradle
@ -47,13 +47,13 @@ allprojects {
|
|||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
eclipse {
|
eclipse {
|
||||||
/*第一次时请注释这段eclipse设置,可能报错*/
|
/*第一次时请注释这段eclipse设置,可能报错
|
||||||
// jdt {
|
jdt {
|
||||||
// File f = file('.settings/org.eclipse.core.resources.prefs')
|
File f = file('.settings/org.eclipse.core.resources.prefs')
|
||||||
// f.write('eclipse.preferences.version=1\n')
|
f.write('eclipse.preferences.version=1\n')
|
||||||
// f.append('encoding/<project>=UTF-8') //use UTF-8
|
f.append('encoding/<project>=UTF-8') //use UTF-8
|
||||||
// }
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
wtp {
|
wtp {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
group =maxkey.top
|
group =maxkey.top
|
||||||
version =2.5.0
|
version =2.6.0
|
||||||
vendor =https://www.maxkey.top
|
vendor =https://www.maxkey.top
|
||||||
author =maxkeyTop
|
author =maxkeyTop
|
||||||
#Version For use jar
|
#Version For use jar
|
||||||
|
|||||||
@ -6,6 +6,7 @@ dependencies {
|
|||||||
//local jars
|
//local jars
|
||||||
compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||||
|
|
||||||
|
compile project(":maxkey-common")
|
||||||
compile project(":maxkey-core")
|
compile project(":maxkey-core")
|
||||||
compile project(":maxkey-persistence")
|
compile project(":maxkey-persistence")
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ dependencies {
|
|||||||
//local jars
|
//local jars
|
||||||
compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||||
|
|
||||||
|
compile project(":maxkey-common")
|
||||||
compile project(":maxkey-core")
|
compile project(":maxkey-core")
|
||||||
compile project(":maxkey-persistence")
|
compile project(":maxkey-persistence")
|
||||||
compile project(":maxkey-protocols:maxkey-protocol-oauth-2.0")
|
compile project(":maxkey-protocols:maxkey-protocol-oauth-2.0")
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
description = "maxkey-authentication-otp"
|
||||||
|
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
//local jars
|
||||||
|
compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||||
|
|
||||||
|
compile project(":maxkey-common")
|
||||||
|
compile project(":maxkey-core")
|
||||||
|
compile project(":maxkey-persistence")
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Class-Path:
|
||||||
|
|
||||||
@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt;
|
package org.maxkey.crypto.password.otp;
|
||||||
|
|
||||||
import org.maxkey.crypto.password.opt.token.AbstractOptTokenStore;
|
import org.maxkey.crypto.password.otp.token.AbstractOtpTokenStore;
|
||||||
import org.maxkey.crypto.password.opt.token.InMemoryOptTokenStore;
|
import org.maxkey.crypto.password.otp.token.InMemoryOtpTokenStore;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.maxkey.util.StringGenerator;
|
import org.maxkey.util.StringGenerator;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -29,10 +29,10 @@ import org.slf4j.LoggerFactory;
|
|||||||
* @author Administrator
|
* @author Administrator
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractOptAuthn {
|
public abstract class AbstractOtpAuthn {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AbstractOptAuthn.class);
|
private static final Logger logger = LoggerFactory.getLogger(AbstractOtpAuthn.class);
|
||||||
|
|
||||||
protected AbstractOptTokenStore optTokenStore = new InMemoryOptTokenStore();
|
protected AbstractOtpTokenStore optTokenStore = new InMemoryOtpTokenStore();
|
||||||
|
|
||||||
//验证码有效間隔
|
//验证码有效間隔
|
||||||
protected int interval = 30;
|
protected int interval = 30;
|
||||||
@ -142,7 +142,7 @@ public abstract class AbstractOptAuthn {
|
|||||||
this.optType = optType;
|
this.optType = optType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOptTokenStore(AbstractOptTokenStore optTokenStore) {
|
public void setOptTokenStore(AbstractOtpTokenStore optTokenStore) {
|
||||||
this.optTokenStore = optTokenStore;
|
this.optTokenStore = optTokenStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt;
|
package org.maxkey.crypto.password.otp;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.algorithm;
|
package org.maxkey.crypto.password.otp.algorithm;
|
||||||
|
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.algorithm;
|
package org.maxkey.crypto.password.otp.algorithm;
|
||||||
|
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.algorithm;
|
package org.maxkey.crypto.password.otp.algorithm;
|
||||||
|
|
||||||
public class KeyUriFormat {
|
public class KeyUriFormat {
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.algorithm;
|
package org.maxkey.crypto.password.otp.algorithm;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.algorithm;
|
package org.maxkey.crypto.password.otp.algorithm;
|
||||||
|
|
||||||
import java.lang.reflect.UndeclaredThrowableException;
|
import java.lang.reflect.UndeclaredThrowableException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -15,9 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl;
|
package org.maxkey.crypto.password.otp.impl;
|
||||||
|
|
||||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,7 +30,7 @@ import org.maxkey.domain.UserInfo;
|
|||||||
* @author Crystal.Sea
|
* @author Crystal.Sea
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CapOtpAuthn extends AbstractOptAuthn {
|
public class CapOtpAuthn extends AbstractOtpAuthn {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -15,17 +15,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl;
|
package org.maxkey.crypto.password.otp.impl;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Hex;
|
import org.apache.commons.codec.binary.Hex;
|
||||||
import org.maxkey.crypto.Base32Utils;
|
import org.maxkey.crypto.Base32Utils;
|
||||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||||
import org.maxkey.crypto.password.opt.algorithm.TimeBasedOTP;
|
import org.maxkey.crypto.password.otp.algorithm.TimeBasedOTP;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class CounterBasedOtpAuthn extends AbstractOptAuthn {
|
public class CounterBasedOtpAuthn extends AbstractOtpAuthn {
|
||||||
private static final Logger _logger = LoggerFactory.getLogger(CounterBasedOtpAuthn.class);
|
private static final Logger _logger = LoggerFactory.getLogger(CounterBasedOtpAuthn.class);
|
||||||
|
|
||||||
|
|
||||||
@ -15,18 +15,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl;
|
package org.maxkey.crypto.password.otp.impl;
|
||||||
|
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import org.maxkey.crypto.Base32Utils;
|
import org.maxkey.crypto.Base32Utils;
|
||||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||||
import org.maxkey.crypto.password.opt.algorithm.HOTP;
|
import org.maxkey.crypto.password.otp.algorithm.HOTP;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class HotpOtpAuthn extends AbstractOptAuthn {
|
public class HotpOtpAuthn extends AbstractOtpAuthn {
|
||||||
private static final Logger _logger = LoggerFactory.getLogger(HotpOtpAuthn.class);
|
private static final Logger _logger = LoggerFactory.getLogger(HotpOtpAuthn.class);
|
||||||
|
|
||||||
boolean addChecksum;
|
boolean addChecksum;
|
||||||
@ -15,20 +15,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl;
|
package org.maxkey.crypto.password.otp.impl;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import org.apache.commons.mail.DefaultAuthenticator;
|
import org.apache.commons.mail.DefaultAuthenticator;
|
||||||
import org.apache.commons.mail.Email;
|
import org.apache.commons.mail.Email;
|
||||||
import org.apache.commons.mail.SimpleEmail;
|
import org.apache.commons.mail.SimpleEmail;
|
||||||
import org.maxkey.configuration.EmailConfig;
|
import org.maxkey.configuration.EmailConfig;
|
||||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
public class MailOtpAuthn extends AbstractOptAuthn {
|
public class MailOtpAuthn extends AbstractOtpAuthn {
|
||||||
private static final Logger _logger = LoggerFactory.getLogger(MailOtpAuthn.class);
|
private static final Logger _logger = LoggerFactory.getLogger(MailOtpAuthn.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl;
|
package org.maxkey.crypto.password.otp.impl;
|
||||||
|
|
||||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
|
|
||||||
public class MobileOtpAuthn extends AbstractOptAuthn {
|
public class MobileOtpAuthn extends AbstractOtpAuthn {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -15,9 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl;
|
package org.maxkey.crypto.password.otp.impl;
|
||||||
|
|
||||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,7 +30,7 @@ import org.maxkey.domain.UserInfo;
|
|||||||
* @author Crystal.Sea
|
* @author Crystal.Sea
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RsaOtpAuthn extends AbstractOptAuthn {
|
public class RsaOtpAuthn extends AbstractOtpAuthn {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -15,19 +15,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl;
|
package org.maxkey.crypto.password.otp.impl;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import org.maxkey.constants.ConstantsProperties;
|
import org.maxkey.constants.ConstantsProperties;
|
||||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
public class SmsOtpAuthn extends AbstractOptAuthn {
|
public class SmsOtpAuthn extends AbstractOtpAuthn {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SmsOtpAuthn.class);
|
private static final Logger logger = LoggerFactory.getLogger(SmsOtpAuthn.class);
|
||||||
|
|
||||||
protected Properties properties;
|
protected Properties properties;
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl;
|
package org.maxkey.crypto.password.otp.impl;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -23,13 +23,13 @@ import java.util.Date;
|
|||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import org.apache.commons.codec.binary.Hex;
|
import org.apache.commons.codec.binary.Hex;
|
||||||
import org.maxkey.crypto.Base32Utils;
|
import org.maxkey.crypto.Base32Utils;
|
||||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
|
||||||
import org.maxkey.crypto.password.opt.algorithm.TimeBasedOTP;
|
import org.maxkey.crypto.password.otp.algorithm.TimeBasedOTP;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class TimeBasedOtpAuthn extends AbstractOptAuthn {
|
public class TimeBasedOtpAuthn extends AbstractOtpAuthn {
|
||||||
private static final Logger _logger = LoggerFactory.getLogger(TimeBasedOtpAuthn.class);
|
private static final Logger _logger = LoggerFactory.getLogger(TimeBasedOtpAuthn.class);
|
||||||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl.sms;
|
package org.maxkey.crypto.password.otp.impl.sms;
|
||||||
|
|
||||||
import com.aliyuncs.CommonRequest;
|
import com.aliyuncs.CommonRequest;
|
||||||
import com.aliyuncs.CommonResponse;
|
import com.aliyuncs.CommonResponse;
|
||||||
@ -26,7 +26,7 @@ import com.aliyuncs.profile.DefaultProfile;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn;
|
import org.maxkey.crypto.password.otp.impl.SmsOtpAuthn;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl.sms;
|
package org.maxkey.crypto.password.otp.impl.sms;
|
||||||
|
|
||||||
import com.tencentcloudapi.common.Credential;
|
import com.tencentcloudapi.common.Credential;
|
||||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||||
@ -26,7 +26,7 @@ import com.tencentcloudapi.sms.v20190711.models.SendSmsResponse;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn;
|
import org.maxkey.crypto.password.otp.impl.SmsOtpAuthn;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl.sms;
|
package org.maxkey.crypto.password.otp.impl.sms;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -29,7 +29,7 @@ import org.apache.http.client.methods.HttpPost;
|
|||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn;
|
import org.maxkey.crypto.password.otp.impl.SmsOtpAuthn;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.maxkey.util.JsonUtils;
|
import org.maxkey.util.JsonUtils;
|
||||||
import org.maxkey.util.StringGenerator;
|
import org.maxkey.util.StringGenerator;
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.impl.sms;
|
package org.maxkey.crypto.password.otp.impl.sms;
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.token;
|
package org.maxkey.crypto.password.otp.token;
|
||||||
|
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
|
|
||||||
public abstract class AbstractOptTokenStore {
|
public abstract class AbstractOtpTokenStore {
|
||||||
|
|
||||||
public abstract void store(UserInfo userInfo, String token, String receiver, String type);
|
public abstract void store(UserInfo userInfo, String token, String receiver, String type);
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.token;
|
package org.maxkey.crypto.password.otp.token;
|
||||||
|
|
||||||
import org.ehcache.UserManagedCache;
|
import org.ehcache.UserManagedCache;
|
||||||
import org.ehcache.config.builders.ExpiryPolicyBuilder;
|
import org.ehcache.config.builders.ExpiryPolicyBuilder;
|
||||||
@ -24,13 +24,13 @@ import org.joda.time.DateTime;
|
|||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.maxkey.constants.ConstantsTimeInterval;
|
import org.maxkey.constants.ConstantsTimeInterval;
|
||||||
import org.maxkey.crypto.password.opt.OneTimePassword;
|
import org.maxkey.crypto.password.otp.OneTimePassword;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class InMemoryOptTokenStore extends AbstractOptTokenStore {
|
public class InMemoryOtpTokenStore extends AbstractOtpTokenStore {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(InMemoryOptTokenStore.class);
|
private static final Logger logger = LoggerFactory.getLogger(InMemoryOtpTokenStore.class);
|
||||||
|
|
||||||
protected static final UserManagedCache<String, OneTimePassword> optTokenStore =
|
protected static final UserManagedCache<String, OneTimePassword> optTokenStore =
|
||||||
UserManagedCacheBuilder.newUserManagedCacheBuilder(String.class, OneTimePassword.class)
|
UserManagedCacheBuilder.newUserManagedCacheBuilder(String.class, OneTimePassword.class)
|
||||||
@ -73,7 +73,7 @@ public class InMemoryOptTokenStore extends AbstractOptTokenStore {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InMemoryOptTokenStore() {
|
public InMemoryOtpTokenStore() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,22 +15,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.crypto.password.opt.token;
|
package org.maxkey.crypto.password.otp.token;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.maxkey.constants.ConstantsTimeInterval;
|
import org.maxkey.constants.ConstantsTimeInterval;
|
||||||
import org.maxkey.crypto.password.opt.OneTimePassword;
|
import org.maxkey.crypto.password.otp.OneTimePassword;
|
||||||
import org.maxkey.domain.UserInfo;
|
import org.maxkey.domain.UserInfo;
|
||||||
import org.maxkey.persistence.redis.RedisConnection;
|
import org.maxkey.persistence.redis.RedisConnection;
|
||||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||||
|
|
||||||
public class RedisOptTokenStore extends AbstractOptTokenStore {
|
public class RedisOtpTokenStore extends AbstractOtpTokenStore {
|
||||||
|
|
||||||
protected int validitySeconds = ConstantsTimeInterval.ONE_MINUTE * 5;
|
protected int validitySeconds = ConstantsTimeInterval.ONE_MINUTE * 5;
|
||||||
|
|
||||||
RedisConnectionFactory connectionFactory;
|
RedisConnectionFactory connectionFactory;
|
||||||
|
|
||||||
public RedisOptTokenStore(RedisConnectionFactory connectionFactory) {
|
public RedisOtpTokenStore(RedisConnectionFactory connectionFactory) {
|
||||||
super();
|
super();
|
||||||
this.connectionFactory = connectionFactory;
|
this.connectionFactory = connectionFactory;
|
||||||
}
|
}
|
||||||
@ -22,8 +22,8 @@ import java.security.InvalidKeyException;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import org.maxkey.crypto.Base32Utils;
|
import org.maxkey.crypto.Base32Utils;
|
||||||
import org.maxkey.crypto.password.opt.algorithm.HOTP;
|
import org.maxkey.crypto.password.otp.algorithm.HOTP;
|
||||||
import org.maxkey.crypto.password.opt.algorithm.HmacOTP;
|
import org.maxkey.crypto.password.otp.algorithm.HmacOTP;
|
||||||
|
|
||||||
|
|
||||||
public class HmacOTPTest {
|
public class HmacOTPTest {
|
||||||
@ -19,7 +19,7 @@ package org.maxkey.otp.algorithm;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.maxkey.crypto.password.opt.algorithm.KeyUriFormat;
|
import org.maxkey.crypto.password.otp.algorithm.KeyUriFormat;
|
||||||
import org.maxkey.util.QRCode;
|
import org.maxkey.util.QRCode;
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
@ -26,7 +26,7 @@ import java.util.TimeZone;
|
|||||||
import org.apache.commons.codec.binary.Hex;
|
import org.apache.commons.codec.binary.Hex;
|
||||||
import org.maxkey.crypto.Base32Utils;
|
import org.maxkey.crypto.Base32Utils;
|
||||||
import org.maxkey.crypto.HexUtils;
|
import org.maxkey.crypto.HexUtils;
|
||||||
import org.maxkey.crypto.password.opt.algorithm.TimeBasedOTP;
|
import org.maxkey.crypto.password.otp.algorithm.TimeBasedOTP;
|
||||||
/**
|
/**
|
||||||
* goole
|
* goole
|
||||||
* @author Crystal.Sea
|
* @author Crystal.Sea
|
||||||
@ -6,6 +6,7 @@ dependencies {
|
|||||||
//local jars
|
//local jars
|
||||||
compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||||
|
|
||||||
|
compile project(":maxkey-common")
|
||||||
compile project(":maxkey-core")
|
compile project(":maxkey-core")
|
||||||
compile project(":maxkey-persistence")
|
compile project(":maxkey-persistence")
|
||||||
|
|
||||||
|
|||||||
7
maxkey-common/build.gradle
Normal file
7
maxkey-common/build.gradle
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
description = "maxkey-common"
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
//local jars
|
||||||
|
compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||||
|
|
||||||
|
}
|
||||||
3
maxkey-common/src/main/java/META-INF/MANIFEST.MF
Normal file
3
maxkey-common/src/main/java/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Class-Path:
|
||||||
|
|
||||||
@ -0,0 +1,230 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.configuration;
|
||||||
|
|
||||||
|
import org.maxkey.constants.ConstantsProperties;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局应用程序配置 包含 1、数据源配置 dataSoruceConfig 2、字符集转换配置 characterEncodingConfig
|
||||||
|
* 3、webseal认证集成配置 webSealConfig 4、系统的配置 sysConfig 5、所有用户可访问地址配置 allAccessUrl
|
||||||
|
*
|
||||||
|
* 其中1、2、3项在applicationContext.xml中配置,配置文件applicationConfig.properties
|
||||||
|
* 4项根据dynamic的属性判断是否动态从sysConfigService动态读取
|
||||||
|
*
|
||||||
|
* @author Crystal.Sea
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@PropertySource(ConstantsProperties.maxKeyPropertySource)
|
||||||
|
@PropertySource(ConstantsProperties.applicationPropertySource)
|
||||||
|
public class ApplicationConfig {
|
||||||
|
private static final Logger _logger = LoggerFactory.getLogger(ApplicationConfig.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
EmailConfig emailConfig;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CharacterEncodingConfig characterEncodingConfig;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
LoginConfig loginConfig;
|
||||||
|
|
||||||
|
@Value("${config.server.basedomain}")
|
||||||
|
String baseDomainName;
|
||||||
|
|
||||||
|
@Value("${config.server.domain}")
|
||||||
|
String domainName;
|
||||||
|
|
||||||
|
@Value("${config.server.name}")
|
||||||
|
String serverName;
|
||||||
|
|
||||||
|
@Value("${config.server.uri}")
|
||||||
|
String serverPrefix;
|
||||||
|
|
||||||
|
@Value("${config.server.default.uri}")
|
||||||
|
String defaultUri;
|
||||||
|
|
||||||
|
@Value("${config.server.management.uri}")
|
||||||
|
String managementUri;
|
||||||
|
|
||||||
|
@Value("${server.port:8080}")
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@Value("${config.identity.kafkasupport:false}")
|
||||||
|
private boolean kafkaSupport;
|
||||||
|
|
||||||
|
@Value("${config.maxkey.uri}")
|
||||||
|
private String maxKeyUri;
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPort(int port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationConfig() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the characterEncodingConfig
|
||||||
|
*/
|
||||||
|
public CharacterEncodingConfig getCharacterEncodingConfig() {
|
||||||
|
return characterEncodingConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param characterEncodingConfig the characterEncodingConfig to set
|
||||||
|
*/
|
||||||
|
public void setCharacterEncodingConfig(CharacterEncodingConfig characterEncodingConfig) {
|
||||||
|
this.characterEncodingConfig = characterEncodingConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoginConfig getLoginConfig() {
|
||||||
|
return loginConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoginConfig(LoginConfig loginConfig) {
|
||||||
|
this.loginConfig = loginConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerName() {
|
||||||
|
return serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerName(String serverName) {
|
||||||
|
this.serverName = serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerPrefix() {
|
||||||
|
return serverPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerPrefix(String serverPrefix) {
|
||||||
|
this.serverPrefix = serverPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the domainName
|
||||||
|
*/
|
||||||
|
public String getDomainName() {
|
||||||
|
return domainName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param domainName the domainName to set
|
||||||
|
*/
|
||||||
|
public void setDomainName(String domainName) {
|
||||||
|
this.domainName = domainName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBaseDomainName() {
|
||||||
|
return baseDomainName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaseDomainName(String baseDomainName) {
|
||||||
|
this.baseDomainName = baseDomainName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the emailConfig
|
||||||
|
*/
|
||||||
|
public EmailConfig getEmailConfig() {
|
||||||
|
return emailConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param emailConfig the emailConfig to set
|
||||||
|
*/
|
||||||
|
public void setEmailConfig(EmailConfig emailConfig) {
|
||||||
|
this.emailConfig = emailConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getManagementUri() {
|
||||||
|
return managementUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setManagementUri(String managementUri) {
|
||||||
|
this.managementUri = managementUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultUri() {
|
||||||
|
return defaultUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultUri(String defaultUri) {
|
||||||
|
this.defaultUri = defaultUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isKafkaSupport() {
|
||||||
|
return kafkaSupport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKafkaSupport(boolean kafkaSupport) {
|
||||||
|
this.kafkaSupport = kafkaSupport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMaxKeyUri() {
|
||||||
|
return maxKeyUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxKeyUri(String maxKeyUri) {
|
||||||
|
this.maxKeyUri = maxKeyUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("ApplicationConfig [emailConfig=");
|
||||||
|
builder.append(emailConfig);
|
||||||
|
builder.append(", characterEncodingConfig=");
|
||||||
|
builder.append(characterEncodingConfig);
|
||||||
|
builder.append(", loginConfig=");
|
||||||
|
builder.append(loginConfig);
|
||||||
|
builder.append(", baseDomainName=");
|
||||||
|
builder.append(baseDomainName);
|
||||||
|
builder.append(", domainName=");
|
||||||
|
builder.append(domainName);
|
||||||
|
builder.append(", serverName=");
|
||||||
|
builder.append(serverName);
|
||||||
|
builder.append(", serverPrefix=");
|
||||||
|
builder.append(serverPrefix);
|
||||||
|
builder.append(", defaultUri=");
|
||||||
|
builder.append(defaultUri);
|
||||||
|
builder.append(", managementUri=");
|
||||||
|
builder.append(managementUri);
|
||||||
|
builder.append(", port=");
|
||||||
|
builder.append(port);
|
||||||
|
builder.append(", kafkaSupport=");
|
||||||
|
builder.append(kafkaSupport);
|
||||||
|
builder.append(", maxKeyUri=");
|
||||||
|
builder.append(maxKeyUri);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.configuration;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
import org.maxkey.constants.ConstantsProperties;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符集转换及转换配置.
|
||||||
|
*
|
||||||
|
* @author Crystal.Sea
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@PropertySource(ConstantsProperties.applicationPropertySource)
|
||||||
|
public class CharacterEncodingConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 源字符集.
|
||||||
|
*/
|
||||||
|
@Value("${server.servlet.encoding.charset.from:UTF-8}")
|
||||||
|
String fromCharSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目标字符集.
|
||||||
|
*/
|
||||||
|
@Value("${server.servlet.encoding.charset:UTF-8}")
|
||||||
|
String toCharSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换标志.
|
||||||
|
*/
|
||||||
|
@Value("${server.servlet.encoding.enabled:false}")
|
||||||
|
boolean encoding = false;
|
||||||
|
|
||||||
|
public CharacterEncodingConfig() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFromCharSet() {
|
||||||
|
return fromCharSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFromCharSet(String fromCharSet) {
|
||||||
|
this.fromCharSet = fromCharSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToCharSet() {
|
||||||
|
return toCharSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToCharSet(String toCharSet) {
|
||||||
|
this.toCharSet = toCharSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEncoding() {
|
||||||
|
return encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEncoding(boolean encoding) {
|
||||||
|
this.encoding = encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符集转换.
|
||||||
|
*
|
||||||
|
* @param encodingString 源字符串
|
||||||
|
* @return encoded目标字符串
|
||||||
|
*/
|
||||||
|
public String encoding(String encodingString) {
|
||||||
|
if (!this.encoding || encodingString == null) {
|
||||||
|
return encodingString;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new String(encodingString.getBytes(this.fromCharSet), this.toCharSet);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("CharacterEncodingConfig [fromCharSet=");
|
||||||
|
builder.append(fromCharSet);
|
||||||
|
builder.append(", toCharSet=");
|
||||||
|
builder.append(toCharSet);
|
||||||
|
builder.append(", encoding=");
|
||||||
|
builder.append(encoding);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.configuration;
|
||||||
|
|
||||||
|
import org.maxkey.constants.ConstantsProperties;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@PropertySource(ConstantsProperties.applicationPropertySource)
|
||||||
|
public class EmailConfig {
|
||||||
|
|
||||||
|
@Value("${spring.mail.username}")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Value("${spring.mail.password}")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Value("${spring.mail.host}")
|
||||||
|
private String smtpHost;
|
||||||
|
|
||||||
|
@Value("${spring.mail.port}")
|
||||||
|
private Integer port;
|
||||||
|
|
||||||
|
@Value("${spring.mail.properties.ssl}")
|
||||||
|
private boolean ssl;
|
||||||
|
|
||||||
|
@Value("${spring.mail.properties.sender}")
|
||||||
|
private String sender;
|
||||||
|
|
||||||
|
public EmailConfig() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @return the username
|
||||||
|
*/
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @param username the username to set
|
||||||
|
*/
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @return the password
|
||||||
|
*/
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @param password the password to set
|
||||||
|
*/
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @return the smtpHost
|
||||||
|
*/
|
||||||
|
public String getSmtpHost() {
|
||||||
|
return smtpHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @param smtpHost the smtpHost to set
|
||||||
|
*/
|
||||||
|
public void setSmtpHost(String smtpHost) {
|
||||||
|
this.smtpHost = smtpHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSender(String sender) {
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @return the port
|
||||||
|
*/
|
||||||
|
public Integer getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @param port the port to set
|
||||||
|
*/
|
||||||
|
public void setPort(Integer port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @return the ssl
|
||||||
|
*/
|
||||||
|
public boolean isSsl() {
|
||||||
|
return ssl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @param ssl the ssl to set
|
||||||
|
*/
|
||||||
|
public void setSsl(boolean ssl) {
|
||||||
|
this.ssl = ssl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("EmailConfig [username=");
|
||||||
|
builder.append(username);
|
||||||
|
builder.append(", password=");
|
||||||
|
builder.append(password);
|
||||||
|
builder.append(", smtpHost=");
|
||||||
|
builder.append(smtpHost);
|
||||||
|
builder.append(", port=");
|
||||||
|
builder.append(port);
|
||||||
|
builder.append(", ssl=");
|
||||||
|
builder.append(ssl);
|
||||||
|
builder.append(", sender=");
|
||||||
|
builder.append(sender);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,147 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.configuration;
|
||||||
|
|
||||||
|
import org.maxkey.constants.ConstantsProperties;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@PropertySource(ConstantsProperties.maxKeyPropertySource)
|
||||||
|
public class LoginConfig {
|
||||||
|
@Value("${config.login.captcha}")
|
||||||
|
boolean captcha;
|
||||||
|
|
||||||
|
//验证码类型 text 文本 , arithmetic算术验证码
|
||||||
|
@Value("${config.login.captcha.type:text}")
|
||||||
|
String captchaType;
|
||||||
|
|
||||||
|
@Value("${config.login.mfa}")
|
||||||
|
boolean mfa;
|
||||||
|
|
||||||
|
@Value("${config.login.socialsignon}")
|
||||||
|
boolean socialSignOn;
|
||||||
|
|
||||||
|
@Value("${config.login.kerberos}")
|
||||||
|
boolean kerberos;
|
||||||
|
|
||||||
|
@Value("${config.login.remeberme}")
|
||||||
|
boolean remeberMe;
|
||||||
|
|
||||||
|
@Value("${config.login.wsfederation}")
|
||||||
|
boolean wsFederation;
|
||||||
|
|
||||||
|
@Value("${config.login.default.uri}")
|
||||||
|
String defaultUri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* .
|
||||||
|
*/
|
||||||
|
public LoginConfig() {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCaptcha() {
|
||||||
|
return captcha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaptcha(boolean captcha) {
|
||||||
|
this.captcha = captcha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSocialSignOn() {
|
||||||
|
return socialSignOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSocialSignOn(boolean socialSignOn) {
|
||||||
|
this.socialSignOn = socialSignOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isKerberos() {
|
||||||
|
return kerberos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKerberos(boolean kerberos) {
|
||||||
|
this.kerberos = kerberos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMfa() {
|
||||||
|
return mfa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMfa(boolean mfa) {
|
||||||
|
this.mfa = mfa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultUri() {
|
||||||
|
return defaultUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultUri(String defaultUri) {
|
||||||
|
this.defaultUri = defaultUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRemeberMe() {
|
||||||
|
return remeberMe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemeberMe(boolean remeberMe) {
|
||||||
|
this.remeberMe = remeberMe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWsFederation() {
|
||||||
|
return wsFederation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWsFederation(boolean wsFederation) {
|
||||||
|
this.wsFederation = wsFederation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCaptchaType() {
|
||||||
|
return captchaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaptchaType(String captchaType) {
|
||||||
|
this.captchaType = captchaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("LoginConfig [captcha=");
|
||||||
|
builder.append(captcha);
|
||||||
|
builder.append(", captchaType=");
|
||||||
|
builder.append(captchaType);
|
||||||
|
builder.append(", mfa=");
|
||||||
|
builder.append(mfa);
|
||||||
|
builder.append(", socialSignOn=");
|
||||||
|
builder.append(socialSignOn);
|
||||||
|
builder.append(", kerberos=");
|
||||||
|
builder.append(kerberos);
|
||||||
|
builder.append(", remeberMe=");
|
||||||
|
builder.append(remeberMe);
|
||||||
|
builder.append(", wsFederation=");
|
||||||
|
builder.append(wsFederation);
|
||||||
|
builder.append(", defaultUri=");
|
||||||
|
builder.append(defaultUri);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.configuration.oidc;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public interface OIDCProviderMetadata {
|
||||||
|
|
||||||
|
public String getIssuer();
|
||||||
|
|
||||||
|
public void setIssuer(String issuer);
|
||||||
|
|
||||||
|
public URI getAuthorizationEndpoint();
|
||||||
|
|
||||||
|
public void setAuthorizationEndpoint(URI authorizationEndpoint);
|
||||||
|
|
||||||
|
public URI getTokenEndpoint();
|
||||||
|
|
||||||
|
public void setTokenEndpoint(URI tokenEndpoint);
|
||||||
|
|
||||||
|
public URI getUserinfoEndpoint();
|
||||||
|
|
||||||
|
public void setUserinfoEndpoint(URI userinfoEndpoint);
|
||||||
|
|
||||||
|
public URI getJwksUri();
|
||||||
|
|
||||||
|
public void setJwksUri(URI jwksUri);
|
||||||
|
|
||||||
|
public URI getRegistrationEndpoint();
|
||||||
|
|
||||||
|
public void setRegistrationEndpoint(URI registrationEndpoint);
|
||||||
|
|
||||||
|
public Set<String> getScopesSupported();
|
||||||
|
|
||||||
|
public void setScopesSupported(Set<String> scopesSupported);
|
||||||
|
|
||||||
|
public Set<String> getResponseTypesSupported();
|
||||||
|
|
||||||
|
public void setResponseTypesSupported(Set<String> responseTypesSupported);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.configuration.oidc;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OIDCProviderMetadataDetails.
|
||||||
|
* @author cm
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class OIDCProviderMetadataDetails implements OIDCProviderMetadata {
|
||||||
|
protected String issuer;
|
||||||
|
|
||||||
|
protected URI authorizationEndpoint;
|
||||||
|
|
||||||
|
protected URI tokenEndpoint;
|
||||||
|
|
||||||
|
protected URI userinfoEndpoint;
|
||||||
|
|
||||||
|
protected URI jwksUri;
|
||||||
|
|
||||||
|
protected URI registrationEndpoint;
|
||||||
|
|
||||||
|
protected Set<String> scopesSupported;
|
||||||
|
|
||||||
|
protected Set<String> responseTypesSupported;
|
||||||
|
|
||||||
|
public String getIssuer() {
|
||||||
|
return issuer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIssuer(String issuer) {
|
||||||
|
this.issuer = issuer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URI getAuthorizationEndpoint() {
|
||||||
|
return authorizationEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthorizationEndpoint(URI authorizationEndpoint) {
|
||||||
|
this.authorizationEndpoint = authorizationEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URI getTokenEndpoint() {
|
||||||
|
return tokenEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTokenEndpoint(URI tokenEndpoint) {
|
||||||
|
this.tokenEndpoint = tokenEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URI getUserinfoEndpoint() {
|
||||||
|
return userinfoEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserinfoEndpoint(URI userinfoEndpoint) {
|
||||||
|
this.userinfoEndpoint = userinfoEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URI getJwksUri() {
|
||||||
|
return jwksUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJwksUri(URI jwksUri) {
|
||||||
|
this.jwksUri = jwksUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URI getRegistrationEndpoint() {
|
||||||
|
return registrationEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegistrationEndpoint(URI registrationEndpoint) {
|
||||||
|
this.registrationEndpoint = registrationEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getScopesSupported() {
|
||||||
|
return scopesSupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScopesSupported(Set<String> scopesSupported) {
|
||||||
|
this.scopesSupported = scopesSupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getResponseTypesSupported() {
|
||||||
|
return responseTypesSupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResponseTypesSupported(Set<String> responseTypesSupported) {
|
||||||
|
this.responseTypesSupported = responseTypesSupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
final int maxLen = 4;
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("OIDCProviderMetadataDetails [issuer=");
|
||||||
|
builder.append(issuer);
|
||||||
|
builder.append(", authorizationEndpoint=");
|
||||||
|
builder.append(authorizationEndpoint);
|
||||||
|
builder.append(", tokenEndpoint=");
|
||||||
|
builder.append(tokenEndpoint);
|
||||||
|
builder.append(", userinfoEndpoint=");
|
||||||
|
builder.append(userinfoEndpoint);
|
||||||
|
builder.append(", jwksUri=");
|
||||||
|
builder.append(jwksUri);
|
||||||
|
builder.append(", registrationEndpoint=");
|
||||||
|
builder.append(registrationEndpoint);
|
||||||
|
builder.append(", scopesSupported=");
|
||||||
|
builder.append(scopesSupported != null ? toString(scopesSupported, maxLen) : null);
|
||||||
|
builder.append(", responseTypesSupported=");
|
||||||
|
builder.append(responseTypesSupported != null ? toString(responseTypesSupported, maxLen) : null);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toString(Collection<?> collection, int maxLen) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("[");
|
||||||
|
int i = 0;
|
||||||
|
for (Iterator<?> iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) {
|
||||||
|
if (i > 0)
|
||||||
|
builder.append(", ");
|
||||||
|
builder.append(iterator.next());
|
||||||
|
}
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Complete remaining properties from
|
||||||
|
// http://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define int for boolean 0 false 1 true.
|
||||||
|
*
|
||||||
|
* @author Crystal.Sea
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Boolean {
|
||||||
|
|
||||||
|
public static final int FALSE = 0;
|
||||||
|
|
||||||
|
public static final int TRUE = 1;
|
||||||
|
|
||||||
|
private int value = FALSE;
|
||||||
|
|
||||||
|
public Boolean() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValue() {
|
||||||
|
return TRUE == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isTrue(int value) {
|
||||||
|
return TRUE == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFalse(int value) {
|
||||||
|
return FALSE == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
public class ConstantsEntryType {
|
||||||
|
|
||||||
|
public static int USERINFO_TYPE = 1;
|
||||||
|
public static int ORG_TYPE = 2;
|
||||||
|
public static int GROUP_TYPE = 3;
|
||||||
|
public static int PASSWORD_TYPE = 4;
|
||||||
|
public static int RESOURCES_TYPE = 5;
|
||||||
|
public static int PERMISSIONS_TYPE = 6;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
public class ConstantsLoginType {
|
||||||
|
|
||||||
|
public static final String LOCAL = "Local Login";
|
||||||
|
public static final String BASIC = "Basic";
|
||||||
|
public static final String SOCIALSIGNON = "Social Sign On";
|
||||||
|
public static final String REMEBER_ME = "RemeberMe";
|
||||||
|
public static final String DESKTOP = "Desktop";
|
||||||
|
public static final String KERBEROS = "Kerberos";
|
||||||
|
public static final String SAMLTRUST = "SAML v2.0 Trust";
|
||||||
|
public static final String MSADTRUST = "MS AD Trust";
|
||||||
|
public static final String CAS = "CAS";
|
||||||
|
public static final String WSFEDERATION = "WsFederation";
|
||||||
|
|
||||||
|
public static final String JWT = "Jwt";
|
||||||
|
|
||||||
|
public static final String HTTPHEADER = "HttpHeader";
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
public final class ConstantsOperateAction {
|
||||||
|
|
||||||
|
public static final int CREATE_ACTION = 1;
|
||||||
|
|
||||||
|
public static final int DELETE_ACTION = 2;
|
||||||
|
|
||||||
|
public static final int UPDATE_ACTION = 3;
|
||||||
|
|
||||||
|
public static final int CHANGE_PASSWORD_ACTION = 4;
|
||||||
|
|
||||||
|
public static final int ADD_MEMBER_ACTION = 5;
|
||||||
|
|
||||||
|
public static final int DELETE_MEMBER_ACTION = 6;
|
||||||
|
|
||||||
|
public static final int VIEW_ACTION = 7;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
public final class ConstantsOperateMessage {
|
||||||
|
|
||||||
|
public static final String INSERT_SUCCESS = "message.action.insert.success";
|
||||||
|
public static final String INSERT_ERROR = "message.action.insert.error";
|
||||||
|
|
||||||
|
public static final String UPDATE_SUCCESS = "message.action.update.success";
|
||||||
|
public static final String UPDATE_ERROR = "message.action.update.error";
|
||||||
|
|
||||||
|
public static final String DELETE_SUCCESS = "message.action.delete.success";
|
||||||
|
public static final String DELETE_ERROR = "message.action.delete.error";
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PASSWORDSETTYPE.
|
||||||
|
* @author Crystal.Sea
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class ConstantsPasswordSetType {
|
||||||
|
|
||||||
|
public static final int PASSWORD_NORMAL = 0;
|
||||||
|
|
||||||
|
public static final int INITIAL_PASSWORD = 1;
|
||||||
|
|
||||||
|
public static final int MANAGER_CHANGED_PASSWORD = 2;
|
||||||
|
|
||||||
|
public static final int PASSWORD_EXPIRED = 3;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PROTOCOLS.
|
||||||
|
* @author Crystal.Sea
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class ConstantsPersistence {
|
||||||
|
|
||||||
|
public static final int INMEMORY = 0;
|
||||||
|
|
||||||
|
public static final int JDBC = 1;
|
||||||
|
|
||||||
|
public static final int REDIS = 2;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
public final class ConstantsPlatformRole {
|
||||||
|
|
||||||
|
public static final String PLATFORM_ADMIN = "PLATFORM_ADMIN";
|
||||||
|
|
||||||
|
public static final String TANANT_ADMIN = "TANANT_ADMIN";
|
||||||
|
|
||||||
|
public static final String ORDINARY_USER = "ORDINARY_USER";
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class ConstantsProperties {
|
||||||
|
|
||||||
|
public static final String applicationPropertySource =
|
||||||
|
"classpath:/application.properties";
|
||||||
|
|
||||||
|
public static final String maxKeyPropertySource =
|
||||||
|
"classpath:/maxkey.properties";
|
||||||
|
|
||||||
|
public static final String kaptchaPropertySource =
|
||||||
|
"classpath:/kaptcha.properties";
|
||||||
|
|
||||||
|
public static String classPathResource(String propertySource) {
|
||||||
|
return propertySource.replaceAll("classpath:","");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void classPathResourceTest() {
|
||||||
|
System.out.println(classPathResource(maxKeyPropertySource));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PROTOCOLS.
|
||||||
|
* @author Crystal.Sea
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class ConstantsProtocols {
|
||||||
|
|
||||||
|
public static final String DESKTOP = "Desktop";
|
||||||
|
|
||||||
|
public static final String BASIC = "Basic";
|
||||||
|
|
||||||
|
public static final String EXTEND_API = "Extend_API";
|
||||||
|
|
||||||
|
public static final String FORMBASED = "Form_Based";
|
||||||
|
|
||||||
|
public static final String TOKENBASED = "Token_Based";
|
||||||
|
|
||||||
|
// OAuth
|
||||||
|
public static final String OAUTH20 = "OAuth_v2.0";
|
||||||
|
// SAML
|
||||||
|
public static final String SAML20 = "SAML_v2.0";
|
||||||
|
|
||||||
|
public static final String OPEN_ID_CONNECT = "OpenID_Connect";
|
||||||
|
|
||||||
|
public static final String CAS = "CAS";
|
||||||
|
|
||||||
|
public static final String JWT = "JWT";
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
public final class ConstantsServiceMessage {
|
||||||
|
|
||||||
|
public static final class EMPLOYEES {
|
||||||
|
public static final String SERVICE_NAME = "employees";
|
||||||
|
public static final String XE00000001 = "XE00000001";
|
||||||
|
public static final String XE00000002 = "XE00000002";
|
||||||
|
public static final String XE00000003 = "XE00000003";
|
||||||
|
public static final String XE00000004 = "XE00000004";
|
||||||
|
public static final String XE00000005 = "XE00000005";
|
||||||
|
public static final String XE00000006 = "XE00000006";
|
||||||
|
public static final String XE00000007 = "XE00000007";
|
||||||
|
public static final String XE00000008 = "XE00000008";
|
||||||
|
|
||||||
|
public static final String XW00000001 = "XW00000001";
|
||||||
|
public static final String XW00000002 = "XW00000002";
|
||||||
|
|
||||||
|
public static final String XS00000001 = "XS00000001";
|
||||||
|
public static final String XS00000002 = "XS00000002";
|
||||||
|
public static final String XS00000003 = "XS00000003";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class ENTERPRISES {
|
||||||
|
public static final String SERVICE_NAME = "enterprises";
|
||||||
|
public static final String XE00000001 = "XE00000001";
|
||||||
|
public static final String XE00000002 = "XE00000002";
|
||||||
|
public static final String XE00000003 = "XE00000003";
|
||||||
|
public static final String XE00000004 = "XE00000004";
|
||||||
|
public static final String XE00000005 = "XE00000005";
|
||||||
|
public static final String XE00000006 = "XE00000006";
|
||||||
|
public static final String XE00000007 = "XE00000007";
|
||||||
|
public static final String XE00000008 = "XE00000008";
|
||||||
|
|
||||||
|
public static final String XS00000001 = "XS00000001";
|
||||||
|
public static final String XS00000002 = "XS00000002";
|
||||||
|
public static final String XS00000003 = "XS00000003";
|
||||||
|
public static final String XS00000004 = "XS00000004";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class RETRIEVEPASSWORD {
|
||||||
|
public static final String SERVICE_NAME = "retrievepassword";
|
||||||
|
public static final String XS00000001 = "XS00000001";
|
||||||
|
public static final String XS00000002 = "XS00000002";
|
||||||
|
public static final String XE00000001 = "XE00000001";
|
||||||
|
public static final String XE00000002 = "XE00000002";
|
||||||
|
public static final String XE00000003 = "XE00000003";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class USERCENTER {
|
||||||
|
public static final String SERVICE_NAME = "usercenter";
|
||||||
|
public static final String XS00000001 = "XS00000001";
|
||||||
|
public static final String XS00000002 = "XS00000002";
|
||||||
|
public static final String XS00000003 = "XS00000003";
|
||||||
|
public static final String XE00000001 = "XE00000001";
|
||||||
|
public static final String XE00000002 = "XE00000002";
|
||||||
|
public static final String XE00000003 = "XE00000003";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class APPLICATIONS {
|
||||||
|
public static final String SERVICE_NAME = "applications";
|
||||||
|
public static final String XS00000001 = "XS00000001";
|
||||||
|
public static final String XS00000002 = "XS00000002";
|
||||||
|
public static final String XS00000003 = "XS00000003";
|
||||||
|
public static final String XS00000004 = "XS00000004";
|
||||||
|
|
||||||
|
public static final String XE00000001 = "XE00000001";
|
||||||
|
public static final String XE00000002 = "XE00000002";
|
||||||
|
public static final String XE00000003 = "XE00000003";
|
||||||
|
public static final String XE00000004 = "XE00000004";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class APPROLES {
|
||||||
|
public static final String SERVICE_NAME = "approles";
|
||||||
|
public static final String XE00000002 = "XE00000002";
|
||||||
|
public static final String XS00000002 = "XS00000002";
|
||||||
|
public static final String XE00000001 = "XE00000001";
|
||||||
|
public static final String XS00000001 = "XS00000001";
|
||||||
|
public static final String XE00000003 = "XE00000003";
|
||||||
|
public static final String XS00000003 = "XS00000003";
|
||||||
|
public static final String XE00000004 = "XE00000004";
|
||||||
|
public static final String XS00000004 = "XS00000004";
|
||||||
|
public static final String XS00000005 = "XS00000005";
|
||||||
|
public static final String XE00000005 = "XE00000005";
|
||||||
|
public static final String XE00000006 = "XE00000006";
|
||||||
|
public static final String XS00000006 = "XS00000006";
|
||||||
|
public static final String XE00000007 = "XE00000007";
|
||||||
|
public static final String XS00000007 = "XS00000007";
|
||||||
|
public static final String XS00000008 = "XS00000008";
|
||||||
|
public static final String XE00000008 = "XE00000008";
|
||||||
|
public static final String XE00000009 = "XE00000009";
|
||||||
|
public static final String XS00000009 = "XS00000009";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class APIUSERS {
|
||||||
|
public static final String SERVICE_NAME = "apiusers";
|
||||||
|
public static final String XS00000003 = "XS00000003";
|
||||||
|
public static final String XE00000003 = "XE00000003";
|
||||||
|
public static final String XW00000001 = "XW00000001";
|
||||||
|
public static final String XW00000002 = "XW00000002";
|
||||||
|
public static final String XS00000001 = "XS00000001";
|
||||||
|
public static final String XE00000001 = "XE00000001";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class PASSWORDPOLICY {
|
||||||
|
public static final String SERVICE_NAME = "passwordpolicy";
|
||||||
|
public static final String XW00000002 = "XW00000002";
|
||||||
|
public static final String XW00000001 = "XW00000001";
|
||||||
|
public static final String XW00000003 = "XW00000003";
|
||||||
|
public static final String XW00000004 = "XW00000004";
|
||||||
|
public static final String XW00000005 = "XW00000005";
|
||||||
|
public static final String XW00000006 = "XW00000006";
|
||||||
|
public static final String XW00000007 = "XW00000007";
|
||||||
|
public static final String XW00000008 = "XW00000008";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
public final class ConstantsStatus {
|
||||||
|
public static final int ACTIVE = 1;
|
||||||
|
|
||||||
|
public static final int INACTIVE = 2;
|
||||||
|
|
||||||
|
public static final int ENABLED = 3;
|
||||||
|
|
||||||
|
public static final int DISABLED = 4;
|
||||||
|
|
||||||
|
public static final int LOCK = 5;
|
||||||
|
|
||||||
|
public static final int UNLOCK = 6;
|
||||||
|
|
||||||
|
public static final int INVALID = 7;
|
||||||
|
|
||||||
|
public static final int EXPIRED = 8;
|
||||||
|
|
||||||
|
public static final int DELETE = 9;
|
||||||
|
|
||||||
|
public static final int VALIDATED = 10;
|
||||||
|
|
||||||
|
public static final int START = 11;
|
||||||
|
|
||||||
|
public static final int STOP = 12;
|
||||||
|
|
||||||
|
public static final int APPROVED = 13;
|
||||||
|
|
||||||
|
public static final int QUITED = 14;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
public final class ConstantsTimeInterval {
|
||||||
|
|
||||||
|
public static final Integer ONE_MINUTE = 60; // 1 minutes
|
||||||
|
|
||||||
|
public static final Integer ONE_HOUR = 60 * 60; // 1 hour
|
||||||
|
|
||||||
|
public static final Integer ONE_DAY = 60 * 60 * 24; // 1 day
|
||||||
|
|
||||||
|
public static final Integer ONE_WEEK = ONE_DAY * 7; // 1 week
|
||||||
|
|
||||||
|
public static final Integer TWO_WEEK = ONE_DAY * 14; // 2 week
|
||||||
|
|
||||||
|
public static final Integer ONE_MONTH = ONE_DAY * 30; // 1 month
|
||||||
|
|
||||||
|
public static final Integer TWO_MONTH = ONE_DAY * 60; // 2 month
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of seconds in one year (= 60 * 60 * 24 * 365).
|
||||||
|
*/
|
||||||
|
public static final Integer ONE_YEAR = 60 * 60 * 24 * 365;
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.constants;
|
||||||
|
|
||||||
|
public class ContentType {
|
||||||
|
|
||||||
|
public static final String TEXT_PLAIN = "text/plain";
|
||||||
|
|
||||||
|
public static final String TEXT_PLAIN_UTF8 = "text/plain;charset=UTF-8";
|
||||||
|
|
||||||
|
public static final String TEXT_XML = "text/xml";
|
||||||
|
|
||||||
|
public static final String TEXT_XML_UTF8 = "text/xml;charset=UTF-8";
|
||||||
|
|
||||||
|
public static final String APPLICATION_JSON = "application/json";
|
||||||
|
|
||||||
|
public static final String APPLICATION_JSON_UTF8 = "application/json;charset=UTF-8";
|
||||||
|
|
||||||
|
public static final String APPLICATION_JWT = "application/jwt";
|
||||||
|
|
||||||
|
public static final String APPLICATION_JWT_UTF8 = "application/jwt;charset=UTF-8";
|
||||||
|
|
||||||
|
public static final String APPLICATION_XML = "application/xml";
|
||||||
|
|
||||||
|
public static final String APPLICATION_XML_UTF8 = "application/xml;charset=UTF-8";
|
||||||
|
|
||||||
|
public static final String IMAGE_GIF = "image/gif";
|
||||||
|
|
||||||
|
public static final String IMAGE_JPEG = "image/jpeg";
|
||||||
|
|
||||||
|
public static final String IMAGE_PNG = "image/png";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -23,7 +23,6 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.maxkey.crypto.jwt.signer.service.JwtSigningAndValidationService;
|
import org.maxkey.crypto.jwt.signer.service.JwtSigningAndValidationService;
|
||||||
import org.maxkey.domain.apps.oauth2.provider.ClientDetails;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -67,20 +66,20 @@ public class SymmetricCacheService {
|
|||||||
* @param client
|
* @param client
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public JwtSigningAndValidationService getSymmetricValidtor(ClientDetails client) {
|
public JwtSigningAndValidationService getSymmetricValidtor(String clientSecret) {
|
||||||
|
|
||||||
if (client == null) {
|
if (clientSecret == null) {
|
||||||
logger.error("Couldn't create symmetric validator for null client");
|
logger.error("Couldn't create symmetric validator for null client");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Strings.isNullOrEmpty(client.getClientSecret())) {
|
if (Strings.isNullOrEmpty(clientSecret)) {
|
||||||
logger.error("Couldn't create symmetric validator for client " + client.getClientId() + " without a client secret");
|
logger.error("Couldn't create symmetric validator for client without a client secret");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return validators.get(client.getClientSecret());
|
return validators.get(clientSecret);
|
||||||
} catch (UncheckedExecutionException ue) {
|
} catch (UncheckedExecutionException ue) {
|
||||||
logger.error("Problem loading client validator", ue);
|
logger.error("Problem loading client validator", ue);
|
||||||
return null;
|
return null;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user