Search in sources :

Example 1 with GithubSettings

use of org.jetbrains.plugins.github.util.GithubSettings in project intellij-community by JetBrains.

the class GithubCreateGistDialog method doOKAction.

@Override
protected void doOKAction() {
    // Store settings
    final GithubSettings settings = GithubSettings.getInstance();
    settings.setAnonymousGist(myGithubCreateGistPanel.isAnonymous());
    settings.setOpenInBrowserGist(myGithubCreateGistPanel.isOpenInBrowser());
    settings.setPrivateGist(myGithubCreateGistPanel.isPrivate());
    super.doOKAction();
}
Also used : GithubSettings(org.jetbrains.plugins.github.util.GithubSettings)

Example 2 with GithubSettings

use of org.jetbrains.plugins.github.util.GithubSettings in project intellij-community by JetBrains.

the class GithubHttpAuthDataProvider method getAuthData.

@Nullable
@Override
public AuthData getAuthData(@NotNull String url) {
    if (!GithubUrlUtil.isGithubUrl(url)) {
        return null;
    }
    GithubSettings settings = GithubSettings.getInstance();
    if (!settings.isValidGitAuth()) {
        return null;
    }
    String host1 = GithubUrlUtil.getHostFromUrl(settings.getHost());
    String host2 = GithubUrlUtil.getHostFromUrl(url);
    if (!host1.equalsIgnoreCase(host2)) {
        return null;
    }
    GithubAuthData auth = settings.getAuthData();
    switch(auth.getAuthType()) {
        case BASIC:
            GithubAuthData.BasicAuth basicAuth = auth.getBasicAuth();
            assert basicAuth != null;
            if (StringUtil.isEmptyOrSpaces(basicAuth.getLogin()) || StringUtil.isEmptyOrSpaces(basicAuth.getPassword())) {
                return null;
            }
            return new AuthData(basicAuth.getLogin(), basicAuth.getPassword());
        case TOKEN:
            GithubAuthData.TokenAuth tokenAuth = auth.getTokenAuth();
            assert tokenAuth != null;
            if (StringUtil.isEmptyOrSpaces(tokenAuth.getToken())) {
                return null;
            }
            return new AuthData(tokenAuth.getToken(), "x-oauth-basic");
        default:
            return null;
    }
}
Also used : AuthData(com.intellij.util.AuthData) GithubAuthData(org.jetbrains.plugins.github.util.GithubAuthData) GithubAuthData(org.jetbrains.plugins.github.util.GithubAuthData) GithubSettings(org.jetbrains.plugins.github.util.GithubSettings) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

GithubSettings (org.jetbrains.plugins.github.util.GithubSettings)2 AuthData (com.intellij.util.AuthData)1 Nullable (org.jetbrains.annotations.Nullable)1 GithubAuthData (org.jetbrains.plugins.github.util.GithubAuthData)1