2011-02-02 15 views
11

Wygląda na to, że większość informacji o WIF jest użytecznych dla umożliwienia federacyjnego uwierzytelniania dla całej aplikacji. Interesuje mnie używanie interfejsu API do tworzenia żądań uwierzytelnienia SAML oraz odbierania/interpretowania odpowiedzi SAML.Utwórz żądanie uwierzytelnienia SAML za pomocą WIF

Znalazłem następujący wpis na SO Reading SAML Attributes from SAML Token, który pozwala mi iść w dobrym kierunku w odniesieniu do odbierania i interpretowania odpowiedzi SAML. Czy ktoś może podać mi więcej informacji o tym, w jaki sposób mogę użyć interfejsu API do tworzenia żądań SAML?

Wszelkie dodatkowe informacje (materiały do ​​czytania, filmy itp.) Na temat API w ogóle byłyby mile widziane.

Odpowiedz

9

Oto mały przykład postać jednego z our samples, który pokazuje w jaki sposób programowo utworzyć prośbę o (SAML) Security Token to STS:

private static SecurityToken GetSamlToken(string realm, string stsEndpoint, ClientCredentials clientCredentials) 
    { 
     using (var factory = new WSTrustChannelFactory(
      new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential), 
      new EndpointAddress(new Uri(stsEndpoint)))) 
     { 
      factory.Credentials.UserName.UserName = clientCredentials.UserName.UserName; 
      factory.Credentials.UserName.Password = clientCredentials.UserName.Password; 
      factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; 
      factory.TrustVersion = TrustVersion.WSTrust13; 

      WSTrustChannel channel = null; 

      try 
      { 
       var rst = new RequestSecurityToken 
           { 
            RequestType = WSTrust13Constants.RequestTypes.Issue, 
            AppliesTo = new EndpointAddress(realm), 
            KeyType = KeyTypes.Bearer, 
           }; 

       channel = (WSTrustChannel)factory.CreateChannel(); 

       return channel.Issue(rst); 
      } 
      finally 
      { 
       if (channel != null) 
       { 
        channel.Abort(); 
       } 

       factory.Abort(); 
      } 
     } 
+0

To była ogromna pomoc. Dzięki, Eugenio. –

+4

Nie wierzę, że to w ogóle tworzy SAML 'AuthnRequest'. Wydaje się tworzyć WSTrust 'RequestSecurityToken'. – atoumey

Powiązane problemy