mitreid-connect
公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.mitre.openid.connect.client.service.impl.DynamicRegistrationClientConfigurationService.DynamicClientRegistrationLoader クラス
org.mitre.openid.connect.client.service.impl.DynamicRegistrationClientConfigurationService.DynamicClientRegistrationLoader の継承関係図
Inheritance graph
org.mitre.openid.connect.client.service.impl.DynamicRegistrationClientConfigurationService.DynamicClientRegistrationLoader 連携図
Collaboration graph

公開メンバ関数

 DynamicClientRegistrationLoader ()
 
 DynamicClientRegistrationLoader (HttpClient httpClient)
 
RegisteredClient load (ServerConfiguration serverConfig) throws Exception
 

非公開変数類

HttpComponentsClientHttpRequestFactory httpFactory
 
Gson gson = new Gson()
 

詳解

Loader class that fetches the client information.

If a client has been registered (ie, it's known to the RegisteredClientService), then this will fetch the client's configuration from the server.

著者
jricher

構築子と解体子

◆ DynamicClientRegistrationLoader() [1/2]

org.mitre.openid.connect.client.service.impl.DynamicRegistrationClientConfigurationService.DynamicClientRegistrationLoader.DynamicClientRegistrationLoader ( )
inline
179  {
180  this(HttpClientBuilder.create().useSystemProperties().build());
181  }

◆ DynamicClientRegistrationLoader() [2/2]

org.mitre.openid.connect.client.service.impl.DynamicRegistrationClientConfigurationService.DynamicClientRegistrationLoader.DynamicClientRegistrationLoader ( HttpClient  httpClient)
inline
183  {
184  this.httpFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
185  }
HttpComponentsClientHttpRequestFactory httpFactory
Definition: DynamicRegistrationClientConfigurationService.java:176

関数詳解

◆ load()

RegisteredClient org.mitre.openid.connect.client.service.impl.DynamicRegistrationClientConfigurationService.DynamicClientRegistrationLoader.load ( ServerConfiguration  serverConfig) throws Exception
inline
188  {
189  RestTemplate restTemplate = new RestTemplate(httpFactory);
190 
191 
192  RegisteredClient knownClient = registeredClientService.getByIssuer(serverConfig.getIssuer());
193  if (knownClient == null) {
194 
195  // dynamically register this client
196  JsonObject jsonRequest = ClientDetailsEntityJsonProcessor.serialize(template);
197  String serializedClient = gson.toJson(jsonRequest);
198 
199  HttpHeaders headers = new HttpHeaders();
200  headers.setContentType(MediaType.APPLICATION_JSON);
201  headers.setAccept(Lists.newArrayList(MediaType.APPLICATION_JSON));
202 
203  HttpEntity<String> entity = new HttpEntity<>(serializedClient, headers);
204 
205  try {
206  String registered = restTemplate.postForObject(serverConfig.getRegistrationEndpointUri(), entity, String.class);
207 
208  RegisteredClient client = ClientDetailsEntityJsonProcessor.parseRegistered(registered);
209 
210  // save this client for later
211  registeredClientService.save(serverConfig.getIssuer(), client);
212 
213  return client;
214  } catch (RestClientException rce) {
215  throw new InvalidClientException("Error registering client with server");
216  }
217  } else {
218 
219  if (knownClient.getClientId() == null) {
220 
221  // load this client's information from the server
222  HttpHeaders headers = new HttpHeaders();
223  headers.set("Authorization", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, knownClient.getRegistrationAccessToken()));
224  headers.setAccept(Lists.newArrayList(MediaType.APPLICATION_JSON));
225 
226  HttpEntity<String> entity = new HttpEntity<>(headers);
227 
228  try {
229  String registered = restTemplate.exchange(knownClient.getRegistrationClientUri(), HttpMethod.GET, entity, String.class).getBody();
230  // TODO: handle HTTP errors
231 
232  RegisteredClient client = ClientDetailsEntityJsonProcessor.parseRegistered(registered);
233 
234  return client;
235  } catch (RestClientException rce) {
236  throw new InvalidClientException("Error loading previously registered client information from server");
237  }
238  } else {
239  // it's got a client ID from the store, don't bother trying to load it
240  return knownClient;
241  }
242  }
243  }
void save(String issuer, RegisteredClient client)
HttpComponentsClientHttpRequestFactory httpFactory
Definition: DynamicRegistrationClientConfigurationService.java:176
RegisteredClientService registeredClientService
Definition: DynamicRegistrationClientConfigurationService.java:68

メンバ詳解

◆ gson

Gson org.mitre.openid.connect.client.service.impl.DynamicRegistrationClientConfigurationService.DynamicClientRegistrationLoader.gson = new Gson()
private

◆ httpFactory

HttpComponentsClientHttpRequestFactory org.mitre.openid.connect.client.service.impl.DynamicRegistrationClientConfigurationService.DynamicClientRegistrationLoader.httpFactory
private

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