Ejemplo n.º 1
0
        private int GetByteCountToSerializeToken()
        {
            int num = 0;

            num += SerializedSecurityAccessToken.serializedSecurityAccessTokenCookie.Length;
            num++;
            num += 4;
            num += Encoding.UTF8.GetByteCount(this.UserSid);
            num += SerializedSecurityAccessToken.GetByteCountToSerializeSidArray(this.GroupSids);
            return(num + SerializedSecurityAccessToken.GetByteCountToSerializeSidArray(this.RestrictedGroupSids));
        }
Ejemplo n.º 2
0
        public byte[] GetBytes()
        {
            byte[] array = new byte[this.GetByteCountToSerializeToken()];
            int    num   = 0;

            SerializedSecurityAccessToken.serializedSecurityAccessTokenCookie.CopyTo(array, num);
            num         += SerializedSecurityAccessToken.serializedSecurityAccessTokenCookie.Length;
            array[num++] = 1;
            SerializedSecurityAccessToken.SerializeStringToByteArray(this.UserSid, array, ref num);
            SerializedSecurityAccessToken.SerializeSidArrayToByteArray(this.GroupSids, array, ref num);
            SerializedSecurityAccessToken.SerializeSidArrayToByteArray(this.RestrictedGroupSids, array, ref num);
            return(array);
        }
Ejemplo n.º 3
0
 private static void SerializeSidArrayToByteArray(SidStringAndAttributes[] sidArray, byte[] byteArray, ref int byteIndex)
 {
     if (sidArray == null || sidArray.Length == 0)
     {
         for (int i = 0; i < 4; i++)
         {
             byteArray[byteIndex++] = 0;
         }
         return;
     }
     BitConverter.GetBytes(sidArray.Length).CopyTo(byteArray, byteIndex);
     byteIndex += 4;
     foreach (SidStringAndAttributes sidStringAndAttributes in sidArray)
     {
         SerializedSecurityAccessToken.SerializeStringToByteArray(sidStringAndAttributes.SecurityIdentifier, byteArray, ref byteIndex);
         BitConverter.GetBytes(sidStringAndAttributes.Attributes).CopyTo(byteArray, byteIndex);
         byteIndex += 4;
     }
 }
Ejemplo n.º 4
0
        // Token: 0x060003FE RID: 1022 RVA: 0x00017434 File Offset: 0x00015634
        public static byte[] CreateSerializedSecurityAccessToken(this IRequestContext requestContext)
        {
            if (requestContext == null)
            {
                throw new ArgumentNullException("requestContext");
            }
            SerializedSecurityAccessToken serializedSecurityAccessToken = new SerializedSecurityAccessToken();

            try
            {
                using (ClientSecurityContext clientSecurityContext = IdentityUtils.ClientSecurityContextFromIdentity(requestContext.GetCallerIdentity(), true))
                {
                    clientSecurityContext.SetSecurityAccessToken(serializedSecurityAccessToken);
                }
            }
            catch (AuthzException ex)
            {
                throw new HttpException(401, ex.Message);
            }
            return(serializedSecurityAccessToken.GetSecurityContextBytes());
        }
Ejemplo n.º 5
0
        public static byte[] CreateSerializedSecurityAccessToken(this HttpContext httpContext)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            SerializedSecurityAccessToken serializedSecurityAccessToken = new SerializedSecurityAccessToken();

            try
            {
                IIdentity callerIdentity = httpContext.GetCallerIdentity();
                using (ClientSecurityContext clientSecurityContext = callerIdentity.CreateClientSecurityContext(true))
                {
                    clientSecurityContext.SetSecurityAccessToken(serializedSecurityAccessToken);
                }
            }
            catch (AuthzException ex)
            {
                throw new HttpException(401, ex.Message);
            }
            return(serializedSecurityAccessToken.GetSecurityContextBytes());
        }
 // Token: 0x0600039F RID: 927 RVA: 0x000148F7 File Offset: 0x00012AF7
 private int GetByteCountToSerializeToken()
 {
     return(0 + SerializedSecurityAccessToken.serializedSecurityAccessTokenCookie.Length + 1 + 4 + Encoding.UTF8.GetByteCount(this.UserSid) + SerializedSecurityAccessToken.GetByteCountToSerializeSidArray(this.GroupSids) + SerializedSecurityAccessToken.GetByteCountToSerializeSidArray(this.RestrictedGroupSids));
 }