0a24c7d40cf315b00144c49929ddff378dd2ae6d.svn-base
2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.common.web;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.utils.FileUtils;
import com.thinkgem.jeesite.modules.sys.security.SystemAuthorizingRealm.Principal;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import com.ckfinder.connector.configuration.Configuration;
import com.ckfinder.connector.data.AccessControlLevel;
import com.ckfinder.connector.utils.AccessControlUtil;
/**
* CKFinder配置
* @author ThinkGem
* @version 2014-06-25
*/
public class CKFinderConfig extends Configuration {
public CKFinderConfig(ServletConfig servletConfig) {
super(servletConfig);
}
@Override
protected Configuration createConfigurationInstance() {
Principal principal = (Principal) UserUtils.getPrincipal();
if (principal == null){
return new CKFinderConfig(this.servletConf);
}
boolean isView = true;//UserUtils.getSubject().isPermitted("cms:ckfinder:view");
boolean isUpload = true;//UserUtils.getSubject().isPermitted("cms:ckfinder:upload");
boolean isEdit = true;//UserUtils.getSubject().isPermitted("cms:ckfinder:edit");
AccessControlLevel alc = this.getAccessConrolLevels().get(0);
alc.setFolderView(isView);
alc.setFolderCreate(isEdit);
alc.setFolderRename(false);
alc.setFolderDelete(false);
alc.setFileView(isView);
alc.setFileUpload(isUpload);
alc.setFileRename(isEdit);
alc.setFileDelete(isEdit);
// for (AccessControlLevel a : this.getAccessConrolLevels()){
// System.out.println(a.getRole()+", "+a.getResourceType()+", "+a.getFolder()
// +", "+a.isFolderView()+", "+a.isFolderCreate()+", "+a.isFolderRename()+", "+a.isFolderDelete()
// +", "+a.isFileView()+", "+a.isFileUpload()+", "+a.isFileRename()+", "+a.isFileDelete());
// }
AccessControlUtil.getInstance(this).loadACLConfig();
try {
// Principal principal = (Principal)SecurityUtils.getSubject().getPrincipal();
// this.baseURL = ServletContextFactory.getServletContext().getContextPath()+"/userfiles/"+principal+"/";
this.baseURL = FileUtils.path(Servlets.getRequest().getContextPath() + Global.USERFILES_BASE_URL + principal + "/");
this.baseDir = FileUtils.path(Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL + principal + "/");
} catch (Exception e) {
throw new RuntimeException(e);
}
return new CKFinderConfig(this.servletConf);
}
@Override
public boolean checkAuthentication(final HttpServletRequest request) {
return UserUtils.getPrincipal()!=null;
}
}