Example #1
0
        private static AuthMetadata FetchAuthMetadata(string authMetadataUrl, bool trustSslCert, bool requireIssuingEndpoint, Task.TaskWarningLoggingDelegate writeWarning, Task.TaskErrorLoggingDelegate writeError)
        {
            try
            {
                Uri uri = new Uri(authMetadataUrl);
                if (uri.Scheme != Uri.UriSchemeHttps)
                {
                    writeWarning(Strings.WarningMetadataNotOverHttps(authMetadataUrl));
                }
            }
            catch (ArgumentNullException)
            {
                writeError(new TaskException(Strings.ErrorInvalidMetadataUrl(authMetadataUrl)), ErrorCategory.InvalidArgument, null);
            }
            catch (UriFormatException)
            {
                writeError(new TaskException(Strings.ErrorInvalidMetadataUrl(authMetadataUrl)), ErrorCategory.InvalidArgument, null);
            }
            AuthMetadata result = null;

            try
            {
                result = AuthMetadataClient.AcquireMetadata(authMetadataUrl, requireIssuingEndpoint, trustSslCert, true);
            }
            catch (AuthMetadataClientException exception)
            {
                writeError(exception, ErrorCategory.ResourceUnavailable, null);
            }
            catch (AuthMetadataParserException exception2)
            {
                writeError(exception2, ErrorCategory.ParserError, null);
            }
            return(result);
        }
        private AuthMetadata FetchMetadata(string name, string metadataUrl, bool requireIssuingEndpoint)
        {
            AuthMetadata result = null;
            Uri          uri    = null;

            if (!Uri.TryCreate(metadataUrl, UriKind.Absolute, out uri))
            {
                this.Context.Logger.LogTerseEvent(MigrationEventType.Error, MSExchangeAuthAdminEventLogConstants.Tuple_InvalidMetadataUrl, new string[]
                {
                    metadataUrl,
                    name
                });
                return(null);
            }
            try
            {
                result = AuthMetadataClient.AcquireMetadata(metadataUrl, requireIssuingEndpoint, this.TrustAnySSLCertificate, true);
            }
            catch (AuthMetadataClientException ex)
            {
                this.Context.Logger.LogTerseEvent(MigrationEventType.Error, MSExchangeAuthAdminEventLogConstants.Tuple_TransientException, new string[]
                {
                    AnchorLogger.GetDiagnosticInfo(ex, null)
                });
            }
            catch (AuthMetadataParserException ex2)
            {
                this.Context.Logger.LogTerseEvent(MigrationEventType.Error, MSExchangeAuthAdminEventLogConstants.Tuple_CorruptMetadata, new string[]
                {
                    AnchorLogger.GetDiagnosticInfo(ex2, null),
                    metadataUrl,
                    name
                });
            }
            catch (Exception ex3)
            {
                this.Context.Logger.LogTerseEvent(MigrationEventType.Error, MSExchangeAuthAdminEventLogConstants.Tuple_UnableToAccessMetadata, new string[]
                {
                    AnchorLogger.GetDiagnosticInfo(ex3, null),
                    metadataUrl,
                    name
                });
            }
            return(result);
        }