修复:修复TrustHost静态注入问题
parent
b90e326eec
commit
9c096605bb
|
@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,95 +17,94 @@ import java.util.Set;
|
||||||
@Component
|
@Component
|
||||||
public class ConfigConstants {
|
public class ConfigConstants {
|
||||||
|
|
||||||
private static Boolean cacheEnabled;
|
private static Boolean CACHE_ENABLED;
|
||||||
private static String[] simText = {};
|
private static String[] SIM_TEXT = {};
|
||||||
private static String[] media = {};
|
private static String[] MEDIA = {};
|
||||||
private static String officePreviewType;
|
private static String OFFICE_PREVIEW_TYPE;
|
||||||
private static String ftpUsername;
|
private static String FTP_USERNAME;
|
||||||
private static String ftpPassword;
|
private static String FTP_PASSWORD;
|
||||||
private static String ftpControlEncoding;
|
private static String FTP_CONTROL_ENCODING;
|
||||||
private static String fileDir = OfficeUtils.getHomePath() + File.separator + "file" + File.separator;
|
private static String BASE_URL;
|
||||||
private static String baseUrl;
|
private static String FILE_DIR = OfficeUtils.getHomePath() + File.separator + "file" + File.separator;
|
||||||
private static String trustHost;
|
private static CopyOnWriteArraySet<String> TRUST_HOST_SET;
|
||||||
private static Set<String> trustHostSet;
|
|
||||||
|
|
||||||
public static final String DEFAULT_CACHE_ENABLED = "true";
|
public static final String DEFAULT_CACHE_ENABLED = "true";
|
||||||
public static final String DEFAULT_TXT_TYPE = "txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd";
|
public static final String DEFAULT_TXT_TYPE = "txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd";
|
||||||
public static final String DEFAULT_MEDIA_TYPE = "mp3,wav,mp4,flv";
|
public static final String DEFAULT_MEDIA_TYPE = "mp3,wav,mp4,flv";
|
||||||
public static final String DEFAULT_FILE_DIR_VALUE = "default";
|
public static final String DEFAULT_OFFICE_PREVIEW_TYPE = "image";
|
||||||
public static final String DEFAULT_FTP_USERNAME = null;
|
public static final String DEFAULT_FTP_USERNAME = null;
|
||||||
public static final String DEFAULT_FTP_PASSWORD = null;
|
public static final String DEFAULT_FTP_PASSWORD = null;
|
||||||
public static final String DEFAULT_FTP_CONTROL_ENCODING = "UTF-8";
|
public static final String DEFAULT_FTP_CONTROL_ENCODING = "UTF-8";
|
||||||
public static final String DEFAULT_OFFICE_PREVIEW_TYPE = "image";
|
|
||||||
public static final String DEFAULT_BASE_URL = "default";
|
public static final String DEFAULT_BASE_URL = "default";
|
||||||
|
public static final String DEFAULT_FILE_DIR_VALUE = "default";
|
||||||
public static final String DEFAULT_TRUST_HOST = "default";
|
public static final String DEFAULT_TRUST_HOST = "default";
|
||||||
|
|
||||||
public static Boolean isCacheEnabled() {
|
public static Boolean isCacheEnabled() {
|
||||||
return cacheEnabled;
|
return CACHE_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCacheEnabled(Boolean cacheEnabled) {
|
public static void setCacheEnabled(Boolean cacheEnabled) {
|
||||||
ConfigConstants.cacheEnabled = cacheEnabled;
|
CACHE_ENABLED = cacheEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getSimText() {
|
public static String[] getSimText() {
|
||||||
return simText;
|
return SIM_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSimText(String[] simText) {
|
public static void setSimText(String[] simText) {
|
||||||
ConfigConstants.simText = simText;
|
SIM_TEXT = simText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getMedia() {
|
public static String[] getMedia() {
|
||||||
return media;
|
return MEDIA;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMedia(String[] media) {
|
public static void setMedia(String[] Media) {
|
||||||
ConfigConstants.media = media;
|
ConfigConstants.MEDIA = Media;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getOfficePreviewType() {
|
public static String getOfficePreviewType() {
|
||||||
return officePreviewType;
|
return OFFICE_PREVIEW_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setOfficePreviewType(String officePreviewType) {
|
public static void setOfficePreviewType(String officePreviewType) {
|
||||||
ConfigConstants.officePreviewType = officePreviewType;
|
OFFICE_PREVIEW_TYPE = officePreviewType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFtpUsername() {
|
public static String getFtpUsername() {
|
||||||
return ftpUsername;
|
return FTP_USERNAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFtpUsername(String ftpUsername) {
|
public static void setFtpUsername(String ftpUsername) {
|
||||||
ConfigConstants.ftpUsername = ftpUsername;
|
FTP_USERNAME = ftpUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFtpPassword() {
|
public static String getFtpPassword() {
|
||||||
return ftpPassword;
|
return FTP_PASSWORD;
|
||||||
}
|
|
||||||
|
|
||||||
public static String getFtpControlEncoding() {
|
|
||||||
return ftpControlEncoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setFtpControlEncoding(String ftpControlEncoding) {
|
|
||||||
ConfigConstants.ftpControlEncoding = ftpControlEncoding;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFtpPassword(String ftpPassword) {
|
public static void setFtpPassword(String ftpPassword) {
|
||||||
ConfigConstants.ftpPassword = ftpPassword;
|
FTP_PASSWORD = ftpPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFileDir() {
|
public static String getFtpControlEncoding() {
|
||||||
return fileDir;
|
return FTP_CONTROL_ENCODING;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFtpControlEncoding(String ftpControlEncoding) {
|
||||||
|
FTP_CONTROL_ENCODING = ftpControlEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getBaseUrl() {
|
public static String getBaseUrl() {
|
||||||
return baseUrl;
|
return BASE_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBaseUrl(String baseUrl) {
|
public static void setBaseUrl(String baseUrl) {
|
||||||
ConfigConstants.baseUrl = baseUrl;
|
BASE_URL = baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFileDir() {
|
||||||
|
return FILE_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${file.dir:default}")
|
@Value("${file.dir:default}")
|
||||||
|
@ -114,33 +113,32 @@ public class ConfigConstants {
|
||||||
if (!fileDir.endsWith(File.separator)) {
|
if (!fileDir.endsWith(File.separator)) {
|
||||||
fileDir = fileDir + File.separator;
|
fileDir = fileDir + File.separator;
|
||||||
}
|
}
|
||||||
ConfigConstants.fileDir = fileDir;
|
FILE_DIR = fileDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getTrustHost() {
|
|
||||||
return trustHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Value("${trust.host:default}")
|
@Value("${trust.host:default}")
|
||||||
static void setTrustHost(String trustHost) {
|
public void setTrustHostStr(String trustHost) {
|
||||||
ConfigConstants.trustHost = trustHost;
|
setTrustHost(trustHost);
|
||||||
Set<String> trustHostSet;
|
}
|
||||||
|
|
||||||
|
public static void setTrustHost(String trustHost) {
|
||||||
|
CopyOnWriteArraySet<String> trustHostSet;
|
||||||
if (DEFAULT_TRUST_HOST.equals(trustHost.toLowerCase())) {
|
if (DEFAULT_TRUST_HOST.equals(trustHost.toLowerCase())) {
|
||||||
trustHostSet = new HashSet<>();
|
trustHostSet = new CopyOnWriteArraySet<>();
|
||||||
} else {
|
} else {
|
||||||
String[] trustHostArray = trustHost.toLowerCase().split(",");
|
String[] trustHostArray = trustHost.toLowerCase().split(",");
|
||||||
trustHostSet = new HashSet<>(Arrays.asList(trustHostArray));
|
trustHostSet = new CopyOnWriteArraySet<>(Arrays.asList(trustHostArray));
|
||||||
ConfigConstants.setTrustHostSet(trustHostSet);
|
setTrustHostSet(trustHostSet);
|
||||||
}
|
}
|
||||||
ConfigConstants.setTrustHostSet(trustHostSet);
|
setTrustHostSet(trustHostSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getTrustHostSet() {
|
public static Set<String> getTrustHostSet() {
|
||||||
return trustHostSet;
|
return TRUST_HOST_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setTrustHostSet(Set<String> trustHostSet) {
|
private static void setTrustHostSet(CopyOnWriteArraySet<String> trustHostSet) {
|
||||||
ConfigConstants.trustHostSet = trustHostSet;
|
ConfigConstants.TRUST_HOST_SET = trustHostSet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue