コード例 #1
0
        public static LicenseIdentity GetLicenseIdentity(RmsClientManagerContext context, string recipientAddress)
        {
            ArgumentValidator.ThrowIfNull("context", context);
            ArgumentValidator.ThrowIfNullOrEmpty("recipientAddress", recipientAddress);
            ADRawEntry adrawEntry;

            try
            {
                adrawEntry = context.ResolveRecipient(recipientAddress);
            }
            catch (ADTransientException innerException)
            {
                throw new ExchangeConfigurationException(ServerStrings.FailedToReadUserConfig(recipientAddress), innerException);
            }
            catch (ADOperationException innerException2)
            {
                throw new RightsManagementException(RightsManagementFailureCode.ADUserNotFound, ServerStrings.FailedToReadUserConfig(recipientAddress), innerException2);
            }
            if (adrawEntry == null)
            {
                throw new RightsManagementException(RightsManagementFailureCode.ADUserNotFound, ServerStrings.FailedToReadUserConfig(recipientAddress));
            }
            List <string> federatedEmailAddresses = RmsClientManagerUtils.GetFederatedEmailAddresses(context.OrgId, (ProxyAddressCollection)adrawEntry[ADRecipientSchema.EmailAddresses]);

            if (federatedEmailAddresses.Count == 0)
            {
                RmsClientManager.TraceFail(null, context.SystemProbeId, "GetLicenseIdentity: User {0} doesn't have any SMTP proxy address from a domain that is federated.", new object[]
                {
                    recipientAddress
                });
                throw new RightsManagementException(RightsManagementFailureCode.ADUserNotFederated, DirectoryStrings.UserHasNoSmtpProxyAddressWithFederatedDomain);
            }
            return(new LicenseIdentity(federatedEmailAddresses[0], federatedEmailAddresses.ToArray()));
        }
コード例 #2
0
 public static LicenseResponse[] GetLicenseResponses(UseLicenseResult[] endUseLicenses, Uri licenseUri)
 {
     RmsClientManagerUtils.ThrowOnNullOrEmptyArrayArgument("endUseLicenses", endUseLicenses);
     LicenseResponse[] array = new LicenseResponse[endUseLicenses.Length];
     for (int i = 0; i < endUseLicenses.Length; i++)
     {
         UseLicenseResult useLicenseResult = endUseLicenses[i];
         if (useLicenseResult.Error != null)
         {
             array[i] = new LicenseResponse(new RightsManagementException(RightsManagementFailureCode.OfflineRmsServerFailure, ServerStrings.FailedToAcquireUseLicense(licenseUri), useLicenseResult.Error));
         }
         else
         {
             ContentRight?usageRights;
             try
             {
                 usageRights = new ContentRight?(DrmClientUtils.GetUsageRightsFromLicense(useLicenseResult.EndUseLicense));
             }
             catch (RightsManagementException arg)
             {
                 Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceError <int, RightsManagementException>(0L, "Failed to get usage rights from license for recipient index {0}. Error {1}", i, arg);
                 usageRights = null;
             }
             array[i] = new LicenseResponse(useLicenseResult.EndUseLicense, usageRights);
         }
     }
     return(array);
 }
コード例 #3
0
        public static List <string> GetDelegatedEmailAddressesFromB2BUseLicense(string useLicense)
        {
            XmlDocument firstNodeXdoc = RmsClientManagerUtils.GetFirstNodeXdoc(useLicense);

            if (firstNodeXdoc == null)
            {
                return(null);
            }
            XmlNode       xmlNode = firstNodeXdoc.SelectSingleNode("XrML/BODY[@type=\"LICENSE\"]/ISSUEDPRINCIPALS/PRINCIPAL/OBJECT[@type=\"Group-Identity\"]/ADDRESS[@type=\"DelegatedEmailAddress\"]/text()");
            List <string> list    = new List <string>();

            if (RmsClientManagerUtils.ValidateDelegatedEmailAddressOrAliasNode(xmlNode))
            {
                list.Add(xmlNode.Value);
            }
            XmlNodeList xmlNodeList = firstNodeXdoc.SelectNodes("XrML/BODY[@type=\"LICENSE\"]/ISSUEDPRINCIPALS/PRINCIPAL/OBJECT[@type=\"Group-Identity\"]/ADDRESS[@type=\"email_alias\"]/text()");

            foreach (object obj in xmlNodeList)
            {
                XmlNode xmlNode2 = (XmlNode)obj;
                if (RmsClientManagerUtils.ValidateDelegatedEmailAddressOrAliasNode(xmlNode2))
                {
                    list.Add(xmlNode2.Value);
                }
            }
            return(list);
        }
コード例 #4
0
 public UseLicenseAsyncResult(RmsClientManagerContext context, Uri licenseUri, XmlNode[] issuanceLicense, object callerState, AsyncCallback callerCallback) : base(context, callerState, callerCallback)
 {
     ArgumentValidator.ThrowIfNull("licenseUri", licenseUri);
     RmsClientManagerUtils.ThrowOnNullOrEmptyArrayArgument("issuanceLicense", issuanceLicense);
     this.licenseUri      = licenseUri;
     this.issuanceLicense = issuanceLicense;
 }
コード例 #5
0
        public static OrganizationId OrgIdFromPublishingLicenseOrDefault(string publishingLicense, OrganizationId defaultOrgId, out Guid externalDirectoryOrgId)
        {
            ArgumentValidator.ThrowIfNullOrEmpty("publishingLicense", publishingLicense);
            ArgumentValidator.ThrowIfNull("defaultOrgId", defaultOrgId);
            externalDirectoryOrgId = Guid.Empty;
            Guid guid;

            if (!RmsClientManagerUtils.ExtractExternalOrgIdFromPublishingLicense(publishingLicense, out guid))
            {
                return(defaultOrgId);
            }
            Guid b;

            if (!RmsClientManager.IRMConfig.GetTenantExternalDirectoryOrgId(defaultOrgId, out b))
            {
                return(defaultOrgId);
            }
            if (guid == b)
            {
                return(defaultOrgId);
            }
            OrganizationId result;

            if (ADOperationResult.Success == RmsClientManagerUtils.TryGetOrganizationIdFromExternalDirectoryOrgId(guid, out result))
            {
                externalDirectoryOrgId = guid;
                return(result);
            }
            return(defaultOrgId);
        }
コード例 #6
0
 public RmsClientManagerContext(OrganizationId orgId, RmsClientManagerContext.ContextId contextId, string contextValue, IADRecipientCache recipientCache, IRmsLatencyTracker latencyTracker, string publishingLicense = null) : this(orgId, contextId, contextValue, Guid.NewGuid(), recipientCache, latencyTracker)
 {
     if (!string.IsNullOrEmpty(publishingLicense))
     {
         this.orgId = RmsClientManagerUtils.OrgIdFromPublishingLicenseOrDefault(publishingLicense, orgId, out this.externalDirectoryOrgId);
     }
 }
コード例 #7
0
 public RmsClientManagerContext(OrganizationId orgId, RmsClientManagerContext.ContextId contextId, string contextValue, string publishingLicense = null) : this(orgId, contextId, contextValue, Guid.NewGuid(), null, null)
 {
     if (!string.IsNullOrEmpty(publishingLicense))
     {
         this.orgId = RmsClientManagerUtils.OrgIdFromPublishingLicenseOrDefault(publishingLicense, orgId, out this.externalDirectoryOrgId);
     }
 }
