public void Add(ExternalRMSServerInfo entry)
 {
     if (entry == null)
     {
         throw new ArgumentNullException("entry");
     }
     this.dictionary.Add(entry.KeyUri, entry);
     this.serializer.TryWriteToDisk(this.dictionary);
 }
Exemple #2
0
        public static void AddNegativeServerInfo(Uri licenseUri)
        {
            ArgumentValidator.ThrowIfNull("licenseUri", licenseUri);
            RmsServerInfoManager.ThrowIfNotInitialized();
            ExternalRMSServerInfo externalRMSServerInfo = new ExternalRMSServerInfo(licenseUri);

            externalRMSServerInfo.MarkAsNegative();
            RmsServerInfoManager.serverInfoMap.Add(externalRMSServerInfo);
        }
 internal static bool TryReadValues(string[] values, out Uri key, out ExternalRMSServerInfo value)
 {
     if (ExternalRMSServerInfo.TryParse(values, out value))
     {
         key = value.KeyUri;
         return(true);
     }
     key = null;
     return(false);
 }
 internal static bool TryWriteValues(Uri key, ExternalRMSServerInfo value, out string[] values)
 {
     if (key == null || value == null)
     {
         ExternalRmsServerInfoMap.Tracer.TraceDebug(0L, "External Rms Server Info Map failed to write values.");
         values = null;
         return(false);
     }
     values = value.ToStringArray();
     return(true);
 }
        public static bool TryParse(string[] values, out ExternalRMSServerInfo info)
        {
            info = null;
            if (values == null || values.Length != ExternalRMSServerInfo.ColumnNames.Length)
            {
                ExternalRMSServerInfo.Tracer.TraceError(0L, "External Rms Server Info failed to parse values.");
                return(false);
            }
            Uri uri;

            if (!Uri.TryCreate(values[0], UriKind.Absolute, out uri))
            {
                ExternalRMSServerInfo.Tracer.TraceError <string>(0L, "External Rms Server Info failed to parse Key Uri ({0}).", values[0]);
                return(false);
            }
            long num;

            if (long.TryParse(values[5], out num) && num >= DateTime.MinValue.Ticks && num <= DateTime.MaxValue.Ticks)
            {
                DateTime d    = new DateTime(num);
                bool     flag = d != DateTime.MaxValue;
                Uri      uri2;
                if (!Uri.TryCreate(values[1], UriKind.Absolute, out uri2) && !flag)
                {
                    ExternalRMSServerInfo.Tracer.TraceError <string>(0L, "External Rms Server Info failed to parse CertificationWsUrl ({0}).", values[1]);
                }
                Uri uri3;
                if (!Uri.TryCreate(values[2], UriKind.Absolute, out uri3) && !flag)
                {
                    ExternalRMSServerInfo.Tracer.TraceError <string>(0L, "External Rms Server Info failed to parse CertificationWsTargetUri ({0}).", values[2]);
                }
                Uri uri4;
                if (!Uri.TryCreate(values[3], UriKind.Absolute, out uri4) && !flag)
                {
                    ExternalRMSServerInfo.Tracer.TraceError <string>(0L, "External Rms Server Info failed to parse ServerLicensingWsUrl ({0}).", values[3]);
                }
                Uri uri5;
                if (!Uri.TryCreate(values[4], UriKind.Absolute, out uri5) && !flag)
                {
                    ExternalRMSServerInfo.Tracer.TraceError <string>(0L, "External Rms Server Info failed to parse ServerLicensingWsTargetUri ({0}).", values[4]);
                }
                info = new ExternalRMSServerInfo(uri, uri2, uri3, uri4, uri5, d);
                return(true);
            }
            ExternalRMSServerInfo.Tracer.TraceError <string>(0L, "External Rms Server Info failed to parse Expiry Time ({0}).", values[5]);
            return(false);
        }
 public bool TryGet(Uri key, out ExternalRMSServerInfo entry)
 {
     if (key == null)
     {
         entry = null;
         return(false);
     }
     if (!this.dictionary.TryGetValue(key, out entry))
     {
         return(false);
     }
     if (entry.ExpiryTime != DateTime.MaxValue && entry.ExpiryTime < DateTime.UtcNow)
     {
         ExternalRmsServerInfoMap.Tracer.TraceDebug <Uri>(0L, "External Rms Server Info Map removed expired negative entry for key ({0}).", key);
         this.Remove(key);
         entry = null;
         return(false);
     }
     return(true);
 }
Exemple #7
0
 public static void LogAcquireServerInfoResult(RmsClientManagerContext context, ExternalRMSServerInfo serverInfo)
 {
     if (!RmsClientManagerLog.rmsLogEnabled)
     {
         return;
     }
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (serverInfo == null)
     {
         RmsClientManagerLog.LogEvent(RmsClientManagerLog.RmsClientManagerFeature.ServerInfo, RmsClientManagerLog.RmsClientManagerEvent.Success, context.OrgId, context.TransactionId, RmsClientManagerLog.ServerInfoNotFound, context.ContextStringForm);
         return;
     }
     RmsClientManagerLog.LogEvent(RmsClientManagerLog.RmsClientManagerFeature.ServerInfo, RmsClientManagerLog.RmsClientManagerEvent.Success, context.OrgId, context.TransactionId, string.Format(CultureInfo.InvariantCulture, "KeyUri: {0}; CertificationWSPipeline: {1}; CertificationWSTargetUri: {2}; ServerLicensingWSPipeline: {3}; ServerLicensingWSTargetUri: {4}; ExpiryTime: {5}", new object[]
     {
         (serverInfo.KeyUri == null) ? RmsClientManagerLog.ServerInfoUriNull : serverInfo.KeyUri.ToString(),
         (serverInfo.CertificationWSPipeline == null) ? RmsClientManagerLog.ServerInfoUriNull : serverInfo.CertificationWSPipeline.ToString(),
         (serverInfo.CertificationWSTargetUri == null) ? RmsClientManagerLog.ServerInfoUriNull : serverInfo.CertificationWSTargetUri.ToString(),
         (serverInfo.ServerLicensingWSPipeline == null) ? RmsClientManagerLog.ServerInfoUriNull : serverInfo.ServerLicensingWSPipeline.ToString(),
         (serverInfo.ServerLicensingWSTargetUri == null) ? RmsClientManagerLog.ServerInfoUriNull : serverInfo.ServerLicensingWSTargetUri.ToString(),
         serverInfo.ExpiryTime.Ticks.ToString()
     }), context.ContextStringForm);
 }