当前位置: 首页>>代码示例>>Java>>正文


Java UnauthorizedException类代码示例

本文整理汇总了Java中org.eclipse.che.ide.commons.exception.UnauthorizedException的典型用法代码示例。如果您正苦于以下问题:Java UnauthorizedException类的具体用法?Java UnauthorizedException怎么用?Java UnauthorizedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UnauthorizedException类属于org.eclipse.che.ide.commons.exception包,在下文中一共展示了UnauthorizedException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uploadKey

import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
@Override
public void uploadKey(String userId, final AsyncCallback<Void> callback) {
  this.callback = callback;
  this.userId = userId;

  bitbucketService.generateAndUploadSSHKey(
      new AsyncRequestCallback<Void>() {
        @Override
        protected void onSuccess(final Void notUsed) {
          callback.onSuccess(notUsed);
        }

        @Override
        protected void onFailure(final Throwable exception) {
          if (exception instanceof UnauthorizedException) {
            oAuthLoginStart();
            return;
          }

          callback.onFailure(exception);
        }
      });
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:24,代码来源:BitbucketSshKeyProvider.java

示例2: onLoadRepoClickedWhenAuthorizeIsSuccessful

import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
@Test
public void onLoadRepoClickedWhenAuthorizeIsSuccessful() throws Exception {
  final Throwable exception = mock(UnauthorizedException.class);
  String userId = "userId";
  CurrentUser user = mock(CurrentUser.class);
  doReturn(exception).when(promiseError).getCause();

  when(appContext.getCurrentUser()).thenReturn(user);
  when(user.getId()).thenReturn(userId);

  presenter.onLoadRepoClicked();

  verify(gitHubClientService).getRepositoriesList(anyString());
  verify(gitHubClientService).getUserInfo(anyString());
  verify(gitHubClientService).getOrganizations(anyString());

  verify(gitHubAuthenticator).authenticate(anyString(), asyncCallbackCaptor.capture());
  AsyncCallback<OAuthStatus> asyncCallback = asyncCallbackCaptor.getValue();
  asyncCallback.onSuccess(null);

  verify(view, times(3)).setLoaderVisibility(eq(true));
  verify(view, times(3)).setInputsEnableState(eq(false));
  verify(view, times(3)).setInputsEnableState(eq(true));
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:GithubImporterPagePresenterTest.java

示例3: authenticate

import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
private void authenticate(final WorkflowExecutor executor, final Context context) {
  context
      .getVcsHostingService()
      .authenticate(appContext.getCurrentUser())
      .then(authSuccessOp(executor, context))
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError err) throws OperationException {
              try {
                throw err.getCause();
              } catch (UnauthorizedException unEx) {
                notificationManager.notify(
                    messages.stepAuthorizeCodenvyOnVCSHostErrorCannotAccessVCSHostTitle(),
                    messages.stepAuthorizeCodenvyOnVCSHostErrorCannotAccessVCSHostContent(),
                    FAIL,
                    FLOAT_MODE);
                executor.fail(
                    AuthorizeCodenvyOnVCSHostStep.this, context, unEx.getLocalizedMessage());
              } catch (Throwable thr) {
                handleThrowable(thr, executor, context);
              }
            }
          });
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:AuthorizeCodenvyOnVCSHostStep.java

示例4: uploadKey

