Mercurial > 510Connectbot
comparison app/src/main/java/ch/ethz/ssh2/packets/PacketUserauthBanner.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/PacketUserauthBanner.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: PacketUserauthBanner.java 160 2014-05-01 14:30:26Z dkocher@sudo.ch $ | |
15 */ | |
16 public final class PacketUserauthBanner { | |
17 private final byte[] payload; | |
18 | |
19 private final String message; | |
20 | |
21 public PacketUserauthBanner(String message) { | |
22 this.message = message; | |
23 TypesWriter tw = new TypesWriter(); | |
24 tw.writeByte(Packets.SSH_MSG_USERAUTH_BANNER); | |
25 tw.writeString(message); | |
26 tw.writeString(""); | |
27 payload = tw.getBytes(); | |
28 } | |
29 | |
30 public String getBanner() { | |
31 return message; | |
32 } | |
33 | |
34 public PacketUserauthBanner(byte payload[]) throws IOException { | |
35 this.payload = payload; | |
36 TypesReader tr = new TypesReader(payload); | |
37 int packet_type = tr.readByte(); | |
38 | |
39 if (packet_type != Packets.SSH_MSG_USERAUTH_BANNER) { | |
40 throw new PacketTypeException(packet_type); | |
41 } | |
42 | |
43 message = tr.readString("UTF-8"); | |
44 String language = tr.readString(); | |
45 | |
46 if (tr.remain() != 0) { | |
47 throw new PacketFormatException(String.format("Padding in %s", Packets.getMessageName(packet_type))); | |
48 } | |
49 } | |
50 | |
51 public byte[] getPayload() { | |
52 return payload; | |
53 } | |
54 } |