Example #1
0
        internal static async Task <IAsyncTransport> OpenAsync(this SaslProfile saslProfile, string hostname,
                                                               IBufferManager bufferManager, IAsyncTransport transport, DescribedList command)
        {
            // if transport is closed, pump reader should throw exception
            TransportWriter writer = new TransportWriter(transport, e => { });

            ProtocolHeader myHeader = saslProfile.Start(writer, command);

            AsyncPump pump = new AsyncPump(bufferManager, transport);
            SaslCode  code = SaslCode.Auth;

            await pump.PumpAsync(
                SaslProfile.MaxFrameSize,
                header =>
            {
                saslProfile.OnHeader(myHeader, header);
                return(true);
            },
                buffer =>
            {
                return(saslProfile.OnFrame(hostname, writer, buffer, out code));
            }).ConfigureAwait(false);

            await writer.FlushAsync().ConfigureAwait(false);

            if (code != SaslCode.Ok)
            {
                throw new AmqpException(ErrorCode.UnauthorizedAccess,
                                        Fx.Format(SRAmqp.SaslNegoFailed, code));
            }

            return((IAsyncTransport)saslProfile.UpgradeTransportInternal(transport));
        }
Example #2
0
        internal static async Task <IAsyncTransport> OpenAsync(this SaslProfile saslProfile, string hostname,
                                                               IBufferManager bufferManager, IAsyncTransport transport)
        {
            // if transport is closed, pump reader should throw exception
            TransportWriter writer = new TransportWriter(transport, e => { });

            ProtocolHeader myHeader = saslProfile.Start(hostname, writer);

            AsyncPump pump = new AsyncPump(bufferManager, transport);

            await pump.PumpAsync(
                header =>
            {
                saslProfile.OnHeader(myHeader, header);
                return(true);
            },
                buffer =>
            {
                SaslCode code;
                return(saslProfile.OnFrame(writer, buffer, out code));
            });

            await writer.FlushAsync();

            return((IAsyncTransport)saslProfile.UpgradeTransportInternal(transport));
        }
        internal static async Task <IAsyncTransport> OpenAsync(this SaslProfile saslProfile, string hostname, IAsyncTransport transport)
        {
            ProtocolHeader header = saslProfile.Start(hostname, transport);

            AsyncPump pump = new AsyncPump(transport);

            await pump.PumpAsync(
                h => { saslProfile.OnHeader(header, h); return(true); },
                b => { SaslCode code; return(saslProfile.OnFrame(transport, b, out code)); });

            return((IAsyncTransport)saslProfile.UpgradeTransportInternal(transport));
        }
        internal static async Task<IAsyncTransport> OpenAsync(this SaslProfile saslProfile, string hostname, IAsyncTransport transport)
        {
            ProtocolHeader header = saslProfile.Start(hostname, transport);

            AsyncPump pump = new AsyncPump(transport);

            await pump.PumpAsync(
                h => { saslProfile.OnHeader(header, h); return true; },
                b => { SaslCode code; return saslProfile.OnFrame(transport, b, out code); });

            return (IAsyncTransport)saslProfile.UpgradeTransportInternal(transport);
        }
Example #5
0
        internal static async Task<IAsyncTransport> OpenAsync(this SaslProfile saslProfile, string hostname,
            IBufferManager bufferManager, IAsyncTransport transport)
        {
            // if transport is closed, pump reader should throw exception
            TransportWriter writer = new TransportWriter(transport, e => { });

            ProtocolHeader myHeader = saslProfile.Start(hostname, writer);

            AsyncPump pump = new AsyncPump(bufferManager, transport);
            SaslCode code = SaslCode.Auth;

            await pump.PumpAsync(
                header =>
                {
                    saslProfile.OnHeader(myHeader, header);
                    return true;
                },
                buffer =>
                {
                    return saslProfile.OnFrame(writer, buffer, out code);
                });

            await writer.FlushAsync();

            if (code != SaslCode.Ok)
            {
                throw new AmqpException(ErrorCode.UnauthorizedAccess,
                    Fx.Format(SRAmqp.SaslNegoFailed, code));
            }

            return (IAsyncTransport)saslProfile.UpgradeTransportInternal(transport);
        }
Example #6
0
        internal static async Task<IAsyncTransport> OpenAsync(this SaslProfile saslProfile, string hostname,
            IBufferManager bufferManager, IAsyncTransport transport)
        {
            // if transport is closed, pump reader should throw exception
            TransportWriter writer = new TransportWriter(transport, e => { });

            ProtocolHeader myHeader = saslProfile.Start(hostname, writer);

            AsyncPump pump = new AsyncPump(bufferManager, transport);

            await pump.PumpAsync(
                header =>
                {
                    saslProfile.OnHeader(myHeader, header);
                    return true;
                },
                buffer =>
                {
                    SaslCode code;
                    return saslProfile.OnFrame(writer, buffer, out code);
                });

            await writer.FlushAsync();

            return (IAsyncTransport)saslProfile.UpgradeTransportInternal(transport);
        }