273
|
1 /*
|
|
2 * Copyright (c) 2006-2013 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: PacketUserauthSuccess.java 160 2014-05-01 14:30:26Z dkocher@sudo.ch $
|
|
15 */
|
|
16 public final class PacketUserauthSuccess {
|
|
17
|
|
18 private final byte[] payload;
|
|
19
|
|
20 public PacketUserauthSuccess() {
|
|
21 TypesWriter tw = new TypesWriter();
|
|
22 tw.writeByte(Packets.SSH_MSG_USERAUTH_SUCCESS);
|
|
23 payload = tw.getBytes();
|
|
24 }
|
|
25
|
|
26 public PacketUserauthSuccess(byte payload[]) throws IOException {
|
|
27 this.payload = payload;
|
|
28 TypesReader tr = new TypesReader(payload);
|
|
29 int packet_type = tr.readByte();
|
|
30
|
307
|
31 if (packet_type != Packets.SSH_MSG_USERAUTH_SUCCESS) {
|
273
|
32 throw new PacketTypeException(packet_type);
|
|
33 }
|
307
|
34
|
|
35 if (tr.remain() != 0) {
|
273
|
36 throw new PacketFormatException(String.format("Padding in %s", Packets.getMessageName(packet_type)));
|
|
37 }
|
|
38 }
|
|
39
|
|
40 public byte[] getPayload() {
|
|
41 return payload;
|
|
42 }
|
|
43 }
|