comparison src/ch/ethz/ssh2/packets/PacketUserauthInfoRequest.java @ 273:91a31873c42a ganymed

start conversion from trilead to ganymed
author Carl Byington <carl@five-ten-sg.com>
date Fri, 18 Jul 2014 11:21:46 -0700
parents
children 071eccdff8ea
comparison
equal deleted inserted replaced
272:ce2f4e397703 273:91a31873c42a
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
29 int packet_type = tr.readByte();
30
31 if(packet_type != Packets.SSH_MSG_USERAUTH_INFO_REQUEST) {
32 throw new PacketTypeException(packet_type);
33 }
34 name = tr.readString();
35 instruction = tr.readString();
36 languageTag = tr.readString();
37
38 numPrompts = tr.readUINT32();
39
40 prompt = new String[numPrompts];
41 echo = new boolean[numPrompts];
42
43 for(int i = 0; i < numPrompts; i++) {
44 prompt[i] = tr.readString();
45 echo[i] = tr.readBoolean();
46 }
47
48 if(tr.remain() != 0) {
49 throw new PacketFormatException(String.format("Padding in %s", Packets.getMessageName(packet_type)));
50 }
51 }
52
53 public boolean[] getEcho() {
54 return echo;
55 }
56
57 public String getInstruction() {
58 return instruction;
59 }
60
61 public String getLanguageTag() {
62 return languageTag;
63 }
64
65 public String getName() {
66 return name;
67 }
68
69 public int getNumPrompts() {
70 return numPrompts;
71 }
72
73 public String[] getPrompt() {
74 return prompt;
75 }
76 }