예제 #1
0
 public virtual void validate(Bird bird, ValidationResultCollector validationResultCollector)
 {
     if (nameOfBird.Equals(bird.Id))
     {
         validationResultCollector.addError(20, string.Format("Bird {0} is illegal", nameOfBird));
     }
 }
예제 #2
0
 public virtual void validate(FlyingAnimal element, ValidationResultCollector validationResultCollector)
 {
     if (element.Age == null || element.Age < 18)
     {
         validationResultCollector.addWarning(10, "Is not an adult");
     }
 }
예제 #3
0
        public override void validate(Process process, ValidationResultCollector validationResultCollector)
        {
            ICollection <StartEvent> startEvents = process.getChildElementsByType(typeof(StartEvent));
            int startEventCount = startEvents.Count;

            if (startEventCount != 1)
            {
                validationResultCollector.addError(10, string.Format("Process does not have exactly one start event. Got {0:D}.", startEventCount));
            }
        }
예제 #4
0
        public static ResultType SendSPOAuthRequest(ADUser user, Uri targetUri, out string diagnosticMessage, bool appOnly = false, bool useCachedToken = false, bool reloadConfig = false)
        {
            int              startIndex       = user.GetFederatedIdentity().Identity.IndexOf('@') + 1;
            string           domain           = user.GetFederatedIdentity().Identity.Substring(startIndex);
            ICredentials     icredentials     = TestOAuthConnectivityHelper.GetICredentials(appOnly, user, domain);
            OAuthCredentials oauthCredentials = icredentials as OAuthCredentials;

            if (icredentials == null)
            {
                diagnosticMessage = Strings.NullUserError;
                return(ResultType.Error);
            }
            Guid value = Guid.NewGuid();

            oauthCredentials.ClientRequestId = new Guid?(value);
            ValidationResultCollector resultCollector    = new ValidationResultCollector();
            LocalConfiguration        localConfiguration = LocalConfiguration.Load(resultCollector);

            oauthCredentials.Tracer             = new TestOAuthConnectivityHelper.TaskOauthOutboundTracer();
            oauthCredentials.LocalConfiguration = localConfiguration;
            string         text           = targetUri.Scheme + "://" + targetUri.Host + "/_vti_bin/listdata.svc";
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(text);

            httpWebRequest.Method      = "GET";
            httpWebRequest.ContentType = "text/xml";
            httpWebRequest.Headers.Add("X-ExCompId", "OauthPartnerProbe:");
            httpWebRequest.Headers.Add("client-request-id", value.ToString());
            httpWebRequest.Headers.Add(HttpRequestHeader.Authorization, "Bearer");
            httpWebRequest.UserAgent       = "AMProbe/OAUTH/Sharepoint";
            httpWebRequest.Credentials     = icredentials;
            httpWebRequest.PreAuthenticate = true;
            string        value2        = string.Empty;
            StringBuilder stringBuilder = new StringBuilder(1024);

            stringBuilder.AppendLine(Strings.ClientRequestId(value.ToString()));
            string value3 = TestOAuthConnectivityHelper.CheckReloadConfig(reloadConfig);
            string value4 = TestOAuthConnectivityHelper.CheckUseCachedToken(useCachedToken);

            stringBuilder.AppendLine(value3);
            stringBuilder.AppendLine(value4);
            HttpWebResponse httpWebResponse = null;
            ResultType      result          = ResultType.Success;
            string          text2           = string.Empty;

            try
            {
                stringBuilder.AppendLine(Strings.OAuthRequestEndPoint(text));
                httpWebResponse = (httpWebRequest.GetResponse() as HttpWebResponse);
                if (httpWebResponse != null && httpWebResponse.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception(Strings.HttpWebRequestFailure(httpWebResponse.StatusCode.ToString()));
                }
                using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()))
                {
                    value2 = streamReader.ReadToEnd();
                }
            }
            catch (WebException ex)
            {
                text2  = ex.ToString();
                result = ResultType.Error;
            }
            finally
            {
                if (httpWebResponse != null)
                {
                    TestOAuthConnectivityHelper.LogHttpResponseHeaders(httpWebResponse.Headers, ref stringBuilder);
                }
                if (httpWebResponse != null)
                {
                    httpWebResponse.Close();
                }
            }
            stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
            stringBuilder.AppendLine(Strings.TestOAuthResponseDetails("SharePoint"));
            stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
            stringBuilder.AppendLine(Strings.ResponseHeader);
            stringBuilder.AppendLine(value2);
            if (text2 != string.Empty)
            {
                stringBuilder.AppendLine(Strings.ExceptionHeader);
                stringBuilder.AppendLine(text2);
            }
            diagnosticMessage = stringBuilder.ToString();
            return(result);
        }
