internal override void ParseSharingMessageProvider(SharingContext context, SharingMessageProvider sharingMessageProvider) { if (!AddressBookEntryId.IsAddressBookEntryId(context.InitiatorEntryId)) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: InitiatorEntryId is invalid.", context.UserLegacyDN); throw new InvalidSharingDataException("InitiatorEntryId", HexConverter.ByteArrayToHexString(context.InitiatorEntryId)); } if (!string.IsNullOrEmpty(sharingMessageProvider.FolderId)) { try { context.FolderId = StoreObjectId.FromHexEntryId(sharingMessageProvider.FolderId, ObjectClass.GetObjectType(context.FolderClass)); } catch (CorruptDataException) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: FolderId is invalid: {1}", context.UserLegacyDN, sharingMessageProvider.FolderId); throw new InvalidSharingDataException("FolderId", sharingMessageProvider.FolderId); } } if (!string.IsNullOrEmpty(sharingMessageProvider.MailboxId)) { byte[] array = HexConverter.HexStringToByteArray(sharingMessageProvider.MailboxId); if (StoreEntryId.TryParseStoreEntryIdMailboxDN(array) == null) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: MailboxId is invalid: {1}", context.UserLegacyDN, sharingMessageProvider.MailboxId); throw new InvalidSharingDataException("MailboxId", sharingMessageProvider.MailboxId); } context.MailboxId = array; } }
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)); }
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; } }