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


Java HttpStatusCodes.STATUS_CODE_UNAUTHORIZED属性代码示例

本文整理汇总了Java中com.google.api.client.http.HttpStatusCodes.STATUS_CODE_UNAUTHORIZED属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatusCodes.STATUS_CODE_UNAUTHORIZED属性的具体用法?Java HttpStatusCodes.STATUS_CODE_UNAUTHORIZED怎么用?Java HttpStatusCodes.STATUS_CODE_UNAUTHORIZED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.api.client.http.HttpStatusCodes的用法示例。


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

示例1: handleResponse

@Override
public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry) throws IOException {

    if (!supportsRetry) {
        return false;
    }

    if (response.getStatusCode() == HttpStatusCodes.STATUS_CODE_UNAUTHORIZED) {
        authoriser.refresh();
        return true;
    }

    // check if back-off is required for this response
    if (isRequired(response)) {
        try {
            return BackOffUtils.next(sleeper, backOff);
        } catch (InterruptedException exception) {
            // ignore
        }
    }

    return false;
}
 
开发者ID:wooti,项目名称:onedrive-java-client,代码行数:23,代码来源:OneDriveResponseHandler.java

示例2: handleHttpResponseException

@Override
public RegistryAuthenticator handleHttpResponseException(
    HttpResponseException httpResponseException)
    throws HttpResponseException, RegistryErrorException {
  // Only valid for status code of '401 Unauthorized'.
  if (httpResponseException.getStatusCode() != HttpStatusCodes.STATUS_CODE_UNAUTHORIZED) {
    throw httpResponseException;
  }

  // Checks if the 'WWW-Authenticate' header is present.
  String authenticationMethod = httpResponseException.getHeaders().getAuthenticate();
  if (authenticationMethod == null) {
    throw new RegistryErrorExceptionBuilder(getActionDescription(), httpResponseException)
        .addReason("'WWW-Authenticate' header not found")
        .build();
  }

  // Parses the header to retrieve the components.
  try {
    return RegistryAuthenticator.fromAuthenticationMethod(
        authenticationMethod, registryEndpointProperties.getImageName());

  } catch (RegistryAuthenticationFailedException | MalformedURLException ex) {
    throw new RegistryErrorExceptionBuilder(getActionDescription(), ex)
        .addReason("Failed get authentication method from 'WWW-Authenticate' header")
        .build();
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:minikube-build-tools-for-java,代码行数:28,代码来源:AuthenticationMethodRetriever.java

示例3: handleResponse

@Override
public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry) {
    if (response.getStatusCode() == HttpStatusCodes.STATUS_CODE_UNAUTHORIZED) {
        // If the token was revoked, we must mark our credential as invalid
        setAccessToken(null);
    }

    // We didn't do anything to fix the problem
    return false;
}
 
开发者ID:agilie,项目名称:dribbble-android-sdk,代码行数:10,代码来源:OAuthHmacCredential.java


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