JD-237: add result endpoint, migrate on lib-parent-pom (#29)

This commit is contained in:
Anatoly Karlov 2021-04-12 14:53:18 +03:00 committed by GitHub
parent c2da37222f
commit 78ef5e86b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 179 additions and 60 deletions

2
Jenkinsfile vendored
View File

@ -8,6 +8,6 @@ build('three-ds-server-domain-lib', 'docker-host') {
javaLibPipeline = load("build_utils/jenkins_lib/pipeJavaLib.groovy")
}
def buildImageTag = "b04c5291d101132e53e578d96e1628d2e6dab0c0"
def buildImageTag = "442c2c274c1d8e484e5213089906a4271641d95e"
javaLibPipeline(buildImageTag)
}

View File

@ -1 +1,5 @@
# three-ds-server-domain-lib
# three-ds-server-domain-lib
Описание моделей домена макросервиса 3DSS
[3DSS Docker Compose description](https://github.com/rbkmoney/three-ds-server-compose#three-ds-server-compose)

@ -1 +1 @@
Subproject commit e1318727d4d0c3e48f5122bf3197158b6695f50e
Subproject commit 24aa772730be966667adb285a09fcb494d4f218e

10
pom.xml
View File

@ -5,14 +5,14 @@
<parent>
<groupId>com.rbkmoney</groupId>
<artifactId>parent</artifactId>
<version>1.0.5</version>
<artifactId>library-parent-pom</artifactId>
<version>1.0.3</version>
</parent>
<packaging>jar</packaging>
<artifactId>three-ds-server-domain-lib</artifactId>
<version>1.2.3</version>
<version>1.3.0</version>
<url>https://github.com/rbkmoney/three-ds-server-domain-lib</url>
<licenses>
@ -36,12 +36,10 @@
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>8</java.version>
<lombok.version>1.18.4</lombok.version>
<jackson.version>2.11.0</jackson.version>
<spring-core.version>5.2.9.RELEASE</spring-core.version>
<checkstyle.config.suppressions.path>./src/main/resources/checkstyle/checkstyle-suppressions.xml</checkstyle.config.suppressions.path>
</properties>
<dependencies>

View File

@ -29,7 +29,10 @@ public class CustomValidator<T> implements ConstraintValidator<CustomValidation,
.orElse(ConstraintValidationResult.success());
if (!constraintValidationResult.isValid()) {
contextEnricher.enrich(ctx, constraintValidationResult.getConstraintType(), constraintValidationResult.getFieldName());
contextEnricher.enrich(
ctx,
constraintValidationResult.getConstraintType(),
constraintValidationResult.getFieldName());
}
return constraintValidationResult.isValid();

View File

@ -8,8 +8,10 @@ import java.util.List;
public class RBKMoneyAuthenticationRequestCustomValidator extends CustomValidator<RBKMoneyAuthenticationRequest> {
public RBKMoneyAuthenticationRequestCustomValidator(List<ConstraintValidationHandler<RBKMoneyAuthenticationRequest>> constraintValidationHandlers,
ValidatorContextEnricherService contextEnricher) {
public RBKMoneyAuthenticationRequestCustomValidator(
List<ConstraintValidationHandler<RBKMoneyAuthenticationRequest>> constraintValidationHandlers,
ValidatorContextEnricherService contextEnricher
) {
super(constraintValidationHandlers, contextEnricher);
}
}

View File

@ -8,8 +8,10 @@ import java.util.List;
public class RBKMoneyGetChallengeRequestCustomValidator extends CustomValidator<RBKMoneyGetChallengeRequest> {
public RBKMoneyGetChallengeRequestCustomValidator(List<ConstraintValidationHandler<RBKMoneyGetChallengeRequest>> constraintValidationHandlers,
ValidatorContextEnricherService contextEnricher) {
public RBKMoneyGetChallengeRequestCustomValidator(
List<ConstraintValidationHandler<RBKMoneyGetChallengeRequest>> constraintValidationHandlers,
ValidatorContextEnricherService contextEnricher
) {
super(constraintValidationHandlers, contextEnricher);
}
}

View File

@ -8,8 +8,10 @@ import java.util.List;
public class RBKMoneyPreparationRequestCustomValidator extends CustomValidator<RBKMoneyPreparationRequest> {
public RBKMoneyPreparationRequestCustomValidator(List<ConstraintValidationHandler<RBKMoneyPreparationRequest>> constraintValidationHandlers,
ValidatorContextEnricherService contextEnricher) {
public RBKMoneyPreparationRequestCustomValidator(
List<ConstraintValidationHandler<RBKMoneyPreparationRequest>> constraintValidationHandlers,
ValidatorContextEnricherService contextEnricher
) {
super(constraintValidationHandlers, contextEnricher);
}
}

View File

@ -16,8 +16,10 @@ import lombok.*;
import static com.rbkmoney.threeds.server.utils.AccountNumberUtils.hideAccountNumber;
/**
* The Card Range Data data element contains information returned in the PRes message to the 3DS Server from the DS that indicates the most
* recent EMV 3-D Secure version supported by the ACS that hosts that card range. It also may optionally contain the ACS URL for the 3DS
* The Card Range Data data element contains information returned in the PRes message
* to the 3DS Server from the DS that indicates the most
* recent EMV 3-D Secure version supported by the ACS that hosts that card range.
* It also may optionally contain the ACS URL for the 3DS
* Method if supported by the ACS and the DS Start and End Protocol Versions which support the card range.
*/
@AllArgsConstructor

View File

@ -0,0 +1,18 @@
package com.rbkmoney.threeds.server.domain.result;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@JsonInclude(value = JsonInclude.Include.NON_ABSENT)
public class ThreeDsResultRequest {
private String threeDsServerTransId;
}

View File

@ -0,0 +1,19 @@
package com.rbkmoney.threeds.server.domain.result;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@JsonInclude(value = JsonInclude.Include.NON_ABSENT)
public class ThreeDsResultResponse {
private String eci;
private String authenticationValue;
}

View File

@ -1,5 +1,6 @@
package com.rbkmoney.threeds.server.domain.root.emvco;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@ -15,6 +16,7 @@ import com.rbkmoney.threeds.server.domain.transaction.TransactionStatus;
import com.rbkmoney.threeds.server.domain.transaction.TransactionStatusReason;
import com.rbkmoney.threeds.server.domain.whitelist.WhiteListStatus;
import com.rbkmoney.threeds.server.domain.whitelist.WhiteListStatusSource;
import com.rbkmoney.threeds.server.dto.ChallengeFlowTransactionInfo;
import com.rbkmoney.threeds.server.serialization.EnumWrapper;
import com.rbkmoney.threeds.server.serialization.ListWrapper;
import com.rbkmoney.threeds.server.serialization.deserializer.*;
@ -76,4 +78,7 @@ public class RReq extends Message {
@JsonSerialize(using = WhiteListStatusSourceSerializer.class)
private EnumWrapper<WhiteListStatusSource> whiteListStatusSource;
@JsonIgnore
private ChallengeFlowTransactionInfo challengeFlowTransactionInfo;
}

View File

@ -16,7 +16,8 @@ import lombok.*;
* класс - костыль для тестов, который изначально не правильно работает , по идее согласно тестовой спеки ,
* он должен возвращать сразу лабе PGcs, и там плюс должен быть сформированный html с кодированным CReq.
* но тест при такой реализации валился с их стороны хуй знает почему.
* но когда я стал отправлять этот PGcs в DS (DS не принимает изначально такой тип сообщения), DS стал возвращать Erro (что логично),
* но когда я стал отправлять этот PGcs в DS (DS не принимает изначально такой тип сообщения),
* DS стал возвращать Erro (что логично),
* который с потом редиректит лабе и тест успешно завершался, поэтому я оставил все как есть.
*/
@AllArgsConstructor

View File

@ -0,0 +1,24 @@
package com.rbkmoney.threeds.server.dto;
import com.rbkmoney.threeds.server.domain.acs.AcsDecConInd;
import com.rbkmoney.threeds.server.domain.device.DeviceChannel;
import lombok.Builder;
import lombok.Data;
import java.time.LocalDateTime;
@Data
@Builder
public class ChallengeFlowTransactionInfo {
private String threeDsServerTransId;
private DeviceChannel deviceChannel;
private LocalDateTime decoupledAuthMaxTime;
private AcsDecConInd acsDecConInd;
private String dsProviderId;
private String messageVersion;
private String acsUrl;
private String eci;
private String authenticationValue;
}

View File

@ -19,7 +19,9 @@ public enum ConstraintType {
public static ConstraintType of(String value) {
for (ConstraintType t : ConstraintType.values()) {
if (value.equals(t.value)) return t;
if (value.equals(t.value)) {
return t;
}
}
throw new IllegalArgumentException("Unknown constraint type: " + value);

View File

@ -18,7 +18,7 @@ public abstract class AbstractEnumDeserializer<T extends Valuable> extends JsonD
protected abstract T[] enumValues();
@Override
public EnumWrapper<T> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
public EnumWrapper<T> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
ObjectCodec oc = jp.getCodec();
JsonNode node = oc.readTree(jp);

View File

@ -10,7 +10,8 @@ import java.io.IOException;
public abstract class AbstractEnumSerializer<T extends Valuable> extends JsonSerializer<EnumWrapper<T>> {
@Override
public void serialize(EnumWrapper<T> enumWrapper, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
public void serialize(EnumWrapper<T> enumWrapper, JsonGenerator jsonGenerator, SerializerProvider serializers)
throws IOException {
String value = enumWrapper.getValue().getValue();
if (value != null) {
jsonGenerator.writeString(value);

View File

@ -17,7 +17,7 @@ public abstract class AbstractListDeserializer<T> extends JsonDeserializer<ListW
protected abstract Class<T> getClassType();
@Override
public ListWrapper<T> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
public ListWrapper<T> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
ObjectCodec oc = jp.getCodec();
JsonNode node = oc.readTree(jp);

View File

@ -14,14 +14,15 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractListEnumDeserializer<T extends Valuable> extends JsonDeserializer<ListWrapper<EnumWrapper<T>>> {
public abstract class AbstractListEnumDeserializer<T extends Valuable>
extends JsonDeserializer<ListWrapper<EnumWrapper<T>>> {
protected abstract T enumValueOf(String candidate);
protected abstract T[] enumValues();
@Override
public ListWrapper<EnumWrapper<T>> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
public ListWrapper<EnumWrapper<T>> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
ObjectCodec oc = jp.getCodec();
JsonNode node = oc.readTree(jp);
@ -44,7 +45,7 @@ public abstract class AbstractListEnumDeserializer<T extends Valuable> extends J
}
}
private EnumWrapper<T> getEnumElementOfList(ObjectCodec oc, JsonNode node) throws IOException, JsonProcessingException {
private EnumWrapper<T> getEnumElementOfList(ObjectCodec oc, JsonNode node) throws IOException {
if (node.isNull()) {
return null;
} else if (node.isTextual()) {

View File

@ -8,10 +8,15 @@ import com.rbkmoney.threeds.server.domain.Valuable;
import java.io.IOException;
import java.util.List;
public abstract class AbstractListEnumSerializer<T extends Valuable> extends JsonSerializer<ListWrapper<EnumWrapper<T>>> {
public abstract class AbstractListEnumSerializer<T extends Valuable>
extends JsonSerializer<ListWrapper<EnumWrapper<T>>> {
@Override
public void serialize(ListWrapper<EnumWrapper<T>> listWrapper, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
public void serialize(
ListWrapper<EnumWrapper<T>> listWrapper,
JsonGenerator jsonGenerator,
SerializerProvider serializers
) throws IOException {
List<EnumWrapper<T>> values = listWrapper.getValue();
if (values != null) {
jsonGenerator.writeStartArray(values.size());

View File

@ -11,7 +11,8 @@ import java.util.List;
public abstract class AbstractListSerializer<T> extends JsonSerializer<ListWrapper<T>> {
@Override
public void serialize(ListWrapper<T> listWrapper, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
public void serialize(ListWrapper<T> listWrapper, JsonGenerator jsonGenerator, SerializerProvider serializers)
throws IOException {
ObjectMapper objectMapper = (ObjectMapper) jsonGenerator.getCodec();
List<T> values = listWrapper.getValue();

View File

@ -14,12 +14,13 @@ import java.time.DateTimeException;
import java.time.temporal.TemporalAccessor;
@RequiredArgsConstructor
public abstract class AbstractTemporalAccessorDeserializer<T extends TemporalAccessor> extends JsonDeserializer<TemporalAccessorWrapper<T>> {
public abstract class AbstractTemporalAccessorDeserializer<T extends TemporalAccessor>
extends JsonDeserializer<TemporalAccessorWrapper<T>> {
protected abstract T parse(String candidate);
@Override
public TemporalAccessorWrapper<T> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
public TemporalAccessorWrapper<T> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
ObjectCodec oc = jp.getCodec();
JsonNode node = oc.readTree(jp);

View File

@ -7,12 +7,17 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.time.temporal.TemporalAccessor;
public abstract class AbstractTemporalAccessorSerializer<T extends TemporalAccessor> extends JsonSerializer<TemporalAccessorWrapper<T>> {
public abstract class AbstractTemporalAccessorSerializer<T extends TemporalAccessor>
extends JsonSerializer<TemporalAccessorWrapper<T>> {
protected abstract String format(T value);
@Override
public void serialize(TemporalAccessorWrapper<T> temporalAccessorWrapper, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
public void serialize(
TemporalAccessorWrapper<T> temporalAccessorWrapper,
JsonGenerator jsonGenerator,
SerializerProvider serializers
) throws IOException {
T value = temporalAccessorWrapper.getValue();
if (value != null) {
jsonGenerator.writeString(format(value));

View File

@ -2,7 +2,8 @@ package com.rbkmoney.threeds.server.serialization.deserializer;
import java.time.format.DateTimeFormatter;
public class LocalDateTimeMinuteDeserializer extends com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer {
public class LocalDateTimeMinuteDeserializer
extends com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer {
public LocalDateTimeMinuteDeserializer() {
super(DateTimeFormatter.ofPattern("yyyyMMddHHmm"));

View File

@ -2,7 +2,8 @@ package com.rbkmoney.threeds.server.serialization.deserializer;
import java.time.format.DateTimeFormatter;
public class LocalDateTimeMinuteSecondDeserializer extends com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer {
public class LocalDateTimeMinuteSecondDeserializer
extends com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer {
public LocalDateTimeMinuteSecondDeserializer() {
super(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));

View File

@ -3,7 +3,8 @@ package com.rbkmoney.threeds.server.serialization.deserializer;
import com.rbkmoney.threeds.server.domain.threedsrequestor.ThreeDSRequestorAuthenticationInd;
import com.rbkmoney.threeds.server.serialization.AbstractEnumDeserializer;
public class ThreeDSRequestorAuthenticationIndDeserializer extends AbstractEnumDeserializer<ThreeDSRequestorAuthenticationInd> {
public class ThreeDSRequestorAuthenticationIndDeserializer
extends AbstractEnumDeserializer<ThreeDSRequestorAuthenticationInd> {
@Override
protected ThreeDSRequestorAuthenticationInd enumValueOf(String candidate) {

View File

@ -2,7 +2,8 @@ package com.rbkmoney.threeds.server.serialization.serializer;
import java.time.format.DateTimeFormatter;
public class LocalDateTimeMinuteSecondSerializer extends com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer {
public class LocalDateTimeMinuteSecondSerializer
extends com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer {
public LocalDateTimeMinuteSecondSerializer() {
super(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));

View File

@ -3,6 +3,7 @@ package com.rbkmoney.threeds.server.serialization.serializer;
import com.rbkmoney.threeds.server.domain.threedsrequestor.ThreeDSRequestorAuthenticationInd;
import com.rbkmoney.threeds.server.serialization.AbstractEnumSerializer;
public class ThreeDSRequestorAuthenticationIndSerializer extends AbstractEnumSerializer<ThreeDSRequestorAuthenticationInd> {
public class ThreeDSRequestorAuthenticationIndSerializer
extends AbstractEnumSerializer<ThreeDSRequestorAuthenticationInd> {
}

View File

@ -9,62 +9,62 @@ import com.rbkmoney.threeds.server.domain.root.rbkmoney.*;
public class MessageTypeUtils {
public static MessageType resolve(Message message) {
Class<? extends Message> aClass = message.getClass();
if (aClass.equals(ErroWrapper.class) || aClass.equals(Erro.class)) {
Class<? extends Message> messageClass = message.getClass();
if (messageClass.equals(ErroWrapper.class) || messageClass.equals(Erro.class)) {
return MessageType.ERRO;
}
if (aClass.equals(AReq.class)) {
if (messageClass.equals(AReq.class)) {
return MessageType.AREQ;
}
if (aClass.equals(ARes.class)) {
if (messageClass.equals(ARes.class)) {
return MessageType.ARES;
}
if (aClass.equals(PReq.class)) {
if (messageClass.equals(PReq.class)) {
return MessageType.PREQ;
}
if (aClass.equals(PRes.class)) {
if (messageClass.equals(PRes.class)) {
return MessageType.PRES;
}
if (aClass.equals(RReq.class)) {
if (messageClass.equals(RReq.class)) {
return MessageType.RREQ;
}
if (aClass.equals(RRes.class)) {
if (messageClass.equals(RRes.class)) {
return MessageType.RRES;
}
if (aClass.equals(PArq.class)) {
if (messageClass.equals(PArq.class)) {
return MessageType.PARQ;
}
if (aClass.equals(PArs.class)) {
if (messageClass.equals(PArs.class)) {
return MessageType.PARS;
}
if (aClass.equals(PGcq.class)) {
if (messageClass.equals(PGcq.class)) {
return MessageType.PGCQ;
}
if (aClass.equals(PGcs.class)) {
if (messageClass.equals(PGcs.class)) {
return MessageType.PGCS;
}
if (aClass.equals(PPrq.class)) {
if (messageClass.equals(PPrq.class)) {
return MessageType.PPRQ;
}
if (aClass.equals(PPrs.class)) {
if (messageClass.equals(PPrs.class)) {
return MessageType.PPRS;
}
if (aClass.equals(RBKMoneyAuthenticationRequest.class)) {
if (messageClass.equals(RBKMoneyAuthenticationRequest.class)) {
return MessageType.RBKMONEY_AUTHENTICATION_REQUEST;
}
if (aClass.equals(RBKMoneyAuthenticationResponse.class)) {
if (messageClass.equals(RBKMoneyAuthenticationResponse.class)) {
return MessageType.RBKMONEY_AUTHENTICATION_RESPONSE;
}
if (aClass.equals(RBKMoneyPreparationRequest.class)) {
if (messageClass.equals(RBKMoneyPreparationRequest.class)) {
return MessageType.RBKMONEY_PREPARATION_REQUEST;
}
if (aClass.equals(RBKMoneyPreparationResponse.class)) {
if (messageClass.equals(RBKMoneyPreparationResponse.class)) {
return MessageType.RBKMONEY_PREPARATION_RESPONSE;
}
if (aClass.equals(RBKMoneyGetChallengeRequest.class)) {
if (messageClass.equals(RBKMoneyGetChallengeRequest.class)) {
return MessageType.RBKMONEY_GET_CHALLENGE_REQUEST;
}
if (aClass.equals(RBKMoneyGetChallengeResponse.class)) {
if (messageClass.equals(RBKMoneyGetChallengeResponse.class)) {
return MessageType.RBKMONEY_GET_CHALLENGE_RESPONSE;
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress checks="AbbreviationAsWordInName"
files="com[\\/]rbkmoney[\\/]threeds[\\/].*.java"/>
<suppress checks="MemberName"
files="com[\\/]rbkmoney[\\/]threeds[\\/]server[\\/]domain[\\/]root[\\/]proprietary[\\/].*.java"/>
<suppress checks="LineLength"
files="DeserializerTest.java"/>
<suppress checks="LocalVariableName"
files="SerializerTest.java"/>
</suppressions>

View File

@ -46,7 +46,8 @@ public class DeserializerTest {
ObjectMapper mapper = new ObjectMapper();
Object value = mapper.readValue("{\"acctType\":\"" + actualValue + "\"}", Item.class).getAcctType().getValue().getValue();
Object value = mapper.readValue("{\"acctType\":\"" + actualValue + "\"}", Item.class)
.getAcctType().getValue().getValue();
assertEquals(actualValue, value);
}
@ -54,7 +55,8 @@ public class DeserializerTest {
public void enumWrapperGarbageTest() throws IOException {
ObjectMapper mapper = new ObjectMapper();
Object value = mapper.readValue("{\"acctType\":\"" + ACTUAL_GARBAGE_VALUE + "\"}", Item.class).getAcctType().getGarbageValue();
Object value = mapper.readValue("{\"acctType\":\"" + ACTUAL_GARBAGE_VALUE + "\"}", Item.class)
.getAcctType().getGarbageValue();
assertEquals(ACTUAL_GARBAGE_VALUE, value);
}