예제 #5
0
        public static ResultType SendLyncOAuthRequest(ADUser user, Uri targetUri, out string diagnosticMessage, bool appOnly = false, bool useCachedToken = false, bool reloadConfig = false)
        {
            int              startIndex       = user.GetFederatedIdentity().Identity.IndexOf('@') + 1;
            string           domain           = user.GetFederatedIdentity().Identity.Substring(startIndex);
            StringBuilder    stringBuilder    = new StringBuilder();
            ICredentials     icredentials     = TestOAuthConnectivityHelper.GetICredentials(appOnly, user, domain);
            OAuthCredentials oauthCredentials = icredentials as OAuthCredentials;
            string           text             = string.Empty;

            foreach (ProxyAddress proxyAddress in user.EmailAddresses)
            {
                if (proxyAddress.ToString().Contains("sip:"))
                {
                    text = TestOAuthConnectivityHelper.FromSipFormat(proxyAddress.ToString());
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                text = user.PrimarySmtpAddress.ToString();
            }
            if (string.IsNullOrEmpty(text))
            {
                diagnosticMessage = Strings.EMailAddressNotFound(user.Alias);
                return(ResultType.Error);
            }
            Guid value = Guid.NewGuid();

            oauthCredentials.ClientRequestId = new Guid?(value);
            stringBuilder.AppendLine(Strings.ClientRequestId(value.ToString()));
            string value2 = TestOAuthConnectivityHelper.CheckReloadConfig(reloadConfig);
            string value3 = TestOAuthConnectivityHelper.CheckUseCachedToken(useCachedToken);

            stringBuilder.AppendLine(value2);
            stringBuilder.AppendLine(value3);
            ValidationResultCollector resultCollector    = new ValidationResultCollector();
            LocalConfiguration        localConfiguration = LocalConfiguration.Load(resultCollector);

            oauthCredentials.Tracer             = new TestOAuthConnectivityHelper.TaskOauthOutboundTracer();
            oauthCredentials.LocalConfiguration = localConfiguration;
            LyncAnonymousAutodiscoverResult lyncAnonymousAutodiscoverResult = null;

            try
            {
                lyncAnonymousAutodiscoverResult = LyncAutodiscoverWorker.GetAuthenticatedAutodiscoverEndpoint(text, domain);
            }
            catch (WebException ex)
            {
                stringBuilder.AppendLine(Strings.DiagnosticsHeader);
                stringBuilder.AppendLine(lyncAnonymousAutodiscoverResult.DiagnosticInfo);
                stringBuilder.AppendLine(Strings.AutodiscoverFailure);
                stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
                stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
                stringBuilder.AppendLine(ex.ToString());
                diagnosticMessage = stringBuilder.ToString();
                return(ResultType.Error);
            }
            catch (Exception ex2)
            {
                stringBuilder.AppendLine(Strings.DiagnosticsHeader);
                stringBuilder.AppendLine(lyncAnonymousAutodiscoverResult.DiagnosticInfo);
                stringBuilder.AppendLine(Strings.AutodiscoverFailure);
                stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
                stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
                stringBuilder.AppendLine(ex2.ToString());
                diagnosticMessage = stringBuilder.ToString();
                return(ResultType.Error);
            }
            if (string.IsNullOrEmpty(lyncAnonymousAutodiscoverResult.AuthenticatedServerUri))
            {
                stringBuilder.AppendLine(Strings.DiagnosticsHeader);
                stringBuilder.AppendLine(lyncAnonymousAutodiscoverResult.DiagnosticInfo);
                stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
                stringBuilder.AppendLine(Strings.NoAuthenticatedServerUri);
                stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
                diagnosticMessage = stringBuilder.ToString();
                return(ResultType.Error);
            }
            stringBuilder.AppendLine(Strings.DiagnosticsHeader);
            stringBuilder.AppendLine(lyncAnonymousAutodiscoverResult.DiagnosticInfo);
            LyncAutodiscoverResult lyncAutodiscoverResult = null;

            try
            {
                lyncAutodiscoverResult = LyncAutodiscoverWorker.GetUcwaUrl(lyncAnonymousAutodiscoverResult.AuthenticatedServerUri, icredentials);
            }
            catch (WebException ex3)
            {
                stringBuilder.AppendLine(Strings.DiagnosticsHeader);
                stringBuilder.AppendLine(lyncAnonymousAutodiscoverResult.DiagnosticInfo);
                stringBuilder.AppendLine(Strings.UCWADiscoveryUrlException);
                stringBuilder.AppendLine(lyncAutodiscoverResult.Response);
                stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
                stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
                stringBuilder.AppendLine(ex3.ToString());
                diagnosticMessage = stringBuilder.ToString();
                return(ResultType.Error);
            }
            catch (Exception ex4)
            {
                stringBuilder.AppendLine(Strings.DiagnosticsHeader);
                stringBuilder.AppendLine(lyncAnonymousAutodiscoverResult.DiagnosticInfo);
                stringBuilder.AppendLine(Strings.UCWADiscoveryUrlException);
                stringBuilder.AppendLine(lyncAutodiscoverResult.Response);
                stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
                stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
                stringBuilder.AppendLine(ex4.ToString());
                diagnosticMessage = stringBuilder.ToString();
                return(ResultType.Error);
            }
            if (string.IsNullOrEmpty(lyncAutodiscoverResult.UcwaDiscoveryUrl))
            {
                stringBuilder.AppendLine(Strings.DiagnosticsHeader);
                stringBuilder.AppendLine(lyncAnonymousAutodiscoverResult.DiagnosticInfo);
                stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
                stringBuilder.AppendLine(Strings.UCWADiscoveryUrlEmpty);
                stringBuilder.AppendLine(lyncAutodiscoverResult.Response);
                stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
                diagnosticMessage = stringBuilder.ToString();
                return(ResultType.Error);
            }
            stringBuilder.AppendLine(Strings.DiagnosticsHeader);
            stringBuilder.AppendLine(lyncAnonymousAutodiscoverResult.DiagnosticInfo);
            stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
            stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
            diagnosticMessage = stringBuilder.ToString();
            return(ResultType.Success);
        }
예제 #6
0
        public static ResultType SendGenericOAuthRequest(ADUser user, string orgDomain, Uri targetUri, out string diagnosticMessage, bool appOnly = false, bool useCachedToken = false, bool reloadConfig = false)
        {
            string domain = TestOAuthConnectivityHelper.GetDomain(user, orgDomain);

            if (domain == null)
            {
                diagnosticMessage = Strings.NullUserError;
                return(ResultType.Error);
            }
            ICredentials     icredentials     = TestOAuthConnectivityHelper.GetICredentials(appOnly, user, domain);
            OAuthCredentials oauthCredentials = icredentials as OAuthCredentials;

            if (icredentials == null)
            {
                diagnosticMessage = Strings.NullUserError;
                return(ResultType.Error);
            }
            ValidationResultCollector resultCollector    = new ValidationResultCollector();
            LocalConfiguration        localConfiguration = LocalConfiguration.Load(resultCollector);

            oauthCredentials.Tracer             = new TestOAuthConnectivityHelper.TaskOauthOutboundTracer();
            oauthCredentials.LocalConfiguration = localConfiguration;
            Guid value = Guid.NewGuid();

            oauthCredentials.ClientRequestId = new Guid?(value);
            HttpWebResponse httpWebResponse = null;
            ResultType      result          = ResultType.Success;
            string          text            = string.Empty;
            string          s             = string.Empty;
            StringBuilder   stringBuilder = new StringBuilder();
            string          value2        = TestOAuthConnectivityHelper.CheckReloadConfig(reloadConfig);
            string          value3        = TestOAuthConnectivityHelper.CheckUseCachedToken(useCachedToken);

            stringBuilder.AppendLine(value2);
            stringBuilder.AppendLine(value3);
            try
            {
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(new Uri(targetUri.ToString()));
                httpWebRequest.Method      = "GET";
                httpWebRequest.ContentType = "text/xml";
                httpWebRequest.Headers.Add("X-ExCompId", "OauthPartnerProbe:");
                httpWebRequest.Headers.Add("client-request-id", value.ToString());
                httpWebRequest.Headers.Add("request-id", value.ToString());
                httpWebRequest.Headers.Add(HttpRequestHeader.Authorization, "Bearer");
                httpWebRequest.UserAgent   = "AMProbe/OAUTH/Exchange";
                httpWebRequest.Credentials = icredentials;
                httpWebResponse            = (httpWebRequest.GetResponse() as HttpWebResponse);
                if (httpWebResponse != null && httpWebResponse.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception(Strings.ResponseMessage(httpWebResponse.StatusCode.ToString()));
                }
                using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()))
                {
                    s = streamReader.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                text   = ex.ToString();
                result = ResultType.Error;
            }
            finally
            {
                if (httpWebResponse != null)
                {
                    TestOAuthConnectivityHelper.LogHttpResponseHeaders(httpWebResponse.Headers, ref stringBuilder);
                    httpWebResponse.Close();
                }
            }
            stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
            stringBuilder.AppendLine(Strings.ClientRequestId(value.ToString()));
            stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
            stringBuilder.AppendLine(Strings.TestOAuthResponseDetails("Generic"));
            stringBuilder.AppendLine(Strings.ResponseMessage(s));
            if (text != string.Empty)
            {
                stringBuilder.AppendLine(Strings.ExceptionHeader);
                stringBuilder.AppendLine(text);
            }
            diagnosticMessage = stringBuilder.ToString();
            return(result);
        }
