예제 #1
0
        private static void AddAuthorizationHeader(HttpClient httpClient, string tokenXml)
        {
            var tokenEncoder    = new DeflatedSamlTokenHeaderEncoder();
            var encodedTokenXml = tokenEncoder.Encode(tokenXml);

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", encodedTokenXml);
        }
        public void Encode_StringWithI8NChars_RoundtripsCorrectly()
        {
            var tokenHeaderEncoder = new DeflatedSamlTokenHeaderEncoder();

            var encodedTokenHeader = tokenHeaderEncoder.Encode(ArbitraryStringWithI8NChars);

            var decodedTokenHeader = tokenHeaderEncoder.Decode(encodedTokenHeader);

            decodedTokenHeader.Should().Be(ArbitraryStringWithI8NChars);
        }
        private async Task RefreshToken <TConfiguration>(IWebApiClient <TConfiguration> client)
            where TConfiguration : IWebApiConfiguration
        {
            var token = await this.TokenProvider.GetToken(this).ConfigureAwait(false);

            var encoder = new DeflatedSamlTokenHeaderEncoder();
            var bearer  = encoder.Encode(((GenericXmlSecurityToken)token).TokenXml.OuterXml);

            this.TokenValidTo = token.ValidTo;
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearer);
        }
예제 #4
0
        public void LibLogLog4netAdapterPicksUpLogsFromLibrary()
        {
            var appender = ConfigureMemoryAppender();
            var sut      = new DeflatedSamlTokenHeaderEncoder();

            sut.Encode("simulatedtoken");
            var events = appender.GetEvents();

            Assert.AreEqual(1, events.Length);
            foreach (var e in events)
            {
                Console.WriteLine(e.RenderedMessage);
            }
        }