-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpom.xml
772 lines (677 loc) · 36.8 KB
/
pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>dk.statsbiblioteket.sbprojects</groupId>
<artifactId>sbprojects-parent</artifactId>
<version>80</version>
</parent>
<groupId>dk.kb.license</groupId>
<artifactId>ds-license</artifactId>
<version>1.5.3-SNAPSHOT</version>
<packaging>war</packaging>
<description>
# Ds-license(Digitale Samlinger) by the Royal Danish Library.
## Ds-license restricts access to items in collections based on the user credential information.
The primary method in Ds-license is to filter a list of IDs (recordIds) and only return the subset
ID's that the user has access to based in the user information. Access can be restricted
to a presentationtype value. (Download,Search etc.) The filtering is done against a Solr server with all information about the
records. The application has a GUI interface to define all access rules based on user attributes.
## User attributes
The User attributes is key-value pairs, where the values can be a list and a user can have multiple key-value pairs.
All values and keys are strings. The key-values pairs can be WAYF attributes (https://www.wayf.dk/) which is a
standard for describing users at educational institutions and will have some guarateed values always. But the GUI administration
can define arbitarity key-value rules and not just WAYF attributes. All user atttribute keys must be define in
the GUI and they will be available for use when defining a license attribute-group.
### Examples of UserAttributes (WAYF)
| key | values | Remark |
| ----------------------------| ---------------------------|-------------------------------------------------|
| SBIPRolemapper | inhouse,kb | inhouse(local computer), kb (organisation) |
| mail | [email protected] | Can be used to give individual access |
| shachHomeOrganisation | ku.dk | Educational institution |
| eduPersonPrimaryAffiliation | stud | Student. (staff, employee,faculty also values) |
## Packages (pakker) and restrictions (klausulering)
The packages and restrictions are the building blocks that gives access to materials. In
the UML they are both groups, but on the GUI they will be seen as two seperate entities.
Packages gives access to materials (positive Solr filter) while restrictions
forbid access (negative Solr filter). The more packages groups a user validates will give more materials and more validated restrictions will
also give more materials since this will remove the negative filter. The restrictions negative filters are always applied unless
the user validates access to them and that restriction will be removed. Some materials can be locked under several different
restrictions and all must validate before the user can access it. Giving a user access
to a restriction will not mean the user can see all the restricted material. He can still only see what
the packages give access too and the restricted material within those packages.
Whenever a new restriction is added to the configuration it will take immediate effect and block all access for all users.
To give access to the new restriction a licence needed to be edited and configure access to that restriction.
### Example of access with two groups
Group 1 (package): lma_long:"radio"
Group 2 (restriction): klausuleret:"ja"
If the user has acesss to both groups, the final filter query will be: **lma_long:"radio"**
If the user has only access to the first group, the final filter query will be: **lma_long:"radio" -klausuleret:"ja"**
### Example of access with four groups
The normal groups filter queries will be OR'ed.
Group 1 (package): lma_long:"tv"
Group 2 (package): lma_long:"radio"
Group 3 (restriction): klausuleret:"ja"
Group 4 (restiction): individuelt_forbud:"ja"
If the user has access to group 1,2 and 3 the filter query will be: **(lma_long:"radio" OR lma_long"tv") -individuelt_forbud:"ja"**
## Licences
Licenses are the mapping from UserAttributes to groups/packages. One license can give access to several groups.
For each group a license gives access to, the license must also specify a presentation type (or several) for that group.
Presentation types are also defined in the GUI and examples of presentation types are:Stream,Search.Download,Thumbnails,Headlines.
### Licenses structure
A license must define a valid from date and valid to date and is only valid in the date interval. The format is dd-mm-yyyy.
A license has to defines one or more attribute-groups. An attribute-group is mapping from UserAttributes keys to values.
An attribute-group can define several mappings and every single mapping in the attribute group has to validate for the attribute-group to validate, which will
then validate the whole license.So a license can have several attribute groups and just one of them has to validate for the whole license to validate.
The reason you can define several attribute-groups in one license is to avoid defining many identical licences that gives
access to same material but by different conditions.
### License validation algoritm
First the validation check will limit to licenses that are valid for the date of the requests. Then for each license every
attributed group will be checked. If just one of the attribute groups validates then the license validates.
The license will give access to the groups (pakker) defined for the license, but restricted to the presentationtype (Download etc.)
Every license that validate will give access to more material.
All the allow groups will each expand the positive filter query used for filtering Ids. All restriction-group validated will remove
the negative filter blocked by that restriction-group. See 'uml/License_validation_logic.png' for a visualisation
of the validation logic for a license.
## UML model
The UML diagram can be found in the /uml/licensemodule_uml.png folder. The database persistence model and object layer is a
direct implementation of the UML model, except for some naming. The UML model is created using DIA and the project file is also in the folder.
### UML model explained
There are 3 general type classes that can be maintained and the values are configured are used when defining a license.
It is not possible to delete a configuration value if it is used in a license.
## Configuration of the Ds-license
### Property: solr.servers
The configuration requires at least one Solr server for the property 'solr.servers'.
When filtering IDs all Solr servers will be called for filtering and each will be called with all IDs.
### Property: solr.idField
The Solr field used for filtering. Multivalued fields allowed. This field must exist in the schema for the Solr servers.
Example:
If the filter field is 'id' and the filter query generated by from the package is 'subject:danmark'
Then the query will be (id:id1 OR id:id2 OR id:id3..) AND (subject:Denmark). Solr will return documents that is a
subset of the ID's asked for. And this is what happens in the id-filtering.
### Properties: url,driver,username,password
The 4 database properties (JDBC) must be defined: url,driver,username,password
A PostGreSql database is recommended when not running locally. The database tables must be created before use with
DDL file: test/resources/ddl/licensemodule_create_db.ddl
## API
While there are many methods exposed through the API only the following two are necessary for integrating License module into the software stack.
#### checkAccessForIds
This is the method that takes the UserAttributes and a list of IDs. The return value will be the IDs that was not removed in the filtering
and those that the user has access to. The method is called every time a user tries to access or search materials.
#### getUserLicenses
Method only takes the userattributes and returns a list of licences that the userattributes give access to. For each license
the name, validFrom,ValidTo and a description will be returned. This information can be shown to the user.
Developed and maintained by the Royal Danish Library.
</description>
<repositories>
<repository>
<id>sbforge-nexus</id>
<url>https://sbforge.org/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<scm>
<url>https://github.com/kb-dk/ds-license</url>
<connection>scm:git:[email protected]:kb-dk/ds-license.git</connection>
<developerConnection>scm:git:[email protected]:kb-dk/ds-license.git</developerConnection>
<tag>HEAD</tag>
</scm>
<licenses>
<!--SBForge stuff should have a license-->
<license>
<name>${license.name}</name>
<url>${license.url}</url>
</license>
</licenses>
<properties>
<!-- Specify java version here, to support forbiddenapis plugin -->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<!-- Enable forbiddenapis plugin, do disable set to none -->
<api.check.phase>process-test-classes</api.check.phase>
<!--Specify the licenses here, so they can be picked up by openAPI-->
<license.name>Apache License, Version 2.0</license.name>
<license.url>https://www.apache.org/licenses/LICENSE-2.0.txt</license.url>
<timestamp>${maven.build.timestamp}</timestamp>
<project.package>dk.kb.license</project.package>
</properties>
<dependencies>
<dependency>
<groupId>dk.kb.util</groupId>
<artifactId>kb-util</artifactId>
<version>1.5.11</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>4.0.2</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
<!-- Used for DsLicenseClient -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>3.1.8</version>
</dependency>
<!-- Apache CXF and servlet stuff -->
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<!-- Latest version is 4.0.3. Not tested -->
<version>3.6.4</version>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-xml-provider</artifactId>
<version>2.10.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openapitools/jackson-databind-nullable
Used for OpenAPI client generation -->
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- database -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.8.jre7</version>
</dependency>
<dependency>
<groupId>dk.statsbiblioteket.sbutil</groupId>
<artifactId>sbutil-common</artifactId>
<version>0.5.56</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>4.4.0</version>
</dependency>
<!--For the standard unit test-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.1.212</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>8.5.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<!-- Latest version is 4.0.3. Not tested -->
<version>3.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description</artifactId>
<!-- Latest version is 4.0.3. Not tested -->
<version>3.6.2</version>
</dependency>
<dependency>
<!--For the openapi endpoint /openapi.json-->
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
<!-- Latest version is 4.0.3. Not tested -->
<version>3.6.2</version>
</dependency>
<dependency>
<!--For the swagger UI endpoint /api-docs?url=openapi.json-->
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>5.9.0</version>
</dependency>
<!-- OAuth support -->
<!-- https://mvnrepository.com/artifact/org.keycloak/keycloak-core -->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>24.0.1</version>
<exclusions>
<exclusion>
<!-- mockserver-junit-jupiter has 1.1, but transitive resolving has 1.2.2 somewhere-->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- openapitools dependency -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<exclusions>
<exclusion>
<artifactId>jsr311-api</artifactId>
<groupId>javax.ws.rs</groupId>
</exclusion>
<exclusion>
<!-- swagger-jaxrs has 1.1.0.Final, but transitive resolving has 2.0.2 somewhere-->
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</exclusion>
</exclusions>
<version>1.5.23</version>
</dependency>
<!-- To get date parsing to work? -->
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-modules-java8 -->
<!-- <dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-modules-java8</artifactId>
<version>2.13.1</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>-->
<!-- To get client generation to work -->
<!-- https://mvnrepository.com/artifact/org.openapitools/openapi-generator -->
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator</artifactId>
<version>7.1.0</version>
<exclusions>
<exclusion>
<!-- The slf4j-simple logs to stderr and stdout, ignoring logback.xml -->
<artifactId>slf4j-simple</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- Logging dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.11</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.14</version>
</dependency>
<!-- Unit test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mock-server/mockserver-junit-jupiter -->
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-junit-jupiter</artifactId>
<version>5.15.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider -->
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/openapi</directory>
<filtering>true</filtering>
</resource>
<!-- Needed as specifying <resources> overrides all previous definitions -->
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<!-- 2: Copy only build.properties with filtering -->
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>ds-license.build.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<!--This ensures that the openapi_*.yaml have been filtered and copied to target/classes
BEFORE being used by the openapi generator above-->
<phase>generate-sources</phase>
<!--as both the openapi codegen and this execution happens at phase generate-sources, ensure
this happens first by having this placed above codegen in the pom-->
<goals>
<goal>resources</goal>
</goals>
</execution>
<execution>
<id>copy-resources</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/jetty-res</outputDirectory>
<resources>
<resource>
<directory>src/test/jetty</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.2.2</version>
<!-- Running this gives
[WARNING] The value (generator's option) must be either boolean or string. Default to `false`.
which seems to be an unresolved issue: https://github.com/OpenAPITools/openapi-generator/issues/9008 -->
<configuration>
<!-- https://openapi-generator.tech/docs/generators/java/ -->
<generatorName>jaxrs-cxf-extended</generatorName>
<inputSpec>${project.build.outputDirectory}/openapi.yaml</inputSpec><!-- Will always be overridden -->
<modelNameSuffix>Dto</modelNameSuffix>
<generateSupportingFiles>false</generateSupportingFiles>
<generateApiTests>false</generateApiTests>
<generateModelDocumentation>true</generateModelDocumentation>
<generateApis>true</generateApis>
<output>${project.basedir}</output>
<templateDirectory>src/main/templates/</templateDirectory>
<configOptions>
<withXml>true</withXml> <!-- Needed for XML serialization support in the Model -->
<!--https://openapi-generator.tech/docs/generators/jaxrs-cxf-extended/-->
<sourceFolder>target/generated-sources</sourceFolder>
<useSwaggerFeature>true</useSwaggerFeature>
<useSwaggerUI>true</useSwaggerUI>
<apiPackage>${project.package}.api</apiPackage>
<modelPackage>${project.package}.model.v1</modelPackage>
<!--<dateLibrary>threetenbp</dateLibrary>-->
<!--<dateLibrary>Java11</dateLibrary>-->
<implFolder>src/main/java</implFolder>
<invokerPackage>${project.package}</invokerPackage>
</configOptions>
<packageName>${project.package}</packageName>
</configuration>
<executions>
<!-- Version 1 -->
<!-- When a new version is needed, make a copy of three v1-related executions below, then change
v1 to v2 in the copy.
Go to plugin.configuration.webResources.resource.includes in this pom.xml and extend the list
with v2 versions of the JSON & YAML files.
Also remember to:
* Create dk.kb.license.webservice.Application_v2
* Create src/main/openapi/openapi_v2.yaml
* Update src/main/webapp/WEB-INF/web.xml
* Update src/main/webapp/api/index.html
-->
<execution>
<!-- Generate API file from the OpenAPI specification (positioned under the target/generated-sources/ folder).
These files are overwritten on all builds, so they should never be edited manually. -->
<id>v1: Generate api classes</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.outputDirectory}/ds-license-openapi_v1.yaml</inputSpec>
<ignoreFileOverride>
${project.basedir}/.openapi-codegen-ignore-api
</ignoreFileOverride>
<configOptions>
<apiPackage>${project.package}.api.v1</apiPackage>
<modelPackage>${project.package}.model.v1</modelPackage>
<!-- Setting this to true overwrites existing implementations.
Only set it temporarily when creating a new project -->
<generateOperationBody>false</generateOperationBody>
<sourceFolder>target/generated-sources</sourceFolder>
</configOptions>
</configuration>
</execution>
<execution>
<!-- The purpose is to generate skeleton implementation classes, if such classes are not already existing.
Since we always want to overwrite existing api & model-files when the OpenAPI specification is changed,
but never want to overwrite existing implementation-files, we need to do the generation in 2 steps. -->
<id>v1: Generate skeleton impl</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.outputDirectory}/ds-license-openapi_v1.yaml</inputSpec>
<ignoreFileOverride>${project.basedir}/.openapi-codegen-ignore-impl</ignoreFileOverride>
<configOptions>
<apiPackage>${project.package}.api.v1</apiPackage>
<modelPackage>${project.package}.model.v1</modelPackage>
<generateOperationBody>true</generateOperationBody>
</configOptions>
<skipOverwrite>true</skipOverwrite>
</configuration>
</execution>
<execution>
<!-- Generate model files from the OpenAPI specification (positioned under the target/generated-sources/ folder).
Note that this generator used the "java" implementation instead of the default.
This is in order to get XML annotations used when generating XML responses.
These files are overwritten on all builds, so they should never be edited manually. -->
<id>v1: Generate models classes</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.outputDirectory}/ds-license-openapi_v1.yaml</inputSpec>
<ignoreFileOverride>${project.basedir}/.openapi-codegen-ignore-model</ignoreFileOverride>
<generatorName>java</generatorName>
<configOptions>
<generateOperationBody>false</generateOperationBody>
</configOptions>
</configuration>
</execution>
<!-- Client for the backend -->
<execution>
<id>Generate client for JAR package and use by other services</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.outputDirectory}/ds-license-openapi_v1.yaml</inputSpec>
<ignoreFileOverride>${project.basedir}/.openapi-codegen-ignore-api</ignoreFileOverride>
<generatorName>java</generatorName>
<library>native</library>
<!-- Do not generate doc or tests for this client, we will handle this ourselves-->
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModels>false</generateModels>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<!-- Ensure ONLY the ApiClient and supporting classes are created, not the gradle mess-->
<generateSupportingFiles>true</generateSupportingFiles>
<supportingFilesToGenerate>ApiClient.java,ApiException.java,Configuration.java,Pair.java</supportingFilesToGenerate>
<!-- Do NOT use the customised templates as they are only for the webservice part, not the client-->
<!-- Hacked by Asger by setting to an existing folder without templates -->
<templateDirectory>src/main/</templateDirectory>
<configOptions>
<apiPackage>${project.package}.client.v1</apiPackage>
<modelPackage>${project.package}.model.v1</modelPackage>
<invokerPackage>${project.package}.invoker.v1</invokerPackage>
<sourceFolder>target/generated-sources</sourceFolder>
<implFolder>target/generated-sources</implFolder>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<!-- The generated classes for the OpenAPI client are problematic. Disable checking of those for now -->
<plugin>
<groupId>de.thetaphi</groupId>
<artifactId>forbiddenapis</artifactId>
<!-- No version or configuration here as it inherits from parent pom -->
<configuration>
<excludes>
<exclude>**/DsLicenseApi.class</exclude>
<exclude>**/ServiceApi.class</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<!-- Shared configuration -->
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
<!-- Generate a JAR with client classes and openapi-YAML for easy use by other services -->
<attachClasses>true</attachClasses>
<!--Enable maven filtering for the web.xml-->
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
<webResources>
<webResource> <!-- Store application name, version and build time -->
<directory>${basedir}/src/main/resources/</directory>
<includes>
<include>ds-license.build.properties</include>
</includes>
<filtering>true</filtering>
</webResource>
<resource>
<!--Include the openapi spec files so we can serve them-->
<directory>${project.build.outputDirectory}</directory>
<targetPath>.</targetPath>
<includes>
<include>ds-license-openapi_v1.json</include>
<include>ds-license-openapi_v1.yaml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<!-- Used only for mvn jetty:run jetty:run-war -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>10.0.12</version>
<configuration>
<deployMode>FORK</deployMode>
<jvmArgs>-Xmx256m -Djetty.port=9076</jvmArgs>
<jettyXmls>${project.basedir}/target/jetty-res/jetty-env.xml</jettyXmls>
<useTestScope>true</useTestScope>
<!-- https://www.eclipse.org/jetty/documentation/jetty-10/programming-guide/index.html#jetty-run-goal -->
<!-- https://stackoverflow.com/questions/12493798/jetty-maven-plugin-using-scan -->
<scan>2</scan>
<webApp>
<contextPath>/${project.artifactId}/</contextPath>
<descriptor>${project.basedir}/target/${project.build.finalName}/WEB-INF/web.xml</descriptor>
<jettyEnvXml>${project.basedir}/target/jetty-res/jetty-env.xml</jettyEnvXml>
</webApp>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<tarLongFileMode>posix</tarLongFileMode>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<!-- Plugin used to extract information on the current git setup.
See: https://github.com/git-commit-id/git-commit-id-maven-plugin -->
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>7.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<includeOnlyProperties>
<includeOnlyProperty>git.commit.id</includeOnlyProperty>
<includeOnlyProperty>git.branch</includeOnlyProperty>
<includeOnlyProperty>git.closest.tag.name</includeOnlyProperty>
<includeOnlyProperty>git.commit.author.time</includeOnlyProperty>
</includeOnlyProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>