01: package ch.ethz.ssh2.packets;
02:
03: import java.io.IOException;
04:
05: /**
06: * PacketUserauthBanner.
07: *
08: * @author Christian Plattner, plattner@inf.ethz.ch
09: * @version $Id: PacketUserauthBanner.java,v 1.2 2005/08/24 17:54:08 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)
27: throws IOException {
28: this .payload = new byte[len];
29: System.arraycopy(payload, off, this .payload, 0, len);
30:
31: TypesReader tr = new TypesReader(payload, off, len);
32:
33: int packet_type = tr.readByte();
34:
35: if (packet_type != Packets.SSH_MSG_USERAUTH_BANNER)
36: throw new IOException(
37: "This is not a SSH_MSG_USERAUTH_BANNER! ("
38: + packet_type + ")");
39:
40: message = tr.readString("UTF-8");
41: language = tr.readString();
42:
43: if (tr.remain() != 0)
44: throw new IOException(
45: "Padding in SSH_MSG_USERAUTH_REQUEST packet!");
46: }
47:
48: public byte[] getPayload() {
49: if (payload == null) {
50: TypesWriter tw = new TypesWriter();
51: tw.writeByte(Packets.SSH_MSG_USERAUTH_BANNER);
52: tw.writeString(message);
53: tw.writeString(language);
54: payload = tw.getBytes();
55: }
56: return payload;
57: }
58: }
|