comparison app/src/main/java/ch/ethz/ssh2/packets/PacketUserauthInfoRequest.java @ 438:d29cce60f393

migrate from Eclipse to Android Studio
author Carl Byington <carl@five-ten-sg.com>
date Thu, 03 Dec 2015 11:23:55 -0800
parents src/ch/ethz/ssh2/packets/PacketUserauthInfoRequest.java@071eccdff8ea
children
comparison
equal deleted inserted replaced
437:208b31032318 438:d29cce60f393
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
30 if (packet_type != Packets.SSH_MSG_USERAUTH_INFO_REQUEST) {
31 throw new PacketTypeException(packet_type);
32 }
33
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
41 for (int i = 0; i < numPrompts; i++) {
42 prompt[i] = tr.readString();
43 echo[i] = tr.readBoolean();
44 }
45
46 if (tr.remain() != 0) {
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 }