1 18 19 package org.apache.tools.ant.taskdefs.optional.ssh; 20 21 import com.jcraft.jsch.UserInfo; 22 import com.jcraft.jsch.UIKeyboardInteractive; 23 24 27 public class SSHUserInfo implements UserInfo, UIKeyboardInteractive { 28 29 private String name; 30 private String password = null; 31 private String keyfile; 32 private String passphrase = null; 33 private boolean trustAllCertificates; 34 35 36 public SSHUserInfo() { 37 super(); 38 this.trustAllCertificates = false; 39 } 40 41 46 public SSHUserInfo(String password, boolean trustAllCertificates) { 47 super(); 48 this.password = password; 49 this.trustAllCertificates = trustAllCertificates; 50 } 51 52 56 public String getName() { 57 return name; 58 } 59 60 65 public String getPassphrase(String message) { 66 return passphrase; 67 } 68 69 73 public String getPassword() { 74 return password; 75 } 76 77 82 public boolean prompt(String str) { 83 return false; 84 } 85 86 90 public boolean retry() { 91 return false; 92 } 93 94 98 public void setName(String name) { 99 this.name = name; 100 } 101 102 106 public void setPassphrase(String passphrase) { 107 this.passphrase = passphrase; 108 } 109 110 114 public void setPassword(String password) { 115 this.password = password; 116 } 117 118 122 public void setTrust(boolean trust) { 123 this.trustAllCertificates = trust; 124 } 125 126 129 public boolean getTrust() { 130 return this.trustAllCertificates; 131 } 132 133 137 public String getPassphrase() { 138 return passphrase; 139 } 140 141 145 public String getKeyfile() { 146 return keyfile; 147 } 148 149 153 public void setKeyfile(String keyfile) { 154 this.keyfile = keyfile; 155 } 156 157 162 public boolean promptPassphrase(String message) { 163 return true; 164 } 165 166 171 public boolean promptPassword(String passwordPrompt) { 172 return true; 173 } 174 175 180 public boolean promptYesNo(String message) { 181 return trustAllCertificates; 182 } 183 184 189 public void showMessage(String message) { 190 } 192 193 203 public String [] promptKeyboardInteractive(String destination, 204 String name, 205 String instruction, 206 String [] prompt, 207 boolean[] echo) { 208 if (prompt.length != 1 || echo[0] || this.password == null) { 209 return null; 210 } 211 String [] response = new String [1]; 212 response[0] = this.password; 213 return response; 214 } 215 216 } 217 | Popular Tags |