private void Initialize(UserIdentityToken token)
{
if (token == null) throw new ArgumentNullException("token");
m_policyId = token.PolicyId;
UserNameIdentityToken usernameToken = token as UserNameIdentityToken;
if (usernameToken != null)
{
Initialize(new UserNameSecurityToken(usernameToken.UserName, usernameToken.DecryptedPassword));
return;
}
X509IdentityToken x509Token = token as X509IdentityToken;
if (x509Token != null)
{
X509Certificate2 certificate = CertificateFactory.Create(x509Token.CertificateData, true);
Initialize(new X509SecurityToken(certificate));
return;
}
IssuedIdentityToken wssToken = token as IssuedIdentityToken;
if (wssToken != null)
{
Initialize(wssToken, WSSecurityTokenSerializer.DefaultInstance, null);
return;
}
AnonymousIdentityToken anonymousToken = token as AnonymousIdentityToken;
if (anonymousToken != null)
{
m_tokenType = UserTokenType.Anonymous;
m_issuedTokenType = null;
m_displayName = "Anonymous";
m_token = null;
return;
}
throw new ArgumentException("Unrecognized UA user identity token type.", "token");
}