comparison src/com/trilead/ssh2/packets/PacketUserauthBanner.java @ 0:0ce5cc452d02

initial version
author Carl Byington <carl@five-ten-sg.com>
date Thu, 22 May 2014 10:41:19 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0ce5cc452d02
1 package com.trilead.ssh2.packets;
2
3 import java.io.IOException;
4
5 /**
6 * PacketUserauthBanner.
7 *
8 * @author Christian Plattner, plattner@trilead.com
9 * @version $Id: PacketUserauthBanner.java,v 1.1 2007/10/15 12:49:55 cplattne Exp $
10 */
11 public class PacketUserauthBanner {
12 byte[] payload;
13
14 String message;
15 String language;
16
17 public PacketUserauthBanner(String message, String language) {
18 this.message = message;
19 this.language = language;
20 }
21
22 public String getBanner() {
23 return message;
24 }
25
26 public PacketUserauthBanner(byte payload[], int off, int len) throws IOException {
27 this.payload = new byte[len];
28 System.arraycopy(payload, off, this.payload, 0, len);
29 TypesReader tr = new TypesReader(payload, off, len);
30 int packet_type = tr.readByte();
31
32 if (packet_type != Packets.SSH_MSG_USERAUTH_BANNER)
33 throw new IOException("This is not a SSH_MSG_USERAUTH_BANNER! (" + packet_type + ")");
34
35 message = tr.readString("UTF-8");
36 language = tr.readString();
37
38 if (tr.remain() != 0)
39 throw new IOException("Padding in SSH_MSG_USERAUTH_REQUEST packet!");
40 }
41
42 public byte[] getPayload() {
43 if (payload == null) {
44 TypesWriter tw = new TypesWriter();
45 tw.writeByte(Packets.SSH_MSG_USERAUTH_BANNER);
46 tw.writeString(message);
47 tw.writeString(language);
48 payload = tw.getBytes();
49 }
50
51 return payload;
52 }
53 }