• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2006-2011 Christian Plattner. All rights reserved.
3  * Please refer to the LICENSE.txt for licensing details.
4  */
5 package ch.ethz.ssh2.packets;
6 
7 import java.io.IOException;
8 
9 /**
10  * PacketUserauthInfoRequest.
11  *
12  * @author Christian Plattner
13  * @version 2.50, 03/15/10
14  */
15 public class PacketUserauthInfoRequest
16 {
17 	byte[] payload;
18 
19 	String name;
20 	String instruction;
21 	String languageTag;
22 	int numPrompts;
23 
24 	String prompt[];
25 	boolean echo[];
26 
PacketUserauthInfoRequest(byte payload[], int off, int len)27 	public PacketUserauthInfoRequest(byte payload[], int off, int len) throws IOException
28 	{
29 		this.payload = new byte[len];
30 		System.arraycopy(payload, off, this.payload, 0, len);
31 
32 		TypesReader tr = new TypesReader(payload, off, len);
33 
34 		int packet_type = tr.readByte();
35 
36 		if (packet_type != Packets.SSH_MSG_USERAUTH_INFO_REQUEST)
37 			throw new IOException("This is not a SSH_MSG_USERAUTH_INFO_REQUEST! (" + packet_type + ")");
38 
39 		name = tr.readString();
40 		instruction = tr.readString();
41 		languageTag = tr.readString();
42 
43 		numPrompts = tr.readUINT32();
44 
45 		prompt = new String[numPrompts];
46 		echo = new boolean[numPrompts];
47 
48 		for (int i = 0; i < numPrompts; i++)
49 		{
50 			prompt[i] = tr.readString();
51 			echo[i] = tr.readBoolean();
52 		}
53 
54 		if (tr.remain() != 0)
55 			throw new IOException("Padding in SSH_MSG_USERAUTH_INFO_REQUEST packet!");
56 	}
57 
getEcho()58 	public boolean[] getEcho()
59 	{
60 		return echo;
61 	}
62 
getInstruction()63 	public String getInstruction()
64 	{
65 		return instruction;
66 	}
67 
getLanguageTag()68 	public String getLanguageTag()
69 	{
70 		return languageTag;
71 	}
72 
getName()73 	public String getName()
74 	{
75 		return name;
76 	}
77 
getNumPrompts()78 	public int getNumPrompts()
79 	{
80 		return numPrompts;
81 	}
82 
getPrompt()83 	public String[] getPrompt()
84 	{
85 		return prompt;
86 	}
87 }
88