private static async Task <Session> AuthenticateAsync(IClientChannel channel, Identity identity, string password) { var authentication = new PlainAuthentication(); authentication.SetToBase64Password(password); return(await channel.EstablishSessionAsync( (compressionOptions) => compressionOptions[0], (encryptionOptions) => encryptionOptions[0], identity, (schemeOptions, roundtrip) => authentication, "default", CancellationToken.None)); }
public async Task <bool> ConnectAsGuestAsync(string domain, CancellationToken cancellationToken) { var tcpClient = new TcpClient(); #if DEBUG ITraceWriter traceWriter = new DebugTraceWriter("Client"); #else ITraceWriter traceWriter = new FileTraceWriter("client.log"); #endif var transport = new TcpTransport( new TcpClientAdapter(tcpClient), new EnvelopeSerializer(), hostName: _clientUri.Host, traceWriter: traceWriter ); Channel = new ClientChannel(transport, TimeSpan.FromSeconds(60), autoReplyPings: true, autoNotifyReceipt: true); await Channel.Transport.OpenAsync(_clientUri, cancellationToken); var identity = new Identity() { Name = Guid.NewGuid().ToString(), Domain = domain }; var resultSession = await Channel.EstablishSessionAsync( c => c.First(), e => SessionEncryption.TLS, identity, (s, r) => new GuestAuthentication(), Environment.MachineName, cancellationToken); if (resultSession.State != SessionState.Established) { return(false); } return(true); }
public async Task<bool> ConnectAsGuestAsync(string domain, CancellationToken cancellationToken) { var tcpClient = new TcpClient(); #if DEBUG ITraceWriter traceWriter = new DebugTraceWriter("Client"); #else ITraceWriter traceWriter = new FileTraceWriter("client.log"); #endif var transport = new TcpTransport( new TcpClientAdapter(tcpClient), new EnvelopeSerializer(), hostName: _clientUri.Host, traceWriter: traceWriter ); Channel = new ClientChannel(transport, TimeSpan.FromSeconds(60), autoReplyPings: true, autoNotifyReceipt: true); await Channel.Transport.OpenAsync(_clientUri, cancellationToken); var identity = new Identity() { Name = Guid.NewGuid().ToString(), Domain = domain }; var resultSession = await Channel.EstablishSessionAsync( c => c.First(), e => SessionEncryption.TLS, identity, (s, r) => new GuestAuthentication(), Environment.MachineName, cancellationToken); if (resultSession.State != SessionState.Established) { return false; } return true; }
public async Task <bool> ConnectWithPasswordAsync(Identity identity, string password, CancellationToken cancellationToken) { var tcpClient = new TcpClient(); #if DEBUG ITraceWriter traceWriter = new DebugTraceWriter("Client"); #else ITraceWriter traceWriter = new FileTraceWriter("client.log"); #endif var transport = new TcpTransport( new TcpClientAdapter(tcpClient), new EnvelopeSerializer(), hostName: _clientUri.Host, traceWriter: traceWriter ); Channel = new ClientChannel(transport, TimeSpan.FromSeconds(60), autoReplyPings: true, autoNotifyReceipt: true); await Channel.Transport.OpenAsync(_clientUri, cancellationToken); var resultSession = await Channel.EstablishSessionAsync( c => c.First(), e => SessionEncryption.TLS, identity, (s, r) => { var auth = new PlainAuthentication(); auth.SetToBase64Password(password); return(auth); }, Environment.MachineName, cancellationToken); if (resultSession.State != SessionState.Established) { return(false); } return(true); }
private static async Task<Session> AuthenticateAsync(IClientChannel channel, Identity identity, string password) { var authentication = new PlainAuthentication (); authentication.SetToBase64Password (password); return await channel.EstablishSessionAsync ( (compressionOptions) => compressionOptions[0], (encryptionOptions) => encryptionOptions[0], identity, (schemeOptions, roundtrip) => authentication, "default", CancellationToken.None); }
public async Task<bool> ConnectWithPasswordAsync(Identity identity, string password, CancellationToken cancellationToken) { var tcpClient = new TcpClient(); #if DEBUG ITraceWriter traceWriter = new DebugTraceWriter("Client"); #else ITraceWriter traceWriter = new FileTraceWriter("client.log"); #endif var transport = new TcpTransport( new TcpClientAdapter(tcpClient), new EnvelopeSerializer(), hostName: _clientUri.Host, traceWriter: traceWriter ); Channel = new ClientChannel(transport, TimeSpan.FromSeconds(60), autoReplyPings: true, autoNotifyReceipt: true); await Channel.Transport.OpenAsync(_clientUri, cancellationToken); var resultSession = await Channel.EstablishSessionAsync( c => c.First(), e => SessionEncryption.TLS, identity, (s, r) => { var auth = new PlainAuthentication(); auth.SetToBase64Password(password); return auth; }, Environment.MachineName, cancellationToken); if (resultSession.State != SessionState.Established) { return false; } return true; }