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