示例#1
0
        public static PublishedFolder Create(PublishingUrl publishingUrl)
        {
            Util.ThrowOnNullArgument(publishingUrl, "publishingUrl");
            PublishedFolder.SleepIfNecessary();
            SharingAnonymousIdentityCache      instance = SharingAnonymousIdentityCache.Instance;
            SharingAnonymousIdentityCacheKey   key      = publishingUrl.CreateKey();
            SharingAnonymousIdentityCacheValue sharingAnonymousIdentityCacheValue = instance.Get(key);

            if (!sharingAnonymousIdentityCacheValue.IsAccessAllowed)
            {
                ExTraceGlobals.SharingTracer.TraceError <PublishingUrl, Type>(0L, "PublishedFolder.Create(PublishingUrl): Cannot find access allowed folder from the request url: path = {0}, type = {1}.", publishingUrl, publishingUrl.GetType());
                throw new PublishedFolderAccessDeniedException();
            }
            ExTraceGlobals.SharingTracer.TraceDebug <SecurityIdentifier, string, string>(0L, "PublishedFolder.Create(PublishingUrl): User {0} has Sharing Anonymous identity {1}. The corresponding folder identity is {2}.", sharingAnonymousIdentityCacheValue.Sid, publishingUrl.Identity, sharingAnonymousIdentityCacheValue.FolderId);
            StoreObjectId storeObjectId = null;

            try
            {
                storeObjectId = StoreObjectId.Deserialize(sharingAnonymousIdentityCacheValue.FolderId);
            }
            catch (CorruptDataException innerException)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>(0L, "PublishedFolder.Create(PublishingUrl): The folder identity '{0}' is invalid.", sharingAnonymousIdentityCacheValue.FolderId);
                throw new PublishedFolderAccessDeniedException(innerException);
            }
            if (publishingUrl.DataType == SharingDataType.ReachCalendar || publishingUrl.DataType == SharingDataType.Calendar)
            {
                ObscureUrl obscureUrl = publishingUrl as ObscureUrl;
                return(new PublishedCalendar(publishingUrl.Domain, sharingAnonymousIdentityCacheValue.Sid, storeObjectId, (obscureUrl == null) ? null : new ObscureKind?(obscureUrl.ObscureKind), (obscureUrl == null) ? null : obscureUrl.ReachUserSid));
            }
            throw new NotSupportedException();
        }
示例#2
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);
        }
        internal override void ParseSharingMessageProvider(SharingContext context, SharingMessageProvider sharingMessageProvider)
        {
            Uri uri = null;

            if (!PublishingUrl.IsAbsoluteUriString(sharingMessageProvider.BrowseUrl, out uri))
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: BrowseUrl is invalid: {1}", context.UserLegacyDN, sharingMessageProvider.BrowseUrl);
                throw new InvalidSharingDataException("BrowseUrl", sharingMessageProvider.BrowseUrl);
            }
            context.BrowseUrl = sharingMessageProvider.BrowseUrl;
            if (context.DataType == SharingDataType.Calendar)
            {
                if (string.IsNullOrEmpty(sharingMessageProvider.ICalUrl))
                {
                    ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: ICalUrl is missing: {1}", context.UserLegacyDN, sharingMessageProvider.ICalUrl);
                    throw new InvalidSharingDataException("ICalUrl", string.Empty);
                }
                if (!PublishingUrl.IsAbsoluteUriString(sharingMessageProvider.ICalUrl, out uri))
                {
                    ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: ICalUrl is invalid: {1}", context.UserLegacyDN, sharingMessageProvider.ICalUrl);
                    throw new InvalidSharingDataException("ICalUrl", sharingMessageProvider.ICalUrl);
                }
                context.ICalUrl = sharingMessageProvider.ICalUrl;
            }
        }
示例#4
0
        public static SubscribeResultsWebCal Subscribe(MailboxSession mailboxSession, string iCalUrlString, string folderName = null)
        {
            Util.ThrowOnNullArgument(mailboxSession, "mailboxSession");
            Util.ThrowOnNullOrEmptyArgument(iCalUrlString, "iCalUrlString");
            Uri iCalUrl = null;

            if (!PublishingUrl.IsAbsoluteUriString(iCalUrlString, out iCalUrl) || !Array.Exists <string>(WebCalendar.validWebCalendarSchemes, (string scheme) => StringComparer.OrdinalIgnoreCase.Equals(scheme, iCalUrl.Scheme)))
            {
                throw new InvalidSharingDataException("iCalUrlString", iCalUrlString);
            }
            string text;

            if ((text = folderName) == null && (text = WebCalendar.GetFolderNameFromInternetCalendar(iCalUrl)) == null)
            {
                text = (WebCalendar.GetFolderNameFromUrl(iCalUrl) ?? ClientStrings.Calendar.ToString(mailboxSession.InternalPreferedCulture));
            }
            folderName = text;
            PublishingSubscriptionData newSubscription = WebCalendar.CreateSubscriptionData(iCalUrl, folderName);

            return(WebCalendar.InternalSubscribe(mailboxSession, newSubscription, null, null));
        }
示例#5
0
        private void ReadFromMessageXProperties(MessageItem messageItem)
        {
            string valueOrDefault = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingFlavor, null);

            if (valueOrDefault == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: XSharingFlavor is missing", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("XSharingFlavor");
            }
            try
            {
                this.context.SharingFlavor = (SharingFlavor)int.Parse(valueOrDefault, NumberStyles.HexNumber);
            }
            catch (FormatException)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: XSharingFlavor is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault);
                throw new InvalidSharingMessageException("XSharingFlavor");
            }
            string valueOrDefault2 = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingRemoteType, null);

            if (valueOrDefault2 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: XSharingRemoteType is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("XSharingRemoteType");
            }
            if (SharingDataType.FromPublishName(valueOrDefault2) == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: XSharingRemoteType is invalid: {1}.", messageItem.Session.UserLegacyDN, valueOrDefault2);
                throw new InvalidSharingMessageException("XSharingRemoteType");
            }
            string valueOrDefault3 = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingLocalType, null);

            if (valueOrDefault3 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: XSharingLocalType is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("XSharingLocalType");
            }
            if (SharingDataType.FromContainerClass(valueOrDefault3) == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: XSharingLocalType is invalid: {1}.", messageItem.Session.UserLegacyDN, valueOrDefault3);
                throw new InvalidSharingMessageException("XSharingLocalType");
            }
            this.context.FolderClass = valueOrDefault3;
            string valueOrDefault4 = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingRemoteName, null);

            if (valueOrDefault4 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: XSharingRemoteName is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("XSharingRemoteName");
            }
            this.context.FolderName = valueOrDefault4;
            Uri    uri             = null;
            string valueOrDefault5 = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingBrowseUrl, null);

            if (string.IsNullOrEmpty(valueOrDefault5))
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "{0}: XSharingBrowseUrl is missing or empty.", messageItem.Session.UserLegacyDN);
            }
            else
            {
                if (!PublishingUrl.IsAbsoluteUriString(valueOrDefault5, out uri))
                {
                    ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: XSharingBrowseUrl is not well formed : {1}", messageItem.Session.UserLegacyDN, valueOrDefault5);
                    throw new InvalidSharingMessageException("XSharingBrowseUrl");
                }
                this.context.BrowseUrl = valueOrDefault5;
            }
            string valueOrDefault6 = messageItem.GetValueOrDefault <string>(InternalSchema.XSharingRemotePath, null);

            if (valueOrDefault6 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: XSharingRemotePath is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("XSharingRemotePath");
            }
            if (!PublishingUrl.IsAbsoluteUriString(valueOrDefault6, out uri))
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: XSharingRemotePath is not well formed : {1}", messageItem.Session.UserLegacyDN, valueOrDefault6);
                throw new InvalidSharingMessageException("XSharingRemotePath");
            }
            this.context.ICalUrl = valueOrDefault6;
        }