keycloak
公開メンバ関数 | 限定公開メンバ関数 | 限定公開変数類 | 非公開変数類 | 全メンバ一覧
org.keycloak.authorization.client.util.HttpMethod< R > クラステンプレート
org.keycloak.authorization.client.util.HttpMethod< R > 連携図
Collaboration graph

公開メンバ関数

 HttpMethod (Configuration configuration, ClientAuthenticator authenticator, RequestBuilder builder)
 
 HttpMethod (Configuration configuration, ClientAuthenticator authenticator, RequestBuilder builder, Map< String, List< String >> params, Map< String, String > headers)
 
void execute ()
 
execute (HttpResponseProcessor< R > responseProcessor)
 
HttpMethod< R > authorizationBearer (String bearer)
 
HttpMethodResponse< R > response ()
 
HttpMethodAuthenticator< R > authentication ()
 
HttpMethod< R > param (String name, String value)
 
HttpMethod< R > params (String name, String value)
 
HttpMethod< R > json (byte[] entity)
 
HttpMethod< R > form ()
 

限定公開メンバ関数

void preExecute (RequestBuilder builder)
 

限定公開変数類

final RequestBuilder builder
 
final Configuration configuration
 
final Map< String, String > headers
 
final Map< String, List< String > > params
 

非公開変数類

final HttpClient httpClient
 
final ClientAuthenticator authenticator
 
HttpMethodResponse< R > response
 

詳解

著者
Pedro Igor

構築子と解体子

◆ HttpMethod() [1/2]

org.keycloak.authorization.client.util.HttpMethod< R >.HttpMethod ( Configuration  configuration,
ClientAuthenticator  authenticator,
RequestBuilder  builder 
)
inline
52  {
53  this(configuration, authenticator, builder, new HashMap<String, List<String>>(), new HashMap<String, String>());
54  }
final ClientAuthenticator authenticator
Definition: HttpMethod.java:45
final RequestBuilder builder
Definition: HttpMethod.java:46
final Configuration configuration
Definition: HttpMethod.java:47

◆ HttpMethod() [2/2]

org.keycloak.authorization.client.util.HttpMethod< R >.HttpMethod ( Configuration  configuration,
ClientAuthenticator  authenticator,
RequestBuilder  builder,
Map< String, List< String >>  params,
Map< String, String >  headers 
)
inline
56  {
60  this.builder = builder;
61  this.params = params;
62  this.headers = headers;
63  }
final HttpClient httpClient
Definition: HttpMethod.java:44
final Map< String, List< String > > params
Definition: HttpMethod.java:49
HttpClient getHttpClient()
Definition: Configuration.java:62
final ClientAuthenticator authenticator
Definition: HttpMethod.java:45
final RequestBuilder builder
Definition: HttpMethod.java:46
final Configuration configuration
Definition: HttpMethod.java:47
final Map< String, String > headers
Definition: HttpMethod.java:48

関数詳解

◆ authentication()

128  {
129  return new HttpMethodAuthenticator<R>(this, authenticator);
130  }
final ClientAuthenticator authenticator
Definition: HttpMethod.java:45

◆ authorizationBearer()

HttpMethod<R> org.keycloak.authorization.client.util.HttpMethod< R >.authorizationBearer ( String  bearer)
inline
118  {
119  this.builder.addHeader("Authorization", "Bearer " + bearer);
120  return this;
121  }
final RequestBuilder builder
Definition: HttpMethod.java:46

◆ execute() [1/2]

65  {
66  execute(new HttpResponseProcessor<R>() {
67  @Override
68  public R process(byte[] entity) {
69  return null;
70  }
71  });
72  }
void execute()
Definition: HttpMethod.java:65

◆ execute() [2/2]

R org.keycloak.authorization.client.util.HttpMethod< R >.execute ( HttpResponseProcessor< R >  responseProcessor)
inline
74  {
75  byte[] bytes = null;
76 
77  try {
78  for (Map.Entry<String, String> header : this.headers.entrySet()) {
79  this.builder.setHeader(header.getKey(), header.getValue());
80  }
81 
82  preExecute(this.builder);
83 
84  HttpResponse response = this.httpClient.execute(this.builder.build());
85  HttpEntity entity = response.getEntity();
86 
87  if (entity != null) {
88  bytes = EntityUtils.toByteArray(entity);
89  }
90 
91  StatusLine statusLine = response.getStatusLine();
92  int statusCode = statusLine.getStatusCode();
93 
94  if (statusCode < 200 || statusCode >= 300) {
95  throw new HttpResponseException("Unexpected response from server: " + statusCode + " / " + statusLine.getReasonPhrase(), statusCode, statusLine.getReasonPhrase(), bytes);
96  }
97 
98  if (bytes == null) {
99  return null;
100  }
101 
102  return responseProcessor.process(bytes);
103  } catch (HttpResponseException e) {
104  throw e;
105  } catch (Exception e) {
106  throw new RuntimeException("Error executing http method [" + builder + "]. Response : " + String.valueOf(bytes), e);
107  }
108  }
final HttpClient httpClient
Definition: HttpMethod.java:44
void preExecute(RequestBuilder builder)
Definition: HttpMethod.java:110
final RequestBuilder builder
Definition: HttpMethod.java:46
HttpMethodResponse< R > response()
Definition: HttpMethod.java:123

