public Boolean Download( String user , ref SecuruStik.Protocal.PublicKey pk ) { Byte[] pkBytes = null; Boolean ret = Download( user , ref pkBytes ); if ( pkBytes != null ) { try { String pkStr = Encoding.ASCII.GetString( pkBytes ); if ( this.IsOldVersion( pkStr ) ) { //throw new Exception( "Old version" ); //Old version MemoryStream ms = new MemoryStream( pkBytes ); BinaryFormatter bfer = new BinaryFormatter(); pk = (SecuruStik.Protocal.PublicKey)bfer.Deserialize( ms ); //Update this.Update( user , pk ); return true; } else { String[] param = pkStr.Split( '\n' ); pk = new PublicKey( user , param[ 0 ] , param[ 1 ] ); return true; } } catch ( System.Exception ){} } return false; }
public PublicKeyUnit(String id, SecuruStik.Protocal.PublicKey pk) { this._id = id; this.PK = pk; }
public Boolean Send( SecuruStik.Protocal.Packet packet ) { try { if ( this.IsInited == false ) { this.Init(); } if ( this.IsLogin == false ) { this.Login(); } byte[] packetBytes = CommunicatingProtocal.Serialize(packet); this.bw.Write(packetBytes.Length); this.bw.Write(packetBytes); this.bw.Flush(); return true; } catch (System.Exception ex) { MessageBox.Show( new Form { TopMost = true , StartPosition = FormStartPosition.CenterScreen } , "Disconnect with server.\r\nPlease check your network setting or firewall." , "" , MessageBoxButtons.OK , MessageBoxIcon.Error ); return false; } }
public Boolean Request_SetSharingInfo( SecuruStik.Protocal.SharingInfo sharingInfo ) { SecuruStik.Protocal.Request r = new SecuruStik.Protocal.Request(MessageType.Response_SetSharingInfo,this.UserEmail,sharingInfo); return this.Send( r ); }
public Boolean Request_SetPK( SecuruStik.Protocal.PublicKey pk ) { SecuruStik.Protocal.Request r = new SecuruStik.Protocal.Request( MessageType.Request_SetPK , this.UserEmail , pk ); return this.Send( r ); }
private void Send( User user , SecuruStik.Protocal.Packet packet ) { try { byte[] packetBytes = CommunicatingProtocal.Serialize( packet ); user.bw.Write( packetBytes.Length ); user.bw.Write( packetBytes ); user.bw.Flush(); } catch ( System.Exception ) { } }