예제 #1
0
 public override bool TryGetToken(EndpointAddress target, EndpointAddress issuer, out GenericXmlSecurityToken cachedToken)
 {
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     cachedToken = null;
     lock (this.thisLock)
     {
         IssuedTokenCacheBase.Key key = new IssuedTokenCacheBase.Key(target.Uri, (issuer == null) ? null : issuer.Uri);
         GenericXmlSecurityToken  genericXmlSecurityToken;
         if (this.cache.TryGetValue(key, out genericXmlSecurityToken))
         {
             if (genericXmlSecurityToken.ValidTo < DateTime.UtcNow + TimeSpan.FromMinutes(1.0))
             {
                 this.cache.Remove(key);
                 this.OnTokenRemoved(key);
             }
             else
             {
                 cachedToken = genericXmlSecurityToken;
             }
         }
     }
     return(cachedToken != null);
 }
예제 #2
0
 protected override void OnTokenAdded(IssuedTokenCacheBase.Key key, GenericXmlSecurityToken token)
 {
     using (FileStream fileStream = File.Open(this.fileName, FileMode.Append, FileAccess.Write))
     {
         fileStream.Seek(0L, SeekOrigin.End);
         FileIssuedTokenCache.SerializeCachedToken(fileStream, key.Target, key.Issuer, token);
     }
 }
예제 #3
0
 protected override void OnTokenRemoved(IssuedTokenCacheBase.Key key)
 {
     using (FileStream fileStream = File.Open(this.fileName, FileMode.Append, FileAccess.Write))
     {
         fileStream.Seek(0L, SeekOrigin.Begin);
         foreach (IssuedTokenCacheBase.Key key2 in base.Cache.Keys)
         {
             GenericXmlSecurityToken token = base.Cache[key2];
             FileIssuedTokenCache.SerializeCachedToken(fileStream, key.Target, key.Issuer, token);
         }
     }
 }
예제 #4
0
            public override bool Equals(object obj)
            {
                IssuedTokenCacheBase.Key key = obj as IssuedTokenCacheBase.Key;
                if (key == null)
                {
                    return(false);
                }
                bool flag = (this.target == null && key.target == null) || this.target.Equals(key.target);

                if (flag)
                {
                    flag = ((this.issuer == null && key.issuer == null) || this.issuer.Equals(key.issuer));
                }
                return(flag);
            }
예제 #5
0
 public override void AddToken(GenericXmlSecurityToken token, EndpointAddress target, EndpointAddress issuer)
 {
     if (token == null)
     {
         throw new ArgumentNullException("token");
     }
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     lock (this.thisLock)
     {
         IssuedTokenCacheBase.Key key = new IssuedTokenCacheBase.Key(target.Uri, (issuer == null) ? null : issuer.Uri);
         this.cache.Add(key, token);
         this.OnTokenAdded(key, token);
     }
 }
예제 #6
0
 protected abstract void OnTokenRemoved(IssuedTokenCacheBase.Key key);
예제 #7
0
 protected abstract void OnTokenAdded(IssuedTokenCacheBase.Key key, GenericXmlSecurityToken token);
예제 #8
0
 protected override void OnTokenAdded(IssuedTokenCacheBase.Key key, GenericXmlSecurityToken token)
 {
 }
예제 #9
0
 protected override void OnTokenRemoved(IssuedTokenCacheBase.Key key)
 {
 }