예제 #7
0
        public static ResultType SendExchangeOAuthRequest(ADUser user, string orgDomain, Uri targetUri, out string diagnosticMessage, bool appOnly = false, bool useCachedToken = false, bool reloadConfig = false)
        {
            string domain = TestOAuthConnectivityHelper.GetDomain(user, orgDomain);

            if (domain == null)
            {
                diagnosticMessage = Strings.NullUserError;
                return(ResultType.Error);
            }
            ICredentials     icredentials     = TestOAuthConnectivityHelper.GetICredentials(false, user, domain);
            OAuthCredentials oauthCredentials = icredentials as OAuthCredentials;

            if (icredentials == null)
            {
                diagnosticMessage = Strings.NullUserError;
                return(ResultType.Error);
            }
            string value = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">\r\n                                <soap:Header>\r\n                                <t:RequestServerVersion Version=\"Exchange2012\"/>\r\n                                </soap:Header>\r\n                                <soap:Body>\r\n                                <GetFolder xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\">\r\n                                    <FolderShape>\r\n                                    <t:BaseShape>IdOnly</t:BaseShape>\r\n                                    </FolderShape>\r\n                                    <FolderIds>\r\n                                    <t:DistinguishedFolderId Id=\"inbox\"/>\r\n                                    </FolderIds>\r\n                                </GetFolder>\r\n                                </soap:Body>\r\n                            </soap:Envelope>";
            ValidationResultCollector resultCollector    = new ValidationResultCollector();
            LocalConfiguration        localConfiguration = LocalConfiguration.Load(resultCollector);

            oauthCredentials.Tracer             = new TestOAuthConnectivityHelper.TaskOauthOutboundTracer();
            oauthCredentials.LocalConfiguration = localConfiguration;
            Guid value2 = Guid.NewGuid();

            oauthCredentials.ClientRequestId = new Guid?(value2);
            HttpWebResponse httpWebResponse = null;
            ResultType      result          = ResultType.Success;
            string          text            = string.Empty;
            string          s             = string.Empty;
            StringBuilder   stringBuilder = new StringBuilder();
            string          value3        = TestOAuthConnectivityHelper.CheckReloadConfig(reloadConfig);
            string          value4        = TestOAuthConnectivityHelper.CheckUseCachedToken(useCachedToken);

            stringBuilder.AppendLine(value3);
            stringBuilder.AppendLine(value4);
            try
            {
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(new Uri(targetUri.Scheme + "://" + targetUri.Host + "/ews/Exchange.asmx"));
                httpWebRequest.Method      = "POST";
                httpWebRequest.ContentType = "text/xml";
                httpWebRequest.Headers.Add("X-ExCompId", "OauthPartnerProbe:");
                httpWebRequest.Headers.Add("client-request-id", value2.ToString());
                httpWebRequest.Headers.Add("request-id", value2.ToString());
                httpWebRequest.Headers.Add(HttpRequestHeader.Authorization, "Bearer");
                httpWebRequest.UserAgent   = "AMProbe/OAUTH/Exchange";
                httpWebRequest.Credentials = icredentials;
                StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream());
                streamWriter.Write(value);
                streamWriter.Close();
                httpWebResponse = (httpWebRequest.GetResponse() as HttpWebResponse);
                if (httpWebResponse != null && httpWebResponse.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception(Strings.HttpWebRequestFailure(httpWebResponse.StatusCode.ToString()));
                }
                using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()))
                {
                    s = streamReader.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                text   = ex.ToString();
                result = ResultType.Error;
            }
            finally
            {
                if (httpWebResponse != null)
                {
                    TestOAuthConnectivityHelper.LogHttpResponseHeaders(httpWebResponse.Headers, ref stringBuilder);
                    httpWebResponse.Close();
                }
            }
            stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
            stringBuilder.AppendLine(Strings.ClientRequestId(value2.ToString()));
            stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
            stringBuilder.AppendLine(Strings.TestOAuthResponseDetails("Exchange"));
            stringBuilder.AppendLine(Strings.ResponseMessage(s));
            if (text != string.Empty)
            {
                stringBuilder.AppendLine(Strings.ExceptionHeader);
                stringBuilder.AppendLine(text);
            }
            diagnosticMessage = stringBuilder.ToString();
            return(result);
        }
