Beispiel #1
0
        public static void AddNegativeServerInfo(Uri licenseUri)
        {
            ArgumentValidator.ThrowIfNull("licenseUri", licenseUri);
            RmsServerInfoManager.ThrowIfNotInitialized();
            ExternalRMSServerInfo externalRMSServerInfo = new ExternalRMSServerInfo(licenseUri);

            externalRMSServerInfo.MarkAsNegative();
            RmsServerInfoManager.serverInfoMap.Add(externalRMSServerInfo);
        }
Beispiel #2
0
        public static ExternalRMSServerInfo EndAcquireServerInfo(IAsyncResult asyncResult)
        {
            RmsServerInfoManager.ThrowIfNotInitialized();
            ArgumentValidator.ThrowIfNull("asyncResult", asyncResult);
            AcquireServerInfoAsyncResult acquireServerInfoAsyncResult = asyncResult as AcquireServerInfoAsyncResult;

            if (acquireServerInfoAsyncResult == null)
            {
                throw new InvalidOperationException("asyncResult cannot be null and has to be type of AcquireServerInfoAsyncResult");
            }
            acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.EndAcquireServerInfo);
            if (!acquireServerInfoAsyncResult.IsCompleted)
            {
                acquireServerInfoAsyncResult.InternalWaitForCompletion();
            }
            Exception ex = acquireServerInfoAsyncResult.Result as Exception;

            if (ex != null)
            {
                RmsServerInfoManager.Tracer.TraceError <Uri, Exception>(0L, "EndAcquireServerInfo hit an exception; and as a result of it, '{0}' will be marked as negative entry in cache. Exception - {1}", acquireServerInfoAsyncResult.LicenseUri, ex);
                RightsManagementException ex2 = ex as RightsManagementException;
                if (ex2 == null || ex2.IsPermanent)
                {
                    RmsServerInfoManager.AddNegativeServerInfo(acquireServerInfoAsyncResult.LicenseUri);
                }
                RmsClientManagerLog.LogException(RmsClientManagerLog.RmsClientManagerFeature.ServerInfo, acquireServerInfoAsyncResult.Context, ex);
                throw ex;
            }
            ExternalRMSServerInfo externalRMSServerInfo;

            if (!RmsServerInfoManager.serverInfoMap.TryGet(acquireServerInfoAsyncResult.LicenseUri, out externalRMSServerInfo))
            {
                RmsClientManagerLog.LogAcquireServerInfoResult(acquireServerInfoAsyncResult.Context, null);
                RmsServerInfoManager.Tracer.TraceError(0L, "Could not find the server info in the cache");
                return(null);
            }
            RmsClientManagerLog.LogAcquireServerInfoResult(acquireServerInfoAsyncResult.Context, externalRMSServerInfo);
            if (externalRMSServerInfo.IsNegativeEntry)
            {
                RmsServerInfoManager.Tracer.TraceError(0L, "RmsServerInfoManager found requested server info in cache; but it is a negative entry!");
                return(null);
            }
            return(externalRMSServerInfo);
        }
Beispiel #3
0
        public static IAsyncResult BeginAcquireServerInfo(RmsClientManagerContext context, Uri licenseUri, object state, AsyncCallback callback)
        {
            RmsServerInfoManager.ThrowIfNotInitialized();
            ArgumentValidator.ThrowIfNull("licenseUri", licenseUri);
            AcquireServerInfoAsyncResult acquireServerInfoAsyncResult = new AcquireServerInfoAsyncResult(context, licenseUri, state, callback);

            acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.BeginAcquireServerInfo);
            ExternalRMSServerInfo externalRMSServerInfo;

            if (RmsServerInfoManager.serverInfoMap.TryGet(licenseUri, out externalRMSServerInfo))
            {
                acquireServerInfoAsyncResult.InvokeCallback();
                return(acquireServerInfoAsyncResult);
            }
            RmsClientManagerLog.LogUriEvent(RmsClientManagerLog.RmsClientManagerFeature.ServerInfo, RmsClientManagerLog.RmsClientManagerEvent.Acquire, context, licenseUri);
            WebProxy localServerProxy;

            try
            {
                localServerProxy = RmsClientManagerUtils.GetLocalServerProxy(true);
            }
            catch (ExchangeConfigurationException value)
            {
                acquireServerInfoAsyncResult.InvokeCallback(value);
                return(acquireServerInfoAsyncResult);
            }
            bool flag = RmsServerInfoManager.outstandingFindServiceLocationCalls.EnqueueResult(licenseUri, acquireServerInfoAsyncResult);

            if (flag)
            {
                acquireServerInfoAsyncResult.ServerWSManager = new ServerWSManager(licenseUri, RmsServerInfoManager.perfCounters, acquireServerInfoAsyncResult.LatencyTracker, localServerProxy, RmsClientManager.AppSettings.RmsSoapQueriesTimeout);
                ServiceType[] serviceTypes = new ServiceType[]
                {
                    ServiceType.CertificationWSService,
                    ServiceType.ServerLicensingWSService,
                    ServiceType.CertificationMexService,
                    ServiceType.ServerLicensingMexService
                };
                RmsClientManager.TracePass(null, context.SystemProbeId, "Querying the RMS server {0} for server info", new object[]
                {
                    licenseUri
                });
                acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.BeginFindServiceLocationsFirstRequest);
                try
                {
                    acquireServerInfoAsyncResult.ServerWSManager.BeginFindServiceLocations(serviceTypes, RmsClientManagerUtils.WrapCallbackWithUnhandledExceptionHandlerAndUpdatePoisonContext(new AsyncCallback(RmsServerInfoManager.AcquireServiceLocationCallback)), acquireServerInfoAsyncResult);
                    return(acquireServerInfoAsyncResult);
                }
                catch (InvalidOperationException ex)
                {
                    RmsClientManager.TraceFail(null, context.SystemProbeId, "Hit an exception during BeginFindServiceLocations {0}", new object[]
                    {
                        ex
                    });
                    acquireServerInfoAsyncResult.InvokeCallback(new RightsManagementException(RightsManagementFailureCode.FindServiceLocationFailed, ServerStrings.FailedToFindServerInfo(licenseUri), ex));
                    return(acquireServerInfoAsyncResult);
                }
            }
            RmsClientManager.TracePass(null, context.SystemProbeId, "A request for server info for the license uri {0} is already pending. Enqueuing the result", new object[]
            {
                licenseUri
            });
            acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.BeginFindServiceLocationsPendingRequest);
            return(acquireServerInfoAsyncResult);
        }