CODENVY-170 rename autghorize method to authenticate
Signed-off-by: Max Shaposhnik <mshaposhnik@codenvy.com>6.19.x
parent
e6a68d6039
commit
5f9026eebf
|
|
@ -20,9 +20,9 @@ import org.eclipse.che.security.oauth.OAuthStatus;
|
|||
*/
|
||||
public interface OAuth2Authenticator {
|
||||
|
||||
void authorize(String authenticatorUrl, AsyncCallback<OAuthStatus> callback);
|
||||
void authenticate(String authenticationUrl, AsyncCallback<OAuthStatus> callback);
|
||||
|
||||
Promise<OAuthStatus> authorize(String authenticationUrl);
|
||||
Promise<OAuthStatus> authenticate(String authenticationUrl);
|
||||
|
||||
String getProviderName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ public class DefaultOAuthAuthenticatorImpl implements OAuth2Authenticator, OAuth
|
|||
}
|
||||
|
||||
@Override
|
||||
public void authorize(String authenticationUrl, @NotNull final AsyncCallback<OAuthStatus> callback) {
|
||||
public void authenticate(String authenticationUrl, @NotNull final AsyncCallback<OAuthStatus> callback) {
|
||||
this.authenticationUrl = authenticationUrl;
|
||||
this.callback = callback;
|
||||
showDialog();
|
||||
}
|
||||
|
||||
public Promise<OAuthStatus> authorize(String authenticationUrl) {
|
||||
public Promise<OAuthStatus> authenticate(String authenticationUrl) {
|
||||
this.authenticationUrl = authenticationUrl;
|
||||
|
||||
return AsyncPromiseHelper.createFromAsyncRequest(new AsyncPromiseHelper.RequestCall<OAuthStatus>() {
|
||||
|
|
|
|||
|
|
@ -175,23 +175,23 @@ public class ProjectImporter extends AbstractImporter {
|
|||
if(authenticator == null) {
|
||||
authenticator = oAuth2AuthenticatorRegistry.getAuthenticator("default");
|
||||
}
|
||||
authenticator.authorize(OAuth2AuthenticatorUrlProvider.get(restContext, authenticateUrl),
|
||||
new AsyncCallback<OAuthStatus>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
callback.onFailure(new Exception(caught.getMessage()));
|
||||
}
|
||||
authenticator.authenticate(OAuth2AuthenticatorUrlProvider.get(restContext, authenticateUrl),
|
||||
new AsyncCallback<OAuthStatus>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
callback.onFailure(new Exception(caught.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(OAuthStatus result) {
|
||||
if (!result.equals(OAuthStatus.NOT_PERFORMED)) {
|
||||
doImport(pathToProject, projectName, sourceStorage);
|
||||
} else {
|
||||
subscriber.onFailure("Authentication cancelled");
|
||||
callback.onCompleted();
|
||||
}
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onSuccess(OAuthStatus result) {
|
||||
if (!result.equals(OAuthStatus.NOT_PERFORMED)) {
|
||||
doImport(pathToProject, projectName, sourceStorage);
|
||||
} else {
|
||||
subscriber.onFailure("Authentication cancelled");
|
||||
callback.onCompleted();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,13 +82,13 @@ public class GitHubAuthenticatorImpl implements OAuth2Authenticator, OAuthCallba
|
|||
}
|
||||
|
||||
@Override
|
||||
public void authorize(String authenticationUrl, @NotNull final AsyncCallback<OAuthStatus> callback) {
|
||||
public void authenticate(String authenticationUrl, @NotNull final AsyncCallback<OAuthStatus> callback) {
|
||||
this.authenticationUrl = authenticationUrl;
|
||||
this.callback = callback;
|
||||
view.showDialog();
|
||||
}
|
||||
|
||||
public Promise<OAuthStatus> authorize(String authenticationUrl) {
|
||||
public Promise<OAuthStatus> authenticate(String authenticationUrl) {
|
||||
this.authenticationUrl = authenticationUrl;
|
||||
|
||||
return AsyncPromiseHelper.createFromAsyncRequest(new AsyncPromiseHelper.RequestCall<OAuthStatus>() {
|
||||
|
|
|
|||
|
|
@ -282,9 +282,9 @@ public class GithubImporterPagePresenter extends AbstractWizardPage<ProjectConfi
|
|||
*/
|
||||
private void authorize() {
|
||||
showProcessing(true);
|
||||
gitHubAuthenticator.authorize(
|
||||
gitHubAuthenticator.authenticate(
|
||||
OAuth2AuthenticatorUrlProvider.get(restContext, "github", appContext.getCurrentUser().getProfile().getUserId(),
|
||||
Lists.asList("user", new String[] {"repo", "write:public_key"})),
|
||||
Lists.asList("user", new String[]{"repo", "write:public_key"})),
|
||||
new AsyncCallback<OAuthStatus>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public class GitHubAuthenticatorImplTest {
|
|||
@Test
|
||||
public void dialogShouldBeShow() throws Exception {
|
||||
AsyncCallback<OAuthStatus> callback = getCallBack();
|
||||
gitHubAuthenticator.authorize(null, callback);
|
||||
gitHubAuthenticator.authenticate(null, callback);
|
||||
|
||||
verify(view).showDialog();
|
||||
assertThat(gitHubAuthenticator.callback, is(callback));
|
||||
|
|
@ -171,7 +171,7 @@ public class GitHubAuthenticatorImplTest {
|
|||
when(user.getProfile()).thenReturn(profile);
|
||||
when(profile.getId()).thenReturn(userId);
|
||||
|
||||
gitHubAuthenticator.authorize(null, getCallBack());
|
||||
gitHubAuthenticator.authenticate(null, getCallBack());
|
||||
gitHubAuthenticator.onAuthenticated(authStatus);
|
||||
|
||||
verify(view).isGenerateKeysSelected();
|
||||
|
|
@ -198,7 +198,7 @@ public class GitHubAuthenticatorImplTest {
|
|||
when(user.getProfile()).thenReturn(profile);
|
||||
when(profile.getId()).thenReturn(userId);
|
||||
|
||||
gitHubAuthenticator.authorize(null, getCallBack());
|
||||
gitHubAuthenticator.authenticate(null, getCallBack());
|
||||
gitHubAuthenticator.onAuthenticated(authStatus);
|
||||
|
||||
verify(keyProvider).uploadKey(eq(userId), generateKeyCallbackCaptor.capture());
|
||||
|
|
@ -229,7 +229,7 @@ public class GitHubAuthenticatorImplTest {
|
|||
when(profile.getId()).thenReturn(userId);
|
||||
when(dialogFactory.createMessageDialog(anyString(), anyString(), Matchers.<ConfirmCallback>anyObject())).thenReturn(messageDialog);
|
||||
|
||||
gitHubAuthenticator.authorize(null, getCallBack());
|
||||
gitHubAuthenticator.authenticate(null, getCallBack());
|
||||
gitHubAuthenticator.onAuthenticated(authStatus);
|
||||
|
||||
verify(keyProvider).uploadKey(eq(userId), generateKeyCallbackCaptor.capture());
|
||||
|
|
@ -266,7 +266,7 @@ public class GitHubAuthenticatorImplTest {
|
|||
when(pair.getName()).thenReturn(GITHUB_HOST);
|
||||
when(pair.getService()).thenReturn(SshKeyManagerPresenter.GIT_SSH_SERVICE);
|
||||
|
||||
gitHubAuthenticator.authorize(null, getCallBack());
|
||||
gitHubAuthenticator.authenticate(null, getCallBack());
|
||||
gitHubAuthenticator.onAuthenticated(authStatus);
|
||||
|
||||
verify(keyUploader).uploadKey(eq(userId), generateKeyCallbackCaptor.capture());
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ public class GithubImporterPagePresenterTest {
|
|||
verify(gitHubClientService).getUserInfo();
|
||||
verify(gitHubClientService).getOrganizations();
|
||||
|
||||
verify(gitHubAuthenticator).authorize(anyString(), asyncCallbackCaptor.capture());
|
||||
verify(gitHubAuthenticator).authenticate(anyString(), asyncCallbackCaptor.capture());
|
||||
AsyncCallback<OAuthStatus> asyncCallback = asyncCallbackCaptor.getValue();
|
||||
asyncCallback.onFailure(exception);
|
||||
|
||||
|
|
@ -463,7 +463,7 @@ public class GithubImporterPagePresenterTest {
|
|||
verify(gitHubClientService).getUserInfo();
|
||||
verify(gitHubClientService).getOrganizations();
|
||||
|
||||
verify(gitHubAuthenticator).authorize(anyString(), asyncCallbackCaptor.capture());
|
||||
verify(gitHubAuthenticator).authenticate(anyString(), asyncCallbackCaptor.capture());
|
||||
AsyncCallback<OAuthStatus> asyncCallback = asyncCallbackCaptor.getValue();
|
||||
asyncCallback.onSuccess(null);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue