forked from eclipse-tractusx/managed-identity-wallet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWalletControllerApiDocs.java
555 lines (542 loc) · 33.4 KB
/
WalletControllerApiDocs.java
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
package org.eclipse.tractusx.managedidentitywallets.apidocs;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
public class WalletControllerApiDocs {
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@RequestBody(content = {
@Content(examples = {
@ExampleObject(name = "Create wallet with BPN", value = """
{
"businessPartnerNumber": "BPNL000000000001",
"companyName": "companyA",
"didUrl": "portal.com:BPNL000000000001"
}
""")
})
})
@ApiResponses(value = {
@ApiResponse(responseCode = "400", description = "The input does not comply to the syntax requirements", content = {
@Content(examples = {
@ExampleObject(name = "Response in case of invalid data provided", value = """
{
"type": "about:blank",
"title": "Invalid data provided",
"status": 400,
"detail": "details",
"instance": "API endpoint",
"properties":
{
"timestamp": 1689760833962,
"errors":
{
"filed": "filed error message"
}
}
}
""")
})
}),
@ApiResponse(responseCode = "401", description = "The request could not be completed due to a failed authorization.", content = {
@Content(examples = {}) }),
@ApiResponse(responseCode = "403", description = "The request could not be completed due to a forbidden access", content = {
@Content(examples = {}) }),
@ApiResponse(responseCode = "409", description = "The request could not be completed due to a conflict.", content = {
@Content(examples = {
@ExampleObject(name = "Wallet already exist", value = """
{
"type": "about:blank",
"title": "Wallet is already exists for bpn BPNL000000000001",
"status": 409,
"detail": "Wallet is already exists for bpn BPNL000000000001",
"instance": "/api/wallets",
"properties": {
"timestamp": 1689762639948
}
}
""")
}) }),
@ApiResponse(responseCode = "500", description = "Any other internal server error", content = {
@Content(examples = {
@ExampleObject(name = "Internal server error", value = """
{
"type": "about:blank",
"title": "Error Title",
"status": 500,
"detail": "Error Details",
"instance": "API endpoint",
"properties": {
"timestamp": 1689762476720
}
}
""")
}) }),
@ApiResponse(responseCode = "201", content = {
@Content(examples = {
@ExampleObject(name = "Success response", value = """
{
"name": "companyA",
"did": "did:web:localhost:BPNL000000000001",
"bpn": "BPNL000000000501",
"algorithm": "ED25519",
"didDocument":
{
"@context":
[
"https://www.w3.org/ns/did/v1",
"https://w3c.github.io/vc-jws-2020/contexts/v1"
],
"id": "did:web:localhost:BPNL000000000001",
"verificationMethod":
[
{
"controller": "did:web:localhost:BPNL000000000001",
"id": "did:web:localhost:BPNL000000000001#key-1",
"publicKeyJwk":
{
"crv": "Ed25519",
"kty": "OKP",
"x": "0Ap6FsX5UuRBIoOzxWtcFA2ymnqXw0U08Ino_mIuYM4"
},
"type": "JsonWebKey2020"
},
{
"controller": "did:web:localhost:BPNL000000000001",
"id": "did:web:localhost:BPNL000000000001#key-2",
"publicKeyJwk":
{
"crv": "secp256k1",
"kty": "EC",
"x": "f9PkTOpsbcgKe_-s6bNCve3-aB1VZAFsCub8C5bhDn0",
"y": "xH1d7jCFavolGVZtaWcZZGP2nLuEsamDCotD56llxUk"
},
"type": "JsonWebKey2020"
}
]
}
}
""")
})
})
})
@Operation(summary = "Create Wallet", description = "Permission: **add_wallets** (The BPN of the base wallet must equal BPN of caller)\n\n Create a wallet and store it", security = { @SecurityRequirement(name = "Authenticate using access_token") })
public @interface CreateWalletApiDoc {
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Operation(summary = "Store Verifiable Credential", description = "Permission: **update_wallets** OR **update_wallet** (The BPN of wallet to extract credentials from must equal BPN of caller) \n\n Store a verifiable credential in the wallet of the given identifier", security = { @SecurityRequirement(name = "Authenticate using access_token") })
@RequestBody(content = {
@Content(examples = @ExampleObject("""
{
"@context":
[
"https://www.w3.org/2018/credentials/v1",
"https://registry.lab.gaia-x.eu/development/api/trusted-shape-registry/v1/shapes/jsonld/trustframework#"
],
"id": "did:web:localhost.in#123456789",
"type":
[
"VerifiableCredential", "LegalParticipant"
],
"issuer": "did:web:localhost.in",
"issuanceDate": "2023-05-04T07:36:03.633Z",
"credentialSubject":
{
"id": "https://localhost/.well-known/participant.json",
"type": "gx:LegalParticipant",
"gx:legalName": "Sample Company",
"gx:legalRegistrationNumber":
{
"gx:taxID": "113123123"
},
"gx:headquarterAddress":
{
"gx:countrySubdivisionCode": "BE-BRU"
},
"gx:legalAddress":
{
"gx:countrySubdivisionCode": "BE-BRU"
},
"gx-terms-and-conditions:gaiaxTermsAndConditions": "70c1d713215f95191a11d38fe2341faed27d19e083917bc8732ca4fea4976700"
},
"proof":
{
"type": "JsonWebSignature2020",
"created": "2023-05-04T07:36:04.079Z",
"proofPurpose": "assertionMethod",
"verificationMethod": "did:web:localhost",
"jws": "eyJhbGciOiJQUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..iHki8WC3nPfcSRkC_AV4tXh0ikfT7BLPTGc_0ecI8zontTmJLqwcpPfAt0PFsoo3SkZgc6j636z55jj5tagBc-OKoiDu7diWryNAnL9ASsmWJyrPhOKVARs6x6PxVaTFBuyCfAHZeipxmkcYfNB_jooIXO2HuRcL2odhsQHELkGc5IDD-aBMWyNpfVAaYQ-cCzvDflZQlsowziUKfMkBfwpwgMdXFIgKWYdDIRvzA-U-XiC11-6QV7tPeKsMguEU0F5bh8cCEm2rooqXtENcsM_7cqFdQoOyblJyM-agoz2LUTj9QIdn9_gnNkGN-2U7_qBJWmHkK1Hm_mHqcNeeQw"
}
}
"""))
})
@ApiResponses(value = {
@ApiResponse(responseCode = "401", description = "The request could not be completed due to a failed authorization.", content = {
@Content(examples = {}) }),
@ApiResponse(responseCode = "403", description = "The request could not be completed due to a forbidden access", content = {
@Content(examples = {}) }),
@ApiResponse(responseCode = "500", description = "Any other internal server error", content = {
@Content(examples = {
@ExampleObject(name = "Internal server error", value = """
{
"type": "about:blank",
"title": "Error Title",
"status": 500,
"detail": "Error Details",
"instance": "API endpoint",
"properties": {
"timestamp": 1689762476720
}
}
""")
}) }),
@ApiResponse(responseCode = "400", description = "The input does not comply to the syntax requirements", content = {
@Content(examples = {
@ExampleObject(name = "Response in case of invalid data provided", value = """
{
"type": "about:blank",
"title": "title",
"status": 400,
"detail": "details",
"instance": "API endpoint",
"properties":
{
"timestamp": 1689760833962,
"errors":
{
}
}
}
""")
})
}),
@ApiResponse(responseCode = "404", description = "Wallet not found with provided identifier", content = {
@Content(examples = {
@ExampleObject(name = "Wallet not found with provided identifier", value = """
{
"type": "about:blank",
"title": "Wallet not found for identifier did:web:localhost:BPNL000000044001",
"status": 404,
"detail": "Wallet not found for identifier did:web:localhost:BPNL000000044001",
"instance": "/api/wallets/did%3Aweb%3Alocalhost%3ABPNL0000000/credentials",
"properties": {
"timestamp": 1689765541959
}
}
""")
}) }),
@ApiResponse(responseCode = "201", description = "Success Response", content = { @Content(examples = {
@ExampleObject(name = "Success Response", value = """
{
"message": "Credential with id did:web:localhost#123456789 has been successfully stored"
}
""")
})
})
})
public @interface StoreVerifiableCredentialApiDoc {
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@ApiResponses(value = {
@ApiResponse(responseCode = "401", description = "The request could not be completed due to a failed authorization.", content = {
@Content(examples = {}) }),
@ApiResponse(responseCode = "403", description = "The request could not be completed due to a forbidden access", content = {
@Content(examples = {}) }),
@ApiResponse(responseCode = "500", description = "Any other internal server error", content = {
@Content(examples = {
@ExampleObject(name = "Internal server error", value = """
{
"type": "about:blank",
"title": "Error Title",
"status": 500,
"detail": "Error Details",
"instance": "API endpoint",
"properties": {
"timestamp": 1689762476720
}
}
""")
}) }),
@ApiResponse(responseCode = "400", description = "The input does not comply to the syntax requirements", content = {
@Content(examples = {
@ExampleObject(name = "Response in case of invalid data provided", value = """
{
"type": "about:blank",
"title": "title",
"status": 400,
"detail": "details",
"instance": "API endpoint",
"properties":
{
"timestamp": 1689760833962,
"errors":
{
}
}
}
""")
})
}),
@ApiResponse(responseCode = "404", description = "Wallet not found with provided identifier", content = {
@Content(examples = {
@ExampleObject(name = "Wallet not found with provided identifier", value = """
{
"type": "about:blank",
"title": "Wallet not found for identifier did:web:localhost:BPNL0000000501",
"status": 404,
"detail": "Wallet not found for identifier did:web:localhost:BPNL0000000501",
"instance": "/api/wallets/did%3Aweb%3Alocalhost%3ABPNL0000000501",
"properties": {
"timestamp": 1689764377224
}
}
""")
}) }),
@ApiResponse(responseCode = "200", description = "Wallet Details", content = { @Content(examples = {
@ExampleObject(name = "Wallet details without with credentials false", value = """
{
"name": "companyA",
"did": "did:web:localhost:BPNL000000000001",
"bpn": "BPNL000000000001",
"algorithm": "ED25519",
"didDocument":
{
"@context":
[
"https://www.w3.org/ns/did/v1",
"https://w3c.github.io/vc-jws-2020/contexts/v1"
],
"id": "did:web:localhost:BPNL000000000001",
"verificationMethod":
[
{
"controller": "did:web:localhost:BPNL000000000001",
"id": "did:web:localhost:BPNL000000000001#",
"publicKeyJwk":
{
"crv": "Ed25519",
"kty": "OKP",
"x": "mhph0ZSVk7cDVmazbaaC3jBDpphW4eNygAK9gHPlMow"
},
"type": "JsonWebKey2020"
}
]
}
}
"""),
@ExampleObject(name = "Wallet details without with credentials true", value = """
{
"name": "companyA",
"did": "did:web:localhost:BPNL000000000001",
"bpn": "BPNL000000000001",
"algorithm": "ED25519",
"didDocument":
{
"@context":
[
"https://www.w3.org/ns/did/v1",
"https://w3c.github.io/vc-jws-2020/contexts/v1"
],
"id": "did:web:localhost:BPNL000000000001",
"verificationMethod":
[
{
"controller": "did:web:localhost:BPNL000000000001",
"id": "did:web:localhost:BPNL000000000001#",
"publicKeyJwk":
{
"crv": "Ed25519",
"kty": "OKP",
"x": "mhph0ZSVk7cDVmazbaaC3jBDpphW4eNygAK9gHPlMow"
},
"type": "JsonWebKey2020"
}
]
},
"verifiableCredentials":
[
{
"@context":
[
"https://www.w3.org/2018/credentials/v1",
"https://catenax-ng.github.io/product-core-schemas/businessPartnerData.json",
"https://w3id.org/security/suites/jws-2020/v1"
],
"id": "did:web:localhost:BPNL000000000000#a1f8ae36-9919-4ed8-8546-535280acc5bf",
"type":
[
"VerifiableCredential",
"BpnCredential"
],
"issuer": "did:web:localhost:BPNL000000000000",
"issuanceDate": "2023-07-19T09:14:45Z",
"expirationDate": "2023-09-30T18:30:00Z",
"credentialSubject":
[
{
"bpn": "BPNL000000000001",
"id": "did:web:localhost:BPNL000000000001",
"type": "BpnCredential"
}
],
"proof":
{
"created": "2023-07-19T09:14:47Z",
"jws": "eyJhbGciOiJFZERTQSJ9..O69dLGMDVgZQJ7chFx3aUbkJFvibH8WWunw634rIDC77_pdiUHvQpQ0hq15_7OgFMy3dp-9H-pNgxTZ-i4UXCw",
"proofPurpose": "proofPurpose",
"type": "JsonWebSignature2020",
"verificationMethod": "did:web:localhost:BPNL000000000000#"
}
}
]
}
""")
}) }) })
@Operation(summary = "Retrieve wallet by BPN", description = "Permission: **view_wallets** OR **view_wallet** (The BPN of Wallet to retrieve must equal the BPN of caller or Base wallet, authority wallet can see all wallets) \n\n Retrieve single wallet by identifier, with or without its credentials", security = { @SecurityRequirement(name = "Authenticate using access_token") })
public @interface RetrieveWalletApiDoc {
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@ApiResponses(value = {
@ApiResponse(responseCode = "401", description = "The request could not be completed due to a failed authorization.", content = {
@Content(examples = {}) }),
@ApiResponse(responseCode = "403", description = "The request could not be completed due to a forbidden access", content = {
@Content(examples = {}) }),
@ApiResponse(responseCode = "500", description = "Any other internal server error", content = {
@Content(examples = {
@ExampleObject(name = "Internal server error", value = """
{
"type": "about:blank",
"title": "Error Title",
"status": 500,
"detail": "Error Details",
"instance": "API endpoint",
"properties": {
"timestamp": 1689762476720
}
}
""")
}) }),
@ApiResponse(responseCode = "400", description = "The input does not comply to the syntax requirements", content = {
@Content(examples = {
@ExampleObject(name = "Response in case of invalid data provided", value = """
{
"type": "about:blank",
"title": "title",
"status": 400,
"detail": "details",
"instance": "API endpoint",
"properties":
{
"timestamp": 1689760833962,
"errors":
{
}
}
}
""")
})
}),
@ApiResponse(responseCode = "200", description = "Wallet list", content = {
@Content(examples = {
@ExampleObject(name = "Wallet list", value = """
{
"content": [
{
"name": "companyA",
"did": "did:web:localhost:BPNL000000000001",
"bpn": "BPNL000000000001",
"algorithm": "ED25519",
"didDocument": {
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3c.github.io/vc-jws-2020/contexts/v1"
],
"id": "did:web:localhost:BPNL000000000001",
"verificationMethod": [
{
"controller": "did:web:localhost:BPNL000000000001",
"id": "did:web:localhost:BPNL000000000001#",
"publicKeyJwk": {
"crv": "Ed25519",
"kty": "OKP",
"x": "mhph0ZSVk7cDVmazbaaC3jBDpphW4eNygAK9gHPlMow"
},
"type": "JsonWebKey2020"
}
]
}
}
],
"pageable": {
"sort": {
"empty": false,
"sorted": true,
"unsorted": false
},
"offset": 0,
"pageNumber": 0,
"pageSize": 1,
"paged": true,
"unpaged": false
},
"totalElements": 3,
"totalPages": 3,
"last": false,
"size": 1,
"number": 0,
"sort": {
"empty": false,
"sorted": true,
"unsorted": false
},
"first": true,
"numberOfElements": 1,
"empty": false
}
""")
})
})
})
@Operation(summary = "List of wallets", description = "Permission: **view_wallets** \n\n Retrieve list of registered wallets", security = { @SecurityRequirement(name = "Authenticate using access_token") })
public @interface RetrieveWalletsApiDoc {
}
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Parameter(name = "pageNumber", description = "Page number, Page number start with zero")
public @interface PageNumberParameterDoc {
}
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Parameter(name = "size", description = "Number of records per page")
public @interface SizeParameterDoc {
}
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Parameter(name = "sortColumn", description = "Sort column name", examples = {
@ExampleObject(value = "createdAt", name = "Creation date"),
@ExampleObject(value = "name", name = "Wallet name"),
@ExampleObject(value = "did", name = "Wallet did"),
@ExampleObject(value = "bpn", name = "Wallet BPN")
})
public @interface SortColumnParameterDoc {
}
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Parameter(name = "sortTpe", description = "Sort order", examples = {
@ExampleObject(value = "desc", name = "Descending order"),
@ExampleObject(value = "asc", name = "Ascending order") })
public @interface SortTypeParameterDoc {
}
}