@@ -13,7 +13,7 @@ namespace GitHub.Api
1313 public class LoginManager : ILoginManager
1414 {
1515 readonly string [ ] scopes = { "user" , "repo" , "gist" , "write:public_key" } ;
16- readonly ILoginCache loginCache ;
16+ readonly IKeychain keychain ;
1717 readonly ITwoFactorChallengeHandler twoFactorChallengeHandler ;
1818 readonly string clientId ;
1919 readonly string clientSecret ;
@@ -23,26 +23,26 @@ public class LoginManager : ILoginManager
2323 /// <summary>
2424 /// Initializes a new instance of the <see cref="LoginManager"/> class.
2525 /// </summary>
26- /// <param name="loginCache ">The cache in which to store login details .</param>
26+ /// <param name="keychain ">The keychain in which to store credentials .</param>
2727 /// <param name="twoFactorChallengeHandler">The handler for 2FA challenges.</param>
2828 /// <param name="clientId">The application's client API ID.</param>
2929 /// <param name="clientSecret">The application's client API secret.</param>
3030 /// <param name="authorizationNote">An note to store with the authorization.</param>
3131 /// <param name="fingerprint">The machine fingerprint.</param>
3232 public LoginManager (
33- ILoginCache loginCache ,
33+ IKeychain keychain ,
3434 ITwoFactorChallengeHandler twoFactorChallengeHandler ,
3535 string clientId ,
3636 string clientSecret ,
3737 string authorizationNote = null ,
3838 string fingerprint = null )
3939 {
40- Guard . ArgumentNotNull ( loginCache , nameof ( loginCache ) ) ;
40+ Guard . ArgumentNotNull ( keychain , nameof ( keychain ) ) ;
4141 Guard . ArgumentNotNull ( twoFactorChallengeHandler , nameof ( twoFactorChallengeHandler ) ) ;
4242 Guard . ArgumentNotEmptyString ( clientId , nameof ( clientId ) ) ;
4343 Guard . ArgumentNotEmptyString ( clientSecret , nameof ( clientSecret ) ) ;
4444
45- this . loginCache = loginCache ;
45+ this . keychain = keychain ;
4646 this . twoFactorChallengeHandler = twoFactorChallengeHandler ;
4747 this . clientId = clientId ;
4848 this . clientSecret = clientSecret ;
@@ -64,7 +64,7 @@ public async Task<User> Login(
6464
6565 // Start by saving the username and password, these will be used by the `IGitHubClient`
6666 // until an authorization token has been created and acquired:
67- await loginCache . SaveLogin ( userName , password , hostAddress ) . ConfigureAwait ( false ) ;
67+ await keychain . Save ( userName , password , hostAddress ) . ConfigureAwait ( false ) ;
6868
6969 var newAuth = new NewAuthorization
7070 {
@@ -99,13 +99,13 @@ public async Task<User> Login(
9999 }
100100 else
101101 {
102- await loginCache . EraseLogin ( hostAddress ) . ConfigureAwait ( false ) ;
102+ await keychain . Delete ( hostAddress ) . ConfigureAwait ( false ) ;
103103 throw ;
104104 }
105105 }
106106 } while ( auth == null ) ;
107107
108- await loginCache . SaveLogin ( userName , auth . Token , hostAddress ) . ConfigureAwait ( false ) ;
108+ await keychain . Save ( userName , auth . Token , hostAddress ) . ConfigureAwait ( false ) ;
109109
110110 var retry = 0 ;
111111
@@ -141,7 +141,7 @@ public async Task Logout(HostAddress hostAddress, IGitHubClient client)
141141 Guard . ArgumentNotNull ( hostAddress , nameof ( hostAddress ) ) ;
142142 Guard . ArgumentNotNull ( client , nameof ( client ) ) ;
143143
144- await loginCache . EraseLogin ( hostAddress ) ;
144+ await keychain . Delete ( hostAddress ) ;
145145 }
146146
147147 async Task < ApplicationAuthorization > CreateAndDeleteExistingApplicationAuthorization (
@@ -219,7 +219,7 @@ async Task<ApplicationAuthorization> HandleTwoFactorAuthorization(
219219 catch ( Exception e )
220220 {
221221 await twoFactorChallengeHandler . ChallengeFailed ( e ) ;
222- await loginCache . EraseLogin ( hostAddress ) . ConfigureAwait ( false ) ;
222+ await keychain . Delete ( hostAddress ) . ConfigureAwait ( false ) ;
223223 throw ;
224224 }
225225 }
0 commit comments