15
15
*/
16
16
package io .micronaut .aws .secretsmanager ;
17
17
18
- import com .fasterxml .jackson .core .JsonProcessingException ;
19
- import com .fasterxml .jackson .databind .ObjectMapper ;
20
18
import io .micronaut .context .annotation .BootstrapContextCompatible ;
21
19
import io .micronaut .context .annotation .Requires ;
22
20
import io .micronaut .core .annotation .Experimental ;
23
21
import io .micronaut .core .annotation .NonNull ;
22
+ import io .micronaut .json .JsonMapper ;
24
23
import org .slf4j .Logger ;
25
24
import org .slf4j .LoggerFactory ;
26
25
import software .amazon .awssdk .services .secretsmanager .SecretsManagerClient ;
38
37
import software .amazon .awssdk .services .secretsmanager .model .SecretListEntry ;
39
38
import software .amazon .awssdk .services .secretsmanager .model .SecretsManagerException ;
40
39
import jakarta .inject .Singleton ;
40
+
41
+ import java .io .IOException ;
41
42
import java .util .Base64 ;
42
43
import java .util .HashMap ;
43
44
import java .util .List ;
@@ -58,15 +59,15 @@ public class SecretsManagerKeyValueFetcher implements SecretsKeyValueFetcher {
58
59
private static final Logger LOG = LoggerFactory .getLogger (SecretsManagerKeyValueFetcher .class );
59
60
60
61
protected final SecretsManagerClient secretsClient ;
61
- protected final ObjectMapper objectMapper ;
62
+ protected final JsonMapper objectMapper ;
62
63
63
64
/**
64
65
*
65
66
* @param secretsClient Secrets Client
66
67
* @param objectMapper Object Mapper
67
68
*/
68
69
public SecretsManagerKeyValueFetcher (SecretsManagerClient secretsClient ,
69
- ObjectMapper objectMapper ) {
70
+ JsonMapper objectMapper ) {
70
71
this .secretsClient = secretsClient ;
71
72
this .objectMapper = objectMapper ;
72
73
}
@@ -124,12 +125,12 @@ public Optional<Map> keyValuesByPrefix(@NonNull String prefix) {
124
125
* @param result a map that collects the results
125
126
*/
126
127
@ NonNull
127
- protected void addSecretDetailsToResults (SecretListEntry secret , Map result ) {
128
+ protected void addSecretDetailsToResults (SecretListEntry secret , Map result ) {
128
129
Optional <String > secretValueOptional = fetchSecretValue (secretsClient , secret .name ());
129
130
if (secretValueOptional .isPresent ()) {
130
131
try {
131
132
result .putAll (objectMapper .readValue (secretValueOptional .get (), Map .class ));
132
- } catch (JsonProcessingException e ) {
133
+ } catch (IOException e ) {
133
134
if (LOG .isWarnEnabled ()) {
134
135
LOG .warn ("could not read secret ({}) value from JSON to Map" , secret .name ());
135
136
}
0 commit comments