import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void uploadKey(final String userId, final AsyncCallback<Void> callback) {
  this.callback = callback;
  this.userId = userId;

  oAuthServiceClient
      .getToken("github")
      .then(
          result -> {
            gitHubService.updatePublicKey(
                result.getToken(),
                new AsyncRequestCallback<Void>() {
                  @Override
                  protected void onSuccess(Void o) {
                    callback.onSuccess(o);
                  }

                  @Override
                  protected void onFailure(Throwable e) {
                    if (e instanceof UnauthorizedException) {
                      oAuthLoginStart();
                      return;
                    }
                    callback.onFailure(e);
                  }
                });
          })
      .catchError(
          error -> {
            oAuthLoginStart();
          });
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:GitHubSshKeyUploader.java

示例5: onFailRequest

import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
protected void onFailRequest(PromiseError arg) {
  showProcessing(false);
  if (arg.getCause() instanceof UnauthorizedException) {
    authorize();
  } else {
    notificationManager.notify(locale.authorizationFailed(), FAIL, FLOAT_MODE);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:GithubImporterPagePresenter.java

示例6: onLoadRepoClickedWhenAuthorizeIsFailed

import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
@Test
public void onLoadRepoClickedWhenAuthorizeIsFailed() throws Exception {
  String userId = "userId";
  CurrentUser user = mock(CurrentUser.class);

  when(appContext.getCurrentUser()).thenReturn(user);
  when(user.getId()).thenReturn(userId);

  final Throwable exception = mock(UnauthorizedException.class);
  doReturn(exception).when(promiseError).getCause();

  presenter.onLoadRepoClicked();

  verify(gitHubClientService).getRepositoriesList(anyString());
  verify(gitHubClientService).getUserInfo(anyString());
  verify(gitHubClientService).getOrganizations(anyString());

  verify(gitHubAuthenticator).authenticate(anyString(), asyncCallbackCaptor.capture());
  AsyncCallback<OAuthStatus> asyncCallback = asyncCallbackCaptor.getValue();
  asyncCallback.onFailure(exception);

  verify(view, times(2)).setLoaderVisibility(eq(true));
  verify(view, times(2)).setInputsEnableState(eq(false));
  verify(view, times(2)).setInputsEnableState(eq(true));
  verify(view, never()).setAccountNames(any());
  verify(view, never()).showGithubPanel();
  verify(view, never()).setRepositories(org.mockito.ArgumentMatchers.any());
}
 
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:GithubImporterPagePresenterTest.java

示例7: handleError

import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
/**
 * Handler some action whether some exception happened.
 *
 * @param throwable exception what happened
 */
void handleError(
    @NotNull Throwable throwable, StatusNotification notification, GitOutputConsole console) {
  notification.setStatus(FAIL);
  if (throwable instanceof UnauthorizedException) {
    console.printError(locale.messagesNotAuthorizedTitle());
    console.print(locale.messagesNotAuthorizedContent());
    notification.setTitle(locale.messagesNotAuthorizedTitle());
    notification.setContent(locale.messagesNotAuthorizedContent());
    return;
  }

  String errorMessage = throwable.getMessage();
  if (errorMessage == null) {
    console.printError(locale.pushFail());
    notification.setTitle(locale.pushFail());
    return;
  }

  try {
    errorMessage = dtoFactory.createDtoFromJson(errorMessage, ServiceError.class).getMessage();
    if (errorMessage.equals("Unable get private ssh key")) {
      console.printError(locale.messagesUnableGetSshKey());
      notification.setTitle(locale.messagesUnableGetSshKey());
      return;
    }
    console.printError(errorMessage);
    notification.setTitle(errorMessage);
  } catch (Exception e) {
    console.printError(errorMessage);
    notification.setTitle(errorMessage);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:PushToRemotePresenter.java

示例8: getUserErrorOp

import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
private Operation<PromiseError> getUserErrorOp(
    final WorkflowExecutor executor, final Context context) {
  return new Operation<PromiseError>() {
    @Override
    public void apply(PromiseError error) throws OperationException {
      try {
        throw error.getCause();
      } catch (UnauthorizedException unEx) {
        authenticate(executor, context);
      } catch (Throwable thr) {
        handleThrowable(thr, executor, context);
      }
    }
  };
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:AuthorizeCodenvyOnVCSHostStep.java

示例9: onUnauthorized

import org.eclipse.che.ide.commons.exception.UnauthorizedException; //导入依赖的package包/类
/**
 * If unauthorized.
 *
 * @param response
 */
protected void onUnauthorized(Response response) {
  onFailure(new UnauthorizedException(response, request));
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:AsyncRequestCallback.java


注:本文中的org.eclipse.che.ide.commons.exception.UnauthorizedException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。