Esempio n. 1
0
        public static ActiveCryptoModeRpcResult[] GetTenantActiveCryptoMode(RmsClientManagerContext clientContext)
        {
            if (clientContext == null)
            {
                throw new ArgumentNullException("clientContext");
            }
            RpcClientWrapper.InitializeIfNeeded();
            string randomRpcTargetServerName = RpcClientWrapper.instance.GetRandomRpcTargetServerName();

            byte[] data = null;
            ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Entry, clientContext, string.Format("OfflineRmsRpcClient.GetTenantActiveCryptoMode against RPC server {0}", randomRpcTargetServerName));
            try
            {
                using (OfflineRmsRpcClient offlineRmsRpcClient = new OfflineRmsRpcClient(randomRpcTargetServerName))
                {
                    data = offlineRmsRpcClient.GetTenantActiveCryptoMode(1, new GetTenantActiveCryptoModeRpcParameters(clientContext).Serialize());
                }
            }
            catch (RpcException ex)
            {
                ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Error, clientContext, string.Format("OfflineRmsRpcClient.GetTenantActiveCryptoMode against RPC server {0} failed with RPC Exception {1}", randomRpcTargetServerName, ServerManagerLog.GetExceptionLogString(ex, ServerManagerLog.ExceptionLogOption.IncludeStack | ServerManagerLog.ExceptionLogOption.IncludeInnerException)));
                throw new RightsManagementServerException(ServerStrings.RpcClientException("GetTenantActiveCryptoMode", randomRpcTargetServerName), ex, false);
            }
            GetTenantActiveCryptoModeRpcResults getTenantActiveCryptoModeRpcResults = new GetTenantActiveCryptoModeRpcResults(data);

            if (getTenantActiveCryptoModeRpcResults.OverallRpcResult.Status == OverallRpcStatus.Success)
            {
                return(getTenantActiveCryptoModeRpcResults.ActiveCryptoModeRpcResults);
            }
            string serializedString = ErrorResult.GetSerializedString(getTenantActiveCryptoModeRpcResults.OverallRpcResult.ErrorResults);

            ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Error, clientContext, string.Format("OfflineRmsRpcClient.GetTenantActiveCryptoMode against RPC server {0} failed with WellKnownErrorCode {1}, and with Exception {2}", randomRpcTargetServerName, getTenantActiveCryptoModeRpcResults.OverallRpcResult.WellKnownErrorCode, serializedString));
            throw new RightsManagementServerException(ServerStrings.FailedToRpcAcquireUseLicenses(clientContext.OrgId.ToString(), serializedString, randomRpcTargetServerName), getTenantActiveCryptoModeRpcResults.OverallRpcResult.WellKnownErrorCode, getTenantActiveCryptoModeRpcResults.OverallRpcResult.Status == OverallRpcStatus.PermanentFailure);
        }
Esempio n. 2
0
        public static UseLicenseRpcResult[] AcquireUseLicenses(RmsClientManagerContext clientContext, XmlNode[] rightsAccountCertificate, XmlNode[] issuanceLicense, LicenseeIdentity[] licenseeIdentities)
        {
            if (clientContext == null)
            {
                throw new ArgumentNullException("clientContext");
            }
            if (rightsAccountCertificate == null)
            {
                throw new ArgumentNullException("rightsAccountCertificate");
            }
            if (issuanceLicense == null || issuanceLicense.Length < 1)
            {
                throw new ArgumentNullException("issuanceLicense");
            }
            if (licenseeIdentities == null || licenseeIdentities.Length < 1)
            {
                throw new ArgumentNullException("licenseeIdentities");
            }
            RpcClientWrapper.InitializeIfNeeded();
            string randomRpcTargetServerName = RpcClientWrapper.instance.GetRandomRpcTargetServerName();

            byte[] data = null;
            ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Entry, clientContext, string.Format("OfflineRmsRpcClient.AcquireUseLicenses against RPC server {0}", randomRpcTargetServerName));
            try
            {
                using (OfflineRmsRpcClient offlineRmsRpcClient = new OfflineRmsRpcClient(randomRpcTargetServerName))
                {
                    data = offlineRmsRpcClient.AcquireUseLicenses(1, new AcquireUseLicensesRpcParameters(clientContext, rightsAccountCertificate, issuanceLicense, licenseeIdentities).Serialize());
                }
            }
            catch (RpcException ex)
            {
                ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Error, clientContext, string.Format("OfflineRmsRpcClient.AcquireUseLicenses against RPC server {0} failed with RPC Exception {1}", randomRpcTargetServerName, ServerManagerLog.GetExceptionLogString(ex, ServerManagerLog.ExceptionLogOption.IncludeStack | ServerManagerLog.ExceptionLogOption.IncludeInnerException)));
                throw new RightsManagementServerException(ServerStrings.RpcClientException("AcquireUseLicenses", randomRpcTargetServerName), ex, false);
            }
            AcquireUseLicensesRpcResults acquireUseLicensesRpcResults = new AcquireUseLicensesRpcResults(data);

            if (acquireUseLicensesRpcResults.OverallRpcResult.Status == OverallRpcStatus.Success)
            {
                return(acquireUseLicensesRpcResults.UseLicenseRpcResults);
            }
            string serializedString = ErrorResult.GetSerializedString(acquireUseLicensesRpcResults.OverallRpcResult.ErrorResults);

            ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Error, clientContext, string.Format("OfflineRmsRpcClient.AcquireUseLicenses against RPC server {0} failed with WellKnownErrorCode {1}, and with Exception {2}", randomRpcTargetServerName, acquireUseLicensesRpcResults.OverallRpcResult.WellKnownErrorCode, serializedString));
            throw new RightsManagementServerException(ServerStrings.FailedToRpcAcquireUseLicenses(clientContext.OrgId.ToString(), serializedString, randomRpcTargetServerName), acquireUseLicensesRpcResults.OverallRpcResult.WellKnownErrorCode, acquireUseLicensesRpcResults.OverallRpcResult.Status == OverallRpcStatus.PermanentFailure);
        }
