1 package ch.ethz.ssh2.packets; 2 3 import java.io.IOException ; 4 5 11 public class PacketUserauthRequestPublicKey 12 { 13 byte[] payload; 14 15 String userName; 16 String serviceName; 17 String password; 18 String pkAlgoName; 19 byte[] pk; 20 byte[] sig; 21 22 public PacketUserauthRequestPublicKey(String serviceName, String user, 23 String pkAlgorithmName, byte[] pk, byte[] sig) 24 { 25 this.serviceName = serviceName; 26 this.userName = user; 27 this.pkAlgoName = pkAlgorithmName; 28 this.pk = pk; 29 this.sig = sig; 30 } 31 32 public PacketUserauthRequestPublicKey(byte payload[], int off, int len) throws IOException 33 { 34 this.payload = new byte[len]; 35 System.arraycopy(payload, off, this.payload, 0, len); 36 37 TypesReader tr = new TypesReader(payload, off, len); 38 39 int packet_type = tr.readByte(); 40 41 if (packet_type != Packets.SSH_MSG_USERAUTH_REQUEST) 42 throw new IOException ("This is not a SSH_MSG_USERAUTH_REQUEST! (" 43 + packet_type + ")"); 44 45 throw new IOException ("Not implemented!"); 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("publickey"); 57 tw.writeBoolean(true); 58 tw.writeString(pkAlgoName); 59 tw.writeString(pk, 0, pk.length); 60 tw.writeString(sig, 0, sig.length); 61 payload = tw.getBytes(); 62 } 63 return payload; 64 } 65 } 66 | Popular Tags |