1 package ch.ethz.ssh2.packets; 2 3 import java.io.IOException ; 4 5 11 public class PacketUserauthRequestNone 12 { 13 byte[] payload; 14 15 String userName; 16 String serviceName; 17 18 public PacketUserauthRequestNone(String serviceName, String user) 19 { 20 this.serviceName = serviceName; 21 this.userName = user; 22 } 23 24 public PacketUserauthRequestNone(byte payload[], int off, int len) throws IOException 25 { 26 this.payload = new byte[len]; 27 System.arraycopy(payload, off, this.payload, 0, len); 28 29 TypesReader tr = new TypesReader(payload, off, len); 30 31 int packet_type = tr.readByte(); 32 33 if (packet_type != Packets.SSH_MSG_USERAUTH_REQUEST) 34 throw new IOException ("This is not a SSH_MSG_USERAUTH_REQUEST! (" + packet_type + ")"); 35 36 userName = tr.readString(); 37 serviceName = tr.readString(); 38 39 String method = tr.readString(); 40 41 if (method.equals("none") == false) 42 throw new IOException ("This is not a SSH_MSG_USERAUTH_REQUEST with type none!"); 43 44 if (tr.remain() != 0) 45 throw new IOException ("Padding in SSH_MSG_USERAUTH_REQUEST packet!"); 46 } 47 48 public byte[] getPayload() 49 { 50 if (payload == null) 51 { 52 TypesWriter tw = new TypesWriter(); 53 tw.writeByte(Packets.SSH_MSG_USERAUTH_REQUEST); 54 tw.writeString(userName); 55 tw.writeString(serviceName); 56 tw.writeString("none"); 57 payload = tw.getBytes(); 58 } 59 return payload; 60 } 61 } 62 | Popular Tags |