In order to prepare my application to use ADFS I have to work with federation now we have a solution with a server with federated services using WIF for security, whe have a client consuming this services and we have and STS wich taken a usename password for identifying the user.
Everything work fine, all my claims are generated correctly and I can use them in my applcation.
Now we must use ADFS in addition of our Internal IdentityProvider, I'd just take my sts and divide it between two parts, a "federation provider" called by client and trusted by server and a part in charge of authentication For this I just add following code in my CustomSecurityTokenHandler in FederationProvider
UserNameSecurityToken userNameTokenFromRP = token as UserNameSecurityToken;
WSTrustChannelFactory stsClient = new WSTrustChannelFactory("IdentityConfiguration");
stsClient.Credentials.UserName.UserName = userNameTokenFromRP.UserName;
stsClient.Credentials.UserName.Password = userNameTokenFromRP.Password;
IWSTrustChannelContract stsProxy = stsClient.CreateChannel();
RequestSecurityToken rst = new RequestSecurityToken(WSTrust13Constants.RequestTypes.Issue, WSTrust13Constants.KeyTypes.Symmetric);
rst.AppliesTo = new System.ServiceModel.EndpointAddress("http://localhost:8010/FederationProvider.svc");
rst.Claims.Add(new RequestClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", false));
rst.Issuer = new System.ServiceModel.EndpointAddress("http://localhost:8020/IdentityProvider.svc");
rst.Lifetime = new Lifetime(DateTime.Now, DateTime.Now + new TimeSpan(0, 30, 0));
rst.TokenType = Microsoft.IdentityModel.Tokens.SecurityTokenTypes.OasisWssSaml11TokenProfile11;
RequestSecurityTokenResponse rstr;
var stsToken = stsProxy.Issue(rst, out rstr);
and this in my Web.config file:
<client>
<endpoint name="IdentityConfiguration" address="http://localhost:8020/IdentityProvider.svc"
binding="ws2007HttpBinding" bindingConfiguration="SecurityTokenBinding"
contract="Microsoft.IdentityModel.Protocols.WSTrust.IWSTrustChannelContract">
<identity>
<certificate encodedValue="MyEncodedValue" />
</identity>
</endpoint>
</client>
On identity side I continue generate my claims the same way I did before The problem I have is in my RSTR the token is null and tokenXML is encrypted, I don't understand how to use federation in this case?
If someone can help me?
thanks for reading me
Ange