Source Code Cross Referenced for SftpFileSystemConfigBuilder.java in  » Library » Apache-commons-vfs-20070724-src » org » apache » commons » vfs » provider » sftp » 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 » Library » Apache commons vfs 20070724 src » org.apache.commons.vfs.provider.sftp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.commons.vfs.provider.sftp;
018:
019:        import com.jcraft.jsch.UserInfo;
020:        import org.apache.commons.vfs.FileSystemConfigBuilder;
021:        import org.apache.commons.vfs.FileSystemException;
022:        import org.apache.commons.vfs.FileSystemOptions;
023:
024:        import java.io.File;
025:        import java.io.Serializable;
026:
027:        /**
028:         * The config builder for various sftp configuration options
029:         *
030:         * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
031:         * @version $Revision: 480428 $ $Date: 2006-11-28 22:15:24 -0800 (Tue, 28 Nov 2006) $
032:         */
033:        public class SftpFileSystemConfigBuilder extends
034:                FileSystemConfigBuilder {
035:            private final static SftpFileSystemConfigBuilder builder = new SftpFileSystemConfigBuilder();
036:
037:            private final static String USER_DIR_IS_ROOT = SftpFileSystemConfigBuilder.class
038:                    .getName()
039:                    + ".USER_DIR_IS_ROOT";
040:            private final static String TIMEOUT = SftpFileSystemConfigBuilder.class
041:                    .getName()
042:                    + ".TIMEOUT";
043:
044:            public final static ProxyType PROXY_HTTP = new ProxyType("http");
045:            public final static ProxyType PROXY_SOCKS5 = new ProxyType("socks");
046:
047:            public static class ProxyType implements  Serializable, Comparable {
048:                private final String proxyType;
049:
050:                private ProxyType(final String proxyType) {
051:                    this .proxyType = proxyType;
052:                }
053:
054:                public int compareTo(Object o) {
055:                    return proxyType.compareTo(((ProxyType) o).proxyType);
056:                }
057:
058:                public boolean equals(Object o) {
059:                    if (this  == o) {
060:                        return true;
061:                    }
062:                    if (o == null || getClass() != o.getClass()) {
063:                        return false;
064:                    }
065:
066:                    ProxyType proxyType1 = (ProxyType) o;
067:
068:                    if (proxyType != null ? !proxyType
069:                            .equals(proxyType1.proxyType)
070:                            : proxyType1.proxyType != null) {
071:                        return false;
072:                    }
073:
074:                    return true;
075:                }
076:            }
077:
078:            public static SftpFileSystemConfigBuilder getInstance() {
079:                return builder;
080:            }
081:
082:            private SftpFileSystemConfigBuilder() {
083:            }
084:
085:            /**
086:             * Set the userinfo class to use if e.g. a password or a not known host
087:             * will be contacted
088:             *
089:             * @param opts
090:             * @param info
091:             */
092:            public void setUserInfo(FileSystemOptions opts, UserInfo info) {
093:                setParam(opts, UserInfo.class.getName(), info);
094:            }
095:
096:            /**
097:             * @param opts
098:             * @see #setUserInfo
099:             */
100:            public UserInfo getUserInfo(FileSystemOptions opts) {
101:                return (UserInfo) getParam(opts, UserInfo.class.getName());
102:            }
103:
104:            /**
105:             * Set the known_hosts file. e.g. /home/user/.ssh/known_hosts2<br>
106:             * Need to use a java.io.File as JSch cant deal with vfs FileObjects ;-)
107:             *
108:             * @param opts
109:             * @param sshdir
110:             */
111:            public void setKnownHosts(FileSystemOptions opts, File sshdir)
112:                    throws FileSystemException {
113:                setParam(opts, "knownHosts", sshdir);
114:            }
115:
116:            /**
117:             * @param opts
118:             * @see #setKnownHosts
119:             */
120:            public File getKnownHosts(FileSystemOptions opts) {
121:                return (File) getParam(opts, "knownHosts");
122:            }
123:
124:            /**
125:             * Set the identity files (your private key files).<br>
126:             * Need to use a java.io.File as JSch cant deal with vfs FileObjects ;-)
127:             *
128:             * @param opts
129:             * @param identities
130:             */
131:            public void setIdentities(FileSystemOptions opts, File[] identities)
132:                    throws FileSystemException {
133:                setParam(opts, "identities", identities);
134:            }
135:
136:            /**
137:             * configure the compression to use.<br>
138:             * e.g. pass "zlib,none" to enable the compression.<br>
139:             * See the jsch documentation for details.
140:             *
141:             * @param opts
142:             * @param compression
143:             * @throws FileSystemException
144:             */
145:            public void setCompression(FileSystemOptions opts,
146:                    String compression) throws FileSystemException {
147:                setParam(opts, "compression", compression);
148:            }
149:
150:            /**
151:             * @param opts
152:             * @see #setCompression
153:             */
154:            public String getCompression(FileSystemOptions opts) {
155:                return (String) getParam(opts, "compression");
156:            }
157:
158:            /**
159:             * @param opts
160:             * @see #setIdentities
161:             */
162:            public File[] getIdentities(FileSystemOptions opts) {
163:                return (File[]) getParam(opts, "identities");
164:            }
165:
166:            /**
167:             * configure the host key checking to use.<br>
168:             * valid arguments are only yes, no and ask.<br>
169:             * See the jsch documentation for details.
170:             *
171:             * @param opts
172:             * @param hostKeyChecking
173:             * @throws FileSystemException
174:             */
175:            public void setStrictHostKeyChecking(FileSystemOptions opts,
176:                    String hostKeyChecking) throws FileSystemException {
177:                if (hostKeyChecking == null
178:                        || (!hostKeyChecking.equals("ask")
179:                                && !hostKeyChecking.equals("no") && !hostKeyChecking
180:                                .equals("yes"))) {
181:                    throw new FileSystemException(
182:                            "vfs.provider.sftp/StrictHostKeyChecking-arg.error",
183:                            hostKeyChecking);
184:                }
185:
186:                setParam(opts, "StrictHostKeyChecking", hostKeyChecking);
187:            }
188:
189:            /**
190:             * @param opts
191:             * @return the option value
192:             * @see #setStrictHostKeyChecking(FileSystemOptions, String)
193:             */
194:            public String getStrictHostKeyChecking(FileSystemOptions opts) {
195:                return (String) getParam(opts, "StrictHostKeyChecking");
196:            }
197:
198:            /**
199:             * use user directory as root (do not change to fs root)
200:             *
201:             * @param opts
202:             * @param userDirIsRoot
203:             */
204:            public void setUserDirIsRoot(FileSystemOptions opts,
205:                    boolean userDirIsRoot) {
206:                setParam(opts, USER_DIR_IS_ROOT, userDirIsRoot ? Boolean.TRUE
207:                        : Boolean.FALSE);
208:            }
209:
210:            /**
211:             * @param opts
212:             * @see #setUserDirIsRoot
213:             */
214:            public Boolean getUserDirIsRoot(FileSystemOptions opts) {
215:                return (Boolean) getParam(opts, USER_DIR_IS_ROOT);
216:            }
217:
218:            /**
219:             * set the timeout value on jsch session
220:             *
221:             * @param opts
222:             * @param timeout
223:             */
224:            public void setTimeout(FileSystemOptions opts, Integer timeout) {
225:                setParam(opts, TIMEOUT, timeout);
226:            }
227:
228:            /**
229:             * @param opts
230:             * @see #setTimeout
231:             */
232:            public Integer getTimeout(FileSystemOptions opts) {
233:                return (Integer) getParam(opts, TIMEOUT);
234:            }
235:
236:            protected Class getConfigClass() {
237:                return SftpFileSystem.class;
238:            }
239:
240:            /**
241:             * Set the proxy to use for sftp connection.<br>
242:             * You have to set the ProxyPort too if you would like to have the proxy relly used.
243:             *
244:             * @param proxyHost the host
245:             * @see #setProxyPort
246:             */
247:            public void setProxyHost(FileSystemOptions opts, String proxyHost) {
248:                setParam(opts, "proxyHost", proxyHost);
249:            }
250:
251:            /**
252:             * Set the proxy-port to use for sftp connection
253:             * You have to set the ProxyHost too if you would like to have the proxy relly used.
254:             *
255:             * @param proxyPort the port
256:             * @see #setProxyHost
257:             */
258:            public void setProxyPort(FileSystemOptions opts, int proxyPort) {
259:                setParam(opts, "proxyPort", new Integer(proxyPort));
260:            }
261:
262:            /**
263:             * Get the proxy to use for sftp connection
264:             * You have to set the ProxyPort too if you would like to have the proxy relly used.
265:             *
266:             * @return proxyHost
267:             * @see #setProxyPort
268:             */
269:            public String getProxyHost(FileSystemOptions opts) {
270:                return (String) getParam(opts, "proxyHost");
271:            }
272:
273:            /**
274:             * Get the proxy-port to use for sftp the connection
275:             * You have to set the ProxyHost too if you would like to have the proxy relly used.
276:             *
277:             * @return proxyPort: the port number or 0 if it is not set
278:             * @see #setProxyHost
279:             */
280:            public int getProxyPort(FileSystemOptions opts) {
281:                if (!hasParam(opts, "proxyPort")) {
282:                    return 0;
283:                }
284:
285:                return ((Number) getParam(opts, "proxyPort")).intValue();
286:            }
287:
288:            /**
289:             * Set the proxy type to use for sftp connection.
290:             */
291:            public void setProxyType(FileSystemOptions opts, ProxyType proxyType) {
292:                setParam(opts, "proxyType", proxyType);
293:            }
294:
295:            /**
296:             * Get the proxy type to use for sftp connection.
297:             */
298:            public ProxyType getProxyType(FileSystemOptions opts) {
299:                return (ProxyType) getParam(opts, "proxyType");
300:            }
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.