Exemplo n.º 1
0
 public static byte[] ParseTenantHint(MailboxSignatureSectionMetadata metadata, byte[] buffer, ref int offset)
 {
     byte[] array = new byte[metadata.Length];
     Buffer.BlockCopy(buffer, offset, array, 0, metadata.Length);
     offset += metadata.Length;
     return(array);
 }
Exemplo n.º 2
0
        private void InternalParse(byte[] buffer, IMailboxSignatureSectionProcessor sectionProcessor)
        {
            int i = 0;

            while (i < buffer.Length)
            {
                MailboxSignatureSectionMetadata mailboxSignatureSectionMetadata = MailboxSignatureSectionMetadata.Parse(buffer, ref i);
                if (mailboxSignatureSectionMetadata.Length > buffer.Length - i)
                {
                    throw new ArgumentException("Metadata declares length past our buffer end.");
                }
                int  num  = i;
                bool flag = sectionProcessor.Process(mailboxSignatureSectionMetadata, buffer, ref i);
                if (i - num != mailboxSignatureSectionMetadata.Length)
                {
                    throw new ArgumentException("Parsed more data than declared in metadata.");
                }
                if (flag)
                {
                    if ((from section in this.sections
                         select section.Metadata.Type).Contains(mailboxSignatureSectionMetadata.Type))
                    {
                        throw new ArgumentException("Same section appears more than once.");
                    }
                    this.sections.Add(new MailboxSignatureSectionsContainer.SignatureSection(mailboxSignatureSectionMetadata, new ArraySegment <byte>(buffer, num, mailboxSignatureSectionMetadata.Length)));
                }
            }
        }
Exemplo n.º 3
0
        public void UpdateSection(MailboxSignatureSectionMetadata metadata, byte[] data)
        {
            int num = this.sections.FindIndex((MailboxSignatureSectionsContainer.SignatureSection e) => e.Metadata.Type == metadata.Type);

            if (num != -1)
            {
                this.sections.RemoveAt(num);
            }
            this.sections.Add(new MailboxSignatureSectionsContainer.SignatureSection(metadata, new ArraySegment <byte>(data)));
        }
Exemplo n.º 4
0
        public static PartitionInformation Parse(MailboxSignatureSectionMetadata metadata, byte[] buffer, ref int offset)
        {
            if (metadata.Length != 20)
            {
                throw new ArgumentException("Invalide PartitionInformation section");
            }
            Guid guid = Serialization.DeserializeGuid(buffer, ref offset);

            PartitionInformation.ControlFlags controlFlags = (PartitionInformation.ControlFlags)Serialization.DeserializeUInt32(buffer, ref offset);
            return(new PartitionInformation(guid, controlFlags));
        }
Exemplo n.º 5
0
 internal SignatureSection(MailboxSignatureSectionMetadata metadata, ArraySegment <byte> data)
 {
     this.metadata = metadata;
     this.data     = data;
 }
 public bool Process(MailboxSignatureSectionMetadata sectionMetadata, byte[] buffer, ref int offset)
 {
     offset += sectionMetadata.Length;
     return(true);
 }