comparison src/ch/ethz/ssh2/packets/PacketServiceAccept.java @ 273:91a31873c42a ganymed

start conversion from trilead to ganymed
author Carl Byington <carl@five-ten-sg.com>
date Fri, 18 Jul 2014 11:21:46 -0700
parents
children 071eccdff8ea
comparison
equal deleted inserted replaced
272:ce2f4e397703 273:91a31873c42a
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.PacketTypeException;
10
11 /**
12 * @author Christian Plattner
13 * @version $Id: PacketServiceAccept.java 160 2014-05-01 14:30:26Z dkocher@sudo.ch $
14 */
15 public final class PacketServiceAccept {
16 private final byte[] payload;
17
18 public PacketServiceAccept(String serviceName) {
19
20 TypesWriter tw = new TypesWriter();
21 tw.writeByte(Packets.SSH_MSG_SERVICE_ACCEPT);
22 tw.writeString(serviceName);
23 payload = tw.getBytes();
24 }
25
26 public PacketServiceAccept(byte payload[]) throws IOException {
27 this.payload = payload;
28
29 TypesReader tr = new TypesReader(payload);
30
31 int packet_type = tr.readByte();
32
33 if(packet_type != Packets.SSH_MSG_SERVICE_ACCEPT) {
34 throw new PacketTypeException(packet_type);
35 }
36 if(tr.remain() != 0) {
37 String serviceName = tr.readString();
38 }
39 }
40
41 public byte[] getPayload() {
42 return payload;
43 }
44 }