Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1702: Use Enum Instead of String for Callback URL Type #1710

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 59 additions & 58 deletions docs/WebServices-Methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -1392,17 +1392,17 @@ REST endpoint: `POST /rest/v3/application/callback/create`

`CreateCallbackUrlRequest`

| Type | Name | Description |
|----------------|------|-------------|
| `String` | `applicationId` | Associated application ID. |
| `String` | `name` | Callback URL name, for visual identification. |
| `String` | `type` | Type of the callback. Either `ACTIVATION_STATUS_CHANGE` or `OPERATION_STATUS_CHANGE`. |
| `String` | `callbackUrl` | Callback URL that should be notified about activation status updates. |
| `List<String>` | `attributes` | Attributes which should be sent with the callback. See possible attributes bellow. |
| `String` | `authentication` | Callback HTTP request authentication configuration. |
| `Duration` | `retentionPeriod` | Duration in ISO 8601 duration format after which a completed callback event is automatically removed from database. |
| `Duration` | `initialBackoff` | Initial delay in ISO 8601 duration format before retry attempt following a callback event failure, if retries are enabled. |
| `Integer` | `maxAttempts` | Maximum number of attempts to send a callback event. |
| Type | Name | Description |
|-------------------|------|-------------|
| `String` | `applicationId` | Associated application ID. |
| `String` | `name` | Callback URL name, for visual identification. |
| `CallbackUrlType` | `type` | Type of the callback. Either `ACTIVATION_STATUS_CHANGE` or `OPERATION_STATUS_CHANGE`. |
| `String` | `callbackUrl` | Callback URL that should be notified about activation status updates. |
| `List<String>` | `attributes` | Attributes which should be sent with the callback. See possible attributes bellow. |
| `String` | `authentication` | Callback HTTP request authentication configuration. |
| `Duration` | `retentionPeriod` | Duration in ISO 8601 duration format after which a completed callback event is automatically removed from database. |
| `Duration` | `initialBackoff` | Initial delay in ISO 8601 duration format before retry attempt following a callback event failure, if retries are enabled. |
| `Integer` | `maxAttempts` | Maximum number of attempts to send a callback event. |

When creating a callback URL of type `ACTIVATION_STATUS_CHANGE`, following `attributes` can be used:

Expand Down Expand Up @@ -1467,17 +1467,18 @@ The `authentication` parameter contains a JSON-based configuration for client TL

`CreateCallbackUrlResponse`

| Type | Name | Description |
|----------------|------|-------------|
| `String` | `id` | Callback URL identifier (UUID4). |
| `String` | `applicationId` | Associated application ID. |
| `String` | `name` | Callback URL name, for visual identification. |
| `String` | `callbackUrl` | Callback URL that should be notified about activation status updates. |
| `List<String>` | `attributes` | Attributes which should be sent with the callback. |
| `String` | `authentication` | Callback HTTP request authentication configuration. |
| `Duration` | `retentionPeriod` | Duration in ISO 8601 duration format after which a completed callback event is automatically removed from database. |
| `Duration` | `initialBackoff` | Initial delay in ISO 8601 duration format before retry attempt following a callback event failure, if retries are enabled. |
| `Integer` | `maxAttempts` | Maximum number of attempts to send a callback event. |
| Type | Name | Description |
|-------------------|------|-------------|
| `String` | `id` | Callback URL identifier (UUID4). |
| `String` | `applicationId` | Associated application ID. |
| `String` | `name` | Callback URL name, for visual identification. |
| `CallbackUrlType` | `type` | Type of the callback. Either `ACTIVATION_STATUS_CHANGE` or `OPERATION_STATUS_CHANGE`. |
| `String` | `callbackUrl` | Callback URL that should be notified about activation status updates. |
| `List<String>` | `attributes` | Attributes which should be sent with the callback. |
| `String` | `authentication` | Callback HTTP request authentication configuration. |
| `Duration` | `retentionPeriod` | Duration in ISO 8601 duration format after which a completed callback event is automatically removed from database. |
| `Duration` | `initialBackoff` | Initial delay in ISO 8601 duration format before retry attempt following a callback event failure, if retries are enabled. |
| `Integer` | `maxAttempts` | Maximum number of attempts to send a callback event. |

### Method 'updateCallbackUrl'

Expand All @@ -1489,18 +1490,18 @@ REST endpoint: `POST /rest/v3/application/callback/update`

`UpdateCallbackUrlRequest`

