• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FIWARE / credentials-config-service / #57

13 Jan 2026 07:06AM UTC coverage: 83.163% (-0.4%) from 83.552%
#57

push

web-flow
MIgrate to liquibase (#22)

* refactor(db): replace flyway with liquibase

Liquibase has better support for different types of databases. It allows having a single migration file for all databases.

* do not copy test resources into prod image

* update README.md

* rename 2.0.3 database migration script

---------

Co-authored-by: Stefan Wiedemann <wistefan@googlemail.com>

0 of 3 new or added lines in 1 file covered. (0.0%)

19 existing lines in 3 files now uncovered.

568 of 683 relevant lines covered (83.16%)

0.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.62
/src/main/java/org/fiware/iam/ServiceMapper.java
1
package org.fiware.iam;
2

3
import com.fasterxml.jackson.databind.ObjectMapper;
4
import io.github.wistefan.dcql.model.*;
5
import org.fiware.iam.ccs.model.*;
6
import org.fiware.iam.repository.*;
7
import org.fiware.iam.repository.Credential;
8
import org.mapstruct.Mapper;
9

10
import java.util.*;
11
import java.util.stream.Collectors;
12

13
import static org.fiware.iam.ccs.model.MetaDataQueryVO.*;
14

15
/**
16
 * Responsible for mapping entities from the Service api domain to the internal model.
17
 */
18
@Mapper(componentModel = "jsr330")
19
public interface ServiceMapper {
20

21
        static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
1✔
22

23
        default Service map(ServiceVO serviceVO) {
24
                if (serviceVO == null) {
1✔
25
                        return null;
×
26
                }
27
                Service service = new Service();
1✔
28
                service.setId(serviceVO.getId());
1✔
29
                service.setAuthorizationType(map(serviceVO.getAuthorizationType()));
1✔
30
                service.setDefaultOidcScope(serviceVO.getDefaultOidcScope());
1✔
31
                service.setOidcScopes(
1✔
32
                                serviceVO.getOidcScopes()
1✔
33
                                                .entrySet()
1✔
34
                                                .stream()
1✔
35
                                                .map(e -> {
1✔
36
                                                        ScopeEntry scopeEntry = new ScopeEntry();
1✔
37
                                                        scopeEntry.setScopeKey(e.getKey());
1✔
38
                                                        scopeEntry.setService(service);
1✔
39
                                                        scopeEntry.setCredentials(Optional.ofNullable(e.getValue().getCredentials()).
1✔
40
                                                                        orElse(List.of()).stream().map(this::map).toList());
1✔
41
                                                        scopeEntry.setPresentationDefinition(this.map(e.getValue().getPresentationDefinition()));
1✔
42
                                                        scopeEntry.setDcqlQuery(this.map(e.getValue().getDcql()));
1✔
43
                                                        return scopeEntry;
1✔
44
                                                })
45
                                                .toList());
1✔
46
                return service;
1✔
47
        }
48

49
        default ServiceVO map(Service service) {
50
                if (service == null) {
1✔
UNCOV
51
                        return null;
×
52
                }
53
                return new ServiceVO().id(service.getId())
1✔
54
                                .authorizationType(map(service.getAuthorizationType()))
1✔
55
                                .defaultOidcScope(service.getDefaultOidcScope())
1✔
56
                                .oidcScopes(this.toOidcScopes(service.getOidcScopes()));
1✔
57
        }
58

59
        default PresentationDefinition map(PresentationDefinitionVO presentationDefinitionVO) {
60
                if (presentationDefinitionVO == null) {
1✔
61
                        return null;
1✔
62
                }
63

64
                PresentationDefinition presentationDefinition = new PresentationDefinition();
1✔
65
                presentationDefinition.setId(presentationDefinitionVO.getId());
1✔
66
                presentationDefinition.setName(presentationDefinitionVO.getName());
1✔
67
                presentationDefinition.setPurpose(presentationDefinitionVO.getPurpose());
1✔
68
                presentationDefinition.setInputDescriptors(this.mapInputDescriptors(presentationDefinitionVO
1✔
69
                                .getInputDescriptors()));
1✔
70
                presentationDefinition.setFormat(this.mapFormatVO(presentationDefinitionVO
1✔
71
                                .getFormat()));
1✔
72

73
                return presentationDefinition;
1✔
74
        }
75

76
        default Collection<InputDescriptor> mapInputDescriptors(Collection<InputDescriptorVO> inputDescriptorVOS) {
77
                if (inputDescriptorVOS == null) {
1✔
UNCOV
78
                        return null;
×
79
                }
80
                return inputDescriptorVOS
1✔
81
                                .stream()
1✔
82
                                .map(this::mapInputDescriptorVO).toList();
1✔
83
        }
84

85
        default Collection<Format> mapFormatVO(Map<String, Object> formatsMap) {
86
                if (formatsMap == null) {
1✔
UNCOV
87
                        return null;
×
88
                }
89

90
                return formatsMap
1✔
91
                                .entrySet()
1✔
92
                                .stream()
1✔
93
                                .map(e -> {
1✔
94
                                        FormatObject formatObject = OBJECT_MAPPER.convertValue(e.getValue(), FormatObject.class);
1✔
95
                                        Format format = new Format();
1✔
96
                                        format.setFormatKey(e.getKey());
1✔
97
                                        format.setAlg(formatObject.getAlg());
1✔
98
                                        format.setProofType(formatObject.getProofType());
1✔
99
                                        return format;
1✔
100
                                }).toList();
1✔
101
        }
102

103
        default Map<String, Object> mapFormats(Collection<Format> formats) {
104
                if (formats == null) {
1✔
105
                        return null;
1✔
106
                }
107

108
                Map<String, Object> formatsMap = new HashMap<>();
1✔
109

110
                formats.stream()
1✔
111
                                .forEach(format -> {
1✔
112
                                        Map<String, Object> formatMap = new HashMap<>();
1✔
113
                                        Optional.ofNullable(format.getAlg()).ifPresent(algs -> formatMap.put("alg", algs));
1✔
114
                                        Optional.ofNullable(format.getProofType()).ifPresent(pt -> formatMap.put("proof_type", pt));
1✔
115
                                        formatsMap.put(format.getFormatKey(), formatMap);
1✔
116
                                });
1✔
117

118
                return formatsMap;
1✔
119
        }
120

121
        AuthorizationType map(ServiceVO.AuthorizationType authorizationType);
122

123
        ServiceVO.AuthorizationType map(AuthorizationType authorizationType);
124

125
        InputDescriptorVO mapInputDescriptor(InputDescriptor inputDescriptor);
126

127
        InputDescriptor mapInputDescriptorVO(InputDescriptorVO inputDescriptor);
128

129
        PresentationDefinitionVO map(PresentationDefinition presentationDefinition);
130

131
        TrustedParticipantsListEndpointVO.Type map(ListType type);
132

133
        ListType map(TrustedParticipantsListEndpointVO.Type type);
134

135
        default Map<String, ServiceScopesEntryVO> toOidcScopes(Collection<ScopeEntry> scopeEntries) {
136
                if (scopeEntries == null) {
1✔
UNCOV
137
                        return null;
×
138
                }
139
                Map<String, ServiceScopesEntryVO> scopes = new LinkedHashMap<>();
1✔
140
                scopeEntries
1✔
141
                                .forEach(entry -> {
1✔
142
                                        ServiceScopesEntryVO scopesEntryVO = new ServiceScopesEntryVO();
1✔
143
                                        scopesEntryVO.setPresentationDefinition(this.map(entry.getPresentationDefinition()));
1✔
144
                                        scopesEntryVO.setCredentials(this.map(entry.getCredentials()));
1✔
145
                                        scopesEntryVO.setDcql(this.map(entry.getDcqlQuery()));
1✔
146
                                        scopes.put(entry.getScopeKey(), scopesEntryVO);
1✔
147
                                });
1✔
148
                return scopes;
1✔
149
        }
150

151
        DCQLVO map(DcqlQuery dcqlQuery);
152

153
        DcqlQuery map(DCQLVO dcqlvo);
154

155
        default CredentialQuery map(CredentialQueryVO credentialQueryVO) {
156
                if (credentialQueryVO == null) {
1✔
UNCOV
157
                        return null;
×
158
                }
159
                CredentialQuery credentialQuery = new CredentialQuery();
1✔
160
                credentialQuery.setId(credentialQueryVO.getId());
1✔
161
                credentialQuery.setFormat(this.map(credentialQueryVO.getFormat()));
1✔
162
                credentialQuery.setMultiple(credentialQueryVO.getMultiple());
1✔
163
                credentialQuery.setClaims(Optional.ofNullable(credentialQueryVO.getClaims()).orElse(List.of())
1✔
164
                                .stream().map(this::map).toList());
1✔
165
                credentialQuery.setMeta(this.map(credentialQueryVO.getMeta()));
1✔
166
                credentialQuery.setRequireCryptographicHolderBinding(credentialQueryVO.getRequireCryptographicHolderBinding());
1✔
167
                credentialQuery.setClaimSets(credentialQueryVO.getClaimSets());
1✔
168
                credentialQuery.setTrustedAuthorities(Optional.ofNullable(credentialQueryVO.getTrustedAuthorities()).orElse(List.of())
1✔
169
                                .stream().map(this::map).toList());
1✔
170
                return credentialQuery;
1✔
171
        }
172

173
        default CredentialQueryVO map(CredentialQuery credentialQuery) {
174
                if (credentialQuery == null) {
1✔
UNCOV
175
                        return null;
×
176
                }
177
                CredentialQueryVO credentialQueryVO = new CredentialQueryVO();
1✔
178
                credentialQueryVO.setId(credentialQuery.getId());
1✔
179
                credentialQueryVO.setFormat(this.map(credentialQuery.getFormat()));
1✔
180
                credentialQueryVO.setMultiple(credentialQuery.getMultiple());
1✔
181
                credentialQueryVO.setClaims(Optional.ofNullable(credentialQuery.getClaims()).orElse(List.of())
1✔
182
                                .stream().map(this::map).toList());
1✔
183
                credentialQueryVO.setMeta(map(credentialQuery.getMeta()));
1✔
184
                credentialQueryVO.setRequireCryptographicHolderBinding(credentialQuery.getRequireCryptographicHolderBinding());
1✔
185
                credentialQueryVO.setClaimSets(credentialQuery.getClaimSets());
1✔
186
                credentialQueryVO.setTrustedAuthorities(Optional.ofNullable(credentialQuery.getTrustedAuthorities()).orElse(List.of())
1✔
187
                                .stream().map(this::map).toList());
1✔
188
                return credentialQueryVO;
1✔
189
        }
190

191
        TrustedAuthorityQueryVO map(TrustedAuthorityQuery trustedAuthorityQuery);
192

193
        TrustedAuthorityQuery map(TrustedAuthorityQueryVO trustedAuthorityQueryVO);
194

195
        default TrustedAuthorityType map(String type) {
196
                return TrustedAuthorityType.fromValue(type);
1✔
197
        }
198

199
        default String map(TrustedAuthorityType type) {
200
                return type.getValue();
1✔
201
        }
202

203
        default Map<String, Object> map(MetaDataQueryVO metaDataQueryVO) {
204
                if (metaDataQueryVO == null) {
1✔
UNCOV
205
                        return null;
×
206
                }
207
                Map<String, Object> metaMap = new HashMap<>();
1✔
208
                if (metaDataQueryVO.getVctValues() != null) {
1✔
209
                        metaMap.put(JSON_PROPERTY_VCT_VALUES, metaDataQueryVO.getVctValues());
1✔
210
                }
211
                if (metaDataQueryVO.getTypeValues() != null) {
1✔
212
                        metaMap.put(JSON_PROPERTY_TYPE_VALUES, metaDataQueryVO.getTypeValues());
1✔
213
                }
214
                if (metaDataQueryVO.getDoctypeValue() != null) {
1✔
215
                        metaMap.put(JSON_PROPERTY_DOCTYPE_VALUE, metaDataQueryVO.getDoctypeValue());
1✔
216
                }
217
                return metaMap;
1✔
218
        }
219

220
        default MetaDataQueryVO map(Map<String, Object> meta) {
221
                if (meta == null) {
1✔
UNCOV
222
                        return null;
×
223
                }
224
                MetaDataQueryVO metaDataQueryVO = new MetaDataQueryVO();
1✔
225
                if (meta.containsKey(JSON_PROPERTY_VCT_VALUES)) {
1✔
226
                        metaDataQueryVO.setVctValues((List<String>) meta.get(JSON_PROPERTY_VCT_VALUES));
1✔
227
                }
228
                if (meta.containsKey(JSON_PROPERTY_DOCTYPE_VALUE)) {
1✔
229
                        metaDataQueryVO.setDoctypeValue((String) meta.get(JSON_PROPERTY_DOCTYPE_VALUE));
1✔
230
                }
231
                if (meta.containsKey(JSON_PROPERTY_TYPE_VALUES)) {
1✔
232
                        metaDataQueryVO.setTypeValues((List<List<String>>) meta.get(JSON_PROPERTY_TYPE_VALUES));
1✔
233
                }
234
                return metaDataQueryVO;
1✔
235
        }
236

237
        ClaimsQuery map(ClaimsQueryVO claimsQueryVO);
238

239
        ClaimsQueryVO map(ClaimsQuery claimsQuery);
240

241
        CredentialQueryVO.Format map(CredentialFormat credentialFormat);
242

243
        CredentialFormat map(CredentialQueryVO.Format credentialFormat);
244

245
        CredentialSetQueryVO map(CredentialSetQuery credentialSetQuery);
246

247
        CredentialSetQuery map(CredentialSetQueryVO credentialSetQueryVO);
248

249
        default EndpointEntry stringToEndpointEntry(String url) {
250
                EndpointEntry entry = new EndpointEntry();
1✔
251
                entry.setType(EndpointType.TRUSTED_PARTICIPANTS);
1✔
252
                entry.setListType(ListType.EBSI);
1✔
253
                entry.setEndpoint(url);
1✔
254
                return entry;
1✔
255
        }
256

257
        default Credential map(CredentialVO credentialVO) {
258
                if (credentialVO == null) {
1✔
UNCOV
259
                        return null;
×
260
                }
261
                Credential credential = new Credential();
1✔
262
                credential.setCredentialType(credentialVO.getType());
1✔
263
                List<EndpointEntry> trustedList = new ArrayList<>();
1✔
264
                Optional.ofNullable(issuersToEntries(credentialVO.getTrustedIssuersLists())).ifPresent(trustedList::addAll);
1✔
265

266
                credentialVO.getTrustedParticipantsLists()
1✔
267
                                .forEach(tpl -> {
1✔
268
                                        if (tpl instanceof String tplS) {
1✔
269
                                                trustedList.add(stringToEndpointEntry(tplS));
1✔
270
                                        } else {
271
                                                trustedList.add(participantToEntry(OBJECT_MAPPER.convertValue(tpl, TrustedParticipantsListEndpointVO.class)));
1✔
272
                                        }
273
                                });
1✔
274

275
                credential.setTrustedLists(trustedList);
1✔
276

277
                if (credentialVO.getHolderVerification() != null) {
1✔
278
                        credential.setHolderClaim(credentialVO.getHolderVerification().getClaim());
1✔
279
                        credential.setVerifyHolder(credentialVO.getHolderVerification().getEnabled());
1✔
280
                } else {
281
                        credential.setVerifyHolder(false);
×
UNCOV
282
                        credential.setHolderClaim(null);
×
283
                }
284
                credential.setRequireCompliance(credentialVO.getRequireCompliance());
1✔
285
                credential.setJwtInclusion(map(credentialVO.getJwtInclusion()));
1✔
286
                return credential;
1✔
287
        }
288

289
        JwtInclusion map(JwtInclusionVO jwtInclusionVO);
290

291
        JwtInclusionVO map(JwtInclusion jwtInclusion);
292

293
        default List<CredentialVO> map(Collection<Credential> credentials) {
294
                if (credentials == null) {
1✔
UNCOV
295
                        return null;
×
296
                }
297
                return credentials.stream().map(this::map).toList();
1✔
298
        }
299

300
        default CredentialVO map(Credential credential) {
301
                if (credential == null) {
1✔
UNCOV
302
                        return null;
×
303
                }
304
                return new CredentialVO()
1✔
305
                                .type(credential.getCredentialType())
1✔
306
                                .trustedIssuersLists(entriesToIssuers(credential.getTrustedLists()))
1✔
307
                                .trustedParticipantsLists(entriesToParticipants(credential.getTrustedLists()).stream().map(Object.class::cast).toList())
1✔
308
                                .requireCompliance(credential.isRequireCompliance())
1✔
309
                                .jwtInclusion(map(credential.getJwtInclusion()))
1✔
310
                                .holderVerification(new HolderVerificationVO()
1✔
311
                                                .enabled(credential.isVerifyHolder())
1✔
312
                                                .claim(credential.getHolderClaim()));
1✔
313
        }
314

315
        /**
316
         * Map a list of TrustedParticipantsListVO-entries, to a list of {@link EndpointEntry} with
317
         * type {{@link EndpointType#TRUSTED_PARTICIPANTS}
318
         */
319
        default List<EndpointEntry> participantsToEntries(List<TrustedParticipantsListEndpointVO> endpoints) {
320
                if (endpoints == null) {
×
UNCOV
321
                        return null;
×
322
                }
323
                return endpoints.stream()
×
324
                                .map(endpoint -> {
×
325
                                        EndpointEntry entry = new EndpointEntry();
×
326
                                        entry.setEndpoint(endpoint.getUrl());
×
327
                                        entry.setListType(map(endpoint.getType()));
×
328
                                        entry.setType(EndpointType.TRUSTED_PARTICIPANTS);
×
UNCOV
329
                                        return entry;
×
330
                                })
UNCOV
331
                                .toList();
×
332
        }
333

334
        default EndpointEntry participantToEntry(TrustedParticipantsListEndpointVO trustedParticipantsListVO) {
335
                if (trustedParticipantsListVO == null) {
1✔
UNCOV
336
                        return null;
×
337
                }
338
                EndpointEntry entry = new EndpointEntry();
1✔
339
                entry.setEndpoint(trustedParticipantsListVO.getUrl());
1✔
340
                entry.setListType(map(trustedParticipantsListVO.getType()));
1✔
341
                entry.setType(EndpointType.TRUSTED_PARTICIPANTS);
1✔
342
                return entry;
1✔
343
        }
344

345
        /**
346
         * Map a list of string-entries, encoding TrustedIssuers endpoints to a list of {@link EndpointEntry} with
347
         * type {{@link EndpointType#TRUSTED_ISSUERS}
348
         */
349
        default List<EndpointEntry> issuersToEntries(List<String> endpoints) {
350
                if (endpoints == null) {
1✔
UNCOV
351
                        return null;
×
352
                }
353
                return endpoints.stream()
1✔
354
                                .map(endpoint -> {
1✔
355
                                        EndpointEntry entry = new EndpointEntry();
1✔
356
                                        entry.setEndpoint(endpoint);
1✔
357
                                        entry.setType(EndpointType.TRUSTED_ISSUERS);
1✔
358
                                        return entry;
1✔
359
                                })
360
                                .toList();
1✔
361
        }
362

363
        /**
364
         * Return issuer endpoints from the {@link EndpointEntry} list to a list of strings
365
         */
366
        default List<String> entriesToIssuers(List<EndpointEntry> endpoints) {
367
                if (endpoints == null) {
1✔
368
                        return List.of();
1✔
369
                }
370
                return endpoints.stream()
1✔
371
                                .filter(entry -> entry.getType().equals(EndpointType.TRUSTED_ISSUERS))
1✔
372
                                .map(EndpointEntry::getEndpoint)
1✔
373
                                .toList();
1✔
374
        }
375

376
        /**
377
         * Return participant endpoints from the {@link EndpointEntry} list to a list of strings
378
         */
379
        default List<TrustedParticipantsListEndpointVO> entriesToParticipants(List<EndpointEntry> endpoints) {
380
                if (endpoints == null) {
1✔
381
                        return List.of();
1✔
382
                }
383
                return endpoints.stream()
1✔
384
                                .filter(entry -> entry.getType().equals(EndpointType.TRUSTED_PARTICIPANTS))
1✔
385
                                .map(entry -> new TrustedParticipantsListEndpointVO()
1✔
386
                                                .type(map(entry.getListType()))
1✔
387
                                                .url(entry.getEndpoint()))
1✔
388
                                .toList();
1✔
389
        }
390

391
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc