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