@@ -66,7 +66,7 @@ public OpenIDConnectAuthorizer(OIDCLoginCallback callback, TokenStore tokenStore
6666 ////////////////////////////////////////////////////////////
6767 @ Override
6868 public String toString () {
69- return String .format (Locale .ENGLISH , "OpenIDConnectAuthorizer[%s]" , remoteURL );
69+ return String .format (Locale .ENGLISH , "OpenIDConnectAuthorizer[%s]" , getRemoteURL () );
7070 }
7171
7272 ////////////////////////////////////////////////////////////
@@ -120,7 +120,7 @@ public void loginResponse(Object jsonResponse,
120120 Throwable error ,
121121 ContinuationBlock block ) {
122122 if (error != null && (!(error instanceof RemoteRequestResponseException ) ||
123- ((RemoteRequestResponseException ) error ).getCode () != 401 )) {
123+ ((RemoteRequestResponseException ) error ).getCode () != 401 )) {
124124 block .call (false , error );
125125 return ;
126126 }
@@ -195,7 +195,7 @@ public boolean implementedLoginResponse() {
195195
196196 @ Override
197197 public boolean removeStoredCredentials () {
198- if (!deleteTokens ())
198+ if (!deleteTokens ())
199199 return false ;
200200 IDToken = null ;
201201 refreshToken = null ;
@@ -248,6 +248,8 @@ public void setRefreshToken(String refreshToken) {
248248 public static boolean forgetIDTokensForServer (URL serverURL , TokenStore tokenStore ) {
249249 OpenIDConnectAuthorizer authorizer = new OpenIDConnectAuthorizer (null , tokenStore );
250250 authorizer .setRemoteURL (serverURL );
251+ // Deliberately don't set auth.localUUID. This will leave kSecAttrAccount unset in the
252+ // dictionary passed to SecItemDelete, deleting keychain items for all accounts (databases).
251253 return authorizer .deleteTokens ();
252254 }
253255
@@ -260,7 +262,7 @@ public static boolean forgetIDTokensForServer(URL serverURL, TokenStore tokenSto
260262 return false ;
261263
262264 try {
263- return parseTokens (tokenStore .loadTokens (remoteURL ));
265+ return parseTokens (tokenStore .loadTokens (getRemoteURL (), getLocalUUID () ));
264266 } catch (Exception e ) {
265267 Log .w (TAG , "Error in loadTokens()" , e );
266268 return false ;
@@ -270,13 +272,13 @@ public static boolean forgetIDTokensForServer(URL serverURL, TokenStore tokenSto
270272 /*package*/ boolean saveTokens (Map <String , String > tokens ) {
271273 if (tokenStore == null )
272274 return false ;
273- return tokenStore .saveTokens (remoteURL , tokens );
275+ return tokenStore .saveTokens (getRemoteURL (), getLocalUUID () , tokens );
274276 }
275277
276278 /*package*/ boolean deleteTokens () {
277279 if (tokenStore == null )
278280 return false ;
279- return tokenStore .deleteTokens (remoteURL );
281+ return tokenStore .deleteTokens (getRemoteURL (), getLocalUUID () );
280282 }
281283
282284 private boolean parseTokens (Map <String , String > tokens ) {
@@ -301,7 +303,7 @@ private boolean parseTokens(Map<String, String> tokens) {
301303
302304 private void continueAsyncLoginWithURL (URL loginURL , final ContinuationBlock block ) {
303305 Log .v (TAG , "OpenIDConnectAuthorizer: Calling app login callback block..." );
304- final URL remoteURL = this .remoteURL ;
306+ final URL remoteURL = this .getRemoteURL () ;
305307 final URL redirectBaseURL = extractRedirectURL (loginURL );
306308 if (loginCallback != null )
307309 loginCallback .callback (loginURL , redirectBaseURL , new OIDCLoginContinuation () {
@@ -312,8 +314,8 @@ public void callback(URL url, Throwable error) {
312314 "<%s>" , url .toExternalForm ());
313315 // Verify that the authURL matches the site:
314316 if (remoteURL == null ||
315- url .getHost ().compareToIgnoreCase (remoteURL .getHost ()) != 0 ||
316- url .getPort () != remoteURL .getPort ()) {
317+ url .getHost ().compareToIgnoreCase (remoteURL .getHost ()) != 0 ||
318+ url .getPort () != remoteURL .getPort ()) {
317319 Log .w (TAG , "OpenIDConnectAuthorizer: App-provided authURL <%s> " +
318320 "doesn't match server URL; ignoring it" , url .toExternalForm ());
319321 url = null ;
0 commit comments