How to get SecurityToken
from ClaimsPrincipal
?
I need it because I wanna pass it from an MVC application to a WCF service in AuthenticationManager / Authenticate.
In Authenticate method, the value BootstrapContext is null. And even after authenticating, it is getting null sometimes which make it a not reliable choice for me.
This is my Authentication Manager class:
public override ClaimsPrincipal Authenticate(string resourceName, ClaimsPrincipal incomingPrincipal)
{
string passportID = incomingPrincipal.Identity.GetPassportID().ToString();
try
{
// I need the token here
SecurityToken token = GetToken(incomingPrincipal);
return base.Authenticate(resourceName, incomingPrincipal);
}
catch (Exception ex)
{
throw new SecurityException("User is not authenticated.", ex);
}
}