1 package com.trilead.ssh2.packets;
\r
3 import java.io.IOException;
\r
6 * PacketUserauthRequestPassword.
\r
8 * @author Christian Plattner, plattner@trilead.com
\r
9 * @version $Id: PacketUserauthRequestNone.java,v 1.1 2007/10/15 12:49:55 cplattne Exp $
\r
11 public class PacketUserauthRequestNone
\r
18 public PacketUserauthRequestNone(String serviceName, String user)
\r
20 this.serviceName = serviceName;
\r
21 this.userName = user;
\r
24 public PacketUserauthRequestNone(byte payload[], int off, int len) throws IOException
\r
26 this.payload = new byte[len];
\r
27 System.arraycopy(payload, off, this.payload, 0, len);
\r
29 TypesReader tr = new TypesReader(payload, off, len);
\r
31 int packet_type = tr.readByte();
\r
33 if (packet_type != Packets.SSH_MSG_USERAUTH_REQUEST)
\r
34 throw new IOException("This is not a SSH_MSG_USERAUTH_REQUEST! (" + packet_type + ")");
\r
36 userName = tr.readString();
\r
37 serviceName = tr.readString();
\r
39 String method = tr.readString();
\r
41 if (method.equals("none") == false)
\r
42 throw new IOException("This is not a SSH_MSG_USERAUTH_REQUEST with type none!");
\r
44 if (tr.remain() != 0)
\r
45 throw new IOException("Padding in SSH_MSG_USERAUTH_REQUEST packet!");
\r
48 public byte[] getPayload()
\r
50 if (payload == null)
\r
52 TypesWriter tw = new TypesWriter();
\r
53 tw.writeByte(Packets.SSH_MSG_USERAUTH_REQUEST);
\r
54 tw.writeString(userName);
\r
55 tw.writeString(serviceName);
\r
56 tw.writeString("none");
\r
57 payload = tw.getBytes();
\r