< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.SctClaimSerializer
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/SctClaimSerializer.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 310
Coverable lines: 310
Total lines: 534
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 146
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/SctClaimSerializer.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Net.Mail;
 7using System.Runtime.Serialization;
 8using System.Security.Cryptography;
 9using System.Security.Cryptography.X509Certificates;
 10using System.Security.Principal;
 11using System.Xml;
 12using CoreWCF.IdentityModel.Claims;
 13using CoreWCF.IdentityModel.Policy;
 14using CoreWCF.Security.Tokens;
 15
 16namespace CoreWCF.Security
 17{
 18    internal static class SctClaimSerializer
 19    {
 20        private static void SerializeSid(SecurityIdentifier sid, SctClaimDictionary dictionary, XmlDictionaryWriter writ
 21        {
 022            byte[] sidBytes = new byte[sid.BinaryLength];
 023            sid.GetBinaryForm(sidBytes, 0);
 024            writer.WriteBase64(sidBytes, 0, sidBytes.Length);
 025        }
 26
 27        private static void WriteRightAttribute(Claim claim, SctClaimDictionary dictionary, XmlDictionaryWriter writer)
 28        {
 029            if (Rights.PossessProperty.Equals(claim.Right))
 30            {
 031                return;
 32            }
 33
 034            writer.WriteAttributeString(dictionary.Right, dictionary.EmptyString, claim.Right);
 035        }
 36
 37        private static string ReadRightAttribute(XmlDictionaryReader reader, SctClaimDictionary dictionary)
 38        {
 039            string right = reader.GetAttribute(dictionary.Right, dictionary.EmptyString);
 040            return string.IsNullOrEmpty(right) ? Rights.PossessProperty : right;
 41        }
 42
 43        private static void WriteSidAttribute(SecurityIdentifier sid, SctClaimDictionary dictionary, XmlDictionaryWriter
 44        {
 045            byte[] sidBytes = new byte[sid.BinaryLength];
 046            sid.GetBinaryForm(sidBytes, 0);
 047            writer.WriteAttributeString(dictionary.Sid, dictionary.EmptyString, Convert.ToBase64String(sidBytes));
 048        }
 49
 50        private static SecurityIdentifier ReadSidAttribute(XmlDictionaryReader reader, SctClaimDictionary dictionary)
 51        {
 052            byte[] sidBytes = Convert.FromBase64String(reader.GetAttribute(dictionary.Sid, dictionary.EmptyString));
 053            return new SecurityIdentifier(sidBytes, 0);
 54        }
 55
 56        public static void SerializeClaim(Claim claim, SctClaimDictionary dictionary, XmlDictionaryWriter writer, XmlObj
 57        {
 58            // the order in which known claim types are checked is optimized for use patterns
 059            if (claim == null)
 60            {
 061                writer.WriteElementString(dictionary.NullValue, dictionary.EmptyString, string.Empty);
 062                return;
 63            }
 064            else if (ClaimTypes.Sid.Equals(claim.ClaimType))
 65            {
 066                writer.WriteStartElement(dictionary.WindowsSidClaim, dictionary.EmptyString);
 067                WriteRightAttribute(claim, dictionary, writer);
 068                SerializeSid((SecurityIdentifier)claim.Resource, dictionary, writer);
 069                writer.WriteEndElement();
 070                return;
 71            }
 072            else if (ClaimTypes.DenyOnlySid.Equals(claim.ClaimType))
 73            {
 074                writer.WriteStartElement(dictionary.DenyOnlySidClaim, dictionary.EmptyString);
 075                WriteRightAttribute(claim, dictionary, writer);
 076                SerializeSid((SecurityIdentifier)claim.Resource, dictionary, writer);
 077                writer.WriteEndElement();
 078                return;
 79            }
 080            else if (ClaimTypes.X500DistinguishedName.Equals(claim.ClaimType))
 81            {
 082                writer.WriteStartElement(dictionary.X500DistinguishedNameClaim, dictionary.EmptyString);
 083                WriteRightAttribute(claim, dictionary, writer);
 084                byte[] rawData = ((X500DistinguishedName)claim.Resource).RawData;
 085                writer.WriteBase64(rawData, 0, rawData.Length);
 086                writer.WriteEndElement();
 087                return;
 88            }
 089            else if (ClaimTypes.Thumbprint.Equals(claim.ClaimType))
 90            {
 091                writer.WriteStartElement(dictionary.X509ThumbprintClaim, dictionary.EmptyString);
 092                WriteRightAttribute(claim, dictionary, writer);
 093                byte[] thumbprint = (byte[])claim.Resource;
 094                writer.WriteBase64(thumbprint, 0, thumbprint.Length);
 095                writer.WriteEndElement();
 096                return;
 97            }
 098            else if (ClaimTypes.Name.Equals(claim.ClaimType))
 99            {
 0100                writer.WriteStartElement(dictionary.NameClaim, dictionary.EmptyString);
 0101                WriteRightAttribute(claim, dictionary, writer);
 0102                writer.WriteString((string)claim.Resource);
 0103                writer.WriteEndElement();
 0104                return;
 105            }
 0106            else if (ClaimTypes.Dns.Equals(claim.ClaimType))
 107            {
 0108                writer.WriteStartElement(dictionary.DnsClaim, dictionary.EmptyString);
 0109                WriteRightAttribute(claim, dictionary, writer);
 0110                writer.WriteString((string)claim.Resource);
 0111                writer.WriteEndElement();
 0112                return;
 113            }
 0114            else if (ClaimTypes.Rsa.Equals(claim.ClaimType))
 115            {
 0116                writer.WriteStartElement(dictionary.RsaClaim, dictionary.EmptyString);
 0117                WriteRightAttribute(claim, dictionary, writer);
 0118                writer.WriteString(((RSA)claim.Resource).ToXmlString(false));
 0119                writer.WriteEndElement();
 0120                return;
 121            }
 0122            else if (ClaimTypes.Email.Equals(claim.ClaimType))
 123            {
 0124                writer.WriteStartElement(dictionary.MailAddressClaim, dictionary.EmptyString);
 0125                WriteRightAttribute(claim, dictionary, writer);
 0126                writer.WriteString(((MailAddress)claim.Resource).Address);
 0127                writer.WriteEndElement();
 0128                return;
 129            }
 0130            else if (claim == Claim.System)
 131            {
 0132                writer.WriteElementString(dictionary.SystemClaim, dictionary.EmptyString, string.Empty);
 0133                return;
 134            }
 0135            else if (ClaimTypes.Hash.Equals(claim.ClaimType))
 136            {
 0137                writer.WriteStartElement(dictionary.HashClaim, dictionary.EmptyString);
 0138                WriteRightAttribute(claim, dictionary, writer);
 0139                byte[] hash = (byte[])claim.Resource;
 0140                writer.WriteBase64(hash, 0, hash.Length);
 0141                writer.WriteEndElement();
 0142                return;
 143            }
 0144            else if (ClaimTypes.Spn.Equals(claim.ClaimType))
 145            {
 0146                writer.WriteStartElement(dictionary.SpnClaim, dictionary.EmptyString);
 0147                WriteRightAttribute(claim, dictionary, writer);
 0148                writer.WriteString((string)claim.Resource);
 0149                writer.WriteEndElement();
 0150                return;
 151            }
 0152            else if (ClaimTypes.Upn.Equals(claim.ClaimType))
 153            {
 0154                writer.WriteStartElement(dictionary.UpnClaim, dictionary.EmptyString);
 0155                WriteRightAttribute(claim, dictionary, writer);
 0156                writer.WriteString((string)claim.Resource);
 0157                writer.WriteEndElement();
 0158                return;
 159            }
 0160            else if (ClaimTypes.Uri.Equals(claim.ClaimType))
 161            {
 0162                writer.WriteStartElement(dictionary.UrlClaim, dictionary.EmptyString);
 0163                WriteRightAttribute(claim, dictionary, writer);
 0164                writer.WriteString(((Uri)claim.Resource).AbsoluteUri);
 0165                writer.WriteEndElement();
 0166                return;
 167            }
 168            else
 169            {
 170                // this is an extensible claim... need to delegate to xml object serializer
 0171                serializer.WriteObject(writer, claim);
 172            }
 0173        }
 174
 175        public static void SerializeClaimSet(ClaimSet claimSet, SctClaimDictionary dictionary, XmlDictionaryWriter write
 176        {
 0177            if (claimSet is X509CertificateClaimSet)
 178            {
 0179                X509CertificateClaimSet x509ClaimSet = (X509CertificateClaimSet)claimSet;
 0180                writer.WriteStartElement(dictionary.X509CertificateClaimSet, dictionary.EmptyString);
 0181                byte[] rawData = x509ClaimSet.X509Certificate.RawData;
 0182                writer.WriteBase64(rawData, 0, rawData.Length);
 0183                writer.WriteEndElement();
 184            }
 0185            else if (claimSet == ClaimSet.System)
 186            {
 0187                writer.WriteElementString(dictionary.SystemClaimSet, dictionary.EmptyString, string.Empty);
 188            }
 0189            else if (claimSet == ClaimSet.Windows)
 190            {
 0191                writer.WriteElementString(dictionary.WindowsClaimSet, dictionary.EmptyString, string.Empty);
 192            }
 0193            else if (claimSet == ClaimSet.Anonymous)
 194            {
 0195                writer.WriteElementString(dictionary.AnonymousClaimSet, dictionary.EmptyString, string.Empty);
 196            }
 0197            else if (claimSet is WindowsClaimSet || claimSet is DefaultClaimSet)
 198            {
 0199                writer.WriteStartElement(dictionary.ClaimSet, dictionary.EmptyString);
 0200                writer.WriteStartElement(dictionary.PrimaryIssuer, dictionary.EmptyString);
 0201                if (claimSet.Issuer == claimSet)
 202                {
 0203                    writer.WriteElementString(dictionary.NullValue, dictionary.EmptyString, string.Empty);
 204                }
 205                else
 206                {
 0207                    SerializeClaimSet(claimSet.Issuer, dictionary, writer, serializer, claimSerializer);
 208                }
 0209                writer.WriteEndElement();
 210
 0211                foreach (Claim claim in claimSet)
 212                {
 0213                    writer.WriteStartElement(dictionary.Claim, dictionary.EmptyString);
 0214                    SerializeClaim(claim, dictionary, writer, claimSerializer);
 0215                    writer.WriteEndElement();
 216                }
 0217                writer.WriteEndElement();
 218            }
 219            else
 220            {
 0221                serializer.WriteObject(writer, claimSet);
 222            }
 0223        }
 224
 225        public static Claim DeserializeClaim(XmlDictionaryReader reader, SctClaimDictionary dictionary, XmlObjectSeriali
 226        {
 0227            if (reader.IsStartElement(dictionary.NullValue, dictionary.EmptyString))
 228            {
 0229                reader.ReadElementString();
 0230                return null;
 231            }
 0232            else if (reader.IsStartElement(dictionary.WindowsSidClaim, dictionary.EmptyString))
 233            {
 0234                string right = ReadRightAttribute(reader, dictionary);
 0235                reader.ReadStartElement();
 0236                byte[] sidBytes = reader.ReadContentAsBase64();
 0237                reader.ReadEndElement();
 0238                return new Claim(ClaimTypes.Sid, new SecurityIdentifier(sidBytes, 0), right);
 239            }
 0240            else if (reader.IsStartElement(dictionary.DenyOnlySidClaim, dictionary.EmptyString))
 241            {
 0242                string right = ReadRightAttribute(reader, dictionary);
 0243                reader.ReadStartElement();
 0244                byte[] sidBytes = reader.ReadContentAsBase64();
 0245                reader.ReadEndElement();
 0246                return new Claim(ClaimTypes.DenyOnlySid, new SecurityIdentifier(sidBytes, 0), right);
 247            }
 0248            else if (reader.IsStartElement(dictionary.X500DistinguishedNameClaim, dictionary.EmptyString))
 249            {
 0250                string right = ReadRightAttribute(reader, dictionary);
 0251                reader.ReadStartElement();
 0252                byte[] rawData = reader.ReadContentAsBase64();
 0253                reader.ReadEndElement();
 0254                return new Claim(ClaimTypes.X500DistinguishedName, new X500DistinguishedName(rawData), right);
 255            }
 0256            else if (reader.IsStartElement(dictionary.X509ThumbprintClaim, dictionary.EmptyString))
 257            {
 0258                string right = ReadRightAttribute(reader, dictionary);
 0259                reader.ReadStartElement();
 0260                byte[] thumbprint = reader.ReadContentAsBase64();
 0261                reader.ReadEndElement();
 0262                return new Claim(ClaimTypes.Thumbprint, thumbprint, right);
 263            }
 0264            else if (reader.IsStartElement(dictionary.NameClaim, dictionary.EmptyString))
 265            {
 0266                string right = ReadRightAttribute(reader, dictionary);
 0267                reader.ReadStartElement();
 0268                string name = reader.ReadString();
 0269                reader.ReadEndElement();
 0270                return new Claim(ClaimTypes.Name, name, right);
 271            }
 0272            else if (reader.IsStartElement(dictionary.DnsClaim, dictionary.EmptyString))
 273            {
 0274                string right = ReadRightAttribute(reader, dictionary);
 0275                reader.ReadStartElement();
 0276                string dns = reader.ReadString();
 0277                reader.ReadEndElement();
 0278                return new Claim(ClaimTypes.Dns, dns, right);
 279            }
 0280            else if (reader.IsStartElement(dictionary.RsaClaim, dictionary.EmptyString))
 281            {
 0282                string right = ReadRightAttribute(reader, dictionary);
 0283                reader.ReadStartElement();
 0284                string rsaXml = reader.ReadString();
 0285                reader.ReadEndElement();
 286
 0287                RSA rsa = RSA.Create();
 0288                rsa.FromXmlString(rsaXml);
 0289                return new Claim(ClaimTypes.Rsa, rsa, right);
 290            }
 0291            else if (reader.IsStartElement(dictionary.MailAddressClaim, dictionary.EmptyString))
 292            {
 0293                string right = ReadRightAttribute(reader, dictionary);
 0294                reader.ReadStartElement();
 0295                string address = reader.ReadString();
 0296                reader.ReadEndElement();
 0297                return new Claim(ClaimTypes.Email, new System.Net.Mail.MailAddress(address), right);
 298            }
 0299            else if (reader.IsStartElement(dictionary.SystemClaim, dictionary.EmptyString))
 300            {
 0301                reader.ReadElementString();
 0302                return Claim.System;
 303            }
 0304            else if (reader.IsStartElement(dictionary.HashClaim, dictionary.EmptyString))
 305            {
 0306                string right = ReadRightAttribute(reader, dictionary);
 0307                reader.ReadStartElement();
 0308                byte[] hash = reader.ReadContentAsBase64();
 0309                reader.ReadEndElement();
 0310                return new Claim(ClaimTypes.Hash, hash, right);
 311            }
 0312            else if (reader.IsStartElement(dictionary.SpnClaim, dictionary.EmptyString))
 313            {
 0314                string right = ReadRightAttribute(reader, dictionary);
 0315                reader.ReadStartElement();
 0316                string spn = reader.ReadString();
 0317                reader.ReadEndElement();
 0318                return new Claim(ClaimTypes.Spn, spn, right);
 319            }
 0320            else if (reader.IsStartElement(dictionary.UpnClaim, dictionary.EmptyString))
 321            {
 0322                string right = ReadRightAttribute(reader, dictionary);
 0323                reader.ReadStartElement();
 0324                string upn = reader.ReadString();
 0325                reader.ReadEndElement();
 0326                return new Claim(ClaimTypes.Upn, upn, right);
 327            }
 0328            else if (reader.IsStartElement(dictionary.UrlClaim, dictionary.EmptyString))
 329            {
 0330                string right = ReadRightAttribute(reader, dictionary);
 0331                reader.ReadStartElement();
 0332                string url = reader.ReadString();
 0333                reader.ReadEndElement();
 0334                return new Claim(ClaimTypes.Uri, new Uri(url), right);
 335            }
 336            else
 337            {
 0338                return (Claim)serializer.ReadObject(reader);
 339            }
 340        }
 341
 342        public static ClaimSet DeserializeClaimSet(XmlDictionaryReader reader, SctClaimDictionary dictionary, XmlObjectS
 343        {
 0344            if (reader.IsStartElement(dictionary.NullValue, dictionary.EmptyString))
 345            {
 0346                reader.ReadElementString();
 0347                return null;
 348            }
 0349            else if (reader.IsStartElement(dictionary.X509CertificateClaimSet, dictionary.EmptyString))
 350            {
 0351                reader.ReadStartElement();
 0352                byte[] rawData = reader.ReadContentAsBase64();
 0353                reader.ReadEndElement();
 0354                return new X509CertificateClaimSet(new X509Certificate2(rawData), false);
 355            }
 0356            else if (reader.IsStartElement(dictionary.SystemClaimSet, dictionary.EmptyString))
 357            {
 0358                reader.ReadElementString();
 0359                return ClaimSet.System;
 360            }
 0361            else if (reader.IsStartElement(dictionary.WindowsClaimSet, dictionary.EmptyString))
 362            {
 0363                reader.ReadElementString();
 0364                return ClaimSet.Windows;
 365            }
 0366            else if (reader.IsStartElement(dictionary.AnonymousClaimSet, dictionary.EmptyString))
 367            {
 0368                reader.ReadElementString();
 0369                return ClaimSet.Anonymous;
 370            }
 0371            else if (reader.IsStartElement(dictionary.ClaimSet, dictionary.EmptyString))
 372            {
 0373                ClaimSet issuer = null;
 0374                List<Claim> claims = new List<Claim>();
 0375                reader.ReadStartElement();
 376
 0377                if (reader.IsStartElement(dictionary.PrimaryIssuer, dictionary.EmptyString))
 378                {
 0379                    reader.ReadStartElement();
 0380                    issuer = DeserializeClaimSet(reader, dictionary, serializer, claimSerializer);
 0381                    reader.ReadEndElement();
 382                }
 383
 0384                while (reader.IsStartElement())
 385                {
 0386                    reader.ReadStartElement();
 0387                    claims.Add(DeserializeClaim(reader, dictionary, claimSerializer));
 0388                    reader.ReadEndElement();
 389                }
 390
 0391                reader.ReadEndElement();
 0392                return issuer != null ? new DefaultClaimSet(issuer, claims) : new DefaultClaimSet(claims);
 393            }
 394            else
 395            {
 0396                return (ClaimSet)serializer.ReadObject(reader);
 397            }
 398        }
 399
 400        public static void SerializeIdentities(AuthorizationContext authContext, SctClaimDictionary dictionary, XmlDicti
 401        {
 402            IList<IIdentity> identities;
 0403            if (authContext.Properties.TryGetValue(SecurityUtils.Identities, out object obj))
 404            {
 0405                identities = obj as IList<IIdentity>;
 0406                if (identities != null && identities.Count > 0)
 407                {
 0408                    writer.WriteStartElement(dictionary.Identities, dictionary.EmptyString);
 0409                    for (int i = 0; i < identities.Count; ++i)
 410                    {
 0411                        SerializePrimaryIdentity(identities[i], dictionary, writer, serializer);
 412                    }
 0413                    writer.WriteEndElement();
 414                }
 415            }
 0416        }
 417
 418        private static void SerializePrimaryIdentity(IIdentity identity, SctClaimDictionary dictionary, XmlDictionaryWri
 419        {
 0420            if (identity != null && identity != SecurityUtils.AnonymousIdentity)
 421            {
 0422                writer.WriteStartElement(dictionary.PrimaryIdentity, dictionary.EmptyString);
 0423                if (identity is WindowsIdentity)
 424                {
 0425                    WindowsIdentity wid = (WindowsIdentity)identity;
 0426                    writer.WriteStartElement(dictionary.WindowsSidIdentity, dictionary.EmptyString);
 0427                    WriteSidAttribute(wid.User, dictionary, writer);
 428
 429                    // This is to work around WOW64 bug Windows OS 1491447
 0430                    string authenticationType = null;
 0431                    using (WindowsIdentity self = WindowsIdentity.GetCurrent())
 432                    {
 433                        // is owner or admin?  AuthenticationType could throw un-authorized exception
 0434                        if ((self.User == wid.Owner) ||
 0435                            (wid.Owner != null && self.Groups.Contains(wid.Owner)) ||
 0436                            (wid.Owner != SecurityUtils.AdministratorsSid && self.Groups.Contains(SecurityUtils.Administ
 437                        {
 0438                            authenticationType = wid.AuthenticationType;
 439                        }
 0440                    }
 0441                    if (!string.IsNullOrEmpty(authenticationType))
 442                    {
 0443                        writer.WriteAttributeString(dictionary.AuthenticationType, dictionary.EmptyString, authenticatio
 444                    }
 445
 0446                    writer.WriteString(wid.Name);
 0447                    writer.WriteEndElement();
 448                }
 0449                else if (identity is WindowsSidIdentity)
 450                {
 0451                    WindowsSidIdentity wsid = (WindowsSidIdentity)identity;
 0452                    writer.WriteStartElement(dictionary.WindowsSidIdentity, dictionary.EmptyString);
 0453                    WriteSidAttribute(wsid.SecurityIdentifier, dictionary, writer);
 0454                    if (!string.IsNullOrEmpty(wsid.AuthenticationType))
 455                    {
 0456                        writer.WriteAttributeString(dictionary.AuthenticationType, dictionary.EmptyString, wsid.Authenti
 457                    }
 458
 0459                    writer.WriteString(wsid.Name);
 0460                    writer.WriteEndElement();
 461                }
 0462                else if (identity is GenericIdentity)
 463                {
 0464                    GenericIdentity genericIdentity = (GenericIdentity)identity;
 0465                    writer.WriteStartElement(dictionary.GenericIdentity, dictionary.EmptyString);
 0466                    if (!string.IsNullOrEmpty(genericIdentity.AuthenticationType))
 467                    {
 0468                        writer.WriteAttributeString(dictionary.AuthenticationType, dictionary.EmptyString, genericIdenti
 469                    }
 470
 0471                    writer.WriteString(genericIdentity.Name);
 0472                    writer.WriteEndElement();
 473                }
 474                else
 475                {
 0476                    serializer.WriteObject(writer, identity);
 477                }
 0478                writer.WriteEndElement();
 479            }
 0480        }
 481
 482        public static IList<IIdentity> DeserializeIdentities(XmlDictionaryReader reader, SctClaimDictionary dictionary, 
 483        {
 0484            List<IIdentity> identities = null;
 0485            if (reader.IsStartElement(dictionary.Identities, dictionary.EmptyString))
 486            {
 0487                identities = new List<IIdentity>();
 0488                reader.ReadStartElement();
 0489                while (reader.IsStartElement(dictionary.PrimaryIdentity, dictionary.EmptyString))
 490                {
 0491                    IIdentity identity = DeserializePrimaryIdentity(reader, dictionary, serializer);
 0492                    if (identity != null && identity != SecurityUtils.AnonymousIdentity)
 493                    {
 0494                        identities.Add(identity);
 495                    }
 496                }
 0497                reader.ReadEndElement();
 498            }
 0499            return identities;
 500        }
 501
 502        private static IIdentity DeserializePrimaryIdentity(XmlDictionaryReader reader, SctClaimDictionary dictionary, X
 503        {
 0504            IIdentity identity = null;
 0505            if (reader.IsStartElement(dictionary.PrimaryIdentity, dictionary.EmptyString))
 506            {
 0507                reader.ReadStartElement();
 0508                if (reader.IsStartElement(dictionary.WindowsSidIdentity, dictionary.EmptyString))
 509                {
 0510                    SecurityIdentifier sid = ReadSidAttribute(reader, dictionary);
 0511                    string authenticationType = reader.GetAttribute(dictionary.AuthenticationType, dictionary.EmptyStrin
 0512                    reader.ReadStartElement();
 0513                    string name = reader.ReadContentAsString();
 0514                    identity = new WindowsSidIdentity(sid, name, authenticationType ?? string.Empty);
 0515                    reader.ReadEndElement();
 516                }
 0517                else if (reader.IsStartElement(dictionary.GenericIdentity, dictionary.EmptyString))
 518                {
 0519                    string authenticationType = reader.GetAttribute(dictionary.AuthenticationType, dictionary.EmptyStrin
 0520                    reader.ReadStartElement();
 0521                    string name = reader.ReadContentAsString();
 0522                    identity = SecurityUtils.CreateIdentity(name, authenticationType ?? string.Empty);
 0523                    reader.ReadEndElement();
 524                }
 525                else
 526                {
 0527                    identity = (IIdentity)serializer.ReadObject(reader);
 528                }
 0529                reader.ReadEndElement();
 530            }
 0531            return identity;
 532        }
 533    }
 534}

Methods/Properties

SerializeSid(System.Security.Principal.SecurityIdentifier,CoreWCF.Security.SctClaimDictionary,System.Xml.XmlDictionaryWriter)
WriteRightAttribute(CoreWCF.IdentityModel.Claims.Claim,CoreWCF.Security.SctClaimDictionary,System.Xml.XmlDictionaryWriter)
ReadRightAttribute(System.Xml.XmlDictionaryReader,CoreWCF.Security.SctClaimDictionary)
WriteSidAttribute(System.Security.Principal.SecurityIdentifier,CoreWCF.Security.SctClaimDictionary,System.Xml.XmlDictionaryWriter)
ReadSidAttribute(System.Xml.XmlDictionaryReader,CoreWCF.Security.SctClaimDictionary)
SerializeClaim(CoreWCF.IdentityModel.Claims.Claim,CoreWCF.Security.SctClaimDictionary,System.Xml.XmlDictionaryWriter,System.Runtime.Serialization.XmlObjectSerializer)
SerializeClaimSet(CoreWCF.IdentityModel.Claims.ClaimSet,CoreWCF.Security.SctClaimDictionary,System.Xml.XmlDictionaryWriter,System.Runtime.Serialization.XmlObjectSerializer,System.Runtime.Serialization.XmlObjectSerializer)
DeserializeClaim(System.Xml.XmlDictionaryReader,CoreWCF.Security.SctClaimDictionary,System.Runtime.Serialization.XmlObjectSerializer)
DeserializeClaimSet(System.Xml.XmlDictionaryReader,CoreWCF.Security.SctClaimDictionary,System.Runtime.Serialization.XmlObjectSerializer,System.Runtime.Serialization.XmlObjectSerializer)
SerializeIdentities(CoreWCF.IdentityModel.Policy.AuthorizationContext,CoreWCF.Security.SctClaimDictionary,System.Xml.XmlDictionaryWriter,System.Runtime.Serialization.XmlObjectSerializer)
SerializePrimaryIdentity(System.Security.Principal.IIdentity,CoreWCF.Security.SctClaimDictionary,System.Xml.XmlDictionaryWriter,System.Runtime.Serialization.XmlObjectSerializer)
DeserializeIdentities(System.Xml.XmlDictionaryReader,CoreWCF.Security.SctClaimDictionary,System.Runtime.Serialization.XmlObjectSerializer)
DeserializePrimaryIdentity(System.Xml.XmlDictionaryReader,CoreWCF.Security.SctClaimDictionary,System.Runtime.Serialization.XmlObjectSerializer)