예제 #1
0
 public override bool Equals(object obj)
 {
     if (obj != null)
     {
         if (obj.GetType() == this.GetType())
         {
             CardspacePolicyInfo policyToCompare = (CardspacePolicyInfo)obj;
             return(policyToCompare.IdentityProvider == this.IdentityProvider &&
                    policyToCompare.RelyingParty == this.RelyingParty &&
                    policyToCompare.Certificate == this.Certificate);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
예제 #2
0
        //-----------------------------------------

        //-----------------------------------------
        // Constructors
        //-----------------------------------------
        protected override SecurityToken GetInfoCardSecurityToken(bool requiresInfoCard, System.IdentityModel.Selectors.CardSpacePolicyElement[] chain, System.IdentityModel.Selectors.SecurityTokenSerializer tokenSerializer)
        {
            CardspacePolicyInfo policyInfo    = new CardspacePolicyInfo(chain);
            TimeZone            localTimeZone = TimeZone.CurrentTimeZone;

            if (    //Does the cache contain a token with the specified policy info?
                _cachedInformationCardTokens.ContainsKey(policyInfo) &&
                //Is the token is still valid?
                localTimeZone.ToLocalTime(_cachedInformationCardTokens[policyInfo].ValidFrom) < DateTime.Now &&
                localTimeZone.ToLocalTime(_cachedInformationCardTokens[policyInfo].ValidTo) > DateTime.Now
                )
            {
                return(CachedInformationCardTokens[policyInfo]);
            }
            else
            {
                lock (CachedInformationCardTokens)
                {
                    SecurityToken newInformationCardToken = base.GetInfoCardSecurityToken(requiresInfoCard, chain, tokenSerializer);
                    CachedInformationCardTokens.Add(policyInfo, newInformationCardToken);
                    return(newInformationCardToken);
                }
            }
        }