Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.jcraft.jsch.UIKeyboardInteractive;
- import com.jcraft.jsch.UserInfo;
- public class MyUserInfo implements UserInfo, UIKeyboardInteractive{
- /** LOG is the logger object of class */
- private static final Logger LOG = Logger.getLogger(MyUserInfo.class);
- private String username;
- private String password;
- public MyUserInfo(String username, String password){
- this.username = username;
- this.password = password;
- }
- /**
- * This method is overriding the getPassphrase method.
- *
- * @see com.jcraft.jsch.UserInfo#getPassphrase()
- */
- public String getPassphrase() {
- return null;
- }
- /**
- * This method is overriding the getPassword method.
- *
- * @see com.jcraft.jsch.UserInfo#getPassword()
- */
- public String getPassword() {
- return password;
- }
- /**
- * This method is overriding the promptPassphrase method.
- *
- * @see com.jcraft.jsch.UserInfo#promptPassphrase(java.lang.String)
- */
- public boolean promptPassphrase(String arg0) {
- return true;
- }
- /**
- * This method is overriding the promptPassword method.
- *
- * @see com.jcraft.jsch.UserInfo#promptPassword(java.lang.String)
- */
- public boolean promptPassword(String arg0) {
- return true;
- }
- /**
- * This method is overriding the promptYesNo method.
- *
- * @see com.jcraft.jsch.UserInfo#promptYesNo(java.lang.String)
- */
- public boolean promptYesNo(String arg0) {
- return true;
- }
- /**
- * This method is overriding the showMessage method.
- *
- * @see com.jcraft.jsch.UserInfo#showMessage(java.lang.String)
- */
- public void showMessage(String arg0) {
- }
- /**
- * This method is overriding the promptKeyboardInteractive method.
- * response size MUST be equal to prompt size
- *
- *
- * @see com.jcraft.jsch.UIKeyboardInteractive#promptKeyboardInteractive(java.lang.String, java.lang.String, java.lang.String, java.lang.String[], boolean[])
- */
- public String[] promptKeyboardInteractive(String arg0, String arg1,
- String arg2, String[] prompts, boolean[] echos) {
- String response[] = new String[prompts.length];
- for(int i = 0 ; i < prompts.length; i++){
- LOG.debug("Received keyboard prompt..");
- if(echos[i])
- response[i] = username;
- else response[i] = password;
- }
- return response;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement