Skip to content

Commit

Permalink
fix(config-ap): lock audit endpoint parameter declaration error#9460 (#…
Browse files Browse the repository at this point in the history
…9473)

* fix(config-api): asset mgt endpoint fixes

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): asset upload mgt ehancement and fido

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): asset upload mgt ehancement and fido

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): asset upload mgt ehancement and fido

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(config-api): asset upload

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(config-api): lock review comments

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): lock code review comments

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): lock master renamed to lock server

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): lock master renamed to lock server

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): lock master renamed to lock server

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): lock master renamed to lock server

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): fido2 delete functionality

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(config-api): acr validation

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): doc(config-api): IDP schema attribute descriptions #9187

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): sync with main

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): uploading assets via API generates 2 entries #9178

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): asset mgt, fido and IDP changes

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): fido2 device endpoint

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): fido2 endpoint

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): fido2 endpoint

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): sync with main

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): sync with main

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): sync with main

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): resolved sonar review issues

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): sonar review comment fix

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): swagger spec

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): saml config attribute description

Signed-off-by: pujavs <pujas.works@gmail.com>

* doc(config-api): added SAML attribute description

Signed-off-by: pujavs <pujas.works@gmail.com>

* doc(config-api): added SAML attribute description

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): sync with main

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(jans-lock): code review comment fix isssue#9305

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(jans-lock): code review comment fix isssue#9305

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): lock review point

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(lock): code review comment

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(lock): code review comment

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(config-api): sync with main

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): lock endpoint fixes and SAML IDP NPE

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): asset enhancement

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): implement timer for asset mgt to fetch and deploy assets forconfig-api #9403

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(config-api): scope validation issue #9426

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(config-api): asset delete error fix

Signed-off-by: pujavs <pujas.works@gmail.com>

* feat(config-api): sysnc with main

Signed-off-by: pujavs <pujas.works@gmail.com>

* fix(config-ap): lock audit endpoint parameter declaration error#9460

Signed-off-by: pujavs <pujas.works@gmail.com>

---------

Signed-off-by: pujavs <pujas.works@gmail.com>
Former-commit-id: 404b5bb
  • Loading branch information
pujavs authored Sep 12, 2024
1 parent b65ec75 commit e3ca0d2
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 77 deletions.
16 changes: 8 additions & 8 deletions jans-config-api/docs/jans-config-api-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -10807,10 +10807,10 @@ components:
ttl:
type: integer
format: int32
opbrowserState:
type: string
persisted:
type: boolean
opbrowserState:
type: string
SessionIdAccessMap:
type: object
properties:
Expand Down
12 changes: 6 additions & 6 deletions jans-config-api/plugins/docs/lock-plugin-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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 }))
Expand Down Expand Up @@ -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<HealthEntry> entries = auditService.getHealthEntrysByRange(eventStartDate, eventEndDate, limit);
return Response.ok(entries).build();
}
Expand Down Expand Up @@ -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<LogEntry> entries = auditService.getLogEntrysByRange(eventStartDate, eventEndDate, limit);
return Response.ok(entries).build();
}
Expand Down Expand Up @@ -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<TelemetryEntry> entries = auditService.getTelemetryEntrysByRange(eventStartDate, eventEndDate, limit);
return Response.ok(entries).build();
}
Expand Down

0 comments on commit e3ca0d2

Please sign in to comment.