コード例 #8
0
        public static ExDateTime GetUseLicenseExpiryTime(string license, ContentRight usageRights)
        {
            ArgumentValidator.ThrowIfNullOrEmpty("license", license);
            XmlDocument firstNodeXdoc = RmsClientManagerUtils.GetFirstNodeXdoc(license);

            if (firstNodeXdoc == null)
            {
                Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceDebug(0L, "Failed to parse the use license. Returning DateTime.MaxValue");
                return(ExDateTime.MaxValue);
            }
            XmlNode xmlNode = firstNodeXdoc.SelectSingleNode("XrML/BODY[@type=\"LICENSE\"]/ISSUEDTIME/text()");

            if (xmlNode == null || string.IsNullOrEmpty(xmlNode.Value))
            {
                Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceError(0L, "Failed to parse the use license to get the issued Time. Returning DateTime.MaxValue");
                return(ExDateTime.MaxValue);
            }
            DateTime d;

            if (!DateTime.TryParseExact(xmlNode.Value, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out d))
            {
                Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceError <string>(0L, "Invalid IssuedTime entry {0}. Returning DateTime.MaxValue", xmlNode.Value);
                return(ExDateTime.MaxValue);
            }
            if (usageRights.IsUsageRightGranted(ContentRight.Owner))
            {
                Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceDebug(0L, "User has OWNER rights - trying to get the expiry time from owner node");
                XmlNode xmlNode2 = firstNodeXdoc.SelectSingleNode("XrML/BODY[@type=\"LICENSE\"]/WORK/RIGHTSGROUP[@name=\"Main-Rights\"]/RIGHTSLIST/OWNER/CONDITIONLIST/TIME/INTERVALTIME/@days");
                if (xmlNode2 != null)
                {
                    Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceDebug <string>(0L, "Found the owner node {0}", xmlNode2.Value);
                    int num;
                    if (int.TryParse(xmlNode2.Value, out num))
                    {
                        return(new ExDateTime(ExTimeZone.TimeZoneFromKind(DateTimeKind.Utc), d + TimeSpan.FromDays((double)num)));
                    }
                }
                Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceDebug(0L, "Couldn't find the OWNER node - either OWNER has no expiry or the value is not parsable");
                return(ExDateTime.MaxValue);
            }
            if (usageRights.IsUsageRightGranted(ContentRight.View))
            {
                Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceDebug(0L, "User has VIEW rights - trying to get the expiry time from VIEW node");
                XmlNode xmlNode3 = firstNodeXdoc.SelectSingleNode("XrML/BODY[@type=\"LICENSE\"]/WORK/RIGHTSGROUP[@name=\"Main-Rights\"]/RIGHTSLIST/VIEW/CONDITIONLIST/TIME/INTERVALTIME/@days");
                if (xmlNode3 != null)
                {
                    Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceDebug <string>(0L, "Found the view node {0}", xmlNode3.Value);
                    int num2;
                    if (int.TryParse(xmlNode3.Value, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out num2))
                    {
                        return(new ExDateTime(ExTimeZone.TimeZoneFromKind(DateTimeKind.Utc), d + TimeSpan.FromDays((double)num2)));
                    }
                }
                Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceDebug(0L, "Couldn't find the VIEW node - either VIEW rights has no expiry or the value is not parsable");
            }
            return(ExDateTime.MaxValue);
        }
コード例 #9
0
        public static ChannelFactory <IWSCertificationServiceChannel> CreateCertificationChannelFactory(Uri targetUri, EndpointAddress epa, LicenseIdentity identity, OrganizationId organizationId, IRmsLatencyTracker latencyTracker)
        {
            CustomBinding binding = RmsClientManagerUtils.CreateCustomBinding(organizationId, 0);
            ChannelFactory <IWSCertificationServiceChannel> channelFactory = new ChannelFactory <IWSCertificationServiceChannel>(binding, epa);

            channelFactory.Endpoint.Behaviors.Remove(typeof(ClientCredentials));
            channelFactory.Endpoint.Behaviors.Add(new SamlClientCredentials(identity, organizationId, targetUri, Offer.IPCCertificationSTS, latencyTracker));
            return(channelFactory);
        }
