source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 4.0 KB
Line 
1/*
2 * Copyright 2003-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant.taskdefs.optional.ssh;
19
20import com.jcraft.jsch.UserInfo;
21
22/**
23 */
24public class SSHUserInfo implements UserInfo {
25
26 private String name;
27 private String password = null;
28 private String keyfile;
29 private String passphrase = null;
30 private boolean firstTime = true;
31 private boolean trustAllCertificates;
32
33 public SSHUserInfo() {
34 super();
35 this.trustAllCertificates = false;
36 }
37
38 public SSHUserInfo(String password, boolean trustAllCertificates) {
39 super();
40 this.password = password;
41 this.trustAllCertificates = trustAllCertificates;
42 }
43
44 /**
45 * Gets the user name.
46 * @return the user name
47 */
48 public String getName() {
49 return name;
50 }
51
52 /**
53 * Gets the pass phrase of the user.
54 * @param message a message
55 * @return the passphrase
56 */
57 public String getPassphrase(String message) {
58 return passphrase;
59 }
60
61 /**
62 * Gets the user's password.
63 * @return the user's password
64 */
65 public String getPassword() {
66 return password;
67 }
68
69 /**
70 * Prompts a string.
71 * @param str the string
72 * @return whether the string was prompted
73 */
74 public boolean prompt(String str) {
75 return false;
76 }
77
78 /**
79 * Indicates whether a retry was done.
80 * @return whether a retry was done
81 */
82 public boolean retry() {
83 return false;
84 }
85
86 /**
87 * Sets the name.
88 * @param name The name to set
89 */
90 public void setName(String name) {
91 this.name = name;
92 }
93
94 /**
95 * Sets the passphrase.
96 * @param passphrase The passphrase to set
97 */
98 public void setPassphrase(String passphrase) {
99 this.passphrase = passphrase;
100 }
101
102 /**
103 * Sets the password.
104 * @param password The password to set
105 */
106 public void setPassword(String password) {
107 this.password = password;
108 }
109
110 /**
111 * Sets the trust.
112 * @param trust whether to trust or not.
113 */
114 public void setTrust(boolean trust) {
115 this.trustAllCertificates = trust;
116 }
117
118 /**
119 * @return whether to trust or not.
120 */
121 public boolean getTrust() {
122 return this.trustAllCertificates;
123 }
124
125 /**
126 * Returns the passphrase.
127 * @return String
128 */
129 public String getPassphrase() {
130 return passphrase;
131 }
132
133 /**
134 * Returns the keyfile.
135 * @return String
136 */
137 public String getKeyfile() {
138 return keyfile;
139 }
140
141 /**
142 * Sets the keyfile.
143 * @param keyfile The keyfile to set
144 */
145 public void setKeyfile(String keyfile) {
146 this.keyfile = keyfile;
147 }
148
149 public boolean promptPassphrase(String message) {
150 return true;
151 }
152
153 public boolean promptPassword(String passwordPrompt) {
154 //log(passwordPrompt, Project.MSG_DEBUG);
155 if (firstTime) {
156 firstTime = false;
157 return true;
158 }
159 return firstTime;
160 }
161
162 public boolean promptYesNo(String message) {
163 //log(prompt, Project.MSG_DEBUG);
164 return trustAllCertificates;
165 }
166
167 public void showMessage(String message) {
168 //log(message, Project.MSG_DEBUG);
169 }
170
171}
Note: See TracBrowser for help on using the repository browser.