/*
* CKFinder
* ========
* http://ckfinder.com
* Copyright (C) 2007-2013, CKSource - Frederico Knabben. All rights reserved.
*
* The software, this file and its contents are subject to the CKFinder
* License. Please read the license.txt file before using, installing, copying,
* modifying or distribute this file or part of its contents. The contents of
* this file is part of the Source Code of CKFinder.
*/
package com.ckfinder.connector.configuration;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.ckfinder.connector.ServletContextFactory;
import com.ckfinder.connector.data.AccessControlLevel;
import com.ckfinder.connector.data.PluginInfo;
import com.ckfinder.connector.data.PluginParam;
import com.ckfinder.connector.data.ResourceType;
import com.ckfinder.connector.utils.FileUtils;
import com.ckfinder.connector.utils.PathUtils;
/**
* Loads configuration from XML.a
*/
public class Configuration implements IConfiguration {
protected static final int MAX_QUALITY = 100;
protected static final float MAX_QUALITY_FLOAT = 100f;
private long lastCfgModificationDate;
protected boolean enabled;
protected String xmlFilePath;
protected String baseDir;
protected String baseURL;
protected String licenseName;
protected String licenseKey;
protected Integer imgWidth;
protected Integer imgHeight;
protected float imgQuality;
protected Map<String, ResourceType> types;
protected ArrayList<String> typesOrder;
protected boolean thumbsEnabled;
protected String thumbsURL;
protected String thumbsDir;
protected String thumbsPath;
protected boolean thumbsDirectAccess;
protected Integer thumbsMaxHeight;
protected Integer thumbsMaxWidth;
protected float thumbsQuality;
protected List<AccessControlLevel> accessControlLevels;
protected List<String> hiddenFolders;
protected List<String> hiddenFiles;
protected boolean doubleExtensions;
protected boolean forceASCII;
protected boolean checkSizeAfterScaling;
protected String uriEncoding;
protected String userRoleSessionVar;
protected List<PluginInfo> plugins;
protected boolean secureImageUploads;
protected List<String> htmlExtensions;
protected List<String> defaultResourceTypes;
protected IBasePathBuilder basePathBuilder;
protected boolean disallowUnsafeCharacters;
private boolean loading;
private Events events;
private boolean debug;
protected ServletConfig servletConf;
/**
* Constructor.
*
* @param servletConfig servlet config to get parameters from web-xml
*/
public Configuration(final ServletConfig servletConfig) {
this.servletConf = servletConfig;
this.xmlFilePath = servletConfig.getInitParameter("XMLConfig");
this.plugins = new ArrayList<PluginInfo>();
this.htmlExtensions = new ArrayList<String>();
this.hiddenFolders = new ArrayList<String>();
this.hiddenFiles = new ArrayList<String>();
this.defaultResourceTypes = new ArrayList<String>();
}
/**
* clears all configuration values.
*/
private void clearConfiguration() {
this.debug = false;
this.enabled = false;
this.baseDir = "";
this.baseURL = "";
this.licenseName = "";
this.licenseKey = "";
this.imgWidth = DEFAULT_IMG_WIDTH;
this.imgHeight = DEFAULT_IMG_HEIGHT;
this.imgQuality = DEFAULT_IMG_QUALITY;
this.types = new HashMap<String, ResourceType>();
this.typesOrder = new ArrayList<String>();
this.thumbsEnabled = false;
this.thumbsURL = "";
this.thumbsDir = "";
this.thumbsPath = "";
this.thumbsQuality = DEFAULT_IMG_QUALITY;
this.thumbsDirectAccess = false;
this.thumbsMaxHeight = DEFAULT_THUMB_MAX_HEIGHT;
this.thumbsMaxWidth = DEFAULT_THUMB_MAX_WIDTH;
this.accessControlLevels = new ArrayList<AccessControlLevel>();
this.hiddenFolders = new ArrayList<String>();
this.hiddenFiles = new ArrayList<String>();
this.doubleExtensions = false;
this.forceASCII = false;
this.checkSizeAfterScaling = false;
this.uriEncoding = DEFAULT_URI_ENCODING;
this.userRoleSessionVar = "";
this.plugins = new ArrayList<PluginInfo>();
this.secureImageUploads = false;
this.htmlExtensions = new ArrayList<String>();
this.defaultResourceTypes = new ArrayList<String>();
this.events = new Events();
this.basePathBuilder = null;
this.disallowUnsafeCharacters = false;
}
/**
* initialize configuration from XML config file.
*
* @throws Exception when error occurs.
*/
public void init() throws Exception {
clearConfiguration();
this.loading = true;
File file = new File(getFullConfigPath());
this.lastCfgModificationDate = file.lastModified();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(file);
doc.normalize();
Node node = doc.getFirstChild();
if (node != null) {
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeName().equals("enabled")) {
this.enabled = Boolean.valueOf(childNode.getTextContent().trim());
}
if (childNode.getNodeName().equals("baseDir")) {
this.baseDir = childNode.getTextContent().trim();
this.baseDir = PathUtils.escape(this.baseDir);
this.baseDir = PathUtils.addSlashToEnd(this.baseDir);
}
if (childNode.getNodeName().equals("baseURL")) {
this.baseURL = childNode.getTextContent().trim();
this.baseURL = PathUtils.escape(baseURL);
this.baseURL = PathUtils.addSlashToEnd(this.baseURL);
}
if (childNode.getNodeName().equals("licenseName")) {
this.licenseName = childNode.getTextContent().trim();
}
if (childNode.getNodeName().equals("licenseKey")) {
this.licenseKey = childNode.getTextContent().trim();
}
if (childNode.getNodeName().equals("imgWidth")) {
String width = childNode.getTextContent().trim();
width = width.replaceAll("//D", "");
try {
this.imgWidth = Integer.valueOf(width);
} catch (NumberFormatException e) {
this.imgWidth = null;
}
}
if (childNode.getNodeName().equals("imgQuality")) {
String quality = childNode.getTextContent().trim();
quality = quality.replaceAll("//D", "");
this.imgQuality = adjustQuality(quality);
}
if (childNode.getNodeName().equals("imgHeight")) {
String height = childNode.getTextContent().trim();
height = height.replaceAll("//D", "");
try {
this.imgHeight = Integer.valueOf(height);
} catch (NumberFormatException e) {
this.imgHeight = null;
}
}
if (childNode.getNodeName().equals("thumbs")) {
setThumbs(childNode.getChildNodes());
}
if (childNode.getNodeName().equals("accessControls")) {
setACLs(childNode.getChildNodes());
}
if (childNode.getNodeName().equals("hideFolders")) {
setHiddenFolders(childNode.getChildNodes());
}
if (childNode.getNodeName().equals("hideFiles")) {
setHiddenFiles(childNode.getChildNodes());
}
if (childNode.getNodeName().equals("checkDoubleExtension")) {
this.doubleExtensions = Boolean.valueOf(childNode.getTextContent().trim());
}
if (childNode.getNodeName().equals("disallowUnsafeCharacters")) {
this.disallowUnsafeCharacters = Boolean.valueOf(childNode.getTextContent().trim());
}
if (childNode.getNodeName().equals("forceASCII")) {
this.forceASCII = Boolean.valueOf(childNode
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
国家电力项目源码.zip (1232个子文件)
version-1.6.2.aar 8KB
Configuration.class 21KB
FileUtils.class 21KB
ElecApplicationFlowServiceImpl.class 15KB
FileUploadCommand.class 14KB
ElecUserServiceImpl.class 11KB
ElecUserAction.class 10KB
InitCommand.class 9KB
MoveFilesCommand.class 9KB
CopyFilesCommand.class 9KB
ElecRoleServiceImpl.class 8KB
MD5keyBean.class 8KB
ConnectorServlet.class 7KB
ElecUser.class 7KB
FindSystemByKeywordResponse.class 7KB
FindSystemByKeyword.class 7KB
IWebSystemDDLServiceMessageReceiverInOut.class 7KB
CKFinderTag.class 7KB
ElecMenuAction.class 7KB
ThumbnailCommand.class 7KB
LuceneUtils.class 7KB
CommonDaoImpl.class 7KB
ImageUtils.class 7KB
ElecApplicationFlowAction.class 6KB
GetFilesCommand.class 6KB
ErrorUtils.class 6KB
DeleteFilesCommand.class 6KB
AccessControlUtil.class 6KB
ConnectorServlet$CommandHandlerEnum.class 5KB
ElecFileUploadServiceImpl.class 5KB
Command.class 5KB
ElecApplication.class 5KB
ConfigurationFactory.class 5KB
DownloadFileCommand.class 5KB
RenameFileCommand.class 5KB
ErrorAndLimitInterceptor.class 5KB
RenameFolderCommand.class 5KB
GetFoldersCommand.class 5KB
ElecProcessDefinitionServiceImpl.class 5KB
XMLCommand.class 4KB
SystemFilter.class 4KB
ElecApplicationTemplateAction.class 4KB
XMLCreator.class 4KB
ElecSystemDDLServiceImpl.class 4KB
ErrorCommand.class 4KB
ElecFileUploadAction.class 4KB
CreateFolderCommand.class 4KB
XMLErrorCommand.class 4KB
ElecApplicationTemplateServiceImpl.class 4KB
Events.class 4KB
ExcelFileGenerator.class 4KB
LoadCookiesCommand.class 3KB
TestDao.class 3KB
FindSystemByKeywordResponse$Factory.class 3KB
ElecCommonMsgAction.class 3KB
PageInfo.class 3KB
ResourceType.class 3KB
FindSystemByKeyword$Factory.class 3KB
IWebSystemDDLServiceSkeleton.class 3KB
ElecFileUploadDaoImpl.class 3KB
GenerateSqlFromExcel.class 3KB
FileUploadFilter.class 3KB
ElecTextServiceImpl.class 3KB
ElecFileUpload.class 3KB
CKFinderSetupCKEditor.class 3KB
XmlElementData.class 3KB
ElecExportFieldsAction.class 3KB
AccessControlLevel.class 3KB
ElecProcessDefinitionAction.class 3KB
AccessControlUtil$ACLEntry.class 3KB
ElecPopedom.class 3KB
ElecSystemDDLDaoImpl.class 3KB
ElecApplicationTemplate.class 3KB
IConfiguration.class 3KB
DeleteFolderCommand.class 3KB
QuickUploadCommand.class 3KB
TestService.class 2KB
ElecApplicationVariables.class 2KB
LogonUtils.class 2KB
FileUploadDocument.class 2KB
ElecRoleAction.class 2KB
ElecCommonMsgServiceImpl.class 2KB
Constants$Errors.class 2KB
NaturalOrderComparator.class 2KB
TestHibernateCache.class 2KB
FileUploadUtils.class 2KB
ElecSystemDDLAction.class 2KB
ElecApproveInfo.class 2KB
ElecSystemDDL.class 2KB
CommonDaoImpl$3.class 2KB
ElecFileUploadDaoImpl$1.class 2KB
BaseAction.class 2KB
PathUtils.class 2KB
ConnectorException.class 2KB
ElecSystemDDLDaoImpl$1.class 2KB
ElecExportFieldsServiceImpl.class 2KB
PluginInfo.class 2KB
ConfigurationPathBuilder.class 2KB
ElecUserDaoImpl.class 2KB
DefaultPathBuilder.class 2KB
共 1232 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
- weixin_468715772021-05-25假的不能用
hzldds2019
- 粉丝: 112
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功