コード例 #10
0
        private static void AcquireServerLicensingMexCallback(ICancelableAsyncResult asyncResult)
        {
            RmsServerInfoManager.Tracer.TraceDebug(0L, "AcquireServerLicensingMexCallback invoked");
            ArgumentValidator.ThrowIfNull("asyncResult", asyncResult);
            ArgumentValidator.ThrowIfNull("asyncResult.AsyncState", asyncResult.AsyncState);
            AcquireServerInfoAsyncResult acquireServerInfoAsyncResult = asyncResult.AsyncState as AcquireServerInfoAsyncResult;

            if (acquireServerInfoAsyncResult == null)
            {
                throw new InvalidOperationException("asyncResult.AsyncState has to be type of AcquireServerInfoAsyncResult.");
            }
            acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.AcquireServerLicensingMexCallback);
            Exception ex = null;

            try
            {
                DownloadResult downloadResult = acquireServerInfoAsyncResult.HttpClient.EndDownload(asyncResult);
                acquireServerInfoAsyncResult.LatencyTracker.EndTrackRmsLatency(RmsOperationType.AcquireServerLicensingMexData);
                if (downloadResult.IsSucceeded)
                {
                    Uri targetUriFromResponse = RmsClientManagerUtils.GetTargetUriFromResponse(downloadResult.ResponseStream);
                    if (targetUriFromResponse == null)
                    {
                        ex = new RightsManagementException(RightsManagementFailureCode.FailedToExtractTargetUriFromMex, ServerStrings.FailedToFindTargetUriFromMExData(acquireServerInfoAsyncResult.ServerLicensingMExUri), acquireServerInfoAsyncResult.LicenseUri.ToString());
                    }
                    else
                    {
                        acquireServerInfoAsyncResult.ServerInfo.ServerLicensingWSTargetUri = TokenTarget.Fix(targetUriFromResponse);
                        RmsServerInfoManager.serverInfoMap.Add(acquireServerInfoAsyncResult.ServerInfo);
                    }
                }
                else
                {
                    RmsClientManager.TraceFail(null, acquireServerInfoAsyncResult.Context.SystemProbeId, "Failed to download data from server licensing MEx {0}.  Exception is {1}", new object[]
                    {
                        acquireServerInfoAsyncResult.ServerLicensingMExUri,
                        downloadResult.Exception
                    });
                    ex = new RightsManagementException(RightsManagementFailureCode.FailedToDownloadMexData, ServerStrings.FailedToDownloadServerLicensingMExData(downloadResult.ResponseUri), downloadResult.Exception, acquireServerInfoAsyncResult.LicenseUri.ToString());
                    ((RightsManagementException)ex).IsPermanent = !downloadResult.IsRetryable;
                }
            }
            finally
            {
                acquireServerInfoAsyncResult.Release();
            }
            RmsServerInfoManager.Tracer.TraceDebug(0L, "AcquireServiceLocationCallback: Invoking find service location callbacks");
            RmsServerInfoManager.outstandingFindServiceLocationCalls.InvokeCallbacks(acquireServerInfoAsyncResult.LicenseUri, ex);
        }
コード例 #11
0
 public static LicenseeIdentity[] ConvertToLicenseeIdentities(RmsClientManagerContext context, string[] identities)
 {
     ArgumentValidator.ThrowIfNull("context", context);
     RmsClientManagerUtils.ThrowOnNullOrEmptyArrayArgument("identities", identities);
     LicenseeIdentity[] array = new LicenseeIdentity[identities.Length];
     for (int i = 0; i < identities.Length; i++)
     {
         if (!SmtpAddress.IsValidSmtpAddress(identities[i]))
         {
             throw new RightsManagementException(RightsManagementFailureCode.InvalidRecipient, ServerStrings.RecipientAddressInvalid(identities[i]));
         }
         ADRawEntry adrawEntry;
         try
         {
             adrawEntry = context.ResolveRecipient(identities[i]);
         }
         catch (ADTransientException innerException)
         {
             throw new ExchangeConfigurationException(ServerStrings.FailedToReadUserConfig(identities[i]), innerException);
         }
         catch (ADOperationException innerException2)
         {
             throw new RightsManagementException(RightsManagementFailureCode.ADUserNotFound, ServerStrings.FailedToReadUserConfig(identities[i]), innerException2);
         }
         IList <string> list = RmsClientManagerUtils.EmptyProxyList;
         string         text = null;
         bool           flag = false;
         if (adrawEntry != null)
         {
             ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)adrawEntry[ADRecipientSchema.EmailAddresses];
             if (proxyAddressCollection != null && proxyAddressCollection.Count != 0)
             {
                 list = new List <string>(proxyAddressCollection.Count);
                 foreach (ProxyAddress proxyAddress in proxyAddressCollection)
                 {
                     list.Add(proxyAddress.ValueString);
                 }
             }
             SmtpAddress smtpAddress = (SmtpAddress)adrawEntry[ADRecipientSchema.PrimarySmtpAddress];
             if (smtpAddress.IsValidAddress)
             {
                 text = smtpAddress.ToString();
             }
             flag = RmsClientManagerUtils.TreatRecipientAsRMSSuperuser(context.OrgId, (RecipientTypeDetails)adrawEntry[ADRecipientSchema.RecipientTypeDetails]);
         }
         array[i] = new LicenseeIdentity(string.IsNullOrEmpty(text) ? identities[i] : text, list, flag);
     }
     return(array);
 }
コード例 #12
0
        public ExternalRmsServerInfoMap(string path, int maxCount, IMruDictionaryPerfCounters perfCounters)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }
            string uniqueFileNameForProcess = RmsClientManagerUtils.GetUniqueFileNameForProcess("ExternalRmsServerInfo_1.dat");

            this.dictionary = new MruDictionary <Uri, ExternalRMSServerInfo>(maxCount, new ExternalRmsServerInfoMap.UriComparer(), perfCounters);
            this.serializer = new MruDictionarySerializer <Uri, ExternalRMSServerInfo>(path, uniqueFileNameForProcess, ExternalRMSServerInfo.ColumnNames, new MruDictionarySerializerRead <Uri, ExternalRMSServerInfo>(ExternalRmsServerInfoMap.TryReadValues), new MruDictionarySerializerWrite <Uri, ExternalRMSServerInfo>(ExternalRmsServerInfoMap.TryWriteValues), perfCounters);
            if (!this.serializer.TryReadFromDisk(this.dictionary))
            {
                ExternalRmsServerInfoMap.Tracer.TraceError <string>(0L, "External Rms Server Info Map failed to read map-file ({0}).", uniqueFileNameForProcess);
            }
        }
コード例 #13
0
 internal static bool ExtractExternalOrgIdFromPublishingLicense(string publishingLicense, out Guid externalDirectoryOrgId)
 {
     ArgumentValidator.ThrowIfNullOrEmpty("publishingLicense", publishingLicense);
     externalDirectoryOrgId = Guid.Empty;
     try
     {
         XmlDocument firstNodeXdoc = RmsClientManagerUtils.GetFirstNodeXdoc(publishingLicense);
         if (firstNodeXdoc == null)
         {
             return(false);
         }
         XmlNodeList xmlNodeList = firstNodeXdoc.SelectNodes("/XrML/BODY/ISSUEDPRINCIPALS/PRINCIPAL");
         if (xmlNodeList == null || xmlNodeList.Count == 0)
         {
             return(false);
         }
         foreach (object obj in xmlNodeList[0])
         {
             XmlNode xmlNode = (XmlNode)obj;
             if (!(xmlNode.Name != "SECURITYLEVEL") && xmlNode.Attributes != null)
             {
                 bool   flag = false;
                 string text = null;
                 foreach (object obj2 in xmlNode.Attributes)
                 {
                     XmlAttribute xmlAttribute = (XmlAttribute)obj2;
                     if (xmlAttribute.Name == "name" && xmlAttribute.Value == "Tenant-ID")
                     {
                         flag = true;
                     }
                     else if (xmlAttribute.Name == "value")
                     {
                         text = xmlAttribute.Value;
                     }
                 }
                 if (flag && !string.IsNullOrEmpty(text))
                 {
                     return(Guid.TryParse(text, out externalDirectoryOrgId));
                 }
             }
         }
     }
     catch (XmlException arg)
     {
         Microsoft.Exchange.Diagnostics.Components.Transport.ExTraceGlobals.RightsManagementTracer.TraceError <XmlException>(0L, "Exception while extracting MSODS tenant ID from publishing license: {0}", arg);
     }
     return(false);
 }
コード例 #14
0
        public static WebProxy GetLocalServerProxy(bool isEndPointExternal)
        {
            Uri localServerProxyAddress = RmsClientManagerUtils.GetLocalServerProxyAddress();

            if (localServerProxyAddress == null)
            {
                Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceDebug(0L, "No proxy is configured. Using system defaults");
                return(null);
            }
            if (isEndPointExternal)
            {
                Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceDebug <Uri>(0L, "InternetWeb proxy is configured {0}. Using that to connect to external endpoint", localServerProxyAddress);
                return(new WebProxy(localServerProxyAddress, true));
            }
            Microsoft.Exchange.Diagnostics.Components.Data.Storage.ExTraceGlobals.RightsManagementTracer.TraceDebug <Uri>(0L, "InternetWeb proxy is configured {0} but the end point is internal. Connecting directly", localServerProxyAddress);
            return(RmsClientManagerUtils.EmptyWebProxy);
        }
コード例 #15
0
 private RmsClientManagerContext(OrganizationId orgId, RmsClientManagerContext.ContextId contextId, string contextValue, Guid transactionId, IADRecipientCache recipientCache, IRmsLatencyTracker latencyTracker)
 {
     ArgumentValidator.ThrowIfNull("orgId", orgId);
     this.orgId          = orgId;
     this.tenantId       = RmsClientManagerUtils.GetTenantGuidFromOrgId(this.orgId);
     this.contextId      = contextId;
     this.contextValue   = contextValue;
     this.transactionId  = transactionId;
     this.recipientCache = recipientCache;
     this.latencyTracker = (latencyTracker ?? NoopRmsLatencyTracker.Instance);
     if (this.recipientCache != null && this.recipientCache.ADSession != null)
     {
         this.recipientSession = this.recipientCache.ADSession;
         return;
     }
     this.recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, this.orgId.Equals(OrganizationId.ForestWideOrgId) ? ADSessionSettings.FromRootOrgScopeSet() : ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(orgId), 248, ".ctor", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\rightsmanagement\\RmsClientManagerContext.cs");
 }
コード例 #16
0
        public RmsLicenseStoreInfoMap(string path, int maxCount, IMruDictionaryPerfCounters perfCounters)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }
            this.path = path;
            string uniqueFileNameForProcess = RmsClientManagerUtils.GetUniqueFileNameForProcess("RmsLicenseStoreInfoMap_2.dat");

            this.dictionary             = new MruDictionary <MultiValueKey, RmsLicenseStoreInfo>(maxCount, new RmsLicenseStoreInfoMap.MultiValueKeyComparer(), perfCounters);
            this.dictionary.OnRemoved  += this.MruDictionaryOnRemoved;
            this.dictionary.OnReplaced += this.MruDictionaryOnReplaced;
            this.serializer             = new MruDictionarySerializer <MultiValueKey, RmsLicenseStoreInfo>(path, uniqueFileNameForProcess, RmsLicenseStoreInfo.ColumnNames, new MruDictionarySerializerRead <MultiValueKey, RmsLicenseStoreInfo>(RmsLicenseStoreInfoMap.TryReadValues), new MruDictionarySerializerWrite <MultiValueKey, RmsLicenseStoreInfo>(RmsLicenseStoreInfoMap.TryWriteValues), perfCounters);
            if (!this.serializer.TryReadFromDisk(this.dictionary))
            {
                RmsLicenseStoreInfoMap.Tracer.TraceError <string>(0L, "Rms License Store Info Map failed to read map-file ({0}).", uniqueFileNameForProcess);
            }
        }
コード例 #17
0
        public static void Start()
        {
            Server localServer = null;

            RmsClientManagerLog.rmsLogSchema = new LogSchema("Microsoft Exchange Server", Assembly.GetExecutingAssembly().GetName().Version.ToString(), "Rms Client Manager Log", RmsClientManagerLog.Fields);
            RmsClientManagerLog.rmsLog       = new Log(RmsClientManagerUtils.GetUniqueFileNameForProcess(RmsClientManagerLog.LogSuffix, true), new LogHeaderFormatter(RmsClientManagerLog.rmsLogSchema), "RmsClientManagerLog");
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 254, "Start", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\rightsmanagement\\RmsClientManagerLog.cs");
                localServer = topologyConfigurationSession.FindLocalServer();
                RmsClientManagerLog.notificationCookie = ADNotificationAdapter.RegisterChangeNotification <Server>(localServer.Id, new ADNotificationCallback(RmsClientManagerLog.HandleConfigurationChange));
            });

            if (!adoperationResult.Succeeded)
            {
                RmsClientManagerLog.Tracer.TraceError <Exception>(0L, "Failed to get the local server.  Unable to load the log configuration. Error {0}", adoperationResult.Exception);
                throw new ExchangeConfigurationException(ServerStrings.FailedToReadConfiguration, adoperationResult.Exception);
            }
            RmsClientManagerLog.Configure(localServer);
        }
コード例 #18
0
 public static ExDateTime GetUseLicenseExpiryTime(LicenseResponse response)
 {
     ArgumentValidator.ThrowIfNull("response", response);
     return(RmsClientManagerUtils.GetUseLicenseExpiryTime(response.License, (response.UsageRights != null) ? response.UsageRights.Value : ContentRight.None));
 }