예제 #8
0
        public static ResultType SendAutodiscoverOAuthRequest(ADUser user, string orgDomain, Uri targetUri, out string diagnosticMessage, bool appOnly = false, bool useCachedToken = false, bool reloadConfig = false)
        {
            string domain = TestOAuthConnectivityHelper.GetDomain(user, orgDomain);

            if (domain == null)
            {
                diagnosticMessage = Strings.NullUserError;
                return(ResultType.Error);
            }
            ICredentials     icredentials     = TestOAuthConnectivityHelper.GetICredentials(appOnly, user, domain);
            OAuthCredentials oauthCredentials = icredentials as OAuthCredentials;

            if (icredentials == null)
            {
                diagnosticMessage = Strings.NullUserError;
                return(ResultType.Error);
            }
            StringBuilder             stringBuilder      = new StringBuilder();
            ValidationResultCollector resultCollector    = new ValidationResultCollector();
            LocalConfiguration        localConfiguration = LocalConfiguration.Load(resultCollector);

            oauthCredentials.Tracer             = new TestOAuthConnectivityHelper.TaskOauthOutboundTracer();
            oauthCredentials.LocalConfiguration = localConfiguration;
            Guid value = Guid.NewGuid();

            oauthCredentials.ClientRequestId = new Guid?(value);
            string value2 = TestOAuthConnectivityHelper.CheckReloadConfig(reloadConfig);
            string value3 = TestOAuthConnectivityHelper.CheckUseCachedToken(useCachedToken);

            stringBuilder.AppendLine(value2);
            stringBuilder.AppendLine(value3);
            AutodiscoverService autodiscoverService = new AutodiscoverService(4);

            autodiscoverService.Url          = new Uri(targetUri.Scheme + "://" + targetUri.Host + "/autodiscover/autodiscover.svc");
            autodiscoverService.TraceEnabled = true;
            autodiscoverService.Credentials  = new OAuthCredentials(oauthCredentials);
            ResultType result = ResultType.Success;

            try
            {
                string text = (user == null) ? ("@" + domain) : user.PrimarySmtpAddress.ToString();
                GetUserSettingsResponse userSettings = autodiscoverService.GetUserSettings(text, new UserSettingName[]
                {
                    58,
                    75
                });
                if (userSettings.ErrorCode != null && (userSettings.ErrorCode != 3 || !(text == "@" + domain)))
                {
                    result = ResultType.Error;
                }
            }
            catch (Exception ex)
            {
                stringBuilder.AppendLine(ex.ToString());
                result = ResultType.Error;
            }
            stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
            stringBuilder.AppendLine(Strings.ClientRequestId(value.ToString()));
            stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
            stringBuilder.AppendLine(Strings.TestOAuthResponseDetails("Exchange"));
            stringBuilder.AppendLine(Strings.TestOutboundOauthLog);
            stringBuilder.AppendLine(Strings.TestOAuthResponseDetails("Autodiscover"));
            stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
            diagnosticMessage = stringBuilder.ToString();
            return(result);
        }
