package net.minecraft.network.packet; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.security.PublicKey; import net.minecraft.util.CryptManager; public class Packet253ServerAuthData extends Packet { private String serverId; private PublicKey publicKey; private byte[] verifyToken = new byte[0]; public Packet253ServerAuthData() {} public Packet253ServerAuthData(String par1Str, PublicKey par2PublicKey, byte[] par3ArrayOfByte) { this.serverId = par1Str; this.publicKey = par2PublicKey; this.verifyToken = par3ArrayOfByte; } /** * Abstract. Reads the raw packet data from the data stream. */ public void readPacketData(DataInputStream par1DataInputStream) throws IOException { this.serverId = readString(par1DataInputStream, 20); this.publicKey = CryptManager.decodePublicKey(readBytesFromStream(par1DataInputStream)); this.verifyToken = readBytesFromStream(par1DataInputStream); } /** * Abstract. Writes the raw packet data to the data stream. */ public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException { writeString(this.serverId, par1DataOutputStream); writeByteArray(par1DataOutputStream, this.publicKey.getEncoded()); writeByteArray(par1DataOutputStream, this.verifyToken); } /** * Passes this Packet on to the NetHandler for processing. */ public void processPacket(NetHandler par1NetHandler) { par1NetHandler.handleServerAuthData(this); } /** * Abstract. Return the size of the packet (not counting the header). */ public int getPacketSize() { return 2 + this.serverId.length() * 2 + 2 + this.publicKey.getEncoded().length + 2 + this.verifyToken.length; } @SideOnly(Side.CLIENT) public String getServerId() { return this.serverId; } @SideOnly(Side.CLIENT) public PublicKey getPublicKey() { return this.publicKey; } @SideOnly(Side.CLIENT) public byte[] getVerifyToken() { return this.verifyToken; } }