title: How to read claims from SamlSecurityToken
body: <p>I authenticate on ADFS from code and get a decrypted <code>SamlSecurityToken</code>:</p>
  
  <pre><code>var factory = new WSTrustChannelFactory(
      new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential),
      "https://my-adfs-domain.com/adfs/services/trust/13/UserNameMixed")
  {
      TrustVersion = System.ServiceModel.Security.TrustVersion.WSTrust13,
      Credentials =
      {
          UserName =
          {
              UserName = "username",
              Password = "password"
          }
      }
  };
  
  var token = (GenericXmlSecurityToken)factory.CreateChannel().Issue(
      new RequestSecurityToken
      {
          RequestType = RequestTypes.Issue,
          AppliesTo = new EndpointAddress("https://my-service-domain.com"),
          KeyType = KeyTypes.Symmetric,
          RequestDisplayToken = true
      });
  
  SamlSecurityToken decryptedToken;
  
  using (var stream = new MemoryStream())
  {
      using (var writer = XmlWriter.Create(stream))
          token.TokenXml.WriteTo(writer);
  
      stream.Seek(0, SeekOrigin.Begin);
  
      using (var reader = XmlReader.Create(stream))
          decryptedToken = (SamlSecurityToken)FederatedAuthentication
              .FederationConfiguration.IdentityConfiguration
              .SecurityTokenHandlers.ReadToken(reader);
  }
  
  var userEmail = decryptedToken.Assertion.Statements
      .OfType&lt;SamlAttributeStatement&gt;().Single()
      .Attributes[0].AttributeValues[0];
  </code></pre>
  
  <p>As a next step I'm going to read claims (e.g. user email) from the issued token. </p>
  
  <p>I can extract a part of the related information by code above.</p>
  
  <p>However, I'm looking for a more straightforward and secure way to extract full list of claims from an issued <code>SamlSecurityToken</code>.</p>