forked from unicode-org/cldr
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLDR-18165 cla: github sso: generate login url
- add LoginManager to manage the sso
- Loading branch information
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tools/cldr-apps/src/main/java/org/unicode/cldr/web/auth/LoginManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.unicode.cldr.web.auth; | ||
|
||
import java.util.logging.Logger; | ||
import org.unicode.cldr.web.SurveyLog; | ||
|
||
public class LoginManager { | ||
|
||
static final Logger logger = SurveyLog.forClass(LoginManager.class); | ||
|
||
public static final LoginManager getInstance() { | ||
return Helper.INSTANCE; | ||
} | ||
|
||
private static final class Helper { | ||
|
||
static final LoginManager INSTANCE = new LoginManager(); | ||
} | ||
|
||
// Simple implementation for now. | ||
public LoginManager() { | ||
try { | ||
github = new GithubLoginFactory(); | ||
if (!github.valid()) { | ||
logger.info("Github login not valid"); | ||
github = null; | ||
} | ||
logger.info("Github login available"); | ||
} catch (Throwable t) { | ||
SurveyLog.logException(t, "trying to setup GitHub"); | ||
github = null; | ||
} | ||
} | ||
|
||
GithubLoginFactory github = null; | ||
|
||
public String getLoginString(LoginFactory.LoginIntent intent) { | ||
if (github == null) return null; | ||
return github.getLoginUrl(intent); | ||
} | ||
} |