diff --git a/pom.xml b/pom.xml index b62c4b7..1d623d0 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,6 @@ - 4.0.0 @@ -13,7 +12,7 @@ adapter-flow-lib - 0.1.4 + 0.1.5 jar adapter-flow-lib @@ -45,54 +44,29 @@ ${env.REGISTRY} UTF-8 UTF-8 - 15 - 0.3.6 - + 1.0.4 1.20-be9cdeb - - 3.10 + 1.563-d384c12 + 3.12.0 1.15 - - 1.7.33 - 1.18.22 - 1.2.10 - 7.0.1 - - 2.11.2 - [1.0.4,) - - 1.544-dcd92dd - 1.62-07f2b0f - - 1.0.6 - 1.0.1 - 1.0.0 + 1.7.36 + 1.18.24 + 1.2.11 + 7.1.1 + 2.13.2 5.8.2 - 0.0.1 2.22.2 - 5.3.14 4.0.1 2.0.1.Final - 1.0.0 2.11.2 - - 2.6.3 + 5.3.19 + 2.6.7 + 1.66-01353ce + 1.1.1 - - - - javax.validation - validation-api - ${validation-api.version} - - - javax.servlet - javax.servlet-api - ${javax.servlet-api.version} - provided - + org.springframework.boot spring-boot-starter-validation @@ -111,6 +85,18 @@ ${spring.version} provided + + + javax.validation + validation-api + ${validation-api.version} + + + javax.servlet + javax.servlet-api + ${javax.servlet-api.version} + provided + org.apache.commons commons-lang3 @@ -174,16 +160,6 @@ ${woody.version} provided - - dev.vality.adapter-client-lib - cds-client-storage - ${adapter-client-lib.version} - - - dev.vality.adapter-client-lib - hellgate-adapter-client - ${adapter-client-lib.version} - dev.vality bender-proto @@ -192,8 +168,14 @@ dev.vality - error-mapping-java - ${error-mapping-java.version} + cds-proto + ${cds-proto.version} + provided + + + dev.vality + adapter-common-lib + ${adapter-common-lib.version} @@ -231,7 +213,7 @@ dev.vality.logback nop-rolling - 1.0.0 + 1.0.1 test diff --git a/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java b/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java index 149a7d6..53187ea 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java +++ b/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java @@ -1,5 +1,10 @@ package dev.vality.adapter.flow.lib.converter.entry; +import dev.vality.adapter.common.cds.BankCardExtractor; +import dev.vality.adapter.common.cds.CdsStorageClient; +import dev.vality.adapter.common.cds.model.CardDataProxyModel; +import dev.vality.adapter.common.damsel.ProxyProviderPackageCreators; +import dev.vality.adapter.common.damsel.ProxyProviderPackageExtractors; import dev.vality.adapter.flow.lib.constant.MetaData; import dev.vality.adapter.flow.lib.constant.Step; import dev.vality.adapter.flow.lib.constant.TargetStatus; @@ -10,17 +15,12 @@ import dev.vality.adapter.flow.lib.service.TemporaryContextService; import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor; import dev.vality.adapter.flow.lib.utils.CardDataUtils; import dev.vality.adapter.flow.lib.utils.TargetStatusResolver; -import dev.vality.cds.client.storage.CdsClientStorage; -import dev.vality.cds.client.storage.utils.BankCardExtractor; import dev.vality.cds.storage.Auth3DS; import dev.vality.cds.storage.CardData; import dev.vality.cds.storage.SessionData; import dev.vality.damsel.domain.BankCard; import dev.vality.damsel.domain.TransactionInfo; import dev.vality.damsel.proxy_provider.*; -import dev.vality.java.cds.utils.model.CardDataProxyModel; -import dev.vality.java.damsel.utils.creators.ProxyProviderPackageCreators; -import dev.vality.java.damsel.utils.extractors.ProxyProviderPackageExtractors; import lombok.RequiredArgsConstructor; import org.springframework.core.convert.converter.Converter; @@ -30,7 +30,7 @@ import java.util.Map; @RequiredArgsConstructor public class CtxToEntryModelConverter implements Converter { - private final CdsClientStorage cdsStorage; + private final CdsStorageClient cdsStorageClient; private final TemporaryContextDeserializer temporaryContextDeserializer; private final IdGenerator idGenerator; private final TemporaryContextService temporaryContextService; @@ -51,7 +51,7 @@ public class CtxToEntryModelConverter implements Converter { private final TemporaryContextDeserializer temporaryContextDeserializer; - private final CdsClientStorage cdsStorage; + private final CdsStorageClient cdsStorageClient; private final IdGenerator idGenerator; private final TemporaryContextService temporaryContextService; @@ -94,7 +94,7 @@ public class RecCtxToEntryModelConverter implements Converter mobilePaymentDataBuilder = MobilePaymentData.builder(); if (generalExitStateModel == null || generalExitStateModel.getNextStep() == null) { - SessionData sessionData = cdsStorage.getSessionData(context); + SessionData sessionData = cdsStorageClient.getSessionData(context); if (sessionData.getAuthData().isSetAuth3ds()) { Auth3DS auth3ds = sessionData.getAuthData().getAuth3ds(); mobilePaymentDataBuilder.cryptogram(auth3ds.getCryptogram()) @@ -136,7 +136,7 @@ public class RecCtxToEntryModelConverter implements Converter) invocationOnMock -> CardDataProxyModel.builder() .expMonth((byte) expMonthNon3ds) .expYear((short) expYearNon3ds) .cardholderName(cardholderName) .pan(panSuccessNon3ds) - .build()).when(cdsClientStorage).getCardData(any(RecurrentTokenContext.class)); + .build()).when(cdsStorageClient).getCardData(any(RecurrentTokenContext.class)); doAnswer((Answer) invocation -> new CardData() .setExpDate(new ExpDate() @@ -98,7 +98,7 @@ public class MockUtil { .setYear((short) expYearNon3ds)) .setPan(panSuccessNon3ds) .setCardholderName(cardholderName)) - .when(cdsClientStorage).getCardData(any(PaymentContext.class)); + .when(cdsStorageClient).getCardData(any(PaymentContext.class)); doAnswer((Answer) invocation -> new CardData() .setExpDate(new ExpDate() @@ -106,32 +106,32 @@ public class MockUtil { .setYear((short) expYearNon3ds)) .setPan(panSuccessNon3ds) .setCardholderName(cardholderName)) - .when(cdsClientStorage).getCardData(any(String.class)); + .when(cdsStorageClient).getCardData(any(String.class)); } - public static void mockSessionData(CdsClientStorage cdsClientStorage) { - mockCvv(CVV_NON3DS, cdsClientStorage); + public static void mockSessionData(CdsStorageClient cdsStorageClient) { + mockCvv(CVV_NON3DS, cdsStorageClient); } - public static void mock3ds1SessionData(CdsClientStorage cdsClientStorage) { - mockCvv(CVV_3DS_1, cdsClientStorage); + public static void mock3ds1SessionData(CdsStorageClient cdsStorageClient) { + mockCvv(CVV_3DS_1, cdsStorageClient); } - public static void mock3ds2FullFlowSessionData(CdsClientStorage cdsClientStorage) { - mockCvv(CVV_3DS_2, cdsClientStorage); + public static void mock3ds2FullFlowSessionData(CdsStorageClient cdsStorageClient) { + mockCvv(CVV_3DS_2, cdsStorageClient); } - public static void mock3ds2SimpleFlowSessionData(CdsClientStorage cdsClientStorage) { - mockCvv(CVV_3DS_2_SIMPLE_FLOW, cdsClientStorage); + public static void mock3ds2SimpleFlowSessionData(CdsStorageClient cdsStorageClient) { + mockCvv(CVV_3DS_2_SIMPLE_FLOW, cdsStorageClient); } - private static void mockCvv(String cvvNon3ds, CdsClientStorage cdsClientStorage) { + private static void mockCvv(String cvvNon3ds, CdsStorageClient cdsStorageClient) { doAnswer((Answer) invocation -> new SessionData(AuthData.card_security_code(new CardSecurityCode(cvvNon3ds)))) - .when(cdsClientStorage).getSessionData(any(RecurrentTokenContext.class)); + .when(cdsStorageClient).getSessionData(any(RecurrentTokenContext.class)); doAnswer((Answer) invocation -> new SessionData(AuthData.card_security_code(new CardSecurityCode(cvvNon3ds)))) - .when(cdsClientStorage).getSessionData(any(PaymentContext.class)); + .when(cdsStorageClient).getSessionData(any(PaymentContext.class)); } public static void mockIdGenerator(BenderSrv.Iface benderClient) throws TException { diff --git a/src/test/java/dev/vality/adapter/flow/lib/logback/mask/PatternMaskingLayoutTest.java b/src/test/java/dev/vality/adapter/flow/lib/logback/mask/PatternMaskingLayoutTest.java new file mode 100644 index 0000000..ca6c290 --- /dev/null +++ b/src/test/java/dev/vality/adapter/flow/lib/logback/mask/PatternMaskingLayoutTest.java @@ -0,0 +1,139 @@ +package dev.vality.adapter.flow.lib.logback.mask; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.classic.spi.IThrowableProxy; +import ch.qos.logback.classic.spi.LoggerContextVO; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.slf4j.LoggerFactory; +import org.slf4j.Marker; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class PatternMaskingLayoutTest { + + private PatternMaskingLayout patternMaskingLayout = new PatternMaskingLayout(); + + @BeforeEach + public void init() { + patternMaskingLayout.setPattern("%-5p [%d{ISO8601}] %m%n"); + + String[] maskPatterns = {"\\b\\d{6}([\\d\\s]{2,9})\\d{4}\\b", "(\\b\\d{3}\\b)"}; + for (String maskPattern : maskPatterns) { + patternMaskingLayout.addMaskPattern(maskPattern); + } + + LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); + loggerContext.reset(); + patternMaskingLayout.setContext(loggerContext); + patternMaskingLayout.start(); + } + + @Test + public void testPatternMaskingLayout() { + Calendar calendar = new GregorianCalendar(2019, Calendar.APRIL, 15, 14, 15, 16); + + String msg = + "http://localhost/?COMMAND=PREAUTH&VERSION=1.0&PAN=3412345678909876&PAN2=9876543219987654&EXPDATE" + + "=2012&TERMID=1235111&AMOUNT=1000&CURRENCY=643&INVOICE=invoice_id.1&CVV2=123" + + "&RRN=904792140574&CONDITION=3&TDSDATA="; + + ILoggingEvent loggingEvent = createLoggingEvent(Level.DEBUG, calendar.getTime(), msg); + + assertEquals( + "DEBUG [2019-04-15 14:15:16,000] http://localhost/?COMMAND=PREAUTH&VERSION=1.0" + + "&PAN=341234******9876&PAN2=987654******7654&EXPDATE=2012&TERMID=1235111&AMOUNT=1000" + + "&CURRENCY=***&INVOICE=invoice_id.1&CVV2=***&RRN=904792**0574&CONDITION=3&TDSDATA=" + + System.lineSeparator(), + patternMaskingLayout.doLayout(loggingEvent)); + } + + ILoggingEvent createLoggingEvent(Level logLevel, Date date, String msg) { + + return new ILoggingEvent() { + + @Override + public String getThreadName() { + return null; + } + + @Override + public Level getLevel() { + return logLevel; + } + + @Override + public String getMessage() { + return null; + } + + @Override + public Object[] getArgumentArray() { + return new Object[0]; + } + + @Override + public String getFormattedMessage() { + return msg; + } + + @Override + public String getLoggerName() { + return "loggerName"; + } + + @Override + public LoggerContextVO getLoggerContextVO() { + return null; + } + + @Override + public IThrowableProxy getThrowableProxy() { + return null; + } + + @Override + public StackTraceElement[] getCallerData() { + return null; + } + + @Override + public boolean hasCallerData() { + return false; + } + + @Override + public Marker getMarker() { + return null; + } + + @Override + public Map getMDCPropertyMap() { + return null; + } + + @Override + public Map getMdc() { + return null; + } + + @Override + public long getTimeStamp() { + return date.getTime(); + } + + @Override + public void prepareForDeferredProcessing() { + + } + }; + } + +} \ No newline at end of file