Exemplo n.º 1
0
        private static string RedactX400Address(string x400Addr, out string raw, out string redacted)
        {
            raw      = null;
            redacted = null;
            if (string.IsNullOrWhiteSpace(x400Addr))
            {
                return(x400Addr);
            }
            IList <string> list;

            if (!X400AddressParser.TryParse(x400Addr, out list))
            {
                return(x400Addr);
            }
            foreach (int num in SuppressingPiiData.typesNeedRedact)
            {
                if (num < list.Count)
                {
                    string text = SuppressingPiiData.Redact(list[num], out raw, out redacted);
                    if (text != null && X400AddressParser.MaxComponentLengths[num] < text.Length)
                    {
                        text = text.Substring(0, X400AddressParser.MaxComponentLengths[num]);
                    }
                    list[num] = text;
                }
            }
            return(X400AddressParser.ToCanonicalString(list));
        }
Exemplo n.º 2
0
        internal static bool TryGetRoutingAddress(IADRecipientCache recipientCache, string participantEmailAddress, string type, string context, string participantSmtpAddress, out RoutingAddress result, out bool usedParticipantSmtpEmailAddress, bool useParticipantSmtpEmailAddressIfNecessary = false)
        {
            result = RoutingAddress.Empty;
            usedParticipantSmtpEmailAddress = false;
            TraceHelper.StoreDriverTracer.TracePass <string, string>(TraceHelper.MessageProbeActivityId, 0L, "Try to get routing address for {0}:{1}.", type, participantEmailAddress);
            string text = SubmissionItemUtils.StripSingleQuotes(participantEmailAddress);

            if (string.IsNullOrEmpty(type) || string.IsNullOrEmpty(text))
            {
                TraceHelper.StoreDriverTracer.TracePass <string>(TraceHelper.MessageProbeActivityId, 0L, "Required {0} properties are empty", context);
                return(false);
            }
            if (type.Equals("SMTP", StringComparison.OrdinalIgnoreCase))
            {
                result = new RoutingAddress(text);
                if (result.IsValid)
                {
                    return(true);
                }
                string text2;
                if (ConfigurationProvider.TryGetDefaultDomainName(recipientCache.OrganizationId, out text2) && !string.IsNullOrEmpty(text2))
                {
                    result = new RoutingAddress(text, text2);
                    if (result.IsValid)
                    {
                        return(true);
                    }
                }
                result = RoutingAddress.Empty;
                TraceHelper.StoreDriverTracer.TracePass <string, string>(TraceHelper.MessageProbeActivityId, 0L, "{0} Smtp Address is invalid {1}", context, text);
                return(false);
            }
            else
            {
                if (SubmissionItemUtils.TryGetRoutingAddressFromAD(recipientCache, participantEmailAddress, type, out result))
                {
                    return(true);
                }
                if (type.Equals("X400", StringComparison.OrdinalIgnoreCase))
                {
                    bool flag;
                    if (!X400AddressParser.TryGetCanonical(participantEmailAddress, false, out text, out flag))
                    {
                        return(false);
                    }
                    if (string.IsNullOrEmpty(text))
                    {
                        return(false);
                    }
                }
                if (useParticipantSmtpEmailAddressIfNecessary && !string.IsNullOrEmpty(participantSmtpAddress))
                {
                    result = new RoutingAddress(participantSmtpAddress);
                    if (result.IsValid)
                    {
                        usedParticipantSmtpEmailAddress = true;
                        return(true);
                    }
                }
                result = RoutingAddress.Empty;
                SmtpProxyAddress smtpProxyAddress;
                if (SmtpProxyAddress.TryEncapsulate(type, text, ConfigurationProvider.GetDefaultDomainName(), out smtpProxyAddress))
                {
                    result = (RoutingAddress)smtpProxyAddress.SmtpAddress;
                    return(true);
                }
                TraceHelper.StoreDriverTracer.TracePass <string, string>(TraceHelper.MessageProbeActivityId, 0L, "Couldn't encapsulate address {0}:{1}.", type, participantEmailAddress);
                return(false);
            }
        }