KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > ssh2 > packets > PacketUserauthRequestPublicKey


1 package ch.ethz.ssh2.packets;
2
3 import java.io.IOException JavaDoc;
4
5 /**
6  * PacketUserauthRequestPublicKey.
7  *
8  * @author Christian Plattner, plattner@inf.ethz.ch
9  * @version $Id: PacketUserauthRequestPublicKey.java,v 1.2 2005/08/24 17:54:08 cplattne Exp $
10  */

11 public class PacketUserauthRequestPublicKey
12 {
13     byte[] payload;
14
15     String JavaDoc userName;
16     String JavaDoc serviceName;
17     String JavaDoc password;
18     String JavaDoc pkAlgoName;
19     byte[] pk;
20     byte[] sig;
21
22     public PacketUserauthRequestPublicKey(String JavaDoc serviceName, String JavaDoc user,
23             String JavaDoc 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 JavaDoc
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 JavaDoc("This is not a SSH_MSG_USERAUTH_REQUEST! ("
43                     + packet_type + ")");
44
45         throw new IOException JavaDoc("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