本文整理汇总了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;
}
示例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;
}