◆ form()

166  {
167  return new HttpMethod<R>(this.configuration, authenticator, this.builder, this.params, this.headers) {
168  @Override
169  protected void preExecute(RequestBuilder builder) {
170  if (params != null) {
171  List<NameValuePair> formparams = new ArrayList<>();
172 
173  for (Map.Entry<String, List<String>> param : params.entrySet()) {
174  for (String value : param.getValue()) {
175  formparams.add(new BasicNameValuePair(param.getKey(), value));
176  }
177  }
178 
179  try {
180  builder.setEntity(new UrlEncodedFormEntity(formparams, "UTF-8"));
181  } catch (UnsupportedEncodingException e) {
182  throw new RuntimeException("Error creating form parameters");
183  }
184  }
185  }
186  };
187  }
HttpMethod< R > param(String name, String value)
Definition: HttpMethod.java:132
final Map< String, List< String > > params
Definition: HttpMethod.java:49
void preExecute(RequestBuilder builder)
Definition: HttpMethod.java:110
final ClientAuthenticator authenticator
Definition: HttpMethod.java:45
final RequestBuilder builder
Definition: HttpMethod.java:46
final Configuration configuration
Definition: HttpMethod.java:47
final Map< String, String > headers
Definition: HttpMethod.java:48

◆ json()

HttpMethod<R> org.keycloak.authorization.client.util.HttpMethod< R >.json ( byte []  entity)
inline
160  {
161  this.builder.addHeader("Content-Type", "application/json");
162  this.builder.setEntity(new ByteArrayEntity(entity));
163  return this;
164  }
final RequestBuilder builder
Definition: HttpMethod.java:46

◆ param()

HttpMethod<R> org.keycloak.authorization.client.util.HttpMethod< R >.param ( String  name,
String  value 
)
inline
132  {
133  if (value != null) {
134  List<String> values = params.get(name);
135 
136  if (values == null || !values.isEmpty()) {
137  values = new ArrayList<>();
138  params.put(name, values);
139  }
140 
141  values.add(value);
142  }
143  return this;
144  }
final Map< String, List< String > > params
Definition: HttpMethod.java:49

◆ params()

HttpMethod<R> org.keycloak.authorization.client.util.HttpMethod< R >.params ( String  name,
String  value 
)
inline
146  {
147  if (value != null) {
148  List<String> values = params.get(name);
149 
150  if (values == null) {
151  values = new ArrayList<>();
152  params.put(name, values);
153  }
154 
155  values.add(value);
156  }
157  return this;
158  }
final Map< String, List< String > > params
Definition: HttpMethod.java:49

◆ preExecute()

void org.keycloak.authorization.client.util.HttpMethod< R >.preExecute ( RequestBuilder  builder)
inlineprotected
110  {
111  for (Map.Entry<String, List<String>> param : params.entrySet()) {
112  for (String value : param.getValue()) {
113  builder.addParameter(param.getKey(), value);
114  }
115  }
116  }
HttpMethod< R > param(String name, String value)
Definition: HttpMethod.java:132
final Map< String, List< String > > params
Definition: HttpMethod.java:49
final RequestBuilder builder
Definition: HttpMethod.java:46

◆ response()

123  {
124  this.response = new HttpMethodResponse(this);
125  return this.response;
126  }
HttpMethodResponse< R > response()
Definition: HttpMethod.java:123

メンバ詳解

◆ authenticator

◆ builder

final RequestBuilder org.keycloak.authorization.client.util.HttpMethod< R >.builder
protected

◆ configuration

◆ headers

final Map<String, String> org.keycloak.authorization.client.util.HttpMethod< R >.headers
protected

◆ httpClient

final HttpClient org.keycloak.authorization.client.util.HttpMethod< R >.httpClient
private

◆ params

final Map<String, List<String> > org.keycloak.authorization.client.util.HttpMethod< R >.params
protected

◆ response


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