コード例 #19
0
        public static OrganizationId OrgIdFromPublishingLicenseOrDefault(string publishingLicense, OrganizationId defaultOrgId)
        {
            Guid guid;

            return(RmsClientManagerUtils.OrgIdFromPublishingLicenseOrDefault(publishingLicense, defaultOrgId, out guid));
        }
コード例 #20
0
 public FederationServerLicenseAsyncResult(RmsClientManagerContext context, Uri licenseUri, XmlNode[] issuanceLicense, LicenseIdentity[] identities, LicenseResponse[] responses, object callerState, AsyncCallback callerCallback) : base(context, licenseUri, issuanceLicense, callerState, callerCallback)
 {
     RmsClientManagerUtils.ThrowOnNullOrEmptyArrayArgument("identities", identities);
     this.identities = identities;
     this.responses  = responses;
 }
コード例 #21
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);
        }
コード例 #22
0
        private static void AcquireCertificationMexCallback(ICancelableAsyncResult asyncResult)
        {
            RmsServerInfoManager.Tracer.TraceDebug(0L, "AcquireCertificationMexCallback invoked");
            ArgumentValidator.ThrowIfNull("asyncResult", asyncResult);
            ArgumentValidator.ThrowIfNull("asyncResult.AsyncState", asyncResult.AsyncState);
            AcquireServerInfoAsyncResult acquireServerInfoAsyncResult = asyncResult.AsyncState as AcquireServerInfoAsyncResult;

            if (acquireServerInfoAsyncResult == null)
            {
                throw new InvalidOperationException("asyncResult.AsyncState has to be type of AcquireServerInfoAsyncResult.");
            }
            acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.AcquireCertificationMexCallback);
            Exception ex = null;

            try
            {
                DownloadResult downloadResult = acquireServerInfoAsyncResult.HttpClient.EndDownload(asyncResult);
                acquireServerInfoAsyncResult.LatencyTracker.EndTrackRmsLatency(RmsOperationType.AcquireCertificationMexData);
                if (downloadResult.IsSucceeded)
                {
                    Uri targetUriFromResponse = RmsClientManagerUtils.GetTargetUriFromResponse(downloadResult.ResponseStream);
                    if (targetUriFromResponse == null)
                    {
                        ex = new RightsManagementException(RightsManagementFailureCode.FailedToExtractTargetUriFromMex, ServerStrings.FailedToFindTargetUriFromMExData(acquireServerInfoAsyncResult.CertificationMExUri), acquireServerInfoAsyncResult.LicenseUri.ToString());
                    }
                    else
                    {
                        acquireServerInfoAsyncResult.ServerInfo.CertificationWSTargetUri = TokenTarget.Fix(targetUriFromResponse);
                        acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.BeginDownloadServerLicensingMexData);
                        WebProxy localServerProxy;
                        try
                        {
                            localServerProxy = RmsClientManagerUtils.GetLocalServerProxy(true);
                        }
                        catch (ExchangeConfigurationException ex2)
                        {
                            ex = ex2;
                            return;
                        }
                        HttpSessionConfig httpSessionConfig = new HttpSessionConfig();
                        if (localServerProxy != null)
                        {
                            httpSessionConfig.Proxy = localServerProxy;
                        }
                        acquireServerInfoAsyncResult.LatencyTracker.BeginTrackRmsLatency(RmsOperationType.AcquireServerLicensingMexData);
                        acquireServerInfoAsyncResult.HttpClient.BeginDownload(acquireServerInfoAsyncResult.ServerLicensingMExUri, httpSessionConfig, RmsClientManagerUtils.WrapCancellableCallbackWithUnhandledExceptionHandlerAndUpdatePoisonContext(new CancelableAsyncCallback(RmsServerInfoManager.AcquireServerLicensingMexCallback)), acquireServerInfoAsyncResult);
                    }
                }
                else
                {
                    RmsClientManager.TraceFail(null, acquireServerInfoAsyncResult.Context.SystemProbeId, "Failed to download data from certification MEx {0}.  Exception is {1}", new object[]
                    {
                        acquireServerInfoAsyncResult.CertificationMExUri,
                        downloadResult.Exception
                    });
                    ex = new RightsManagementException(RightsManagementFailureCode.FailedToDownloadMexData, ServerStrings.FailedToDownloadCertificationMExData(downloadResult.ResponseUri), downloadResult.Exception, acquireServerInfoAsyncResult.LicenseUri.ToString());
                    ((RightsManagementException)ex).IsPermanent = !downloadResult.IsRetryable;
                }
            }
            finally
            {
                if (ex != null)
                {
                    acquireServerInfoAsyncResult.Release();
                    RmsServerInfoManager.Tracer.TraceDebug(0L, "AcquireServiceLocationCallback: Invoking find service location callbacks");
                    RmsServerInfoManager.outstandingFindServiceLocationCalls.InvokeCallbacks(acquireServerInfoAsyncResult.LicenseUri, ex);
                }
            }
        }
