Exemplo n.º 1
0
		private void PrepareProtectSimpleResponse(string profileLocation)
		{
			InitializeEngine();

			AddProtectSimpleProfile(profileLocation);	// A profile is a policy, but we chose to call it a Profile :)

			if (m_encryptionManager == null)
			{
				m_encryptionManager = new ContentEncryptionManager(_msgExpander, _msgPacker);
			}

			if (m_encryptionUi != null)
			{
				m_encryptionUi.OnShowDialog += new ShowDialogEvent(m_encryptionUi_OnShowDialog);
			}

			if (!m_encryptionManager.DecryptRequestAttachments(m_request, m_encryptionUi))
			{
				if (!string.IsNullOrEmpty(m_encryptionManager.LastErrorText))
				{
					m_errors.Add(ErrorAsDialogTextKey + m_encryptionManager.LastErrorText);// prepend ErrorAsDialogTextKey constant so that we DO display the message to the user
					m_encryptionManager.LastErrorText = string.Empty;
					m_processResult = ProcessResult.ERRORS;
					m_bUpdateProcessResult = false;
				}
				else
				{
					m_processResult = ProcessResult.CANCELLED;
				}
				return;
			}

			m_response = CallContentScanner();
            
			ResponseAnalyser.CollectAndSendEvents(m_response, ResponseAnalyser.EventType.PolicySet);

			m_uiResponse = ResponseAdapter.UIResponseFromResponse(m_request, m_response);                      

			// hey, you know what - something might have gone wrong in that content scanning. Let's check
			object[] errors = m_uiResponse.GetErrors();
			if (errors.Length > 0)
			{
				// wow! something bad did happen. Better report it back to the user
				RecordDiscoveryErrors(errors);
				return;
			}

			string reason = string.Empty;
			if (!m_uiResponse.Synchronize(out reason))
			{
				Logger.LogError("Unable to synchronize responses. Reason = " + reason);
				m_processResult = ClientManager.ProcessResult.ERRORS;
				return;
			}

			// Check for violations
			if (m_uiResponse != null && !m_uiResponse.ContainsViolations())
			{
				m_processResult = ProcessResult.NO_VIOLATIONS;
				return;
			}

			// Check for Actions in uiResponse
			if (m_uiResponse != null && m_uiResponse.Actions.Count <= 0)
			{
				m_processResult = ProcessResult.NO_ACTIONS;
				return;
			}

			m_processResult = ProcessResult.UNDEFINED;

			CreateOfficeApplicationsUsingUroAttachments();

			return;
		}
Exemplo n.º 2
0
		/// <summary>
		/// Validates and returns the <see cref="Workshare.PolicyContent.Response"/> object within the <see cref="Workshare.Policy.ClientManager.Object.UIResponse"/>
		/// </summary>
		/// <param name="uiResponse">A prepared <see cref="Workshare.Policy.ClientManager.Object.UIResponse"/></param>
		/// <returns>The internal <see cref="Workshare.PolicyContent.Response"/> if it was able to be validated, otherwise null</returns>
		public static Response ResponseFromUIResponse(UIResponse uiResponse)
		{
			if (uiResponse == null)
			{
				throw new ArgumentNullException("uiResponse");
			}

			if (uiResponse.Response == null)
			{
				throw new InvalidOperationException("uiResponse does not contain a Response");
			}
			string reason = string.Empty;
			if (!uiResponse.Synchronize(out reason))
			{
				return null;
			}

			// Now we have to reconcile the 

			return uiResponse.Response;
		}