コード例 #1
0
        public static AuthenticationTicket Read(BinaryReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.ReadInt32() != 3)
            {
                return(null);
            }
            string str  = reader.ReadString();
            string str1 = TicketSerializer.ReadWithDefault(reader, "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name");
            string str2 = TicketSerializer.ReadWithDefault(reader, "http://schemas.microsoft.com/ws/2008/06/identity/claims/role");
            int    num  = reader.ReadInt32();

            Claim[] claim = new Claim[num];
            for (int i = 0; i != num; i++)
            {
                string str3 = TicketSerializer.ReadWithDefault(reader, str1);
                string str4 = reader.ReadString();
                string str5 = TicketSerializer.ReadWithDefault(reader, "http://www.w3.org/2001/XMLSchema#string");
                string str6 = TicketSerializer.ReadWithDefault(reader, "LOCAL AUTHORITY");
                string str7 = TicketSerializer.ReadWithDefault(reader, str6);
                claim[i] = new Claim(str3, str4, str5, str6, str7);
            }
            ClaimsIdentity claimsIdentity = new ClaimsIdentity(claim, str, str1, str2);

            if (reader.ReadInt32() > 0)
            {
                claimsIdentity.BootstrapContext = new BootstrapContext(reader.ReadString());     //--> Contains: BootstrapContext(RSASecurityToken token, SecurityTokenHandler tokenHandler)
            }
            return(new AuthenticationTicket(claimsIdentity, PropertiesSerializer.Read(reader))); //--> Properties contain the Expires, Issued values
        }
        public AuthenticationProperties Deserialize(byte[] data)
        {
            AuthenticationProperties authenticationProperty;

            using (MemoryStream memoryStream = new MemoryStream(data))
            {
                using (BinaryReader binaryReader = new BinaryReader(memoryStream))
                {
                    authenticationProperty = PropertiesSerializer.Read(binaryReader);
                }
            }
            return(authenticationProperty);
        }