public static void Write(BinaryWriter writer, AuthenticationTicket model) { if (writer == null) { throw new ArgumentNullException("writer"); } if (model == null) { throw new ArgumentNullException("model"); } writer.Write(3); ClaimsIdentity identity = model.Identity; writer.Write(identity.AuthenticationType); TicketSerializer.WriteWithDefault(writer, identity.NameClaimType, "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"); TicketSerializer.WriteWithDefault(writer, identity.RoleClaimType, "http://schemas.microsoft.com/ws/2008/06/identity/claims/role"); writer.Write(identity.Claims.Count <Claim>()); foreach (Claim claim in identity.Claims) { TicketSerializer.WriteWithDefault(writer, claim.Type, identity.NameClaimType); writer.Write(claim.Value); TicketSerializer.WriteWithDefault(writer, claim.ValueType, "http://www.w3.org/2001/XMLSchema#string"); TicketSerializer.WriteWithDefault(writer, claim.Issuer, "LOCAL AUTHORITY"); TicketSerializer.WriteWithDefault(writer, claim.OriginalIssuer, claim.Issuer); } BootstrapContext bootstrapContext = identity.BootstrapContext as BootstrapContext; if (bootstrapContext == null || string.IsNullOrWhiteSpace(bootstrapContext.Token)) { writer.Write(0); } else { writer.Write(bootstrapContext.Token.Length); writer.Write(bootstrapContext.Token); } PropertiesSerializer.Write(writer, model.Properties); }