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
 internal SharingSubscriptionData(VersionedId id, string dataType, string sharerIdentity, string sharerName, string remoteFolderId, string remoteFolderName, bool isPrimary, Uri sharerIdentityFederationUri, Uri sharingUrl, StoreObjectId localFolderId, string sharingKey, string subscriberIdentity)
 {
     this.Id                          = id;
     this.DataType                    = SharingDataType.FromExternalName(dataType);
     this.SharerIdentity              = sharerIdentity;
     this.SharerName                  = sharerName;
     this.RemoteFolderId              = remoteFolderId;
     this.RemoteFolderName            = remoteFolderName;
     this.IsPrimary                   = isPrimary;
     this.SharerIdentityFederationUri = sharerIdentityFederationUri;
     this.SharingUrl                  = sharingUrl;
     this.LocalFolderId               = localFolderId;
     this.SharingKey                  = sharingKey;
     this.SubscriberIdentity          = subscriberIdentity;
     this.Key                         = new SharingSubscriptionKey(this.SharerIdentity, this.RemoteFolderId);
 }
Esempio n. 3
0
        internal bool ReadFromMetadataXml(MessageItem messageItem)
        {
            SharingMessage sharingMessage = SharingMessageAttachment.GetSharingMessage(messageItem);

            if (sharingMessage == null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "{0}: The sharing_metadata.xml is invalid", messageItem.Session.UserLegacyDN);
                return(false);
            }
            if (sharingMessage.Validate().Result != ValidationResult.Success)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: The sharing_metadata.xml is invalid", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingMetadata");
            }
            SharingDataType sharingDataType = SharingDataType.FromExternalName(sharingMessage.DataType);

            if (sharingDataType == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: Unknown sharing data type: {1}", messageItem.Session.UserLegacyDN, sharingMessage.DataType);
                throw new InvalidSharingMessageException("DataType");
            }
            this.context.FolderClass = sharingDataType.ContainerClass;
            if (!SmtpAddress.IsValidSmtpAddress(sharingMessage.Initiator.SmtpAddress))
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: Initiator's smtp address is invalid: {1}", messageItem.Session.UserLegacyDN, sharingMessage.Initiator.SmtpAddress);
                throw new InvalidSharingMessageException("InitiatorSmtpAddress");
            }
            this.context.InitiatorName        = sharingMessage.Initiator.Name;
            this.context.InitiatorSmtpAddress = sharingMessage.Initiator.SmtpAddress;
            this.context.InitiatorEntryId     = HexConverter.HexStringToByteArray(sharingMessage.Initiator.EntryId);
            this.context.AvailableSharingProviders.Clear();
            if (sharingMessage.Invitation != null)
            {
                this.ReadActionFromMetadataXml(sharingMessage.Invitation);
            }
            else if (sharingMessage.AcceptOfRequest != null)
            {
                this.ReadActionFromMetadataXml(sharingMessage.AcceptOfRequest);
            }
            else if (sharingMessage.Request != null)
            {
                this.ReadActionFromMetadataXml(sharingMessage.Request);
            }
            else if (sharingMessage.DenyOfRequest != null)
            {
                this.ReadActionFromMetadataXml(sharingMessage.DenyOfRequest);
            }
            if (this.context.AvailableSharingProviders.Count == 0)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: No known sharing provider is found in message.", messageItem.Session.UserLegacyDN);
                throw new NotSupportedSharingMessageException();
            }
            if (this.context.IsPrimary)
            {
                this.context.FolderName = sharingDataType.DisplayName.ToString(messageItem.Session.InternalPreferedCulture);
            }
            this.context.SetDefaultCapabilities();
            SharingMessageType sharingMessageType = SharingContextSerializer.CalculateSharingMessageType(sharingMessage);

            if (sharingMessageType == SharingMessageType.Unknown)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingMessageType is unknown", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingMessageType");
            }
            this.context.SharingMessageType = sharingMessageType;
            return(true);
        }