コード例 #23
0
        private static void AcquireServiceLocationCallback(IAsyncResult asyncResult)
        {
            RmsServerInfoManager.Tracer.TraceDebug(0L, "AcquireServiceLocationCallback invoked");
            ArgumentValidator.ThrowIfNull("asyncResult", asyncResult);
            ArgumentValidator.ThrowIfNull("asyncResult.AsyncState", asyncResult.AsyncState);
            AcquireServerInfoAsyncResult acquireServerInfoAsyncResult = asyncResult.AsyncState as AcquireServerInfoAsyncResult;

            if (acquireServerInfoAsyncResult == null)
            {
                throw new InvalidOperationException("asyncResult.AsyncState has to be type of AcquireServerInfoAsyncResult.");
            }
            acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.AcquireServiceLocationCallback);
            Exception ex = null;

            try
            {
                acquireServerInfoAsyncResult.ServiceLocationResponses = acquireServerInfoAsyncResult.ServerWSManager.EndFindServiceLocations(asyncResult);
                LocalizedString value;
                if (!RmsServerInfoManager.ValidateResponsesAndUpdateServerInfo(acquireServerInfoAsyncResult, out value))
                {
                    ex = new RightsManagementException(RightsManagementFailureCode.FindServiceLocationFailed, ServerStrings.ValidationForServiceLocationResponseFailed(acquireServerInfoAsyncResult.LicenseUri, value));
                }
                else
                {
                    HttpSessionConfig httpSessionConfig = new HttpSessionConfig();
                    WebProxy          localServerProxy  = RmsClientManagerUtils.GetLocalServerProxy(true);
                    if (localServerProxy != null)
                    {
                        httpSessionConfig.Proxy = localServerProxy;
                    }
                    acquireServerInfoAsyncResult.HttpClient = new HttpClient();
                    acquireServerInfoAsyncResult.AddBreadCrumb(Constants.State.BeginDownloadCertificationMexData);
                    acquireServerInfoAsyncResult.LatencyTracker.BeginTrackRmsLatency(RmsOperationType.AcquireCertificationMexData);
                    acquireServerInfoAsyncResult.HttpClient.BeginDownload(acquireServerInfoAsyncResult.CertificationMExUri, httpSessionConfig, RmsClientManagerUtils.WrapCancellableCallbackWithUnhandledExceptionHandlerAndUpdatePoisonContext(new CancelableAsyncCallback(RmsServerInfoManager.AcquireCertificationMexCallback)), acquireServerInfoAsyncResult);
                }
            }
            catch (RightsManagementException ex2)
            {
                RmsClientManager.TraceFail(null, acquireServerInfoAsyncResult.Context.SystemProbeId, "Hit an exception during AcquireServiceLocationCallback {0}", new object[]
                {
                    ex2
                });
                ex = ex2;
            }
            catch (ExchangeConfigurationException ex3)
            {
                RmsClientManager.TraceFail(null, acquireServerInfoAsyncResult.Context.SystemProbeId, "Hit an exception during AcquireServiceLocationCallback {0}", new object[]
                {
                    ex3
                });
                ex = ex3;
            }
            finally
            {
                if (ex != null)
                {
                    acquireServerInfoAsyncResult.Release();
                    RmsServerInfoManager.Tracer.TraceError(0L, "AcquireServiceLocationCallback: Invoking find service location callbacks");
                    RmsServerInfoManager.outstandingFindServiceLocationCalls.InvokeCallbacks(acquireServerInfoAsyncResult.LicenseUri, ex);
                }
            }
        }
コード例 #24
0
 public static string GetUniqueFileNameForProcess(string fileSuffix)
 {
     return(RmsClientManagerUtils.GetUniqueFileNameForProcess(fileSuffix, false));
 }