/*
* 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
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
完整的电力系统项目 (1273个子文件)
version-1.6.2.aar 8KB
FileUtils.class 22KB
ElecUserServiceImpl.class 11KB
FileUploadCommand.class 11KB
InitCommand.class 10KB
Configuration.class 10KB
ElecRoleServiceImpl.class 9KB
MoveFilesCommand.class 8KB
CopyFilesCommand.class 8KB
MD5keyBean.class 8KB
FindSystemByKeywordResponse.class 7KB
FindSystemByKeyword.class 7KB
ElecUserAction.class 7KB
IWebSystemDDLServiceMessageReceiverInOut.class 7KB
ElecUser.class 7KB
LuceneUtils.class 7KB
ConnectorServlet.class 7KB
ImageUtils.class 7KB
GetFilesCommand.class 7KB
ErrorUtils.class 6KB
AccessControlUtil.class 6KB
DeleteFilesCommand.class 6KB
ElecFileUploadServiceImpl.class 6KB
ElecApplicationFlowServiceImpl.class 5KB
CommonDaoImpl.class 5KB
GetFoldersCommand.class 5KB
RenameFileCommand.class 5KB
CKFinderTag.class 5KB
RenameFolderCommand.class 5KB
ElecApplication.class 5KB
ConnectorServlet$CommandHandlerEnum.class 5KB
ElecProcessDefinitionServiceImpl.class 5KB
XMLCreator.class 4KB
FileUploadFilter.class 4KB
ElecSystemDDLServiceImpl.class 4KB
XMLCommand.class 4KB
CreateFolderCommand.class 4KB
Events.class 4KB
ThumbnailCommand.class 4KB
ExcelFileGenerator.class 4KB
DownloadFileCommand.class 4KB
ElecMenuAction.class 4KB
ErrorCommand.class 3KB
ElecApplicationFlowAction.class 3KB
GenerateSqlFromExcel.class 3KB
FindSystemByKeywordResponse$Factory.class 3KB
TestDao.class 3KB
FindSystemByKeyword$Factory.class 3KB
IWebSystemDDLServiceSkeleton.class 3KB
ResourceType.class 3KB
Command.class 3KB
ElecTextServiceImpl.class 3KB
XMLErrorCommand.class 3KB
SystemFilter.class 3KB
ElecFileUpload.class 3KB
XmlElementData.class 3KB
ElecApplicationTemplateAction.class 3KB
IConfiguration.class 3KB
DeleteFolderCommand.class 3KB
AccessControlUtil$ACLEntry.class 3KB
AccessControlLevel.class 3KB
CKFinderSetupCKEditor.class 3KB
ElecApplicationTemplateServiceImpl.class 3KB
ElecPopedom.class 3KB
ElecProcessDefinitionAction.class 3KB
QuickUploadCommand.class 3KB
ElecApplicationTemplate.class 3KB
TestService.class 2KB
BaseAction.class 2KB
ElecFileUploadAction.class 2KB
ElecApplicationVariables.class 2KB
FileUploadDocument.class 2KB
ConfigurationFactory.class 2KB
PageInfo.class 2KB
ElecCommonMsgServiceImpl.class 2KB
NaturalOrderComparator.class 2KB
BeforeExecuteCommandEventArgs.class 2KB
Constants$Errors.class 2KB
LoadCookiesCommand.class 2KB
TestHibernateCache.class 2KB
ElecCommonMsgAction.class 2KB
ElecApproveInfo.class 2KB
ElecSystemDDL.class 2KB
PathUtils.class 2KB
ConnectorException.class 2KB
ElecSystemDDLDaoImpl.class 2KB
LogonUtils.class 2KB
ElecExportFieldsServiceImpl.class 2KB
PluginInfo.class 2KB
ElecRoleAction.class 2KB
ConditionalTagUtil.class 2KB
ElecExportFieldsAction.class 2KB
IElecUserService.class 2KB
ElecSystemDDLAction.class 2KB
TestHibernate.class 1KB
PageBean.class 1KB
ElecExportFields.class 1KB
DefaultPathBuilder.class 1KB
TestHibernateJbpm.class 1KB
ICommonDao.class 1KB
共 1273 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
- qq_413474832018-11-26想问一下运行了以后,点登录为什么没有办法进入系统首页呢,一直都是出来一个锤子? 急需!!!救救孩子吧
- 蹲在路边啃螃蟹2019-09-12并不能使用
- heidou_11232019-01-15并不能进入
phenaibo
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功