01: package ch.ethz.ssh2.packets;
02:
03: import java.io.IOException;
04:
05: /**
06: * PacketUserauthRequestPublicKey.
07: *
08: * @author Christian Plattner, plattner@inf.ethz.ch
09: * @version $Id: PacketUserauthRequestPublicKey.java,v 1.2 2005/08/24 17:54:08 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,
22: String user, 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,
31: int len) throws IOException {
32: this .payload = new byte[len];
33: System.arraycopy(payload, off, this .payload, 0, len);
34:
35: TypesReader tr = new TypesReader(payload, off, len);
36:
37: int packet_type = tr.readByte();
38:
39: if (packet_type != Packets.SSH_MSG_USERAUTH_REQUEST)
40: throw new IOException(
41: "This is not a SSH_MSG_USERAUTH_REQUEST! ("
42: + packet_type + ")");
43:
44: throw new IOException("Not implemented!");
45: }
46:
47: public byte[] getPayload() {
48: if (payload == null) {
49: TypesWriter tw = new TypesWriter();
50: tw.writeByte(Packets.SSH_MSG_USERAUTH_REQUEST);
51: tw.writeString(userName);
52: tw.writeString(serviceName);
53: tw.writeString("publickey");
54: tw.writeBoolean(true);
55: tw.writeString(pkAlgoName);
56: tw.writeString(pk, 0, pk.length);
57: tw.writeString(sig, 0, sig.length);
58: payload = tw.getBytes();
59: }
60: return payload;
61: }
62: }
|