Пример #1
0
        private void CreateFromParts(System.Security.Principal.IdentifierAuthority identifierAuthority, int[] subAuthorities)
        {
            byte num;

            if (subAuthorities == null)
            {
                throw new ArgumentNullException("subAuthorities");
            }
            if (subAuthorities.Length > MaxSubAuthorities)
            {
                throw new ArgumentOutOfRangeException("subAuthorities.Length", subAuthorities.Length, Environment.GetResourceString("IdentityReference_InvalidNumberOfSubauthorities", new object[] { MaxSubAuthorities }));
            }
            if ((identifierAuthority < System.Security.Principal.IdentifierAuthority.NullAuthority) || (identifierAuthority > MaxIdentifierAuthority))
            {
                throw new ArgumentOutOfRangeException("identifierAuthority", identifierAuthority, Environment.GetResourceString("IdentityReference_IdentifierAuthorityTooLarge"));
            }
            this._IdentifierAuthority = identifierAuthority;
            this._SubAuthorities      = new int[subAuthorities.Length];
            subAuthorities.CopyTo(this._SubAuthorities, 0);
            this._BinaryForm    = new byte[8 + (4 * this.SubAuthorityCount)];
            this._BinaryForm[0] = Revision;
            this._BinaryForm[1] = (byte)this.SubAuthorityCount;
            for (num = 0; num < 6; num = (byte)(num + 1))
            {
                this._BinaryForm[2 + num] = (byte)((((long)this._IdentifierAuthority) >> ((5 - num) * 8)) & 0xffL);
            }
            for (num = 0; num < this.SubAuthorityCount; num = (byte)(num + 1))
            {
                for (byte i = 0; i < 4; i = (byte)(i + 1))
                {
                    this._BinaryForm[(8 + (4 * num)) + i] = (byte)(this._SubAuthorities[num] >> (i * 8));
                }
            }
        }
Пример #2
0
        private void CreateFromBinaryForm(byte[] binaryForm, int offset)
        {
            if (binaryForm == null)
            {
                throw new ArgumentNullException("binaryForm");
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", offset, Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
            }
            if ((binaryForm.Length - offset) < MinBinaryLength)
            {
                throw new ArgumentOutOfRangeException("binaryForm", Environment.GetResourceString("ArgumentOutOfRange_ArrayTooSmall"));
            }
            if (binaryForm[offset] != Revision)
            {
                throw new ArgumentException(Environment.GetResourceString("IdentityReference_InvalidSidRevision"), "binaryForm");
            }
            if (binaryForm[offset + 1] > MaxSubAuthorities)
            {
                throw new ArgumentException(Environment.GetResourceString("IdentityReference_InvalidNumberOfSubauthorities", new object[] { MaxSubAuthorities }), "binaryForm");
            }
            int num = 8 + (4 * binaryForm[offset + 1]);

            if ((binaryForm.Length - offset) < num)
            {
                throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_ArrayTooSmall"), "binaryForm");
            }
            System.Security.Principal.IdentifierAuthority identifierAuthority = (System.Security.Principal.IdentifierAuthority)((((((binaryForm[offset + 2] << 40) + (binaryForm[offset + 3] << 0x20)) + (binaryForm[offset + 4] << 0x18)) + (binaryForm[offset + 5] << 0x10)) + (binaryForm[offset + 6] << 8)) + binaryForm[offset + 7]);
            int[] subAuthorities = new int[binaryForm[offset + 1]];
            for (byte i = 0; i < binaryForm[offset + 1]; i = (byte)(i + 1))
            {
                subAuthorities[i] = ((binaryForm[(offset + 8) + (4 * i)] + (binaryForm[((offset + 8) + (4 * i)) + 1] << 8)) + (binaryForm[((offset + 8) + (4 * i)) + 2] << 0x10)) + (binaryForm[((offset + 8) + (4 * i)) + 3] << 0x18);
            }
            this.CreateFromParts(identifierAuthority, subAuthorities);
        }
Пример #3
0
 internal SecurityIdentifier(System.Security.Principal.IdentifierAuthority identifierAuthority, int[] subAuthorities)
 {
     this.CreateFromParts(identifierAuthority, subAuthorities);
 }