Search in sources :

Example 6 with SshKeyUploader

use of org.eclipse.che.plugin.ssh.key.client.SshKeyUploader in project che by eclipse.

the class SshKeyManagerPresenter method onGenerateGithubKeyClicked.

/** {@inheritDoc} */
@Override
public void onGenerateGithubKeyClicked() {
    CurrentUser user = appContext.getCurrentUser();
    final SshKeyUploader githubUploader = registry.getUploaders().get(GITHUB_HOST);
    if (user != null && githubUploader != null) {
        githubUploader.uploadKey(user.getProfile().getUserId(), new AsyncCallback<Void>() {

            @Override
            public void onSuccess(Void result) {
                refreshKeys();
            }

            @Override
            public void onFailure(Throwable exception) {
                removeFailedKey(GITHUB_HOST);
            }
        });
    } else {
        notificationManager.notify(constant.failedToGenerateSshKey(), constant.sshKeysProviderNotFound(GITHUB_HOST), FAIL, FLOAT_MODE);
    }
}
Also used : SshKeyUploader(org.eclipse.che.plugin.ssh.key.client.SshKeyUploader) CurrentUser(org.eclipse.che.ide.api.app.CurrentUser)

Aggregations

SshKeyUploader (org.eclipse.che.plugin.ssh.key.client.SshKeyUploader)6 CurrentUser (org.eclipse.che.ide.api.app.CurrentUser)5 ProfileDto (org.eclipse.che.api.user.shared.dto.ProfileDto)4 OAuthStatus (org.eclipse.che.security.oauth.OAuthStatus)4 Test (org.junit.Test)4 Matchers.anyString (org.mockito.Matchers.anyString)4 MessageDialog (org.eclipse.che.ide.api.dialogs.MessageDialog)2 ArrayList (java.util.ArrayList)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 SshPairDto (org.eclipse.che.api.ssh.shared.dto.SshPairDto)1