diff --git a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/DynamicRegistrationClientConfigurationService.java b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/DynamicRegistrationClientConfigurationService.java index 7543ef76d..5f6cc570c 100644 --- a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/DynamicRegistrationClientConfigurationService.java +++ b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/DynamicRegistrationClientConfigurationService.java @@ -45,6 +45,7 @@ import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.Lists; +import com.google.gson.Gson; import com.google.gson.JsonObject; /** @@ -157,7 +158,8 @@ public class DynamicRegistrationClientConfigurationService implements ClientConf public class DynamicClientRegistrationLoader extends CacheLoader { private HttpClient httpClient = new DefaultHttpClient(); private HttpComponentsClientHttpRequestFactory httpFactory = new HttpComponentsClientHttpRequestFactory(httpClient); - + private Gson gson = new Gson(); // note that this doesn't serialize nulls by default + @Override public RegisteredClient load(ServerConfiguration serverConfig) throws Exception { RestTemplate restTemplate = new RestTemplate(httpFactory); @@ -168,12 +170,13 @@ public class DynamicRegistrationClientConfigurationService implements ClientConf // dynamically register this client JsonObject jsonRequest = ClientDetailsEntityJsonProcessor.serialize(template); + String serializedClient = gson.toJson(jsonRequest); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.setAccept(Lists.newArrayList(MediaType.APPLICATION_JSON)); - HttpEntity entity = new HttpEntity(jsonRequest.toString(), headers); + HttpEntity entity = new HttpEntity(serializedClient, headers); String registered = restTemplate.postForObject(serverConfig.getRegistrationEndpointUri(), entity, String.class); // TODO: handle HTTP errors