예제 #9
0
        protected override void InternalProcessRecord()
        {
            ValidationResultCollector validationResultCollector = new ValidationResultCollector();
            LocalConfiguration        localConfiguration        = LocalConfiguration.Load(validationResultCollector);

            foreach (ValidationResultNode sendToPipeline in validationResultCollector.Results)
            {
                base.WriteObject(sendToPipeline);
            }
            SharePointException ex = null;
            Uri uri = this.SharePointUrl ?? this.tmADObject.SharePointUrl;
            OAuthCredentials oauthCredentials = null;

            try
            {
                using (ClientContext clientContext = new ClientContext(uri))
                {
                    bool         flag = false;
                    ICredentials credentialAndConfigureClientContext = TeamMailboxHelper.GetCredentialAndConfigureClientContext(this.requestor, (this.requestor != null) ? this.requestor.OrganizationId : base.CurrentOrganizationId, clientContext, this.UseAppTokenOnly, out flag);
                    if (!flag)
                    {
                        base.WriteError(new InvalidOperationException(Strings.OauthIsTurnedOff), ErrorCategory.InvalidOperation, null);
                    }
                    oauthCredentials                    = (credentialAndConfigureClientContext as OAuthCredentials);
                    oauthCredentials.Tracer             = new TestSiteMailbox.TaskOauthOutboundTracer();
                    oauthCredentials.LocalConfiguration = localConfiguration;
                    Web web = clientContext.Web;
                    clientContext.Load <Web>(web, new Expression <Func <Web, object> > [0]);
                    clientContext.ExecuteQuery();
                }
            }
            catch (ClientRequestException e)
            {
                ex = new SharePointException(uri.AbsoluteUri, e);
            }
            catch (ServerException e2)
            {
                ex = new SharePointException(uri.AbsoluteUri, e2);
            }
            catch (IOException ex2)
            {
                ex = new SharePointException(uri.AbsoluteUri, new LocalizedString(ex2.Message));
            }
            catch (WebException e3)
            {
                ex = new SharePointException(uri.AbsoluteUri, e3, true);
            }
            if (ex != null)
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine(Strings.TestTeamMailboxOutboundOauthLog);
                stringBuilder.AppendLine(oauthCredentials.Tracer.ToString());
                stringBuilder.AppendLine(Strings.TestTeamMailboxSharePointResponseDetails);
                stringBuilder.AppendLine(ex.DiagnosticInfo);
                ValidationResultNode sendToPipeline2 = new ValidationResultNode(Strings.TestTeamMailboxSharepointCallUnderOauthTask, new LocalizedString(stringBuilder.ToString()), ResultType.Error);
                base.WriteObject(sendToPipeline2);
                return;
            }
            StringBuilder stringBuilder2 = new StringBuilder();

            stringBuilder2.AppendLine(Strings.TestTeamMailboxSharepointCallUnderOauthSuccess(uri.AbsoluteUri));
            stringBuilder2.AppendLine(Strings.TestTeamMailboxOutboundOauthLog);
            stringBuilder2.AppendLine(oauthCredentials.Tracer.ToString());
            ValidationResultNode sendToPipeline3 = new ValidationResultNode(Strings.TestTeamMailboxSharepointCallUnderOauthTask, new LocalizedString(stringBuilder2.ToString()), ResultType.Success);

            base.WriteObject(sendToPipeline3);
        }