public override byte[] AcquireTenantLicenses(int version, byte[] inputParameterBytes) { XmlNode[] rac = null; XmlNode[] clc = null; AcquireTenantLicensesRpcParameters acquireTenantLicensesRpcParameters = null; byte[] result; try { acquireTenantLicensesRpcParameters = new AcquireTenantLicensesRpcParameters(inputParameterBytes); ServerManager.AcquireTenantLicenses(acquireTenantLicensesRpcParameters.ClientManagerContext, acquireTenantLicensesRpcParameters.MachineCertificateChain, acquireTenantLicensesRpcParameters.Identity, out rac, out clc); AcquireTenantLicensesRpcResults acquireTenantLicensesRpcResults = new AcquireTenantLicensesRpcResults(new OverallRpcResult(null), rac, clc); result = acquireTenantLicensesRpcResults.Serialize(); } catch (Exception ex) { if (!(ex is RightsManagementServerException)) { ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.RpcServerWrapper, ServerManagerLog.EventType.Error, (acquireTenantLicensesRpcParameters != null) ? acquireTenantLicensesRpcParameters.ClientManagerContext : null, string.Format("ServerManager.AcquireTenantLicenses has thrown unhandled exception {0}", ServerManagerLog.GetExceptionLogString(ex, ServerManagerLog.ExceptionLogOption.IncludeStack | ServerManagerLog.ExceptionLogOption.IncludeInnerException))); ExWatson.SendReportAndCrashOnAnotherThread(ex); } AcquireTenantLicensesRpcResults acquireTenantLicensesRpcResults2 = new AcquireTenantLicensesRpcResults(new OverallRpcResult(ex), Array <XmlNode> .Empty, Array <XmlNode> .Empty); result = acquireTenantLicensesRpcResults2.Serialize(); } return(result); }
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); }