0
|
1 package com.trilead.ssh2.packets;
|
|
2
|
|
3 import java.io.IOException;
|
|
4
|
|
5 /**
|
|
6 * PacketUserauthRequestPublicKey.
|
|
7 *
|
|
8 * @author Christian Plattner, plattner@trilead.com
|
|
9 * @version $Id: PacketUserauthRequestPublicKey.java,v 1.1 2007/10/15 12:49:55 cplattne Exp $
|
|
10 */
|
|
11 public class PacketUserauthRequestPublicKey {
|
|
12 byte[] payload;
|
|
13
|
|
14 String userName;
|
|
15 String serviceName;
|
|
16 String password;
|
|
17 String pkAlgoName;
|
|
18 byte[] pk;
|
|
19 byte[] sig;
|
|
20
|
|
21 public PacketUserauthRequestPublicKey(String serviceName, String user,
|
|
22 String pkAlgorithmName, byte[] pk, byte[] sig) {
|
|
23 this.serviceName = serviceName;
|
|
24 this.userName = user;
|
|
25 this.pkAlgoName = pkAlgorithmName;
|
|
26 this.pk = pk;
|
|
27 this.sig = sig;
|
|
28 }
|
|
29
|
|
30 public PacketUserauthRequestPublicKey(byte payload[], int off, int len) throws IOException {
|
|
31 this.payload = new byte[len];
|
|
32 System.arraycopy(payload, off, this.payload, 0, len);
|
|
33 TypesReader tr = new TypesReader(payload, off, len);
|
|
34 int packet_type = tr.readByte();
|
|
35
|
|
36 if (packet_type != Packets.SSH_MSG_USERAUTH_REQUEST)
|
|
37 throw new IOException("This is not a SSH_MSG_USERAUTH_REQUEST! ("
|
|
38 + packet_type + ")");
|
|
39
|
|
40 throw new IOException("Not implemented!");
|
|
41 }
|
|
42
|
|
43 public byte[] getPayload() {
|
|
44 if (payload == null) {
|
|
45 TypesWriter tw = new TypesWriter();
|
|
46 tw.writeByte(Packets.SSH_MSG_USERAUTH_REQUEST);
|
|
47 tw.writeString(userName);
|
|
48 tw.writeString(serviceName);
|
|
49 tw.writeString("publickey");
|
|
50 tw.writeBoolean(true);
|
|
51 tw.writeString(pkAlgoName);
|
|
52 tw.writeString(pk, 0, pk.length);
|
|
53 tw.writeString(sig, 0, sig.length);
|
|
54 payload = tw.getBytes();
|
|
55 }
|
|
56
|
|
57 return payload;
|
|
58 }
|
|
59 }
|