I guess I need to clarify.  I have handled the username and password as you 
have indicated here.  The two windows I am getting are something like a "The 
authenticity of host 'blah' can't be established" window followed by  "You are 
allowed to use this connection under these circumstances" warning.  I need to 
be able to send a "Y" or 'enter' key or a mouse click or something to get past 
these; but the call to connect() doesn't return back until after the windows 
are gone.  How can I trip off the windows from inside the java code?

From: Stote, John (RBC Dexia IS) [mailto:john.st...@rbcdexia.com]
Sent: Tuesday, February 09, 2010 2:46 PM
To: Preston, Mike; jsch-users@lists.sourceforge.net
Subject: RE: [JSch-users] SFTP Automation and mouse clicks

This is an FAQ :)

You basically have to subclass UserInfo and provide your credentials at run 
time.


Here you go, mix and match at your convenience. I carved this out of a utility 
I wrote for unattended transfers.

eg:
    // This is the class that is registered with the instance of jsch in
    // the connect_sftp_sesssion function.
    // Its role is to provide a user interface for jsftp so that it can
    // acquire the username/password and optionally keyfile/passphrase
    // information necessary to complete the signon process.
    // Additionally there are some facilities to make statements to the user
    // and get the user to answer Yes No questions.
    // Since the nature of this application is for unattended operation
    // it follows that all the answers are taken from the configuration file
    //
    private class MyUserInfo implements UserInfo {
        int retryDetector = 0;

        public String getPassword() {
            log.debug( "Password being retrived by jsftp" );
            return password;
        }

        public void showMessage(String s) {
            log.debug( "ShowMessage called: \""+ s +"\"" );
            //System.out.println(s);
        }

        public boolean promptYesNo(String s) {
            log.debug( "This JSCH server fingerprint warning/question is 
auto-accepted" );
            // Always return true
            return true;
        }

        public boolean promptPassphrase(String message) {
            log.debug("promptPassphrase called with message \"" + message + 
"\"" );
            return true;
        }

        public String getPassphrase() {
            log.debug( "getpassphrase called (usually if this is called it 
means that keyfile passphrase is wrong)" );
            return "stub";
        }


        public boolean promptPassword( String message ) {
            retryDetector++;

            log.debug( "promptPassword called  (" + retryDetector +" times) 
with message \"" + message + "\"" );

            // Rational is that if ssh is prompting again, then the first 
password
            // was wrong, so we will never get it right since it was hard coded
            // so if that has happened we return false, which bails out of the
            // connection process

            return (retryDetector<=1);
        }
    }

then when you connect

           UserInfo ui = new MyUserInfo();

            session.setUserInfo(ui);

            log.debug( "Connecting to SFTP host" );
            session.connect();

________________________________
From: Preston, Mike [mailto:mike_pres...@csgsystems.com]
Sent: 2010, February, 10 6:24 AM
To: jsch-users@lists.sourceforge.net
Subject: [JSch-users] SFTP Automation and mouse clicks
Our network SFTP site is configured such that the user has a couple of mouse 
clicks on information windows before access is provided.  These windows com up 
as part of the "channel.connect();" call.  I would like to find a way either to 
a) respond to those mouse events such that we automatically click past these 
windows or b) find a way to perform the SFTP without encountering the windows 
at all.  Has anyone encountered this situation, and is there anyone who might 
have a suggestion as to how we can work around it?

TIA,
Mike



____________________________________

This e-mail may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations. Any distribution, use or copying of 
this e-mail or the information it contains by other than an intended 
recipient(s) is unauthorized. If you received this e-mail in error, please 
advise me (by return e-mail or otherwise) immediately and delete this e-mail.



        The contents of any attachment to this e-mail may contain software 
viruses or other defect which might affect your own computer system once 
received or opened. While companies under RBC Dexia Investor Services Trust and 
its affiliates take reasonable precautions to minimize that risk, we cannot 
accept liability or responsibility for any damage or loss which may occur or be 
sustained as a result of a software virus or other defect. You are responsible 
for virus checks before opening any attachment.
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to