|
44 | 44 | @Path("/auditlog") |
45 | 45 | public class AuditLogResource { |
46 | 46 |
|
| 47 | + private static final Set<String> EVENT_TYPES = Set.of(DeviceRegisteredEvent.TYPE, DeviceRemovedEvent.TYPE, UserAccountResetEvent.TYPE, UserKeysChangeEvent.TYPE, UserSetupCodeChangeEvent.TYPE, |
| 48 | + SettingWotUpdateEvent.TYPE, SignedWotIdEvent.TYPE, VaultCreatedEvent.TYPE, VaultUpdatedEvent.TYPE, VaultAccessGrantedEvent.TYPE, |
| 49 | + VaultKeyRetrievedEvent.TYPE, VaultMemberAddedEvent.TYPE, VaultMemberRemovedEvent.TYPE, VaultMemberUpdatedEvent.TYPE, VaultOwnershipClaimedEvent.TYPE); |
| 50 | + |
47 | 51 | @Inject |
48 | 52 | AuditEvent.Repository auditEventRepo; |
49 | 53 | @Inject |
@@ -78,17 +82,16 @@ public List<AuditEventDto> getAllEvents(@QueryParam("startDate") Instant startDa |
78 | 82 | throw new BadRequestException("pageSize must be between 1 and 100"); |
79 | 83 | } else if (type == null) { |
80 | 84 | throw new BadRequestException("type must be specified"); |
81 | | - } else if (!type.isEmpty()) { |
82 | | - var validTypes = Set.of(DeviceRegisteredEvent.TYPE, DeviceRemovedEvent.TYPE, UserAccountResetEvent.TYPE, UserKeysChangeEvent.TYPE, UserSetupCodeChangeEvent.TYPE, |
83 | | - SettingWotUpdateEvent.TYPE, SignedWotIdEvent.TYPE, VaultCreatedEvent.TYPE, VaultUpdatedEvent.TYPE, VaultAccessGrantedEvent.TYPE, |
84 | | - VaultKeyRetrievedEvent.TYPE, VaultMemberAddedEvent.TYPE, VaultMemberRemovedEvent.TYPE, VaultMemberUpdatedEvent.TYPE, VaultOwnershipClaimedEvent.TYPE); |
85 | | - if (!validTypes.containsAll(type)) { |
86 | | - throw new BadRequestException("Invalid event type provided"); |
87 | | - } |
88 | 85 | } else if (paginationId == null) { |
89 | 86 | throw new BadRequestException("paginationId must be specified"); |
90 | 87 | } |
91 | 88 |
|
| 89 | + if (!type.isEmpty()) { |
| 90 | + if (!EVENT_TYPES.containsAll(type)) { |
| 91 | + throw new BadRequestException("Invalid event type provided"); |
| 92 | + } |
| 93 | + } |
| 94 | + |
92 | 95 | return auditEventRepo.findAllInPeriod(startDate, endDate, type, paginationId, order.equals("asc"), pageSize).map(AuditEventDto::fromEntity).toList(); |
93 | 96 | } |
94 | 97 |
|
|
0 commit comments