| Type | Name | Description |
|----------------|------|-------------|
| `String` | `id` | Callback URL identifier (UUID4). |
| `String` | `applicationId` | Associated application ID. |
| `String` | `type` | Type of the callback. Either `ACTIVATION_STATUS_CHANGE` or `OPERATION_STATUS_CHANGE`. |
| `String` | `name` | Callback URL name, for visual identification. |
| `String` | `callbackUrl` | Callback URL that should be notified about activation status updates. |
| `List<String>` | `attributes` | Attributes which should be sent with the callback. See possible attributes bellow. |
| `String` | `authentication` | Callback HTTP request authentication configuration. |
| `Duration` | `retentionPeriod` | Duration in ISO 8601 duration format after which a completed callback event is automatically removed from database. |
| `Duration` | `initialBackoff` | Initial delay in ISO 8601 duration format before retry attempt following a callback event failure, if retries are enabled. |
| `Integer` | `maxAttempts` | Maximum number of attempts to send a callback event. |
| Type | Name | Description |
|-------------------|------|-------------|
| `String` | `id` | Callback URL identifier (UUID4). |
| `String` | `applicationId` | Associated application ID. |
| `CallbackUrlType` | `type` | Type of the callback. Either `ACTIVATION_STATUS_CHANGE` or `OPERATION_STATUS_CHANGE`. |
| `String` | `name` | Callback URL name, for visual identification. |
| `String` | `callbackUrl` | Callback URL that should be notified about activation status updates. |
| `List<String>` | `attributes` | Attributes which should be sent with the callback. See possible attributes bellow. |
| `String` | `authentication` | Callback HTTP request authentication configuration. |
| `Duration` | `retentionPeriod` | Duration in ISO 8601 duration format after which a completed callback event is automatically removed from database. |
| `Duration` | `initialBackoff` | Initial delay in ISO 8601 duration format before retry attempt following a callback event failure, if retries are enabled. |
| `Integer` | `maxAttempts` | Maximum number of attempts to send a callback event. |

When configuring a callback URL of type `ACTIVATION_STATUS_CHANGE`, following `attributes` can be used:

Expand Down Expand Up @@ -1566,18 +1567,18 @@ The `authentication` parameter contains a JSON-based configuration for client TL

`UpdateCallbackUrlResponse`

| Type | Name | Description |
|----------------|------|-------------|
| `String` | `id` | Callback URL identifier (UUID4). |
| `String` | `applicationId` | Associated application ID. |
| `String` | `name` | Callback URL name, for visual identification. |
| `String` | `type` | Type of the callback. Either `ACTIVATION_STATUS_CHANGE` or `OPERATION_STATUS_CHANGE`. |
| `String` | `callbackUrl` | Callback URL that should be notified about activation status updates. |
| `List<String>` | `attributes` | Attributes which should be sent with the callback. |
| `String` | `authentication` | Callback HTTP request authentication configuration. |
| `Duration` | `retentionPeriod` | Duration in ISO 8601 duration format after which a completed callback event is automatically removed from database. |
| `Duration` | `initialBackoff` | Initial delay in ISO 8601 duration format before retry attempt following a callback event failure, if retries are enabled. |
| `Integer` | `maxAttempts` | Maximum number of attempts to send a callback event. |
| Type | Name | Description |
|-------------------|------|-------------|
| `String` | `id` | Callback URL identifier (UUID4). |
| `String` | `applicationId` | Associated application ID. |
| `String` | `name` | Callback URL name, for visual identification. |
| `CallbackUrlType` | `type` | Type of the callback. Either `ACTIVATION_STATUS_CHANGE` or `OPERATION_STATUS_CHANGE`. |
| `String` | `callbackUrl` | Callback URL that should be notified about activation status updates. |
| `List<String>` | `attributes` | Attributes which should be sent with the callback. |
| `String` | `authentication` | Callback HTTP request authentication configuration. |
| `Duration` | `retentionPeriod` | Duration in ISO 8601 duration format after which a completed callback event is automatically removed from database. |
| `Duration` | `initialBackoff` | Initial delay in ISO 8601 duration format before retry attempt following a callback event failure, if retries are enabled. |
| `Integer` | `maxAttempts` | Maximum number of attempts to send a callback event. |

### Method 'getCallbackUrlList'

Expand All @@ -1603,18 +1604,18 @@ REST endpoint: `POST /rest/v3/application/callback/list`

`GetCallbackUrlListResponse.CallbackUrlList`