Esempio n. 3
0
        public static void AcquireTenantLicenses(RmsClientManagerContext clientContext, XmlNode[] machineCertificateChain, string identity, out XmlNode[] racXml, out XmlNode[] clcXml)
        {
            if (clientContext == null)
            {
                throw new ArgumentNullException("clientContext");
            }
            if (machineCertificateChain == null || machineCertificateChain.Length < 1)
            {
                throw new ArgumentNullException("machineCertificateChain");
            }
            if (string.IsNullOrEmpty(identity))
            {
                throw new ArgumentNullException("identity");
            }
            racXml = null;
            clcXml = null;
            RpcClientWrapper.InitializeIfNeeded();
            string randomRpcTargetServerName = RpcClientWrapper.instance.GetRandomRpcTargetServerName();

            byte[] data = null;
            ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Entry, clientContext, string.Format("OfflineRmsRpcClient.AcquireTenantLicenses against RPC server {0}", randomRpcTargetServerName));
            try
            {
                using (OfflineRmsRpcClient offlineRmsRpcClient = new OfflineRmsRpcClient(randomRpcTargetServerName))
                {
                    data = offlineRmsRpcClient.AcquireTenantLicenses(1, new AcquireTenantLicensesRpcParameters(clientContext, identity, machineCertificateChain).Serialize());
                }
            }
            catch (RpcException ex)
            {
                ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Error, clientContext, string.Format("OfflineRmsRpcClient.AcquireTenantLicenses against RPC server {0} failed with RPC Exception {1}", randomRpcTargetServerName, ServerManagerLog.GetExceptionLogString(ex, ServerManagerLog.ExceptionLogOption.IncludeStack | ServerManagerLog.ExceptionLogOption.IncludeInnerException)));
                throw new RightsManagementServerException(ServerStrings.RpcClientException("AcquireTenantLicenses", randomRpcTargetServerName), ex, false);
            }
            AcquireTenantLicensesRpcResults acquireTenantLicensesRpcResults = new AcquireTenantLicensesRpcResults(data);

            if (acquireTenantLicensesRpcResults.OverallRpcResult.Status == OverallRpcStatus.Success)
            {
                racXml = acquireTenantLicensesRpcResults.RacXml;
                clcXml = acquireTenantLicensesRpcResults.ClcXml;
                return;
            }
            string serializedString = ErrorResult.GetSerializedString(acquireTenantLicensesRpcResults.OverallRpcResult.ErrorResults);

            ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcClientWrapper, ServerManagerLog.EventType.Error, clientContext, string.Format("OfflineRmsRpcClient.AcquireTenantLicenses against RPC server {0} failed with WellKnownErrorCode {1} and with Exception {2}", randomRpcTargetServerName, acquireTenantLicensesRpcResults.OverallRpcResult.WellKnownErrorCode, serializedString));
            throw new RightsManagementServerException(ServerStrings.FailedToRpcAcquireRacAndClc(clientContext.OrgId.ToString(), serializedString, randomRpcTargetServerName), acquireTenantLicensesRpcResults.OverallRpcResult.WellKnownErrorCode, acquireTenantLicensesRpcResults.OverallRpcResult.Status == OverallRpcStatus.PermanentFailure);
        }