|
1 | 1 | package com.ziro.espresso.onepasssdk; |
2 | 2 |
|
| 3 | +import com.fasterxml.jackson.databind.DeserializationFeature; |
| 4 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 5 | +import com.fasterxml.jackson.databind.SerializationFeature; |
3 | 6 | import com.google.common.base.Preconditions; |
4 | 7 | import com.google.common.base.Strings; |
5 | | -import com.google.gson.Gson; |
6 | | -import com.google.gson.GsonBuilder; |
7 | 8 | import com.ziro.espresso.fluent.exceptions.SystemUnhandledException; |
8 | 9 | import com.ziro.espresso.okhttp3.OkHttpClientFactory; |
9 | 10 | import com.ziro.espresso.okhttp3.SynchronousCallAdapterFactory; |
10 | 11 | import com.ziro.espresso.streams.MoreCollectors; |
11 | 12 | import java.io.ByteArrayInputStream; |
12 | 13 | import java.io.IOException; |
13 | 14 | import java.io.InputStream; |
| 15 | +import java.text.SimpleDateFormat; |
14 | 16 | import java.time.Duration; |
15 | 17 | import java.util.Objects; |
16 | 18 | import java.util.Properties; |
|
22 | 24 | import okhttp3.OkHttpClient; |
23 | 25 | import okhttp3.Request; |
24 | 26 | import retrofit2.Retrofit; |
25 | | -import retrofit2.converter.gson.GsonConverterFactory; |
| 27 | +import retrofit2.converter.jackson.JacksonConverterFactory; |
26 | 28 |
|
27 | 29 | /** |
28 | 30 | * A connector for interacting with 1Password Connect Server API. |
@@ -116,14 +118,15 @@ public Properties getSecureNoteAsProperties(String vaultId, String itemId) { |
116 | 118 | */ |
117 | 119 | private static OnePasswordConnectServerApiClient createClient( |
118 | 120 | String baseUrl, String accessToken, X509TrustManager trustManager) { |
119 | | - Gson gson = new GsonBuilder() |
120 | | - .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") |
121 | | - .setPrettyPrinting() |
122 | | - .create(); |
| 121 | + |
| 122 | + ObjectMapper objectMapper = new ObjectMapper() |
| 123 | + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) |
| 124 | + .enable(SerializationFeature.INDENT_OUTPUT) |
| 125 | + .setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")); |
123 | 126 |
|
124 | 127 | Retrofit.Builder retrofitBuilder = new Retrofit.Builder() |
125 | 128 | .baseUrl(baseUrl) |
126 | | - .addConverterFactory(GsonConverterFactory.create(gson)) |
| 129 | + .addConverterFactory(JacksonConverterFactory.create(objectMapper)) |
127 | 130 | .addCallAdapterFactory(new SynchronousCallAdapterFactory<>()); |
128 | 131 |
|
129 | 132 | OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder(); |
|
0 commit comments