Skip to content

Commit

Permalink
Improve logging, validations and documentation for operations controller
Browse files Browse the repository at this point in the history
  • Loading branch information
romanstrobl committed Nov 27, 2024
1 parent fbf7f6e commit 3682aa8
Show file tree
Hide file tree
Showing 20 changed files with 142 additions and 537 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.wultra.security.powerauth.client.model.enumeration.SignatureType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.util.LinkedHashMap;
Expand All @@ -34,12 +37,27 @@
@Data
public class OperationApproveRequest {

@Schema(description = "The identifier of the operation", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "Operation ID must not be empty when approving operation")
private String operationId;

@Schema(description = "The identifier of the user", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "User ID must not be empty when approving operation")
private String userId;

@Schema(description = "The identifier of the application", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "Application ID must not be empty when approving operation")
private String applicationId;

@Schema(description = "Operation data to approve", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "Data must not be empty when approving operation")
private String data;

@Schema(description = "PowerAuth signature type", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "Signature type must not be null when approving operation")
private SignatureType signatureType;

@Schema(description = "Additional data associated with the operation", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonSetter(nulls = Nulls.SKIP)
private final Map<String, Object> additionalData = new LinkedHashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;

Expand All @@ -35,8 +36,11 @@
@Data
public class OperationCancelRequest {

@Schema(description = "The identifier of the operation", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "Operation ID must not be empty when cancelling operation")
private String operationId;

@Schema(description = "Additional data associated with the operation", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonSetter(nulls = Nulls.SKIP)
private final Map<String, Object> additionalData = new LinkedHashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package com.wultra.security.powerauth.client.model.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

/**
Expand All @@ -31,11 +33,15 @@ public class OperationClaimRequest {
/**
* Operation identifier.
*/
@Schema(description = "The identifier of the operation", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "Operation ID must not be empty when requesting operation claim")
private String operationId;

/**
* User identifier of the user who is claiming the operation.
*/
@Schema(description = "The identifier of the user", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "User ID must not be empty when requesting operation claim")
private String userId;

}
Original file line number Diff line number Diff line change
@@ -1,48 +1,30 @@
/*
* PowerAuth Server and related software components
* Copyright (C) 2020 Wultra s.r.o.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.wultra.security.powerauth.client.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;

import java.util.*;

/**
* Request method for creating a new operation.
*
* @author Petr Dvorak, [email protected]
*/
@Data
public class OperationCreateRequest {

@Schema(description = "The identifier of the user", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@Size(min = 1, message = "User ID must not be empty when creating operation")
private String userId;

@Schema(description = "List of associated applications", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "Application ID list must not be null when creating operation")
@Size(min = 1, message = "Application ID list must not be empty when creating operation")
private List<String> applications = new ArrayList<>();

@Schema(description = "Activation flag associated with the operation", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String activationFlag;

@Schema(description = "Name of the template used for creating the operation", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "Template name must not be empty when creating operation")
private String templateName;

@Schema(description = "Timestamp of when the operation will expire, overrides expiration period from operation template", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
Expand All @@ -63,6 +45,6 @@ public class OperationCreateRequest {
private Boolean proximityCheckEnabled;

@Schema(description = "Activation ID. It is possible to specify a single device (otherwise all user's activations are taken into account).", requiredMode = Schema.RequiredMode.NOT_REQUIRED, maxLength = 37)
@Size(max = 37, message = "Activation ID must not exceed 37 characters when creating operation")
private String activationId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package com.wultra.security.powerauth.client.model.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

/**
Expand All @@ -28,6 +30,8 @@
@Data
public class OperationDetailRequest {

@Schema(description = "The identifier of the operation", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "Operation ID must not be empty when requesting operation detail")
private String operationId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

package com.wultra.security.powerauth.client.model.request;

import jakarta.validation.constraints.Min;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;

import java.util.ArrayList;
Expand All @@ -32,10 +33,18 @@
@Data
public class OperationExtIdRequest {

@Schema(description = "External identifier of the operation", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "External ID must not be empty when requesting operation lookup by external ID")
private String externalId;

@Schema(description = "Associated application identifiers", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "Application ID list must not be null when requesting operation lookup by external ID")
@Size(min = 1, message = "Application ID list must not be empty when requesting operation lookup by external ID")
private List<String> applications = new ArrayList<>();

@Min(0)
private Integer pageNumber;

@Min(1)
private Integer pageSize;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

import java.util.LinkedHashMap;
Expand All @@ -33,8 +35,11 @@
@Data
public class OperationFailApprovalRequest {

@Schema(description = "The identifier of the operation", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "Operation ID must not be empty when requesting operation approval failure")
private String operationId;

@Schema(description = "Additional data associated with the operation", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonSetter(nulls = Nulls.SKIP)
private final Map<String, Object> additionalData = new LinkedHashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

package com.wultra.security.powerauth.client.model.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.util.ArrayList;
Expand All @@ -32,12 +36,22 @@
@Data
public class OperationListForUserRequest {

@Schema(description = "The identifier of the user", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "User ID must not be empty when requesting operation list")
private String userId;

@Schema(description = "Associated application identifiers", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "Application ID list must not be null when requesting operation list")
@Size(min = 1, message = "Application ID list must not be empty when requesting operation list")
private List<String> applications = new ArrayList<>();

@Min(0)
private Integer pageNumber;

@Min(1)
private Integer pageSize;

@Schema(description = "The identifier of the activation", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String activationId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

import java.util.LinkedHashMap;
Expand All @@ -33,10 +35,19 @@
@Data
public class OperationRejectRequest {

@Schema(description = "The identifier of the operation", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "Operation ID must not be empty when rejecting operation")
private String operationId;

@Schema(description = "The identifier of the user", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "User ID must not be empty when rejecting operation")
private String userId;

@Schema(description = "The identifier of the application", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "Application ID must not be empty when rejecting operation")
private String applicationId;

@Schema(description = "Additional data associated with the operation", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonSetter(nulls = Nulls.SKIP)
private final Map<String, Object> additionalData = new LinkedHashMap<>();

Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3682aa8

Please sign in to comment.