title: Custom UserNameSecurityTokenHandler.ValidateToken is not getting called. How do I get the token handler registered and called?
body: <p>Based on the MSDN documentation I have created a custom UserNameSecurityTokenHandler and put in the CanValidateToken override and ValidateToken override.  I thought I had configured the WCF web service to use the custom handler but the ValdiateToken never gets called.  Here is the custom token handler:</p>
  
  <pre><code>public class CustomUserNameSecurityTokenHandler : UserNameSecurityTokenHandler 
  {
      public override bool CanValidateToken
      {
          get { return true; }
      }
  
      public override ReadOnlyCollection&lt;ClaimsIdentity&gt; ValidateToken(SecurityToken token)
      {
          System.Diagnostics.Debugger.Launch();
  
          if (token == null)
          {
              throw new ArgumentNullException();
          }
          var userNameToken = token as UserNameSecurityToken;
          if (userNameToken == null)
          {
              throw new SecurityTokenException("Invalid token");
          }
  
          if ( userNameToken.UserName != userNameToken.Password )
          {
              throw new SecurityTokenException("Invalid username or password.");
          }
          var claims = new List&lt;Claim&gt;
              {
                  new Claim(System.IdentityModel.Claims.ClaimTypes.Name, userNameToken.UserName),
                  new Claim(
                      "http://schemas.microsoft.com/ws/2008/06/identity/claims/ClaimTypes.AuthenticationInstant",
                      XmlConvert.ToString(DateTime.UtcNow, "yyyy-MM-ddTHH:mm:ss.fffZ"),
                      "http://www.w3.org/2001/XMLSchema#dateTime")
              };
  
          return new ReadOnlyCollection&lt;ClaimsIdentity&gt;(new List&lt;ClaimsIdentity&gt; {new ClaimsIdentity(claims, "Password")});
      }
  }
  </code></pre>
  
  <p>The debugger does not launch.  The client code always fails when I call it.
  Here is my WCF web.config entries for the site:</p>
  
  <pre><code> &lt;configSections&gt;
   &lt;section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt;
  &lt;/configSections&gt;
  &lt;appSettings&gt;
    &lt;add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /&gt;
  &lt;/appSettings&gt;
  &lt;system.web&gt;
    &lt;compilation debug="true" targetFramework="4.5" /&gt;
    &lt;httpRuntime targetFramework="4.5"/&gt;
  &lt;/system.web&gt;
  &lt;system.serviceModel&gt;
    &lt;services&gt;
      &lt;service name="WcfUserName.Service1"&gt;
        &lt;endpoint address="Service1.svc" binding="netHttpBinding"
          contract="WcfUserName.IService1" /&gt;
        &lt;host&gt;
          &lt;baseAddresses&gt;
            &lt;add baseAddress="https://localhost/WcfUserName" /&gt;
          &lt;/baseAddresses&gt;
        &lt;/host&gt;
      &lt;/service&gt;
    &lt;/services&gt;
    &lt;bindings&gt;
      &lt;netHttpBinding&gt;
        &lt;binding&gt;
          &lt;security mode="TransportWithMessageCredential"&gt;
            &lt;message clientCredentialType="UserName" /&gt;
          &lt;/security&gt;
        &lt;/binding&gt;
      &lt;/netHttpBinding&gt;
    &lt;/bindings&gt;
    &lt;behaviors&gt;
      &lt;serviceBehaviors&gt;
        &lt;behavior&gt;
          &lt;serviceCredentials useIdentityConfiguration="true" /&gt;
          &lt;serviceAuthorization principalPermissionMode="Always"/&gt;
          &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
        &lt;/behavior&gt;
       &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
   &lt;protocolMapping&gt;
        &lt;add binding="netHttpBinding" scheme="https" /&gt;
   &lt;/protocolMapping&gt;    
   &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /&gt;
   &lt;/system.serviceModel&gt;
   &lt;system.webServer&gt;
   &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
   &lt;directoryBrowse enabled="true"/&gt;
   &lt;/system.webServer&gt;
  &lt;system.identityModel&gt;
    &lt;identityConfiguration name="identconfig"&gt;
      &lt;securityTokenHandlers&gt;
        &lt;remove type="System.IdentityModel.Tokens.WindowsUserNameSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt;
        &lt;add type="WcfUserName.Security.CustomUserNameSecurityTokenHandler, WcfUserName"/&gt;
      &lt;/securityTokenHandlers&gt;
    &lt;/identityConfiguration&gt;
   &lt;/system.identityModel&gt;
  </code></pre>
  
  <p>I assume something is wrong with my configuration but cannot tell what it is.  Any ideas?</p>