private void Negotiate_ReadWhole_End(IAsyncResult ar) { Negotiation_SO asyncState = (Negotiation_SO)ar.AsyncState; try { asyncState.UpdateContext(); this.EndReadWhole(ar); AuthMethod method = this.ExtractAuthMethod(asyncState.Reply); if (((AuthMethod.NoAcceptable == method) && !asyncState.UseCredentials) && (base._proxyUser != null)) { asyncState.UseCredentials = true; byte[] buffer = this.PrepareNegotiationCmd(asyncState.UseCredentials); base.NStream.BeginWrite(buffer, 0, buffer.Length, new AsyncCallback(this.Negotiate_Write_End), asyncState); } else { this.BeginDoAuthentication(method, new AsyncCallback(this.Negotiate_DoAuth_End), asyncState); } } catch (Exception exception) { asyncState.Exception = exception; asyncState.SetCompleted(); } }
private IAsyncResult BeginNegotiate(AsyncCallback callback, object state) { bool preAuthenticate = base.PreAuthenticate; if (base._proxyUser == null) { preAuthenticate = false; } Negotiation_SO n_so = new Negotiation_SO(preAuthenticate, callback, state); byte[] buffer = this.PrepareNegotiationCmd(n_so.UseCredentials); base.NStream.BeginWrite(buffer, 0, buffer.Length, new AsyncCallback(this.Negotiate_Write_End), n_so); return(n_so); }
private void Negotiate_DoAuth_End(IAsyncResult ar) { Negotiation_SO asyncState = (Negotiation_SO)ar.AsyncState; try { asyncState.UpdateContext(); this.EndDoAuthentication(ar); } catch (Exception exception) { asyncState.Exception = exception; } asyncState.SetCompleted(); }
private void Negotiate_Write_End(IAsyncResult ar) { Negotiation_SO asyncState = (Negotiation_SO)ar.AsyncState; try { asyncState.UpdateContext(); base.NStream.EndWrite(ar); this.BeginReadWhole(asyncState.Reply, 0, 2, new AsyncCallback(this.Negotiate_ReadWhole_End), asyncState); } catch (Exception exception) { asyncState.Exception = exception; asyncState.SetCompleted(); } }
IAsyncResult BeginNegotiate(AsyncCallback callback, object state) { bool useCredentials = PreAuthenticate; if(null == _proxyUser) useCredentials = false; Negotiation_SO stateObj = new Negotiation_SO(useCredentials, callback, state); //----------------------------------- // Send negotiation request byte[] cmd = PrepareNegotiationCmd(stateObj.UseCredentials); NStream.BeginWrite(cmd, 0, cmd.Length, new AsyncCallback(Negotiate_Write_End), stateObj); return stateObj; }