/*
* CKFinder
* ========
* http://ckfinder.com
* Copyright (C) 2007-2012, 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());
}
没有合适的资源?快使用搜索试试~ 我知道了~
ckeditor(包含java包)要改配置jar包可以下载
共149个文件
class:68个
java:61个
jar:8个
4星 · 超过85%的资源 需积分: 13 9 下载量 33 浏览量
2013-03-09
10:42:01
上传
评论 1
收藏 1.1MB RAR 举报
温馨提示
ckeditor(包含java包)要改配置jar包可以下载 这个丰富的东东,简单易用
资源推荐
资源详情
资源评论
收起资源包目录
ckeditor(包含java包)要改配置jar包可以下载 (149个子文件)
Configuration.class 22KB
FileUtils.class 21KB
FileUploadCommand.class 14KB
InitCommand.class 10KB
MoveFilesCommand.class 9KB
CopyFilesCommand.class 9KB
ConnectorServlet.class 8KB
CKFinderTag.class 8KB
ImageUtils.class 7KB
ThumbnailCommand.class 7KB
GetFilesCommand.class 6KB
ErrorUtils.class 6KB
DeleteFilesCommand.class 6KB
AccessControlUtil.class 6KB
ConnectorServlet$CommandHandlerEnum.class 6KB
Command.class 5KB
ConfigurationFactory.class 5KB
DownloadFileCommand.class 5KB
RenameFolderCommand.class 5KB
RenameFileCommand.class 5KB
GetFoldersCommand.class 5KB
XMLCommand.class 4KB
XMLCreator.class 4KB
ErrorCommand.class 4KB
CreateFolderCommand.class 4KB
Events.class 4KB
XMLErrorCommand.class 4KB
LoadCookiesCommand.class 4KB
ResourceType.class 3KB
FileUploadFilter.class 3KB
CKFinderSetupCKEditor.class 3KB
XmlElementData.class 3KB
AccessControlUtil$ACLEntry.class 3KB
AccessControlLevel.class 3KB
DeleteFolderCommand.class 3KB
QuickUploadCommand.class 3KB
IConfiguration.class 3KB
NaturalOrderComparator.class 2KB
Constants$Errors.class 2KB
PathUtils.class 2KB
ConnectorException.class 2KB
ConfigurationPathBuilder.class 2KB
DefaultPathBuilder.class 2KB
PluginInfo.class 2KB
Events$EventTypes.class 1KB
BeforeExecuteCommandEventArgs.class 1KB
EventCommandData.class 1KB
XMLCreator$ErrorNode.class 1KB
FilePostParam.class 1KB
AfterFileUploadEventArgs.class 1KB
Constants.class 1018B
InitCommandEventArgs.class 958B
AccessControlUtil$CheckEntry.class 948B
XmlAttribute.class 849B
ServletContextFactory.class 829B
FileUtils$1.class 783B
PluginParam.class 749B
Plugin.class 612B
IEventHandler.class 336B
EventArgs.class 308B
IBasePathBuilder.class 254B
package-info.class 145B
IPostCommand.class 145B
package-info.class 142B
package-info.class 135B
package-info.class 134B
package-info.class 133B
package-info.class 128B
.classpath 529B
org.eclipse.wst.common.component 462B
org.eclipse.wst.jsdt.ui.superType.container 49B
mail-1.4.1.jar 437KB
CKFinder-2.3.jar 164KB
commons-io-2.0.1.jar 156KB
thumbnailator-0.4.2.jar 89KB
activation-1.1.jar 62KB
commons-fileupload-1.2.2.jar 58KB
CKFinderPlugin-ImageResize-2.3.jar 9KB
CKFinderPlugin-FileEditor-2.3.jar 3KB
Configuration.java 32KB
FileUtils.java 28KB
FileUploadCommand.java 17KB
ConnectorServlet.java 13KB
CopyFilesCommand.java 11KB
MoveFilesCommand.java 11KB
CKFinderTag.java 10KB
ImageUtils.java 9KB
InitCommand.java 9KB
AccessControlUtil.java 8KB
ThumbnailCommand.java 8KB
DeleteFilesCommand.java 7KB
Command.java 7KB
IConfiguration.java 7KB
GetFilesCommand.java 6KB
ErrorUtils.java 6KB
ConfigurationFactory.java 5KB
RenameFileCommand.java 5KB
XMLCreator.java 5KB
ResourceType.java 5KB
DownloadFileCommand.java 5KB
共 149 条
- 1
- 2
资源评论
- wangyang3192014-07-23可以用,多谢分享!
客栈
- 粉丝: 16
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- AIS2024 valid
- 最入门的爬虫代码 python.docx
- 爬虫零基础入门-爬取天气预报.pdf
- 最通俗易懂的 MongoDB 非结构化文档存储数据库教程.zip
- 以mongodb为数据库的订单物流小项目.zip
- 腾讯云-mongodb数据库, 项目部署.zip
- 腾讯 APIJSON 的 MongoDB 数据库插件.zip
- 理解非关系型数据库和关系型数据库的区别.zip
- 操作简单的Mongodb网页web管理工具,基于Spring Boot2.0支持mongodb集群.zip
- tms-mongodb-web,提供访问mongodb数据的REST API和可灵活扩展的mongodb web 客户端.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功