public void CheckTransportContext(TransportContext context)
        {
            var cbt1 = context.GetChannelBinding(ChannelBindingKind.Endpoint);
            var cbt2 = context.GetChannelBinding(ChannelBindingKind.Unique);
            var cbt3 = context.GetChannelBinding(ChannelBindingKind.Unknown);

            CheckChannelBinding(cbt1);
            CheckChannelBinding(cbt2);
            CheckChannelBinding(cbt3);

            Assert.True(cbt1 != null, "ChannelBindingKind.Endpoint token data should be returned from SCHANNEL.");
            Assert.True(cbt2 != null, "ChannelBindingKind.Unique token data should be returned from SCHANNEL.");
            Assert.True(cbt3 == null, "ChannelBindingKind.Unknown token data should not be returned from SCHANNEL since it does not map to a defined context attribute.");
        }
        public void CheckTransportContext(TransportContext context)
        {
            var cbt1 = context.GetChannelBinding(ChannelBindingKind.Endpoint);
            var cbt2 = context.GetChannelBinding(ChannelBindingKind.Unique);
            var cbt3 = context.GetChannelBinding(ChannelBindingKind.Unknown);

            CheckChannelBinding(cbt1);
            CheckChannelBinding(cbt2);
            CheckChannelBinding(cbt3);

            Assert.True(cbt1 != null, "ChannelBindingKind.Endpoint token data should be returned from SCHANNEL.");
            Assert.True(cbt2 != null, "ChannelBindingKind.Unique token data should be returned from SCHANNEL.");
            Assert.True(cbt3 == null, "ChannelBindingKind.Unknown token data should not be returned from SCHANNEL since it does not map to a defined context attribute.");
        }
        public async void WriteToStream(Stream outputStream, HttpContent content, TransportContext context)
        {
            try
            {
                var channelBinding = context.GetChannelBinding(ChannelBindingKind.Endpoint);

                var buffer = new byte[65536];
                using (var video = File.Open(_filename, FileMode.Open, FileAccess.Read))
                {
                    var length    = (int)video.Length;
                    var bytesRead = 1;
                    while (length > 0 && bytesRead > 0)
                    {
                        bytesRead = video.Read(buffer, 0, Math.Min(length, buffer.Length));
                        await outputStream.WriteAsync(buffer, 0, bytesRead);

                        length -= bytesRead;
                    }
                }
            }
            catch (HttpResponseException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                outputStream.Close();
            }
        }
Beispiel #4
0
        public static ChannelBinding GetToken(TransportContext context)
        {
            ChannelBinding token = null;

            if (context != null)
            {
                token = context.GetChannelBinding(ChannelBindingKind.Endpoint);
            }
            return(token);
        }
        private static void CheckTransportContext(TransportContext context)
        {
            var cbt1 = context.GetChannelBinding(ChannelBindingKind.Endpoint);
            var cbt2 = context.GetChannelBinding(ChannelBindingKind.Unique);
            var cbt3 = context.GetChannelBinding(ChannelBindingKind.Unknown);

            CheckChannelBinding(ChannelBindingKind.Endpoint, cbt1);
            CheckChannelBinding(ChannelBindingKind.Unique, cbt2);
            CheckChannelBinding(ChannelBindingKind.Unknown, cbt3);

            Assert.True(cbt1 != null, "ChannelBindingKind.Endpoint token data should be returned.");

            if (OperatingSystem.IsMacOS())
            {
                Assert.True(cbt2 == null, "ChannelBindingKind.Unique token data is not expected on OSX platform.");
            }
            else
            {
                Assert.True(cbt2 != null, "ChannelBindingKind.Unique token data should be returned.");
            }

            Assert.True(cbt3 == null, "ChannelBindingKind.Unknown token data should not be returned.");
        }
Beispiel #6
0
        public void CheckTransportContext(TransportContext context)
        {
            var cbt1 = context.GetChannelBinding(ChannelBindingKind.Endpoint);
            var cbt2 = context.GetChannelBinding(ChannelBindingKind.Unique);
            var cbt3 = context.GetChannelBinding(ChannelBindingKind.Unknown);

            CheckChannelBinding(cbt1);
            CheckChannelBinding(cbt2);
            CheckChannelBinding(cbt3);

            Assert.True(cbt1 != null, "ChannelBindingKind.Endpoint token data should be returned from SCHANNEL.");

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                Assert.True(cbt2 == null, "ChannelBindingKind.Unique token data is not expected from SecureTransport");
            }
            else
            {
                Assert.True(cbt2 != null, "ChannelBindingKind.Unique token data should be returned from SCHANNEL.");
            }

            Assert.True(cbt3 == null, "ChannelBindingKind.Unknown token data should not be returned from SCHANNEL since it does not map to a defined context attribute.");
        }
        public void CheckTransportContext(TransportContext context)
        {
            var cbt1 = context.GetChannelBinding(ChannelBindingKind.Endpoint);
            var cbt2 = context.GetChannelBinding(ChannelBindingKind.Unique);
            var cbt3 = context.GetChannelBinding(ChannelBindingKind.Unknown);

            CheckChannelBinding(ChannelBindingKind.Endpoint, cbt1);
            CheckChannelBinding(ChannelBindingKind.Unique, cbt2);
            CheckChannelBinding(ChannelBindingKind.Unknown, cbt3);

            Assert.True(cbt1 != null, "ChannelBindingKind.Endpoint token data should be returned.");

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                Assert.True(cbt2 == null, "ChannelBindingKind.Unique token data is not expected on OSX platform.");
            }
            else
            {
                Assert.True(cbt2 != null, "ChannelBindingKind.Unique token data should be returned.");
            }

            Assert.True(cbt3 == null, "ChannelBindingKind.Unknown token data should not be returned.");
        }
Beispiel #8
0
        ChannelBinding GetChannelBinding(ChannelBindingKind kind)
        {
            ChannelBinding channelBinding;

            try {
                // Note: Documentation for TransportContext.GetChannelBinding() states that it will return null if the
                // requested channel binding type is not supported, but it also states that it will throw
                // NotSupportedException, so we handle both.
                channelBinding = TransportContext?.GetChannelBinding(kind);
            } catch (NotSupportedException) {
                return(null);
            }

            if (channelBinding == null || channelBinding.IsClosed || channelBinding.IsInvalid)
            {
                return(null);
            }

            return(channelBinding);
        }
Beispiel #9
0
        protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
        {
            ChannelBinding = context.GetChannelBinding(ChannelBindingKind.Endpoint);

            return(base.SerializeToStreamAsync(stream, context));
        }
 /// <inheritdoc />
 public IChannelBinding GetChannelBinding(ChannelBindingKind kind)
 {
     return(_context.GetChannelBinding(kind).ToInterface());
 }
 protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
 {
     ChannelBinding = context.GetChannelBinding(ChannelBindingKind.Endpoint);
     
     return base.SerializeToStreamAsync(stream, context);
 }
 protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
 {
     ChannelBinding = context.GetChannelBinding(ChannelBindingKind.Endpoint);
     return(stream.WriteAsync(_content, 0, _content.Length));
 }
 protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
 {
     ChannelBinding = context.GetChannelBinding(ChannelBindingKind.Endpoint);
     return stream.WriteAsync(_content, 0, _content.Length);
 }