Source Code Cross Referenced for ZipscriptConfig.java in  » Net » DrFTPD » net » sf » drftpd » master » config » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » DrFTPD » net.sf.drftpd.master.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of DrFTPD, Distributed FTP Daemon.
003:         *
004:         * DrFTPD is free software; you can redistribute it and/or modify
005:         * it under the terms of the GNU General Public License as published by
006:         * the Free Software Foundation; either version 2 of the License, or
007:         * (at your option) any later version.
008:         *
009:         * DrFTPD is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         * GNU General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU General Public License
015:         * along with DrFTPD; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:        package net.sf.drftpd.master.config;
019:
020:        import java.io.FileInputStream;
021:        import java.io.IOException;
022:        import java.util.Properties;
023:
024:        import net.sf.drftpd.master.config.FtpConfig;
025:
026:        import org.apache.log4j.Logger;
027:        import org.apache.oro.text.GlobCompiler;
028:        import org.apache.oro.text.regex.MalformedPatternException;
029:        import org.drftpd.GlobalContext;
030:        import org.drftpd.permissions.GlobPathPermission;
031:        import org.drftpd.remotefile.LinkedRemoteFileInterface;
032:        import org.drftpd.usermanager.User;
033:
034:        import com.Ostermiller.util.StringTokenizer;
035:
036:        /**
037:         * @author Teflon
038:         * @version $Id$
039:         */
040:        public class ZipscriptConfig {
041:            private static final Logger logger = Logger
042:                    .getLogger(ZipscriptConfig.class);
043:
044:            protected GlobalContext _gctx;
045:
046:            private String zsConf = "conf/zipscript.conf";
047:
048:            private boolean _statusBarEnabled;
049:
050:            private boolean _offlineFilesEnabled;
051:
052:            private boolean _missingFilesEnabled;
053:
054:            private boolean _id3Enabled;
055:
056:            private boolean _dizEnabled;
057:
058:            private boolean _raceStatsEnabled;
059:
060:            private boolean _restrictSfvEnabled;
061:
062:            private boolean _multiSfvAllowed;
063:
064:            private boolean _SfvFirstRequired;
065:
066:            private boolean _SfvFirstAllowNoExt;
067:
068:            private String _AllowedExts;
069:
070:            private String _SfvFirstUsers;
071:
072:            public ZipscriptConfig(GlobalContext gctx) throws IOException {
073:                _gctx = gctx;
074:                Properties cfg = new Properties();
075:                FileInputStream stream = null;
076:                try {
077:                    stream = new FileInputStream(zsConf);
078:                    cfg.load(stream);
079:                    loadConfig(cfg);
080:                } finally {
081:                    if (stream != null) {
082:                        stream.close();
083:                    }
084:                }
085:            }
086:
087:            public void loadConfig(Properties cfg) throws IOException {
088:                _statusBarEnabled = cfg.getProperty("statusbar.enabled") == null ? true
089:                        : cfg.getProperty("statusbar.enabled")
090:                                .equalsIgnoreCase("true");
091:                _offlineFilesEnabled = cfg.getProperty("files.offline.enabled") == null ? true
092:                        : cfg.getProperty("files.offline.enabled")
093:                                .equalsIgnoreCase("true");
094:                _missingFilesEnabled = cfg.getProperty("files.missing.enabled") == null ? true
095:                        : cfg.getProperty("files.missing.enabled")
096:                                .equalsIgnoreCase("true");
097:                _id3Enabled = cfg.getProperty("cwd.id3info.enabled") == null ? true
098:                        : cfg.getProperty("cwd.id3info.enabled")
099:                                .equalsIgnoreCase("true");
100:                _dizEnabled = cfg.getProperty("cwd.dizinfo.enabled") == null ? true
101:                        : cfg.getProperty("cwd.dizinfo.enabled")
102:                                .equalsIgnoreCase("true");
103:                _raceStatsEnabled = cfg.getProperty("cwd.racestats.enabled") == null ? true
104:                        : cfg.getProperty("cwd.racestats.enabled")
105:                                .equalsIgnoreCase("true");
106:                _restrictSfvEnabled = cfg.getProperty("sfv.restrict.files") == null ? false
107:                        : cfg.getProperty("sfv.restrict.files")
108:                                .equalsIgnoreCase("true");
109:                _multiSfvAllowed = cfg.getProperty("allow.multi.sfv") == null ? true
110:                        : cfg.getProperty("allow.multi.sfv").equalsIgnoreCase(
111:                                "true");
112:                _SfvFirstRequired = cfg.getProperty("sfvfirst.required") == null ? true
113:                        : cfg.getProperty("sfvfirst.required")
114:                                .equalsIgnoreCase("true");
115:                _SfvFirstAllowNoExt = cfg.getProperty("sfvfirst.allownoext") == null ? true
116:                        : cfg.getProperty("sfvfirst.allownoext")
117:                                .equalsIgnoreCase("true");
118:                _AllowedExts = cfg.getProperty("allowedexts") == null ? "sfv"
119:                        : cfg.getProperty("allowedexts").toLowerCase().trim()
120:                                + " sfv";
121:                _SfvFirstUsers = cfg.getProperty("sfvfirst.users") == null ? "*"
122:                        : cfg.getProperty("sfvfirst.users");
123:
124:                // Locals
125:                String SfvFirstPathIgnore = cfg
126:                        .getProperty("sfvfirst.pathignore") == null ? "*" : cfg
127:                        .getProperty("sfvfirst.pathignore");
128:                String SfvFirstPathCheck = cfg
129:                        .getProperty("sfvfirst.pathcheck") == null ? "*" : cfg
130:                        .getProperty("sfvfirst.pathcheck");
131:
132:                // SFV First PathPermissions
133:                if (_SfvFirstRequired) {
134:                    try {
135:                        // this one gets perms defined in sfvfirst.users
136:                        StringTokenizer st = new StringTokenizer(
137:                                SfvFirstPathCheck, " ");
138:                        while (st.hasMoreTokens()) {
139:                            _gctx.getConfig().addPathPermission(
140:                                    "sfvfirst.pathcheck",
141:                                    new GlobPathPermission(new GlobCompiler()
142:                                            .compile(st.nextToken()), FtpConfig
143:                                            .makeUsers(new StringTokenizer(
144:                                                    _SfvFirstUsers, " "))));
145:                        }
146:                        st = new StringTokenizer(SfvFirstPathIgnore, " ");
147:                        while (st.hasMoreTokens()) {
148:                            _gctx.getConfig().addPathPermission(
149:                                    "sfvfirst.pathignore",
150:                                    new GlobPathPermission(new GlobCompiler()
151:                                            .compile(st.nextToken()), FtpConfig
152:                                            .makeUsers(new StringTokenizer("*",
153:                                                    " "))));
154:                        }
155:                    } catch (MalformedPatternException e) {
156:                        logger.warn("Exception when reading " + zsConf, e);
157:                    }
158:                }
159:            }
160:
161:            public GlobalContext getGlobalContext() {
162:                return _gctx;
163:            }
164:
165:            public boolean id3Enabled() {
166:                return _id3Enabled;
167:            }
168:
169:            public boolean dizEnabled() {
170:                return _dizEnabled;
171:            }
172:
173:            public boolean missingFilesEnabled() {
174:                return _missingFilesEnabled;
175:            }
176:
177:            public boolean multiSfvAllowed() {
178:                return _multiSfvAllowed;
179:            }
180:
181:            public boolean offlineFilesEnabled() {
182:                return _offlineFilesEnabled;
183:            }
184:
185:            public boolean raceStatsEnabled() {
186:                return _raceStatsEnabled;
187:            }
188:
189:            public boolean restrictSfvEnabled() {
190:                return _restrictSfvEnabled;
191:            }
192:
193:            public boolean statusBarEnabled() {
194:                return _statusBarEnabled;
195:            }
196:
197:            public boolean checkAllowedExtension(String file) {
198:                if (_SfvFirstAllowNoExt && !file.contains(".")) {
199:                    return true;
200:                }
201:                StringTokenizer st = new StringTokenizer(_AllowedExts, " ");
202:                while (st.hasMoreElements()) {
203:                    String ext = "."
204:                            + st.nextElement().toString().toLowerCase();
205:                    if (file.toLowerCase().endsWith(ext)) {
206:                        return true;
207:                    }
208:                }
209:                return false;
210:            }
211:
212:            public boolean checkSfvFirstEnforcedPath(
213:                    LinkedRemoteFileInterface dir, User user) {
214:                if (_SfvFirstRequired
215:                        && _gctx.getConfig().checkPathPermission(
216:                                "sfvfirst.pathcheck", user, dir)
217:                        && !_gctx.getConfig().checkPathPermission(
218:                                "sfvfirst.pathignore", user, dir)) {
219:                    return true;
220:                }
221:                return false;
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.