1 2 package ch.ethz.ssh2; 3 4 /** 5 * An <code>InteractiveCallback</code> is used to respond to challenges sent 6 * by the server if authentication mode "keyboard-interactive" is selected. 7 * 8 * @see Connection#authenticateWithKeyboardInteractive(String, 9 * String[], InteractiveCallback) 10 * 11 * @author Christian Plattner, plattner@inf.ethz.ch 12 * @version $Id: InteractiveCallback.java,v 1.4 2006/11/01 14:20:24 cplattne Exp $ 13 */ 14 15 public interface InteractiveCallback 16 { 17 /** 18 * This callback interface is used during a "keyboard-interactive" 19 * authentication. Every time the server sends a set of challenges (however, 20 * most often just one challenge at a time), this callback function will be 21 * called to give your application a chance to talk to the user and to 22 * determine the response(s). 23 * <p> 24 * Some copy-paste information from the standard: a command line interface 25 * (CLI) client SHOULD print the name and instruction (if non-empty), adding 26 * newlines. Then for each prompt in turn, the client SHOULD display the 27 * prompt and read the user input. The name and instruction fields MAY be 28 * empty strings, the client MUST be prepared to handle this correctly. The 29 * prompt field(s) MUST NOT be empty strings. 30 * <p> 31 * Please refer to draft-ietf-secsh-auth-kbdinteract-XX.txt for the details. 32 * <p> 33 * Note: clients SHOULD use control character filtering as discussed in 34 * RFC4251 to avoid attacks by including 35 * terminal control characters in the fields to be displayed. 36 * 37 * @param name 38 * the name String sent by the server. 39 * @param instruction 40 * the instruction String sent by the server. 41 * @param numPrompts 42 * number of prompts - may be zero (in this case, you should just 43 * return a String array of length zero). 44 * @param prompt 45 * an array (length <code>numPrompts</code>) of Strings 46 * @param echo 47 * an array (length <code>numPrompts</code>) of booleans. For 48 * each prompt, the corresponding echo field indicates whether or 49 * not the user input should be echoed as characters are typed. 50 * @return an array of reponses - the array size must match the parameter 51 * <code>numPrompts</code>. 52 */ 53 public String[] replyToChallenge(String name, String instruction, int numPrompts, String[] prompt, boolean[] echo) 54 throws Exception; 55 } 56