Source Code Cross Referenced for SSHUserInfo.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » ssh » 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 » Build » ANT » org.apache.tools.ant.taskdefs.optional.ssh 
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:         */
018:
019:        package org.apache.tools.ant.taskdefs.optional.ssh;
020:
021:        import com.jcraft.jsch.UserInfo;
022:        import com.jcraft.jsch.UIKeyboardInteractive;
023:
024:        /**
025:         * Class containing information on an SSH user.
026:         */
027:        public class SSHUserInfo implements  UserInfo, UIKeyboardInteractive {
028:
029:            private String name;
030:            private String password = null;
031:            private String keyfile;
032:            private String passphrase = null;
033:            private boolean trustAllCertificates;
034:
035:            /** Constructor for SSHUserInfo. */
036:            public SSHUserInfo() {
037:                super ();
038:                this .trustAllCertificates = false;
039:            }
040:
041:            /**
042:             * Constructor for SSHUserInfo.
043:             * @param password the user's password
044:             * @param trustAllCertificates if true trust hosts whose identity is unknown
045:             */
046:            public SSHUserInfo(String password, boolean trustAllCertificates) {
047:                super ();
048:                this .password = password;
049:                this .trustAllCertificates = trustAllCertificates;
050:            }
051:
052:            /**
053:             * Gets the user name.
054:             * @return the user name
055:             */
056:            public String getName() {
057:                return name;
058:            }
059:
060:            /**
061:             * Gets the pass phrase of the user.
062:             * @param message a message
063:             * @return the passphrase
064:             */
065:            public String getPassphrase(String message) {
066:                return passphrase;
067:            }
068:
069:            /**
070:             * Gets the user's password.
071:             * @return the user's password
072:             */
073:            public String getPassword() {
074:                return password;
075:            }
076:
077:            /**
078:             * Prompts a string.
079:             * @param str the string
080:             * @return whether the string was prompted
081:             */
082:            public boolean prompt(String str) {
083:                return false;
084:            }
085:
086:            /**
087:             * Indicates whether a retry was done.
088:             * @return whether a retry was done
089:             */
090:            public boolean retry() {
091:                return false;
092:            }
093:
094:            /**
095:             * Sets the name.
096:             * @param name The name to set
097:             */
098:            public void setName(String name) {
099:                this .name = name;
100:            }
101:
102:            /**
103:             * Sets the passphrase.
104:             * @param passphrase The passphrase to set
105:             */
106:            public void setPassphrase(String passphrase) {
107:                this .passphrase = passphrase;
108:            }
109:
110:            /**
111:             * Sets the password.
112:             * @param password The password to set
113:             */
114:            public void setPassword(String password) {
115:                this .password = password;
116:            }
117:
118:            /**
119:             * Sets the trust.
120:             * @param trust whether to trust or not.
121:             */
122:            public void setTrust(boolean trust) {
123:                this .trustAllCertificates = trust;
124:            }
125:
126:            /**
127:             * @return whether to trust or not.
128:             */
129:            public boolean getTrust() {
130:                return this .trustAllCertificates;
131:            }
132:
133:            /**
134:             * Returns the passphrase.
135:             * @return String
136:             */
137:            public String getPassphrase() {
138:                return passphrase;
139:            }
140:
141:            /**
142:             * Returns the keyfile.
143:             * @return String
144:             */
145:            public String getKeyfile() {
146:                return keyfile;
147:            }
148:
149:            /**
150:             * Sets the keyfile.
151:             * @param keyfile The keyfile to set
152:             */
153:            public void setKeyfile(String keyfile) {
154:                this .keyfile = keyfile;
155:            }
156:
157:            /**
158:             * Implement the UserInfo interface.
159:             * @param message ignored
160:             * @return true always
161:             */
162:            public boolean promptPassphrase(String message) {
163:                return true;
164:            }
165:
166:            /**
167:             * Implement the UserInfo interface.
168:             * @param passwordPrompt ignored
169:             * @return true the first time this is called, false otherwise
170:             */
171:            public boolean promptPassword(String passwordPrompt) {
172:                return true;
173:            }
174:
175:            /**
176:             * Implement the UserInfo interface.
177:             * @param message ignored
178:             * @return the value of trustAllCertificates
179:             */
180:            public boolean promptYesNo(String message) {
181:                return trustAllCertificates;
182:            }
183:
184:            //why do we do nothing?
185:            /**
186:             * Implement the UserInfo interface (noop).
187:             * @param message ignored
188:             */
189:            public void showMessage(String message) {
190:                //log(message, Project.MSG_DEBUG);
191:            }
192:
193:            /**
194:             * Implementation of UIKeyboardInteractive#promptKeyboardInteractive.
195:             * @param destination not used.
196:             * @param name        not used.
197:             * @param instruction not used.
198:             * @param prompt      the method checks if this is one in length.
199:             * @param echo        the method checks if the first element is false.
200:             * @return the password in an size one array if there is a password
201:             *         and if the prompt and echo checks pass.
202:             */
203:            public String[] promptKeyboardInteractive(String destination,
204:                    String name, String instruction, String[] prompt,
205:                    boolean[] echo) {
206:                if (prompt.length != 1 || echo[0] || this .password == null) {
207:                    return null;
208:                }
209:                String[] response = new String[1];
210:                response[0] = this.password;
211:                return response;
212:            }
213:
214:        }
w__w___w.java_2_s_.__c___om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.