Search in sources :

Example 1 with GitHttpAuthDataProvider

use of git4idea.remote.GitHttpAuthDataProvider in project intellij-community by JetBrains.

the class GitHttpGuiAuthenticator method askUsername.

@Override
@NotNull
public String askUsername(@NotNull String url) {
    myUnifiedUrl = getUnifiedUrl(url);
    Pair<GitHttpAuthDataProvider, AuthData> authData = findBestAuthData(getUnifiedUrl(url));
    String login = null;
    String password = null;
    if (authData != null) {
        login = authData.second.getLogin();
        password = authData.second.getPassword();
        myDataProvider = authData.first;
    }
    LOG.debug("askUsername. dataProvider=" + getCurrentDataProviderName() + ", unifiedUrl= " + getUnifiedUrl(url) + ", login=" + login + ", passwordKnown=" + (password != null));
    if (login != null && password != null) {
        myPassword = password;
        return login;
    }
    AuthDialog dialog = showAuthDialog(getDisplayableUrl(url), login);
    LOG.debug("askUsername. Showed dialog:" + (dialog == null ? "NULL" : dialog.isOK() ? "OK" : "Cancel"));
    if (dialog == null || !dialog.isOK()) {
        myWasCancelled = true;
        return "";
    }
    // remember values to store in the database afterwards, if authentication succeeds
    myPassword = dialog.getPassword();
    myLogin = dialog.getUsername();
    mySaveOnDisk = dialog.isRememberPassword();
    myPasswordKey = makeKey(myUnifiedUrl, myLogin);
    return myLogin;
}
Also used : AuthData(com.intellij.util.AuthData) GitHttpAuthDataProvider(git4idea.remote.GitHttpAuthDataProvider) AuthDialog(com.intellij.vcsUtil.AuthDialog) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AuthData (com.intellij.util.AuthData)1 AuthDialog (com.intellij.vcsUtil.AuthDialog)1 GitHttpAuthDataProvider (git4idea.remote.GitHttpAuthDataProvider)1 NotNull (org.jetbrains.annotations.NotNull)1