comparison src/com/trilead/ssh2/packets/PacketUserauthRequestNone.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 * PacketUserauthRequestPassword.
7 *
8 * @author Christian Plattner, plattner@trilead.com
9 * @version $Id: PacketUserauthRequestNone.java,v 1.1 2007/10/15 12:49:55 cplattne Exp $
10 */
11 public class PacketUserauthRequestNone {
12 byte[] payload;
13
14 String userName;
15 String serviceName;
16
17 public PacketUserauthRequestNone(String serviceName, String user) {
18 this.serviceName = serviceName;
19 this.userName = user;
20 }
21
22 public PacketUserauthRequestNone(byte payload[], int off, int len) throws IOException {
23 this.payload = new byte[len];
24 System.arraycopy(payload, off, this.payload, 0, len);
25 TypesReader tr = new TypesReader(payload, off, len);
26 int packet_type = tr.readByte();
27
28 if (packet_type != Packets.SSH_MSG_USERAUTH_REQUEST)
29 throw new IOException("This is not a SSH_MSG_USERAUTH_REQUEST! (" + packet_type + ")");
30
31 userName = tr.readString();
32 serviceName = tr.readString();
33 String method = tr.readString();
34
35 if (method.equals("none") == false)
36 throw new IOException("This is not a SSH_MSG_USERAUTH_REQUEST with type none!");
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_REQUEST);
46 tw.writeString(userName);
47 tw.writeString(serviceName);
48 tw.writeString("none");
49 payload = tw.getBytes();
50 }
51
52 return payload;
53 }
54 }