Skip to content

Commit

Permalink
Merge pull request #1573 from /issues/1572-json-null
Browse files Browse the repository at this point in the history
Fix #1572: Handle explicit null JSON value in final fields
  • Loading branch information
banterCZ authored Feb 9, 2024
2 parents de5499f + 41a84d1 commit 6ecf88c
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.dataadapter.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.getlime.security.powerauth.lib.dataadapter.model.entity.OperationContext;

import java.util.LinkedHashMap;
Expand Down Expand Up @@ -52,6 +54,7 @@ public class AfsRequest {
/**
* Extra parameters sent with the request depending on AFS type, e.g. cookies for Threat Mark.
*/
@JsonSetter(nulls = Nulls.SKIP)
private final Map<String, Object> extras = new LinkedHashMap<>();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.dataadapter.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.getlime.security.powerauth.lib.dataadapter.model.entity.ConsentOption;
import io.getlime.security.powerauth.lib.dataadapter.model.entity.OperationContext;

Expand Down Expand Up @@ -48,6 +50,7 @@ public class SaveConsentFormRequest {
/**
* Consent options with values set by the user.
*/
@JsonSetter(nulls = Nulls.SKIP)
private final List<ConsentOption> options;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.dataadapter.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.getlime.security.powerauth.lib.dataadapter.model.entity.ConsentOption;
import io.getlime.security.powerauth.lib.dataadapter.model.entity.OperationContext;

Expand Down Expand Up @@ -53,6 +55,7 @@ public class ValidateConsentFormRequest {
/**
* Consent options with values set by the user.
*/
@JsonSetter(nulls = Nulls.SKIP)
private final List<ConsentOption> options;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.nextstep.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.getlime.security.powerauth.lib.nextstep.model.entity.enumeration.HashAlgorithm;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -39,6 +41,8 @@ public class CreateHashConfigRequest {
private String hashConfigName;
@NotNull
private HashAlgorithm algorithm;

@JsonSetter(nulls = Nulls.SKIP)
private final Map<String, String> parameters = new LinkedHashMap<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.nextstep.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.getlime.security.powerauth.lib.nextstep.model.entity.ApplicationContext;
import io.getlime.security.powerauth.lib.nextstep.model.entity.KeyValueParameter;
import io.getlime.security.powerauth.lib.nextstep.model.entity.OperationFormData;
Expand Down Expand Up @@ -52,6 +54,8 @@ public class CreateOperationRequest {
private String organizationId;
@Size(min = 1, max = 256)
private String externalTransactionId;

@JsonSetter(nulls = Nulls.SKIP)
private final List<KeyValueParameter> params = new ArrayList<>();
private OperationFormData formData;
private ApplicationContext applicationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.nextstep.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
Expand All @@ -41,6 +43,8 @@ public class CreateUserAliasRequest {
@NotBlank
@Size(min = 2, max = 256)
private String aliasValue;

@JsonSetter(nulls = Nulls.SKIP)
private final Map<String, Object> extras = new LinkedHashMap<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.nextstep.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.getlime.security.powerauth.lib.nextstep.model.entity.enumeration.ContactType;
import io.getlime.security.powerauth.lib.nextstep.model.entity.enumeration.CredentialType;
import io.getlime.security.powerauth.lib.nextstep.model.entity.enumeration.CredentialValidationMode;
Expand All @@ -40,14 +42,18 @@ public class CreateUserRequest {
@Size(min = 1, max = 256)
private String userId;

@JsonSetter(nulls = Nulls.SKIP)
private final Map<String, Object> extras = new LinkedHashMap<>();

@JsonSetter(nulls = Nulls.SKIP)
private final List<String> roles = new ArrayList<>();

@Valid
@JsonSetter(nulls = Nulls.SKIP)
private final List<NewContact> contacts = new ArrayList<>();

@Valid
@JsonSetter(nulls = Nulls.SKIP)
private final List<NewCredential> credentials = new ArrayList<>();

/**
Expand Down Expand Up @@ -87,6 +93,7 @@ public static class NewCredential {
// Null value allowed, defaults to CredentialValidationMode.VALIDATE_USERNAME_AND_CREDENTIAL
private CredentialValidationMode validationMode;
@Valid
@JsonSetter(nulls = Nulls.SKIP)
private final List<CredentialHistory> credentialHistory = new ArrayList<>();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.nextstep.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.getlime.security.powerauth.lib.nextstep.model.entity.enumeration.CredentialStatus;
import io.getlime.security.powerauth.lib.nextstep.model.entity.enumeration.UserIdentityStatus;
import jakarta.validation.constraints.Size;
Expand All @@ -42,6 +44,7 @@ public class LookupUsersRequest {
private UserIdentityStatus userIdentityStatus;

// Filter by roles
@JsonSetter(nulls = Nulls.SKIP)
private final List<String> roles = new ArrayList<>();

// Filter by username and credentialName to allow username -> user ID mapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.nextstep.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.getlime.security.powerauth.lib.nextstep.model.enumeration.AuthMethod;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -40,6 +42,7 @@ public class UpdateAuthMethodRequest {
@NotNull
private AuthMethod authMethod;
@NotNull
@JsonSetter(nulls = Nulls.SKIP)
private final Map<String, String> config = new LinkedHashMap<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.nextstep.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.getlime.security.powerauth.lib.nextstep.model.entity.ApplicationContext;
import io.getlime.security.powerauth.lib.nextstep.model.entity.KeyValueParameter;
import io.getlime.security.powerauth.lib.nextstep.model.entity.PAAuthenticationContext;
Expand Down Expand Up @@ -46,11 +48,15 @@ public class UpdateOperationRequest {
@Size(min = 2, max = 256)
private String organizationId;
private AuthMethod authMethod;

@JsonSetter(nulls = Nulls.SKIP)
private final List<AuthInstrument> authInstruments = new ArrayList<>();
private AuthStepResult authStepResult;
private AuthMethod targetAuthMethod;
@Size(min = 2, max = 256)
private String authStepResultDescription;

@JsonSetter(nulls = Nulls.SKIP)
private final List<KeyValueParameter> params = new ArrayList<>();
private ApplicationContext applicationContext;
@Size(min = 36, max = 36)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package io.getlime.security.powerauth.lib.nextstep.model.request;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.getlime.security.powerauth.lib.nextstep.model.entity.enumeration.UserIdentityStatus;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
Expand All @@ -33,6 +35,7 @@
public class UpdateUsersRequest {

@NotNull
@JsonSetter(nulls = Nulls.SKIP)
private final List<String> userIds = new ArrayList<>();
@NotNull
private UserIdentityStatus userIdentityStatus;
Expand Down

0 comments on commit 6ecf88c

Please sign in to comment.