File tree Expand file tree Collapse file tree 1 file changed +35
-3
lines changed
Expand file tree Collapse file tree 1 file changed +35
-3
lines changed Original file line number Diff line number Diff line change 1414// limitations under the License.
1515#endregion
1616
17+ using System ;
18+ using System . Net ;
19+
1720#if FRAMEWORK
1821
1922namespace RestSharp
2023{
2124 /// <summary>
22- /// Tries to Authenticate with the credentials of the currently logged in user
25+ /// Tries to Authenticate with the credentials of the currently logged in user, or impersonate a user
2326 /// </summary>
2427 public class NtlmAuthenticator : IAuthenticator
2528 {
26- public void Authenticate ( IRestClient client , IRestRequest request )
29+ private readonly ICredentials credentials ;
30+
31+ /// <summary>
32+ /// Authenticate with the credentials of the currently logged in user
33+ /// </summary>
34+ public NtlmAuthenticator ( )
35+ : this ( CredentialCache . DefaultCredentials )
36+ {
37+ }
38+
39+ /// <summary>
40+ /// Authenticate by impersonation
41+ /// </summary>
42+ /// <param name="username"></param>
43+ /// <param name="password"></param>
44+ public NtlmAuthenticator ( string username , string password ) : this ( new NetworkCredential ( username , password ) )
45+ {
46+ }
47+
48+ /// <summary>
49+ /// Authenticate by impersonation, using an existing <c>ICredentials</c> instance
50+ /// </summary>
51+ /// <param name="credentials"></param>
52+ public NtlmAuthenticator ( ICredentials credentials )
53+ {
54+ if ( credentials == null ) throw new ArgumentNullException ( "credentials" ) ;
55+ this . credentials = credentials ;
56+ }
57+
58+ public void Authenticate ( IRestClient client , IRestRequest request )
2759 {
28- request . Credentials = System . Net . CredentialCache . DefaultCredentials ;
60+ request . Credentials = credentials ;
2961 }
3062 }
3163}
You can’t perform that action at this time.
0 commit comments