Esempio n. 1
0
        internal static bool TryParse(string url, out PublicUrl publicUrl)
        {
            publicUrl = null;
            Uri uri = null;

            if (!PublishingUrl.IsAbsoluteUriString(url, out uri))
            {
                ExTraceGlobals.SharingTracer.TraceError <string>(0L, "PublicUrl.TryParse(): The string '{0}' is not an valid Uri.", url);
                return(false);
            }
            string localPath = uri.LocalPath;

            ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "PublicUrl.TryParse(): Get path of url: {0}", localPath);
            Match match = PublicUrl.PublicUrlRegex.Match(localPath);

            if (!match.Success)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "PublicUrl.TryParse(): The string '{0}' is not PublicUrl.", url);
                return(false);
            }
            SharingDataType dataType = SharingDataType.FromExternalName(match.Result("${datatype}"));
            string          text     = match.Result("${address}");

            if (!SmtpAddress.IsValidSmtpAddress(text))
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "PublicUrl.TryParse(): {0} is not valid SMTP address.", text);
                return(false);
            }
            publicUrl = new PublicUrl(uri, dataType, new SmtpAddress(text), match.Result("${name}"));
            ExTraceGlobals.SharingTracer.TraceDebug <string, string>(0L, "PublicUrl.TryParse(): The url {0} is parsed as PublicUrl {1}.", url, publicUrl.TraceInfo);
            return(true);
        }
Esempio n. 2
0
        public static PublicUrl Create(string externalUrl, SharingDataType dataType, SmtpAddress smtpAddress, string folderName, SharingAnonymousIdentityCollection sharingAnonymousIdentities)
        {
            Util.ThrowOnNullOrEmptyArgument(externalUrl, "externalUrl");
            Util.ThrowOnNullArgument(dataType, "dataType");
            Util.ThrowOnNullOrEmptyArgument(dataType.ExternalName, "dataType.ExternalName");
            Util.ThrowOnNullOrEmptyArgument(folderName, "folderName");
            string text = string.Join(string.Empty, folderName.Split(".*$&+,/:;=?@\"\\<>#%{}|\\^~[]`".ToCharArray()));

            if (string.IsNullOrEmpty(text))
            {
                text = "MyCalendar";
            }
            text = text.Replace(" ", "_");
            if (sharingAnonymousIdentities != null)
            {
                string text2 = text;
                int    num   = 0;
                for (;;)
                {
                    string urlId = PublicUrl.CalculateIdentity(dataType, text2);
                    if (!sharingAnonymousIdentities.Contains(urlId))
                    {
                        goto IL_CD;
                    }
                    if (++num > 50)
                    {
                        break;
                    }
                    ExTraceGlobals.SharingTracer.TraceDebug <string, int>(0L, "PublicUrl.Create(): {0} has been used in Sharing Anonymous Identities - Appending post fix: {1}.", text, num);
                    text2 = string.Format("{0}({1})", text, num);
                }
                throw new CannotShareFolderException(ServerStrings.ExTooManyObjects("PublicUrl", num, 50));
IL_CD:
                text = text2;
            }
            string uriString = string.Format("{0}/{1}/{2}/{3}/{1}", new object[]
            {
                externalUrl.TrimEnd(new char[]
                {
                    '/'
                }),
                dataType.ExternalName,
                smtpAddress.ToString(),
                text
            });
            PublicUrl publicUrl = new PublicUrl(new Uri(uriString, UriKind.Absolute), dataType, smtpAddress, text);

            ExTraceGlobals.SharingTracer.TraceDebug <PublicUrl, string>(0L, "PublicUrl.Create(): Created an instance of PublicUrl: {0} - {1}.", publicUrl, publicUrl.TraceInfo);
            return(publicUrl);
        }
Esempio n. 3
0
        public static PublishingUrl Create(string url)
        {
            Util.ThrowOnNullOrEmptyArgument(url, "url");
            ObscureUrl result = null;

            if (ObscureUrl.TryParse(url, out result))
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "PublishingUrl.Create(): Get ObscureUrl from url {0}.", url);
                return(result);
            }
            PublicUrl result2 = null;

            if (PublicUrl.TryParse(url, out result2))
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "PublishingUrl.Create(): Get PublicUrl from url {0}.", url);
                return(result2);
            }
            ExTraceGlobals.SharingTracer.TraceError <string>(0L, "PublishingUrl.Create(): Cannot parse url {0} for PublishingUrl", url);
            throw new ArgumentException("Url is not valid: " + url);
        }
Esempio n. 4
0
 private static int GetHashCode(PublicUrl url)
 {
     Util.ThrowOnNullArgument(url, "url");
     return((url.SmtpAddress.ToString() + url.Identity).GetHashCode());
 }
Esempio n. 5
0
 internal PublicUrlKey(PublicUrl url) : base(PublicUrlKey.GetHashCode(url))
 {
     this.smtpAddress         = url.SmtpAddress;
     this.urlId               = url.Identity;
     this.filterBySmtpAddress = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.EmailAddresses, new SmtpProxyAddress(this.smtpAddress.ToString(), false).ToString());
 }
Esempio n. 6
0
 private PublicUrl(Uri uri, SharingDataType dataType, SmtpAddress smtpAddress, string folderName) : base(uri, dataType, PublicUrl.CalculateIdentity(dataType, folderName))
 {
     this.smtpAddress = smtpAddress;
     this.folderName  = folderName;
 }