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; } }
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; } }