Example #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());
     }
 }
Example #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);
        }