示例#1
0
 /// <summary>
 /// Retrives a STS token based on <see cref="Settings"/>
 /// </summary>
 /// <returns></returns>
 public GenericXmlSecurityToken GetSecurityToken()
 {
     if (BootstrapToken != null)
     {
         return((GenericXmlSecurityToken)_stsTokenService.GetTokenWithBootstrapToken(BootstrapToken));
     }
     else
     {
         return((GenericXmlSecurityToken)_stsTokenService.GetToken());
     }
 }
示例#2
0
        private SecurityToken GetTokenInternal(SecurityToken bootstrapToken)
        {
            var cacheKey = bootstrapToken != null ? bootstrapToken.Id + _wspEndpointId : _wspEndpointId;

            var securityToken = (SecurityToken)TokenCache.Get(cacheKey);

            if (securityToken == null)
            {
                if (bootstrapToken == null)
                {
                    securityToken = _stsTokenService.GetToken();
                }
                else
                {
                    securityToken = _stsTokenService.GetTokenWithBootstrapToken(bootstrapToken);
                }
                TokenCache.Add(new CacheItem(cacheKey, securityToken),
                               new CacheItemPolicy {
                    AbsoluteExpiration = securityToken.ValidTo - _cacheClockSkew
                });
            }

            return(securityToken);
        }
示例#3
0
        private string GetSamlTokenXml()
        {
            var securityToken = (GenericXmlSecurityToken)_stsTokenService.GetToken();

            return(securityToken.TokenXml.OuterXml);
        }
        public void TotalFlowTokenExpiredTest()
        {
            // Arrange
            var client = new HelloWorldClient();
            var channelWithIssuedToken = client.ChannelFactory.CreateChannelWithIssuedToken(_stsTokenService.GetToken());

            // Act
            try
            {
                Thread.Sleep(_wait);
                channelWithIssuedToken.HelloSign("Schultz");
                Assert.IsTrue(false, "Expected exception was not thrown!!!");
            }
            catch (MessageSecurityException mse)
            {
                // Assert
                var fe = mse.InnerException as FaultException;
                Assert.IsNotNull(fe, "Expected inner fault exception");
                Assert.AreEqual("At least one security token in the message could not be validated.", fe.Message);
            }
        }