diff --git a/jans-config-api/docs/jans-config-api-swagger.yaml b/jans-config-api/docs/jans-config-api-swagger.yaml index 4da61322d11..04ce0a05b82 100644 --- a/jans-config-api/docs/jans-config-api-swagger.yaml +++ b/jans-config-api/docs/jans-config-api-swagger.yaml @@ -8370,20 +8370,20 @@ components: type: string selected: type: boolean - adminCanEdit: + whitePagesCanView: + type: boolean + userCanView: type: boolean userCanEdit: type: boolean adminCanView: type: boolean - userCanView: + adminCanEdit: type: boolean adminCanAccess: type: boolean userCanAccess: type: boolean - whitePagesCanView: - type: boolean baseDn: type: string PatchRequest: @@ -10371,14 +10371,14 @@ components: type: boolean internal: type: boolean + locationPath: + type: string locationType: type: string enum: - ldap - db - file - locationPath: - type: string baseDn: type: string ScriptError: @@ -10807,10 +10807,10 @@ components: ttl: type: integer format: int32 - opbrowserState: - type: string persisted: type: boolean + opbrowserState: + type: string SessionIdAccessMap: type: object properties: diff --git a/jans-config-api/plugins/docs/lock-plugin-swagger.yaml b/jans-config-api/plugins/docs/lock-plugin-swagger.yaml index 8c786b27e1a..c73fafa5705 100644 --- a/jans-config-api/plugins/docs/lock-plugin-swagger.yaml +++ b/jans-config-api/plugins/docs/lock-plugin-swagger.yaml @@ -32,13 +32,13 @@ paths: format: int32 default: 50 - name: eventStartDate - in: path + in: query description: Event start date in ISO8601 format required: true schema: type: string - name: eventEndtDate - in: path + in: query description: Event end date in ISO8601 format required: true schema: @@ -77,13 +77,13 @@ paths: format: int32 default: 50 - name: eventStartDate - in: path + in: query description: Event start date in ISO8601 format required: true schema: type: string - name: eventEndtDate - in: path + in: query description: Event end date in ISO8601 format required: true schema: @@ -122,13 +122,13 @@ paths: format: int32 default: 50 - name: eventStartDate - in: path + in: query description: Event start date in ISO8601 format required: true schema: type: string - name: eventEndtDate - in: path + in: query description: Event end date in ISO8601 format required: true schema: diff --git a/jans-config-api/plugins/lock-plugin/src/main/java/io/jans/configapi/plugin/lock/rest/AuditResource.java b/jans-config-api/plugins/lock-plugin/src/main/java/io/jans/configapi/plugin/lock/rest/AuditResource.java index ac4d88a0bec..16a2fcaa3e1 100644 --- a/jans-config-api/plugins/lock-plugin/src/main/java/io/jans/configapi/plugin/lock/rest/AuditResource.java +++ b/jans-config-api/plugins/lock-plugin/src/main/java/io/jans/configapi/plugin/lock/rest/AuditResource.java @@ -6,12 +6,6 @@ package io.jans.configapi.plugin.lock.rest; -import java.util.Date; -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; - import io.jans.as.common.service.common.ApplicationFactory; import io.jans.configapi.core.model.ApiError; import io.jans.configapi.core.rest.BaseResource; @@ -23,6 +17,7 @@ import io.jans.configapi.plugin.lock.util.Constants; import io.jans.configapi.util.ApiConstants; import io.jans.orm.PersistenceEntryManager; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.ArraySchema; @@ -31,6 +26,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; + import jakarta.inject.Inject; import jakarta.inject.Named; import jakarta.validation.Valid; @@ -40,27 +36,37 @@ import jakarta.ws.rs.GET; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; +import java.util.Date; +import java.util.List; + +import org.slf4j.Logger; + + @Path(Constants.AUDIT) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public class AuditResource extends BaseResource { + private static final String EVENT_START_DATE_ISO8601 = "eventStartDateIso8601"; + private static final String EVENT_END_DATE_ISO8601 = "eventEndDateIso8601"; + private static final String EVENT_START_DATE_PARSE_ERR = "Can't parse event start date !"; + private static final String EVENT_END_DATE_PARSE_ERR = "Can't parse event end date !"; + @Inject Logger logger; @Inject AuditService auditService; - + @Inject @Named(ApplicationFactory.PERSISTENCE_ENTRY_MANAGER_NAME) PersistenceEntryManager persistenceEntryManager; - + @Operation(summary = "Save health data", description = "Save health data", operationId = "save-health-data", tags = { "Lock - Audit" }, security = @SecurityRequirement(name = "oauth2", scopes = { Constants.LOCK_HEALTH_WRITE_ACCESS })) @@ -91,29 +97,22 @@ public Response postHealthData(@Valid HealthEntry healthEntry) { @Path(Constants.HEALTH + ApiConstants.EVENT_RANGE_PATH) @ProtectedApi(scopes = { Constants.LOCK_HEALTH_READ_ACCESS }) public Response getHealthEntrysByRange( - @Parameter(description = "Search size - max size of the results to return") @DefaultValue(ApiConstants.DEFAULT_LIST_SIZE) @QueryParam(value = ApiConstants.LIMIT) int limit, - @Parameter(description = "Event start date in ISO8601 format") @PathParam("eventStartDate") @NotNull String eventStartDateIso8601, - @Parameter(description = "Event end date in ISO8601 format") @PathParam("eventEndtDate") @NotNull String eventEndDateIso8601) { + @Parameter(description = "Search size - max size of the results to return") @DefaultValue(ApiConstants.DEFAULT_LIST_SIZE) @QueryParam(value = ApiConstants.LIMIT) int limit, + @Parameter(description = "Event start date in ISO8601 format") @QueryParam("eventStartDate") @NotNull String eventStartDateIso8601, + @Parameter(description = "Event end date in ISO8601 format") @QueryParam("eventEndtDate") @NotNull String eventEndDateIso8601) { logger.debug("Get Health entries by by event range"); - if (StringUtils.isBlank(eventStartDateIso8601)) { - throwBadRequestException("Event start date should not be null or empty !"); - } + checkNotNull(eventStartDateIso8601, EVENT_START_DATE_ISO8601); + checkNotNull(eventEndDateIso8601, EVENT_END_DATE_ISO8601); - if (StringUtils.isBlank(eventEndDateIso8601)) { - throwBadRequestException("Event end date should not be null or empty !"); - } + Date eventStartDate = persistenceEntryManager.decodeTime(auditService.getDnForHealthEntry(null), + eventStartDateIso8601); + checkResourceNotNull(eventStartDate, EVENT_START_DATE_PARSE_ERR); - Date eventStartDate = persistenceEntryManager.decodeTime(auditService.getDnForHealthEntry(null), eventStartDateIso8601); - if (eventStartDate == null) { - throwBadRequestException("Can't parse event start date !"); - } + Date eventEndDate = persistenceEntryManager.decodeTime(auditService.getDnForHealthEntry(null), + eventEndDateIso8601); + checkResourceNotNull(eventEndDate, EVENT_END_DATE_PARSE_ERR); - Date eventEndDate = persistenceEntryManager.decodeTime(auditService.getDnForHealthEntry(null), eventEndDateIso8601); - if (eventEndDate == null) { - throwBadRequestException("Can't parse event end date !"); - } - List entries = auditService.getHealthEntrysByRange(eventStartDate, eventEndDate, limit); return Response.ok(entries).build(); } @@ -148,29 +147,22 @@ public Response postLogData(@Valid LogEntry logEntry) { @Path(Constants.LOG + ApiConstants.EVENT_RANGE_PATH) @ProtectedApi(scopes = { Constants.LOCK_LOG_READ_ACCESS }) public Response getLogEntrysByRange( - @Parameter(description = "Search size - max size of the results to return") @DefaultValue(ApiConstants.DEFAULT_LIST_SIZE) @QueryParam(value = ApiConstants.LIMIT) int limit, - @Parameter(description = "Event start date in ISO8601 format") @PathParam("eventStartDate") @NotNull String eventStartDateIso8601, - @Parameter(description = "Event end date in ISO8601 format") @PathParam("eventEndtDate") @NotNull String eventEndDateIso8601) { + @Parameter(description = "Search size - max size of the results to return") @DefaultValue(ApiConstants.DEFAULT_LIST_SIZE) @QueryParam(value = ApiConstants.LIMIT) int limit, + @Parameter(description = "Event start date in ISO8601 format") @QueryParam("eventStartDate") @NotNull String eventStartDateIso8601, + @Parameter(description = "Event end date in ISO8601 format") @QueryParam("eventEndtDate") @NotNull String eventEndDateIso8601) { logger.debug("Get Log entries by by event range"); - if (StringUtils.isBlank(eventStartDateIso8601)) { - throwBadRequestException("Event start date should not be null or empty !"); - } + checkNotNull(eventStartDateIso8601, EVENT_START_DATE_ISO8601); + checkNotNull(eventEndDateIso8601, EVENT_END_DATE_ISO8601); - if (StringUtils.isBlank(eventEndDateIso8601)) { - throwBadRequestException("Event end date should not be null or empty !"); - } + Date eventStartDate = persistenceEntryManager.decodeTime(auditService.getDnForLogEntry(null), + eventStartDateIso8601); + checkResourceNotNull(eventStartDate, EVENT_START_DATE_PARSE_ERR); - Date eventStartDate = persistenceEntryManager.decodeTime(auditService.getDnForLogEntry(null), eventStartDateIso8601); - if (eventStartDate == null) { - throwBadRequestException("Can't parse event start date !"); - } + Date eventEndDate = persistenceEntryManager.decodeTime(auditService.getDnForLogEntry(null), + eventEndDateIso8601); + checkResourceNotNull(eventEndDate, EVENT_END_DATE_PARSE_ERR); - Date eventEndDate = persistenceEntryManager.decodeTime(auditService.getDnForLogEntry(null), eventEndDateIso8601); - if (eventEndDate == null) { - throwBadRequestException("Can't parse event end date !"); - } - List entries = auditService.getLogEntrysByRange(eventStartDate, eventEndDate, limit); return Response.ok(entries).build(); } @@ -204,29 +196,22 @@ public Response postTelemetryData(@Valid TelemetryEntry telemetryEntry) { @Path(Constants.TELEMETRY + ApiConstants.EVENT_RANGE_PATH) @ProtectedApi(scopes = { Constants.LOCK_TELEMETRY_READ_ACCESS }) public Response getTelemetryEntrysByRange( - @Parameter(description = "Search size - max size of the results to return") @DefaultValue(ApiConstants.DEFAULT_LIST_SIZE) @QueryParam(value = ApiConstants.LIMIT) int limit, - @Parameter(description = "Event start date in ISO8601 format") @PathParam("eventStartDate") @NotNull String eventStartDateIso8601, - @Parameter(description = "Event end date in ISO8601 format") @PathParam("eventEndtDate") @NotNull String eventEndDateIso8601) { + @Parameter(description = "Search size - max size of the results to return") @DefaultValue(ApiConstants.DEFAULT_LIST_SIZE) @QueryParam(value = ApiConstants.LIMIT) int limit, + @Parameter(description = "Event start date in ISO8601 format") @QueryParam("eventStartDate") @NotNull String eventStartDateIso8601, + @Parameter(description = "Event end date in ISO8601 format") @QueryParam("eventEndtDate") @NotNull String eventEndDateIso8601) { logger.debug("Get Telemetry entries by by event range"); - if (StringUtils.isBlank(eventStartDateIso8601)) { - throwBadRequestException("Event start date should not be null or empty !"); - } + checkNotNull(eventStartDateIso8601, EVENT_START_DATE_ISO8601); + checkNotNull(eventEndDateIso8601, EVENT_END_DATE_ISO8601); - if (StringUtils.isBlank(eventEndDateIso8601)) { - throwBadRequestException("Event end date should not be null or empty !"); - } + Date eventStartDate = persistenceEntryManager.decodeTime(auditService.getDnForTelemetryEntry(null), + eventStartDateIso8601); + checkResourceNotNull(eventStartDate, EVENT_START_DATE_PARSE_ERR); - Date eventStartDate = persistenceEntryManager.decodeTime(auditService.getDnForTelemetryEntry(null), eventStartDateIso8601); - if (eventStartDate == null) { - throwBadRequestException("Can't parse event start date !"); - } + Date eventEndDate = persistenceEntryManager.decodeTime(auditService.getDnForTelemetryEntry(null), + eventEndDateIso8601); + checkResourceNotNull(eventEndDate, EVENT_END_DATE_PARSE_ERR); - Date eventEndDate = persistenceEntryManager.decodeTime(auditService.getDnForTelemetryEntry(null), eventEndDateIso8601); - if (eventEndDate == null) { - throwBadRequestException("Can't parse event end date !"); - } - List entries = auditService.getTelemetryEntrysByRange(eventStartDate, eventEndDate, limit); return Response.ok(entries).build(); }