| Type | Name | Description |
|----------------|------|-------------|
| `String` | `id` | Callback URL identifier (UUID4). |
| `String` | `applicationId` | Associated application ID. |
| `String` | `name` | Callback URL name, for visual identification. |
| `String` | `type` | Type of the callback. Either `ACTIVATION_STATUS_CHANGE` or `OPERATION_STATUS_CHANGE`. |
| `String` | `callbackUrl` | Callback URL that should be notified about activation status updates. |
| `List<String>` | `attributes` | Attributes which should be sent with the callback. |
| `String` | `authentication` | Callback HTTP request authentication configuration. |
| `Duration` | `retentionPeriod` | Duration in ISO 8601 duration format after which a completed callback event is automatically removed from database. |
| `Duration` | `initialBackoff` | Initial delay in ISO 8601 duration format before retry attempt following a callback event failure, if retries are enabled. |
| `Integer` | `maxAttempts` | Maximum number of attempts to send a callback event. |
| Type | Name | Description |
|-------------------|------|-------------|
| `String` | `id` | Callback URL identifier (UUID4). |
| `String` | `applicationId` | Associated application ID. |
| `String` | `name` | Callback URL name, for visual identification. |
| `CallbackUrlType` | `type` | Type of the callback. Either `ACTIVATION_STATUS_CHANGE` or `OPERATION_STATUS_CHANGE`. |
| `String` | `callbackUrl` | Callback URL that should be notified about activation status updates. |
| `List<String>` | `attributes` | Attributes which should be sent with the callback. |
| `String` | `authentication` | Callback HTTP request authentication configuration. |
| `Duration` | `retentionPeriod` | Duration in ISO 8601 duration format after which a completed callback event is automatically removed from database. |
| `Duration` | `initialBackoff` | Initial delay in ISO 8601 duration format before retry attempt following a callback event failure, if retries are enabled. |
| `Integer` | `maxAttempts` | Maximum number of attempts to send a callback event. |

### Method 'removeCallbackUrl'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.wultra.security.powerauth.client.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.wultra.security.powerauth.client.model.enumeration.CallbackUrlType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

Expand All @@ -36,7 +37,7 @@ public class CallbackUrl {
private String id;
private String applicationId;
private String name;
private String type;
private CallbackUrlType type;
private String callbackUrl;
private List<String> attributes = new ArrayList<>();
private HttpAuthenticationPublic authentication = new HttpAuthenticationPublic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
package com.wultra.security.powerauth.client.model.request;

import com.wultra.security.powerauth.client.model.entity.HttpAuthenticationPrivate;
import com.wultra.security.powerauth.client.model.enumeration.CallbackUrlType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.time.DurationMin;

Expand All @@ -43,8 +45,8 @@ public class CreateCallbackUrlRequest {
@NotBlank
private String name;

@NotBlank
private String type;
@NotNull
private CallbackUrlType type;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Shouldn't it be reflected in WebServices-Methods.md?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, added now


@NotBlank
private String callbackUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
package com.wultra.security.powerauth.client.model.request;

import com.wultra.security.powerauth.client.model.entity.HttpAuthenticationPrivate;
import com.wultra.security.powerauth.client.model.enumeration.CallbackUrlType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.time.DurationMin;

Expand All @@ -46,8 +48,8 @@ public class UpdateCallbackUrlRequest {
@NotBlank
private String name;

@NotBlank
private String type;
@NotNull
private CallbackUrlType type;

@NotBlank
private String callbackUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import com.wultra.security.powerauth.client.model.entity.HttpAuthenticationPublic;
import com.wultra.security.powerauth.client.model.enumeration.CallbackUrlType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

Expand All @@ -38,6 +39,7 @@ public class CreateCallbackUrlResponse {
private String id;
private String applicationId;
private String name;
private CallbackUrlType type;
private String callbackUrl;
private List<String> attributes = new ArrayList<>();
private HttpAuthenticationPublic authentication = new HttpAuthenticationPublic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import com.wultra.security.powerauth.client.model.entity.HttpAuthenticationPublic;
import com.wultra.security.powerauth.client.model.enumeration.CallbackUrlType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import lombok.Data;
Expand All @@ -40,7 +41,7 @@ public class UpdateCallbackUrlResponse {
private String id;
private String applicationId;
private String name;
private String type;
private CallbackUrlType type;
private String callbackUrl;
private List<String> attributes = new ArrayList<>();
private HttpAuthenticationPublic authentication = new HttpAuthenticationPublic();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* PowerAuth Server and related software components
* Copyright (C) 2024 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 io.getlime.security.powerauth.app.server.converter;

import io.getlime.security.powerauth.app.server.database.model.enumeration.CallbackUrlType;

/**
* Convertor between CallbackUrlType from client model and CallbackUrlType from database model.
*
* @author Jan Pesek, jan.pesek@wultra.com
*/
public final class CallbackUrlTypeConverter {

public static CallbackUrlType convert(com.wultra.security.powerauth.client.model.enumeration.CallbackUrlType src) {
if (src == null) {
return null;
}

return switch (src) {
case ACTIVATION_STATUS_CHANGE -> CallbackUrlType.ACTIVATION_STATUS_CHANGE;
case OPERATION_STATUS_CHANGE -> CallbackUrlType.OPERATION_STATUS_CHANGE;
};
}

public static com.wultra.security.powerauth.client.model.enumeration.CallbackUrlType convert(CallbackUrlType src) {
if (src == null) {
return null;
}

return switch (src) {
case ACTIVATION_STATUS_CHANGE -> com.wultra.security.powerauth.client.model.enumeration.CallbackUrlType.ACTIVATION_STATUS_CHANGE;
case OPERATION_STATUS_CHANGE -> com.wultra.security.powerauth.client.model.enumeration.CallbackUrlType.OPERATION_STATUS_CHANGE;
};
}

}
Loading