    001    package net.minecraft.network.packet;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import java.io.DataInputStream;
    006    import java.io.DataOutputStream;
    007    import java.io.IOException;
    008    import java.security.PublicKey;
    009    import net.minecraft.util.CryptManager;
    010
    011    public class Packet253ServerAuthData extends Packet
    012    {
    013        private String serverId;
    014        private PublicKey publicKey;
    015        private byte[] verifyToken = new byte[0];
    016
    017        public Packet253ServerAuthData() {}
    018
    019        public Packet253ServerAuthData(String par1Str, PublicKey par2PublicKey, byte[] par3ArrayOfByte)
    020        {
    021            this.serverId = par1Str;
    022            this.publicKey = par2PublicKey;
    023            this.verifyToken = par3ArrayOfByte;
    024        }
    025
    026        /**
    027         * Abstract. Reads the raw packet data from the data stream.
    028         */
    029        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    030        {
    031            this.serverId = readString(par1DataInputStream, 20);
    032            this.publicKey = CryptManager.func_75896_a(readBytesFromStream(par1DataInputStream));
    033            this.verifyToken = readBytesFromStream(par1DataInputStream);
    034        }
    035
    036        /**
    037         * Abstract. Writes the raw packet data to the data stream.
    038         */
    039        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    040        {
    041            writeString(this.serverId, par1DataOutputStream);
    042            writeByteArray(par1DataOutputStream, this.publicKey.getEncoded());
    043            writeByteArray(par1DataOutputStream, this.verifyToken);
    044        }
    045
    046        /**
    047         * Passes this Packet on to the NetHandler for processing.
    048         */
    049        public void processPacket(NetHandler par1NetHandler)
    050        {
    051            par1NetHandler.handleServerAuthData(this);
    052        }
    053
    054        /**
    055         * Abstract. Return the size of the packet (not counting the header).
    056         */
    057        public int getPacketSize()
    058        {
    059            return 2 + this.serverId.length() * 2 + 2 + this.publicKey.getEncoded().length + 2 + this.verifyToken.length;
    060        }
    061
    062        @SideOnly(Side.CLIENT)
    063        public String getServerId()
    064        {
    065            return this.serverId;
    066        }
    067
    068        @SideOnly(Side.CLIENT)
    069        public PublicKey getPublicKey()
    070        {
    071            return this.publicKey;
    072        }
    073
    074        @SideOnly(Side.CLIENT)
    075        public byte[] getVerifyToken()
    076        {
    077            return this.verifyToken;
    078        }
    079    }