keycloak
静的公開メンバ関数 | 静的非公開メンバ関数 | 全メンバ一覧
org.keycloak.authorization.client.util.Throwables クラス
org.keycloak.authorization.client.util.Throwables 連携図
Collaboration graph

静的公開メンバ関数

static RuntimeException handleWrapException (String message, Throwable cause)
 
static< V > V retryAndWrapExceptionIfNecessary (Callable< V > callable, TokenCallable token, String message, Throwable cause) throws RuntimeException
 

静的非公開メンバ関数

static RuntimeException handleAndWrapHttpResponseException (HttpResponseException exception)
 

詳解

著者
Pedro Igor

関数詳解

◆ handleAndWrapHttpResponseException()

static RuntimeException org.keycloak.authorization.client.util.Throwables.handleAndWrapHttpResponseException ( HttpResponseException  exception)
inlinestaticprivate
94  {
95  if (403 == exception.getStatusCode()) {
96  throw new AuthorizationDeniedException(exception);
97  }
98 
99  return new RuntimeException(exception);
100  }

◆ handleWrapException()

static RuntimeException org.keycloak.authorization.client.util.Throwables.handleWrapException ( String  message,
Throwable  cause 
)
inlinestatic

Handles an

cause

and wraps it into a RuntimeException. The resulting cause contains more details in case the given

cause

is of a HttpResponseException.

引数
callable
pat
messagethe message
causethe root cause
戻り値
a RuntimeException wrapping the given
cause
40  {
41  if (cause instanceof HttpResponseException) {
42  throw handleAndWrapHttpResponseException(HttpResponseException.class.cast(cause));
43  }
44 
45  return new RuntimeException(message, cause);
46  }
static RuntimeException handleAndWrapHttpResponseException(HttpResponseException exception)
Definition: Throwables.java:94

◆ retryAndWrapExceptionIfNecessary()

static <V> V org.keycloak.authorization.client.util.Throwables.retryAndWrapExceptionIfNecessary ( Callable< V >  callable,
TokenCallable  token,
String  message,
Throwable  cause 
) throws RuntimeException
inlinestatic

Retries the given

callable

after obtaining a fresh

token

from the server. If the attempt to retry fails the exception is handled as defined by handleWrapException(String, Throwable).

A retry is only attempted in case the

cause

is a HttpResponseException with a 403 status code. In some cases the session associated with the token is no longer valid and a new token must be issues.

引数
callablethe callable to retry
tokenthe token
messagethe message
causethe cause
<V>the result of the callable
戻り値
the result of the callable
例外
RuntimeExceptionin case the attempt to retry fails
63  {
64  if (token == null || !token.isRetry()) {
65  throw handleWrapException(message, cause);
66  }
67 
68  if (cause instanceof HttpResponseException) {
69  HttpResponseException httpe = HttpResponseException.class.cast(cause);
70 
71  if (httpe.getStatusCode() == 403) {
72  TokenIntrospectionResponse response = token.getHttp().<TokenIntrospectionResponse>post(token.getServerConfiguration().getTokenIntrospectionEndpoint())
73  .authentication()
74  .client()
75  .param("token", token.call())
76  .response().json(TokenIntrospectionResponse.class).execute();
77 
78  if (!response.getActive()) {
79  token.clearToken();
80  try {
81  return callable.call();
82  } catch (Exception e) {
83  throw handleWrapException(message, e);
84  }
85  }
86 
87  throw handleWrapException(message, cause);
88  }
89  }
90 
91  throw new RuntimeException(message, cause);
92  }
static RuntimeException handleWrapException(String message, Throwable cause)
Definition: Throwables.java:40

このクラス詳解は次のファイルから抽出されました: