All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bichromate.tools.myUserInfoSSHFactory Maven / Gradle / Ivy

Go to download

Java, Selenium, Appium, Winium, Extend, and TestNG automated testing framework. Bichromate integrates the best of these frameworks and takes automation to the next level. With Bichromate there is one function call that builds any type of Web,IOS Mobile, Android, and Windows App driver on any platform (Windows, Mac, Linux). From Local web drivers, to SauceLabs, Browserstack, and Selenium grid. Build data driven tests is never easier. Bichromate also gives you built in Factories that, access DBs, Video Capture, FTP, POM Generation, Hilite element.

There is a newer version: 3.13
Show newest version
/*
 * myUserInfoSSHFactory.java	1.0 2013/01/24
 *
 * Copyright (c) 2001 by David Ramer, Inc. All Rights Reserved.
 *
 * David Ramer grants you ("Licensee") a non-exclusive, royalty free, license to use,
 * modify and redistribute this software in source and binary code form,
 * provided that i) this copyright notice and license appear on all copies of
 * the software; and ii) Licensee does not utilize the software in a manner
 * which is disparaging to David Ramer.
 *
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. David Ramer AND ITS LICENSORS SHALL NOT BE
 * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL David Ramer OR ITS
 * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
 * OR INABILITY TO USE SOFTWARE, EVEN IF DRamer HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 *
 * This software is not designed or intended for use in on-line control of
 * aircraft, air traffic, aircraft navigation or aircraft communications; or in
 * the design, construction, operation or maintenance of any nuclear
 * facility. Licensee represents and warrants that it will not use or
 * redistribute the Software for such purposes.
 */
package bichromate.tools;

import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import com.jcraft.jsch.UIKeyboardInteractive;
import com.jcraft.jsch.UserInfo;
/**
 * This class Demonstrates myUserInfoSSHFactory().
 * 
myUserInfoSSHFactory is used to interact with the user when making SSH connection that has *
passkey authentication *
*
* @author davidwramer * @version 1.0 */ public class myUserInfoSSHFactory implements UserInfo, UIKeyboardInteractive{ private boolean silentMode = true; private String myPassword = null; final GridBagConstraints gbc = new GridBagConstraints(0,0,1,1,1,1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0,0,0,0),0,0); private Container panel; String passphrase; JTextField passphraseField=(JTextField)new JPasswordField(20); /** * This class Demonstrates myUserInfoSSHFactory(). *
myUserInfoSSHFactory is used to interact with the user when making SSH connection that has *
passkey authentication *
*
* @param password . passed in when no user interaction needed */ public myUserInfoSSHFactory(String password){ myPassword = password; silentMode = true; } /** * This class Demonstrates myUserInfoSSHFactory(). *
myUserInfoSSHFactory is used to interact with the user when making SSH connection that has *
passkey authentication, This constructor is used when user interaction is required *
*
*/ public myUserInfoSSHFactory(){ } /** * This function Demonstrates getPassword(). *
myUserInfoSSHFactory is used to interact with the user when making SSH connection that has *
*
* @return String password that was set in the constructor */ public String getPassword(){ return myPassword; } /** * This function Demonstrates promptYesNo(). *
Function used when prompting user interaction to connect to specific server *
*
* @param str - Server information that is being connected to * @return boolean true if connection should continue, false otherwise */ public boolean promptYesNo(String str){ if(silentMode){ return true; }else{ Object[] options={ "yes", "no" }; int foo=JOptionPane.showOptionDialog(null, str,"Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); return foo==0; } }// promptYesNo() /** * This function Demonstrates getPassphrase(). *
Function returns the passphrase for SSH authentication of key file *
*
* @return String password */ public String getPassphrase(){ return passphrase; } /** * This function Demonstrates promptPassphrase(). *
Function used prompted user for SSH key passphrase *
*
* @param message - message to be added to the dialog * @return boolean true if passphrase was entered */ public boolean promptPassphrase(String message){ if(silentMode){ passphrase = getPassword(); return true; }else{ Object[] ob={passphraseField}; int result= JOptionPane.showConfirmDialog(null, ob, message,JOptionPane.OK_CANCEL_OPTION); if(result==JOptionPane.OK_OPTION){ passphrase=passphraseField.getText(); return true; }else{ return false; } } } // promptPassphrase() /** * This function Demonstrates promptPassword(). *
Function used prompted user for SSH key passphrase *
*
* @param message - message to be added to the dialog * @return boolean if passphrase was entered */ public boolean promptPassword(String message){ return true; } /** * This function Demonstrates showMessage(). *
Function used prompted user for SSH key passphrase *
*
* @param message - message to be added to the dialog */ public void showMessage(String message){ JOptionPane.showMessageDialog(null, message); } /** * This function Demonstrates promptKeyboardInteractive(). *
Function used prompted user for SSH key passphrase *
*
* @param destination - destination information * @param name - name * @param instruction - instruction * @param prompt - prompt * @param echo - echo * @return String [] - interactions */ public String[] promptKeyboardInteractive(String destination,String name,String instruction,String[] prompt,boolean[] echo){ panel = new JPanel(); panel.setLayout(new GridBagLayout()); gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridx = 0; panel.add(new JLabel(instruction), gbc); gbc.gridy++; gbc.gridwidth = GridBagConstraints.RELATIVE; JTextField[] texts=new JTextField[prompt.length]; for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy