Exemplo n.º 1
0
        public static ObscureUrl CreatePublishCalendarUrl(string externalUrl, Guid mailboxGuid, string domain)
        {
            Util.ThrowOnNullOrEmptyArgument(externalUrl, "externalUrl");
            Util.ThrowOnNullOrEmptyArgument(domain, "domain");
            SharingDataType calendar = SharingDataType.Calendar;
            int             num      = 1;
            string          text;
            string          text2;

            for (;;)
            {
                text  = Guid.NewGuid().ToString("N");
                text2 = ObscureUrl.CalculateHashString(ObscureKind.Restricted, text);
                if (!StringComparer.Ordinal.Equals(text2, ObscureUrl.CalculateHashString(ObscureKind.Normal, text)))
                {
                    goto IL_7D;
                }
                if (++num > 5)
                {
                    break;
                }
                ExTraceGlobals.SharingTracer.TraceDebug <string, int>(0L, "ObscureUrl.CreatePublishCalendarUrl(): Hash strings are identical for GUID {0} - Generating the GUID. Tried times = {1}.", text, num);
            }
            throw new TransientException(ServerStrings.ExTooManyObjects("ObscureUrl", num, 5));
IL_7D:
            string uriString = string.Format("{0}/{1}/{2}@{3}/{4}{5}/{6}", new object[]
            {
                externalUrl.TrimEnd(new char[]
                {
                    '/'
                }),
                calendar.ExternalName,
                mailboxGuid.ToString("N"),
                domain,
                text,
                text2,
                calendar.PublishResourceName
            });
            ObscureUrl obscureUrl = new ObscureUrl(new Uri(uriString, UriKind.Absolute), calendar, mailboxGuid, domain, text, ObscureKind.Restricted, null);

            ExTraceGlobals.SharingTracer.TraceDebug <ObscureUrl, string>(0L, "ObscureUrl.CreatePublishCalendarUrl(): Created an instance of ObscureUrl: {0} - {1}.", obscureUrl, obscureUrl.TraceInfo);
            return(obscureUrl);
        }
Exemplo n.º 2
0
        protected override SharingBindingData CreateDataObjectFromItem(object[] properties)
        {
            VersionedId versionedId = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <VersionedId>(properties, 1);

            if (versionedId == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Binding is missing ID", this.mailboxSession.MailboxOwner);
                return(null);
            }
            string text = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 12);

            if (text == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing sharingLocalType", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            SharingDataType sharingDataType = SharingDataType.FromContainerClass(text);

            if (sharingDataType == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, string>((long)this.GetHashCode(), "{0}: Binding {1} has invalid sharingLocalType: {2}", this.mailboxSession.MailboxOwner, versionedId, text);
                return(null);
            }
            string text2 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 8);

            if (text2 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing initiatorName", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text3 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 9);

            if (text3 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing initiatorSmtpAddress", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text4 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 7);

            if (text4 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing remoteFolderName", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text5 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 18);

            if (text5 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing remoteFolderId", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text6 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 10);

            if (text6 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing localFolderName", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text7 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 11);

            if (text7 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing localFolderUid", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            StoreObjectId localFolderId;

            try
            {
                localFolderId = StoreObjectId.FromHexEntryId(text7, sharingDataType.StoreObjectType);
            }
            catch (CorruptDataException)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} has invalid localFolderUid", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            int?num = SharingItemManagerBase <SharingBindingData> .TryGetPropertyVal <int>(properties, 3);

            if (num == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing flavor", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            bool       isDefaultFolderShared = 0 != (num.Value & 131072);
            DateTime?  lastSyncTimeUtc       = null;
            ExDateTime?exDateTime            = SharingItemManagerBase <SharingBindingData> .TryGetPropertyVal <ExDateTime>(properties, 15);

            if (exDateTime == null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing lastSyncTime", this.mailboxSession.MailboxOwner, versionedId);
            }
            else
            {
                lastSyncTimeUtc = new DateTime?((DateTime)exDateTime.Value.ToUtc());
            }
            return(new SharingBindingData(versionedId, sharingDataType, text2, text3, text4, text5, text6, localFolderId, isDefaultFolderShared, lastSyncTimeUtc));
        }
Exemplo n.º 3
0
        private void ReadFromMessageProperties(MessageItem messageItem)
        {
            SharingFlavor?valueAsNullable = messageItem.GetValueAsNullable <SharingFlavor>(InternalSchema.SharingFlavor);

            if (valueAsNullable == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingFlavor is missing", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingFlavor");
            }
            this.context.SharingFlavor = valueAsNullable.Value;
            SharingCapabilities?valueAsNullable2 = messageItem.GetValueAsNullable <SharingCapabilities>(InternalSchema.SharingCapabilities);

            if (valueAsNullable2 == null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "{0}: SharingCapabilities is missing, use default value", messageItem.Session.UserLegacyDN);
                this.context.SetDefaultCapabilities();
            }
            else
            {
                this.context.SharingCapabilities = valueAsNullable2.Value;
            }
            string valueOrDefault = messageItem.GetValueOrDefault <string>(InternalSchema.SharingInitiatorName, null);

            if (valueOrDefault == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingInitiatorName is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingInitiatorName");
            }
            this.context.InitiatorName = valueOrDefault;
            string valueOrDefault2 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingInitiatorSmtp, null);

            if (valueOrDefault2 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingInitiatorSmtp is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingInitiatorSmtp");
            }
            if (!SmtpAddress.IsValidSmtpAddress(valueOrDefault2))
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingInitiatorSmtp is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault2);
                throw new InvalidSharingMessageException("SharingInitiatorSmtp");
            }
            this.context.InitiatorSmtpAddress = valueOrDefault2;
            byte[] valueOrDefault3 = messageItem.GetValueOrDefault <byte[]>(InternalSchema.SharingInitiatorEntryId, null);
            if (valueOrDefault3 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingInitiatorEntryId is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingInitiatorEntryId");
            }
            if (!AddressBookEntryId.IsAddressBookEntryId(valueOrDefault3))
            {
                ExTraceGlobals.SharingTracer.TraceError <string, byte[]>((long)this.GetHashCode(), "{0}: SharingInitiatorEntryId is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault3);
                throw new InvalidSharingMessageException("SharingInitiatorEntryId");
            }
            this.context.InitiatorEntryId = valueOrDefault3;
            string valueOrDefault4 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingRemoteType, null);

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

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

            if (valueOrDefault6 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingRemoteUid is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingRemoteUid");
            }
            try
            {
                this.context.FolderId = StoreObjectId.FromHexEntryId(valueOrDefault6, ObjectClass.GetObjectType(valueOrDefault4));
            }
            catch (CorruptDataException)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingRemoteUid is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault6);
                throw new InvalidSharingMessageException("SharingRemoteUid");
            }
            string valueOrDefault7 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingRemoteStoreUid, null);

            if (valueOrDefault7 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingRemoteStoreUid is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingRemoteStoreUid");
            }
            byte[] array = null;
            try
            {
                array = HexConverter.HexStringToByteArray(valueOrDefault7);
            }
            catch (FormatException)
            {
            }
            if (array == null || StoreEntryId.TryParseStoreEntryIdMailboxDN(array) == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingRemoteStoreUid is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault7);
                throw new InvalidSharingMessageException("SharingRemoteStoreUid");
            }
            this.context.MailboxId = array;
            SharingContextPermissions?valueAsNullable3 = messageItem.GetValueAsNullable <SharingContextPermissions>(InternalSchema.SharingPermissions);

            if (valueAsNullable3 != null)
            {
                this.context.SharingPermissions = valueAsNullable3.Value;
            }
            SharingContextDetailLevel?valueAsNullable4 = messageItem.GetValueAsNullable <SharingContextDetailLevel>(InternalSchema.SharingDetail);

            if (valueAsNullable4 != null)
            {
                this.context.SharingDetail = valueAsNullable4.Value;
                return;
            }
            if (this.context.DataType == SharingDataType.Calendar)
            {
                this.context.SharingDetail = SharingContextDetailLevel.FullDetails;
            }
        }
Exemplo n.º 4
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;
        }
 internal SubscribeResultsInternal(SharingDataType dataType, string initiatorSmtpAddress, string initiatorName, string remoteFolderName, StoreObjectId remoteFolderId, byte[] remoteMailboxId) : base(dataType, initiatorSmtpAddress, initiatorName, remoteFolderName, null, false, null)
 {
     this.RemoteFolderId  = remoteFolderId;
     this.RemoteMailboxId = remoteMailboxId;
 }
Exemplo n.º 6
0
        public EncryptionResults Encrypt(IExchangePrincipal mailboxOwner, IRecipientSession recipientSession, ExternalUserCollection externalUserCollection, ValidRecipient[] recipients, string sender, string containerClass, string folderId, IFrontEndLocator frontEndLocator)
        {
            SharingDataType sharingDataType = SharingDataType.FromContainerClass(containerClass);

            if (sharingDataType == null || !sharingDataType.IsExternallySharable)
            {
                throw new ArgumentOutOfRangeException("containerClass");
            }
            ADUser aduser = DirectoryHelper.ReadADRecipient(mailboxOwner.MailboxInfo.MailboxGuid, mailboxOwner.MailboxInfo.IsArchive, recipientSession) as ADUser;

            if (aduser == null)
            {
                SharedFolderDataEncryption.Tracer.TraceError <SharedFolderDataEncryption, string>((long)this.GetHashCode(), "{0}: The Active Directory user was not found. Sender={1}.", this, sender);
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            ProxyAddress item = new SmtpProxyAddress(sender, false);

            if (!aduser.EmailAddresses.Contains(item))
            {
                SharedFolderDataEncryption.Tracer.TraceError <SharedFolderDataEncryption, string>((long)this.GetHashCode(), "{0}: The SMTP address was not found in the user AD object for this mailbox. Sender={1}.", this, sender);
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            SharingPolicy sharingPolicy = DirectoryHelper.ReadSharingPolicy(mailboxOwner.MailboxInfo.MailboxGuid, mailboxOwner.MailboxInfo.IsArchive, recipientSession);

            SharedFolderDataEncryption.Tracer.TraceDebug <SharedFolderDataEncryption, object>((long)this.GetHashCode(), "{0}: Sharing policy to be applied to this user: {1}", this, (sharingPolicy == null) ? "<null>" : sharingPolicy.Id);
            SharingPolicyAction sharingPolicyActions = SharedFolderDataEncryption.GetSharingPolicyActions(sharingDataType.StoreObjectType);

            SharedFolderDataRecipient[] externalIdentities = SharedFolderDataEncryption.GetExternalIdentities(externalUserCollection, recipients);
            List <InvalidRecipient>     list = new List <InvalidRecipient>();
            Dictionary <TokenTarget, List <SharedFolderDataRecipient> > dictionary = new Dictionary <TokenTarget, List <SharedFolderDataRecipient> >(externalIdentities.Length, SharedFolderDataEncryption.TokenTargetComparer);

            for (int i = 0; i < recipients.Length; i++)
            {
                SharedFolderDataRecipient item2          = externalIdentities[i];
                ValidRecipient            validRecipient = recipients[i];
                SmtpAddress smtpAddress = new SmtpAddress(validRecipient.SmtpAddress);
                string      domain      = smtpAddress.Domain;
                if (sharingPolicy == null || !sharingPolicy.IsAllowedForAnySharing(domain, sharingPolicyActions))
                {
                    SharedFolderDataEncryption.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Sharing policy does not allow user to share with domain {0}", domain);
                    list.Add(new InvalidRecipient(validRecipient.SmtpAddress, InvalidRecipientResponseCodeType.SystemPolicyBlocksSharingWithThisRecipient));
                }
                else
                {
                    SmtpAddress smtpAddress2 = new SmtpAddress(validRecipient.SmtpAddressForEncryption);
                    TokenTarget tokenTarget  = TargetUriResolver.Resolve(smtpAddress2.Domain, aduser.OrganizationId);
                    if (tokenTarget == null)
                    {
                        list.Add(new InvalidRecipient(validRecipient.SmtpAddress, InvalidRecipientResponseCodeType.RecipientOrganizationNotFederated));
                    }
                    else
                    {
                        List <SharedFolderDataRecipient> list2;
                        if (!dictionary.TryGetValue(tokenTarget, out list2))
                        {
                            list2 = new List <SharedFolderDataRecipient>(1);
                            dictionary.Add(tokenTarget, list2);
                        }
                        list2.Add(item2);
                    }
                }
            }
            List <EncryptedSharedFolderData> list3 = new List <EncryptedSharedFolderData>(dictionary.Count);
            SharedFolderData sharedFolderData      = new SharedFolderData();

            sharedFolderData.DataType          = sharingDataType.ExternalName;
            sharedFolderData.FolderId          = folderId;
            sharedFolderData.SharingUrl        = this.GetSharingUrl(aduser, frontEndLocator);
            sharedFolderData.FederationUri     = this.externalAuthentication.TokenValidator.TargetUri.ToString();
            sharedFolderData.SenderSmtpAddress = sender;
            DelegationTokenRequest delegationTokenRequest = new DelegationTokenRequest
            {
                FederatedIdentity = aduser.GetFederatedIdentity(),
                EmailAddress      = aduser.GetFederatedSmtpAddress(new SmtpAddress(sender)).ToString(),
                Offer             = Offer.SharingInviteMessage
            };
            SecurityTokenService securityTokenService = this.externalAuthentication.GetSecurityTokenService(aduser.OrganizationId);

            foreach (KeyValuePair <TokenTarget, List <SharedFolderDataRecipient> > keyValuePair in dictionary)
            {
                delegationTokenRequest.Target = keyValuePair.Key;
                sharedFolderData.Recipients   = keyValuePair.Value.ToArray();
                try
                {
                    RequestedToken requestedToken = securityTokenService.IssueToken(delegationTokenRequest);
                    list3.Add(this.Encrypt(requestedToken, sharedFolderData));
                }
                catch (WSTrustException ex)
                {
                    foreach (SharedFolderDataRecipient sharedFolderDataRecipient in sharedFolderData.Recipients)
                    {
                        list.Add(new InvalidRecipient(sharedFolderDataRecipient.SmtpAddress, SharedFolderDataEncryption.GetResponseCodeFromException(ex), ex.ToString()));
                    }
                }
            }
            return(new EncryptionResults(list3.ToArray(), list.ToArray()));
        }
 protected override bool InternalValidateCompatibility(Folder folderToShare)
 {
     return(SharingDataType.FromContainerClass(folderToShare.ClassName) != null);
 }
Exemplo n.º 8
0
        protected override bool InternalValidateCompatibility(Folder folderToShare)
        {
            SharingDataType sharingDataType = SharingDataType.FromContainerClass(folderToShare.ClassName);

            return(sharingDataType != null && sharingDataType.IsExternallySharable);
        }
Exemplo n.º 9
0
 private static string CalculateIdentity(SharingDataType dataType, string guidIdentity)
 {
     Util.ThrowOnNullArgument(dataType, "dataType");
     Util.ThrowOnNullOrEmptyArgument(guidIdentity, "guidIdentity");
     return(dataType.PublishResourceName + "\\" + guidIdentity);
 }
Exemplo n.º 10
0
        internal static bool TryParse(string url, out ObscureUrl obscureUrl)
        {
            obscureUrl = null;
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                ExTraceGlobals.SharingTracer.TraceError <string>(0L, "ObscureUrl.TryParse(): The string '{0}' is not an Absolute Uri.", url);
                return(false);
            }
            Uri    uri       = new Uri(url, UriKind.Absolute);
            string localPath = uri.LocalPath;

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

            if (!match.Success)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): The string '{0}' is not desired ObscureUrl. ", url);
                return(false);
            }
            SharingDataType sharingDataType = SharingDataType.FromPublishResourceName(match.Result("${datatype}"));
            Guid            guid            = Guid.Empty;
            Exception       ex = null;

            try
            {
                guid = new Guid(match.Result("${mailboxguid}"));
            }
            catch (FormatException ex2)
            {
                ex = ex2;
            }
            catch (OverflowException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string, Exception>(0L, "ObscureUrl.TryParse(): The string '{0}' is not desired ObscureUrl. Exception = {1}.", url, ex);
                return(false);
            }
            string             text = match.Result("${guid}");
            string             x    = match.Result("${hash}");
            SecurityIdentifier securityIdentifier = null;
            string             text2 = match.Result("${sid}");

            if (sharingDataType == SharingDataType.ReachCalendar)
            {
                if (!StringComparer.Ordinal.Equals(x, ObscureUrl.CalculateHashString(ObscureKind.Normal, text)))
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): Incorrect hash value for reachUrl:'{0}'", url);
                    return(false);
                }
                if (string.IsNullOrEmpty(text2))
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): sid value missing for reachUrl:'{0}'", url);
                    return(false);
                }
                securityIdentifier = new SecurityIdentifier(text2);
                if (!ExternalUser.IsValidReachSid(securityIdentifier))
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): Not a valid reach sid:'{0}'", url);
                    return(false);
                }
                obscureUrl = new ObscureUrl(uri, sharingDataType, guid, match.Result("${domain}"), text, ObscureKind.Normal, securityIdentifier);
                ExTraceGlobals.SharingTracer.TraceDebug <string, string>(0L, "ObscureUrl.TryParse(): The url {0} is parsed as ReachCalendar ObscureUrl {1}.", url, obscureUrl.TraceInfo);
                return(true);
            }
            else
            {
                if (sharingDataType != SharingDataType.Calendar)
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <SharingDataType>(0L, "ObscureUrl.TryParse(): Sharing Datatype:{0} is not supported ", sharingDataType);
                    return(false);
                }
                if (!string.IsNullOrEmpty(text2))
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): SID is not applicable for published calendar url:'{0}'", url);
                    return(false);
                }
                foreach (object obj in Enum.GetValues(typeof(ObscureKind)))
                {
                    ObscureKind obscureKind = (ObscureKind)obj;
                    if (StringComparer.Ordinal.Equals(x, ObscureUrl.CalculateHashString(obscureKind, text)))
                    {
                        obscureUrl = new ObscureUrl(uri, sharingDataType, guid, match.Result("${domain}"), text, obscureKind, securityIdentifier);
                        ExTraceGlobals.SharingTracer.TraceDebug <string, string>(0L, "ObscureUrl.TryParse(): The url {0} is parsed as Calendar ObscureUrl {1}.", url, obscureUrl.TraceInfo);
                        return(true);
                    }
                }
                ExTraceGlobals.SharingTracer.TraceDebug <string>(0L, "ObscureUrl.TryParse(): Incorrect hash value for Calendar url:{0}", url);
                return(false);
            }
        }
Exemplo n.º 11
0
 internal SubscribeResultsWebCal(SharingDataType dataType, string initiatorSmtpAddress, string initiatorName, string remoteFolderName, Uri url, StoreObjectId localFolderId, bool localFolderCreated, LocalizedString localFolderName) : base(dataType, initiatorSmtpAddress, initiatorName, remoteFolderName, localFolderId, localFolderCreated, localFolderName)
 {
     this.Url = url;
 }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
 private static string CalculateIdentity(SharingDataType dataType, string folderName)
 {
     Util.ThrowOnNullArgument(dataType, "dataType");
     Util.ThrowOnNullOrEmptyArgument(folderName, "folderName");
     return(dataType.PublishResourceName + "\\" + Uri.EscapeDataString(folderName));
 }
Exemplo n.º 14
0
 private PublicUrl(Uri uri, SharingDataType dataType, SmtpAddress smtpAddress, string folderName) : base(uri, dataType, PublicUrl.CalculateIdentity(dataType, folderName))
 {
     this.smtpAddress = smtpAddress;
     this.folderName  = folderName;
 }