1: public class SenderVouchesSaml11TokenHandler: Saml11SecurityTokenHandler
2: { 3:
4: public override bool CanValidateToken
5: { 6: get
7: { 8: return true;
9: }
10: }
11:
12: public override string[] GetTokenTypeIdentifiers()
13: { 14: return new string[2]{Consts.cSAML11TokenType, Consts.cSAML11Assertion}; 15: }
16:
17:
18:
19: public override ClaimsIdentityCollection ValidateToken(SecurityToken token)
20: { 21: SamlSecurityToken samlToken = token as SamlSecurityToken;
22: IClaimsIdentity claimsIdentity = this.CreateClaims(samlToken);
23: return new ClaimsIdentityCollection
24: (new List<IClaimsIdentity> { claimsIdentity }); 25:
26: }
27:
28:
29: protected override System.IdentityModel.Tokens.SamlSubject
30: CreateSamlSubject(SecurityTokenDescriptor tokenDescriptor)
31: { 32: SamlSubject subject = new SamlSubject(Consts.cUnspecifiedNameIdentifier,
33: Consts.cNameQualifier, "Alice");
34: subject.ConfirmationMethods.Clear();
35: subject.ConfirmationMethods.Add("urn:oasis:names:tc:SAML:1.0:cm:sender-vouches"); 36:
37: return subject;
38: }
39:
40: protected override System.IdentityModel.Tokens.SamlAuthenticationStatement
41: CreateAuthenticationStatement(System.IdentityModel.Tokens.SamlSubject
42: samlSubject, IdentityModel.Claims.AuthenticationInformation authInfo,
43: IdentityModel.Tokens.SecurityTokenDescriptor tokenDescriptor)
44: { 45: SamlAuthenticationStatement authStatement = new SamlAuthenticationStatement();
46: authStatement.AuthenticationMethod =
47: Saml11Constants.AuthenticationMethods.UnspecifiedString;
48: authStatement.SamlSubject = samlSubject;
49: return authStatement;
50: }
51:
52: ....
53: }