273
|
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 import ch.ethz.ssh2.PacketFormatException;
|
|
10 import ch.ethz.ssh2.PacketTypeException;
|
|
11
|
|
12 /**
|
|
13 * @author Christian Plattner
|
|
14 * @version $Id: PacketUserauthInfoRequest.java 160 2014-05-01 14:30:26Z dkocher@sudo.ch $
|
|
15 */
|
|
16 public final class PacketUserauthInfoRequest {
|
|
17
|
|
18 private final String name;
|
|
19 private final String instruction;
|
|
20 private final String languageTag;
|
|
21 private final int numPrompts;
|
|
22
|
|
23 private final String prompt[];
|
|
24 private final boolean echo[];
|
|
25
|
|
26 public PacketUserauthInfoRequest(byte payload[]) throws IOException {
|
|
27 TypesReader tr = new TypesReader(payload);
|
|
28 int packet_type = tr.readByte();
|
|
29
|
307
|
30 if (packet_type != Packets.SSH_MSG_USERAUTH_INFO_REQUEST) {
|
273
|
31 throw new PacketTypeException(packet_type);
|
|
32 }
|
307
|
33
|
273
|
34 name = tr.readString();
|
|
35 instruction = tr.readString();
|
|
36 languageTag = tr.readString();
|
|
37 numPrompts = tr.readUINT32();
|
|
38 prompt = new String[numPrompts];
|
|
39 echo = new boolean[numPrompts];
|
|
40
|
307
|
41 for (int i = 0; i < numPrompts; i++) {
|
273
|
42 prompt[i] = tr.readString();
|
|
43 echo[i] = tr.readBoolean();
|
|
44 }
|
|
45
|
307
|
46 if (tr.remain() != 0) {
|
273
|
47 throw new PacketFormatException(String.format("Padding in %s", Packets.getMessageName(packet_type)));
|
|
48 }
|
|
49 }
|
|
50
|
|
51 public boolean[] getEcho() {
|
|
52 return echo;
|
|
53 }
|
|
54
|
|
55 public String getInstruction() {
|
|
56 return instruction;
|
|
57 }
|
|
58
|
|
59 public String getLanguageTag() {
|
|
60 return languageTag;
|
|
61 }
|
|
62
|
|
63 public String getName() {
|
|
64 return name;
|
|
65 }
|
|
66
|
|
67 public int getNumPrompts() {
|
|
68 return numPrompts;
|
|
69 }
|
|
70
|
|
71 public String[] getPrompt() {
|
|
72 return prompt;
|
|
73 }
|
|
74 }
|