2013-10-29 127 views
2

我正在完成從WCF移植到SS的應用程序,我有一個關於authenticationservice的問題......我已經實現了我自己的Provider,它從CredentialsAuthProvider中調用hinert並調用hxxp:// url/API /權威性?用戶名= ABC &通= 123它的工作原理... 我想知道(也許我錯了),爲什麼沒有AuthenticateRequest /響應DTOSilverlight的Servicestack身份驗證服務

我問這個,因爲我使用提供的實現here

對於我創建的驗證請求爲

public class AuthRequest 
{ 
    public string UserName { get; set; } 
    public string Password { get; set; } 
} 

和它傳遞給/ AUTH服務,但是當我處理響應(布爾)我得到的響應回調

private void ResponseCallback(IAsyncResult asyncResult) 
    { 
     try 
     { 
      // Get the web response 
      var webRequest = (HttpWebRequest)asyncResult.AsyncState; 
      var webResponse = webRequest.EndGetResponse(asyncResult); 

      // Get the web response stream 
      var stream = webResponse.GetResponseStream(); 

      // Deserialize the json data in the response stream 
      var serializer = new DataContractJsonSerializer(typeof(TResponse)); 


      // bool res = (bool)serializer.ReadObject(stream); //bool cannot be converted since it's not IConvertible 

      var response = (TResponse)serializer.ReadObject(stream); 
    ...} 

任何建議例外嗎?我應該定義自己的AuthFeature嗎? 謝謝

回答

2

您是否在尋找AuthResponse

namespace ServiceStack.ServiceInterface.Auth 
{ 
    [DataContract] 
    public class AuthResponse 
    { 
     public AuthResponse(); 

     [DataMember(Order = 3)] 
     public string ReferrerUrl { get; set; } 
     [DataMember(Order = 4)] 
     public ResponseStatus ResponseStatus { get; set; } 
     [DataMember(Order = 1)] 
     public string SessionId { get; set; } 
     [DataMember(Order = 2)] 
     public string UserName { get; set; } 
    } 
} 

Auth

[DataContract] 
public class Auth : IReturn<AuthResponse> 
{ 
    [DataMember(Order = 1)] 
    public string provider { get; set; } 
    [DataMember(Order = 2)] 
    public string State { get; set; } 
    [DataMember(Order = 3)] 
    public string oauth_token { get; set; } 
    [DataMember(Order = 4)] 
    public string oauth_verifier { get; set; } 
    [DataMember(Order = 5)] 
    public string UserName { get; set; } 
    [DataMember(Order = 6)] 
    public string Password { get; set; } 
    [DataMember(Order = 7)] 
    public bool? RememberMe { get; set; } 
    [DataMember(Order = 8)] 
    public string Continue { get; set; } 
    // Thise are used for digest auth 
    [DataMember(Order = 9)] 
    public string nonce { get; set; } 
    [DataMember(Order = 10)] 
    public string uri { get; set; } 
    [DataMember(Order = 11)] 
    public string response { get; set; } 
    [DataMember(Order = 12)] 
    public string qop { get; set; } 
    [DataMember(Order = 13)] 
    public string nc { get; set; } 
    [DataMember(Order = 14)] 
    public string cnonce { get; set; } 
} 
+0

您好,感謝您的回覆...我就可以了!謝謝 – advapi