Skip to content

Commit

Permalink
* Synchronize login method to prevent multiple authorization pages wh…
Browse files Browse the repository at this point in the history
…en loading multiple files in parallel

* Remove unused "check session" method
  • Loading branch information
jrobinso committed Jun 13, 2020
1 parent 1aedd43 commit 32423f9
Showing 1 changed file with 1 addition and 56 deletions.
57 changes: 1 addition & 56 deletions src/main/java/org/broad/igv/google/OAuthProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public void updateSaveOption(boolean aBoolean) {
/**
* Try to login to secure server. dwm08
*/
public void doSecureLogin() {
public synchronized void doSecureLogin() {
// if user is not currently logged in, attempt to
// log in user if not logged in dwm08
if (!isLoggedIn()) {
Expand All @@ -441,61 +441,6 @@ public void doSecureLogin() {
}
}

/**
* Generate a set of all urls in the session file
*
* @param sessionPath
* @return list of urls
*/
public static Set<String> findUrlsInSessionFile(String sessionPath) {
BufferedReader br = null;
HashSet<String> urlSet = new HashSet<>();
try {
br = new BufferedReader(new FileReader(new File(sessionPath)));
String line;
while ((line = br.readLine()) != null) {
int start = line.indexOf("http");
if (start != -1) {
int mid = line.indexOf("://", start);
int end = line.indexOf("/", mid + 3);
String url = line.substring(start, end);
urlSet.add(url);
}
}

} catch (Exception e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
}
}
}
return urlSet;
}

/**
* Check if any reference in the session file refers to a server protected
* by the oauth protocol. If so, check to see if the user is logged in. If
* user is not logged in, put up login prompt.
*
* @param sessionPath
*/
public void checkServerLogin(String sessionPath) {
Set<String> urlSet = findUrlsInSessionFile(sessionPath);
if (urlSet.size() > 0) {
for (String url : urlSet) {
if (GoogleUtils.isGoogleCloud(url)) {
doSecureLogin();
// user is logged in. Can proceed with the load
return;
}
}
}
}

public JsonObject getResponse() {
return response;
}
Expand Down

0 comments on commit 32423f9

Please sign in to comment.