Bump java version (#6)

* Bump java version
This commit is contained in:
vitaxa 2019-06-28 09:57:01 +03:00 committed by GitHub
parent 7edabb66d8
commit ba0635cb74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 156 additions and 177 deletions

4
.gitmodules vendored Normal file
View File

@ -0,0 +1,4 @@
[submodule "build_utils"]
path = build_utils
url = git@github.com:rbkmoney/build_utils.git
branch = master

49
Jenkinsfile vendored
View File

@ -1,47 +1,18 @@
#!groovy
build('samsungpay-provider', 'java-maven') {
checkoutRepo()
loadBuildUtils()
def javaServicePipeline
runStage('load JavaService pipeline') {
javaServicePipeline = load("build_utils/jenkins_lib/pipeJavaService.groovy")
}
def serviceName = env.REPO_NAME
def mvnArgs = '-DjvmArgs="-Xmx256m"'
def useJava11 = true
def registry = 'dr2.rbkmoney.com'
def registryCredsId = 'jenkins_harbor'
// Run mvn and generate docker file
runStage('Maven package') {
withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) {
def mvn_command_arguments = ' --batch-mode --settings $SETTINGS_XML -P ci ' +
" -Dgit.branch=${env.BRANCH_NAME} " +
" ${mvnArgs}"
if (env.BRANCH_NAME == 'master') {
sh 'mvn deploy' + mvn_command_arguments
} else {
sh 'mvn package' + mvn_command_arguments
}
}
}
def serviceImage;
def imgShortName = 'rbkmoney/' + "${serviceName}" + ':' + '$COMMIT_ID';
getCommitId()
runStage('Build Service image') {
serviceImage = docker.build(imgShortName, '-f ./target/Dockerfile ./target')
}
try {
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic')) {
runStage('Push Service image') {
docker.withRegistry('https://dr.rbkmoney.com/v2/', 'dockerhub-rbkmoneycibot') {
serviceImage.push();
}
// Push under 'withRegistry' generates 2d record with 'long name' in local docker registry.
// Untag the long-name
sh "docker rmi dr.rbkmoney.com/${imgShortName}"
}
}
}
finally {
runStage('Remove local image') {
// Remove the image to keep Jenkins runner clean.
sh "docker rmi ${imgShortName}"
}
}
javaServicePipeline(serviceName, useJava11, mvnArgs, registry, registryCredsId)
}

1
build_utils Submodule

@ -0,0 +1 @@
Subproject commit ea4aa042f482551d624fd49a570d28488f479e93

66
pom.xml
View File

@ -8,23 +8,32 @@
<parent>
<groupId>com.rbkmoney</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.1.1.RELEASE</version>
</parent>
<groupId>com.rbkmoney.provider</groupId>
<artifactId>samsungpay</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.0.3-SNAPSHOT</version>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<server.port>8022</server.port>
<server.rest.port>8080</server.rest.port>
<exposed.ports>${server.port} ${server.rest.port}</exposed.ports>
<dockerfile.base.service.tag>22c57470c4fc47161894f036b7cf9d70f42b75f5</dockerfile.base.service.tag>
<dockerfile.base.service.tag>c0d0900ec19c907d866f8360031a836049985110</dockerfile.base.service.tag>
<dockerfile.registry>${env.REGISTRY}</dockerfile.registry>
<damsel.version>1.232-5e54b26</damsel.version>
<shared.resources.version>0.3.1</shared.resources.version>
<shared.resources.version>0.3.6</shared.resources.version>
<woody-thrift.version>1.1.15</woody-thrift.version>
<nop-rolling.version>1.0.3</nop-rolling.version>
<geck.common.version>0.6.9</geck.common.version>
<lombok.version>1.18.4</lombok.version>
<jaxb.version>2.2.11</jaxb.version>
<javax.version>1.1.1</javax.version>
<swagger.version>2.8.0</swagger.version>
<okhttp.version>3.9.1</okhttp.version>
<jackson.version>2.9.4</jackson.version>
<logstach.version>5.2</logstach.version>
</properties>
<dependencies>
@ -32,17 +41,17 @@
<dependency>
<groupId>com.rbkmoney.woody</groupId>
<artifactId>woody-thrift</artifactId>
<version>1.1.15</version>
<version>${woody-thrift.version}</version>
</dependency>
<dependency>
<groupId>com.rbkmoney.logback</groupId>
<artifactId>nop-rolling</artifactId>
<version>1.0.1</version>
<version>${nop-rolling.version}</version>
</dependency>
<dependency>
<groupId>com.rbkmoney.geck</groupId>
<artifactId>common</artifactId>
<version>0.6.9</version>
<version>${geck.common.version}</version>
</dependency>
<dependency>
<groupId>com.rbkmoney</groupId>
@ -55,10 +64,37 @@
<version>${damsel.version}</version>
</dependency>
<!--Thirdparty libs-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>${javax.version}</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>5.0</version>
<version>${logstach.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@ -91,22 +127,22 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.4</version>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.9.1</version>
<version>${okhttp.version}</version>
</dependency>
<!--Test libs-->
<dependency>
@ -137,8 +173,6 @@
<version>2.6</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@ -9,7 +9,7 @@ import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.HashSet;
import java.util.Set;
@Configuration
@EnableSwagger2
@ -22,8 +22,8 @@ public class SwaggerConfig {
.apis(RequestHandlerSelectors.basePackage(DumbRequestTransactionController.class.getPackage().getName()))
.paths(PathSelectors.any())
.build();
docket.produces(new HashSet(){{add("application/json");}});
docket.produces(Set.of("application/json"));
docket.forCodeGeneration(true);
return docket;
}
}
}

View File

@ -11,7 +11,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
@ -30,7 +30,7 @@ public class ProviderHandler implements PaymentToolProviderSrv.Iface {
public UnwrappedPaymentTool unwrap(WrappedPaymentTool paymentTool) throws InvalidRequest, TException {
log.info("New unwrap request: {}", paymentTool);
if (!paymentTool.getRequest().isSetSamsung()) {
throw new InvalidRequest(Arrays.asList("Received request type is not SamsungPay"));
throw new InvalidRequest(List.of("Received request type is not SamsungPay"));
}
String refId = paymentTool.getRequest().getSamsung().getReferenceId();
String srvId = paymentTool.getRequest().getSamsung().getServiceId();
@ -73,10 +73,10 @@ public class ProviderHandler implements PaymentToolProviderSrv.Iface {
return result;
} catch (IOException e) {
//log.error("Failed to read json data: {}", filterPan(e.getMessage()));
throw new InvalidRequest(Arrays.asList("Failed to read json data"));
throw new InvalidRequest(List.of("Failed to read json data"));
} catch (Exception e) {
log.error("Failed to get credentials", e);
throw new InvalidRequest(Arrays.asList(e.getMessage()));
throw new InvalidRequest(List.of(e.getMessage()));
}
}
}

View File

@ -4,13 +4,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.rbkmoney.provider.samsungpay.service.SPayService;
import com.rbkmoney.woody.api.flow.error.WErrorType;
import com.rbkmoney.woody.api.flow.error.WRuntimeException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@ -24,17 +23,15 @@ import java.util.Map;
@RestController
@RequestMapping("/${server.rest.endpoint}")
@Api(description = "Transaction creation API")
@RequiredArgsConstructor
public class DumbRequestTransactionController {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
private SPayService service;
private final SPayService service;
private ObjectMapper mapper = new ObjectMapper();
private final ObjectMapper mapper = new ObjectMapper();
@ApiOperation(value = "Request SamsungPay transaction", notes = "")
@ApiOperation(value = "Request SamsungPay transaction")
@PostMapping(value = "/transaction", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, headers = "Content-Type=application/json")
@ApiResponses(value = {
@ApiResponse(code= 200, message = "Samsung Pay session object"),
@ -42,7 +39,6 @@ public class DumbRequestTransactionController {
@ApiResponse(code = 503, message = "Samsung Pay service unavailable")
})
@CrossOrigin
public ResponseEntity<String> getTransaction(@RequestBody Map<String, Object> request) {
log.info("New Transaction request: {}", request);

View File

@ -37,73 +37,6 @@ public final class HttpLoggingInterceptor implements Interceptor {
private static final Charset UTF8 = Charset.forName("UTF-8");
private static final org.slf4j.Logger log = LoggerFactory.getLogger(HttpLoggingInterceptor.class);
public enum Level {
/**
* No logs.
*/
NONE,
/**
* Logs request and response lines.
* <p>
* <p>Example:
* <pre>{@code
* --> POST /greeting http/1.1 (3-byte body)
*
* <-- 200 OK (22ms, 6-byte body)
* }</pre>
*/
BASIC,
/**
* Logs request and response lines and their respective headers.
* <p>
* <p>Example:
* <pre>{@code
* --> POST /greeting http/1.1
* Host: example.com
* Content-Type: plain/text
* Content-Length: 3
* --> END POST
*
* <-- 200 OK (22ms)
* Content-Type: plain/text
* Content-Length: 6
* <-- END HTTP
* }</pre>
*/
HEADERS,
/**
* Logs request and response lines and their respective headers and bodies (if present).
* <p>
* <p>Example:
* <pre>{@code
* --> POST /greeting http/1.1
* Host: example.com
* Content-Type: plain/text
* Content-Length: 3
*
* Hi?
* --> END POST
*
* <-- 200 OK (22ms)
* Content-Type: plain/text
* Content-Length: 6
*
* Hello!
* <-- END HTTP
* }</pre>
*/
BODY
}
public interface Logger {
void log(String message);
/**
* A {@link Logger} defaults output appropriate for the current platform.
*/
Logger DEFAULT = message -> log.info(message);
}
public HttpLoggingInterceptor() {
this(Logger.DEFAULT);
}
@ -291,4 +224,71 @@ public final class HttpLoggingInterceptor implements Interceptor {
String contentEncoding = headers.get("Content-Encoding");
return contentEncoding != null && !contentEncoding.equalsIgnoreCase("identity");
}
public enum Level {
/**
* No logs.
*/
NONE,
/**
* Logs request and response lines.
* <p>
* <p>Example:
* <pre>{@code
* --> POST /greeting http/1.1 (3-byte body)
*
* <-- 200 OK (22ms, 6-byte body)
* }</pre>
*/
BASIC,
/**
* Logs request and response lines and their respective headers.
* <p>
* <p>Example:
* <pre>{@code
* --> POST /greeting http/1.1
* Host: example.com
* Content-Type: plain/text
* Content-Length: 3
* --> END POST
*
* <-- 200 OK (22ms)
* Content-Type: plain/text
* Content-Length: 6
* <-- END HTTP
* }</pre>
*/
HEADERS,
/**
* Logs request and response lines and their respective headers and bodies (if present).
* <p>
* <p>Example:
* <pre>{@code
* --> POST /greeting http/1.1
* Host: example.com
* Content-Type: plain/text
* Content-Length: 3
*
* Hi?
* --> END POST
*
* <-- 200 OK (22ms)
* Content-Type: plain/text
* Content-Length: 6
*
* Hello!
* <-- END HTTP
* }</pre>
*/
BODY
}
public interface Logger {
void log(String message);
/**
* A {@link Logger} defaults output appropriate for the current platform.
*/
Logger DEFAULT = log::info;
}
}

View File

@ -4,22 +4,22 @@ import com.rbkmoney.woody.api.flow.error.WErrorDefinition;
import com.rbkmoney.woody.api.flow.error.WRuntimeException;
import com.rbkmoney.woody.api.trace.context.TraceContext;
import com.rbkmoney.woody.thrift.impl.http.error.THTransportErrorMapper;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.util.UriTemplate;
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* Created by vpankrashkin on 26.06.18.
*/
@Slf4j
public class SPayClient {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final int connTimeoutMs;
private final int readTimeoutMs;
@ -52,11 +52,7 @@ public class SPayClient {
return result;
} catch (IOException e) {
WErrorDefinition errDef = errorMapper.mapToDef(e, TraceContext.getCurrentTraceData().getActiveSpan());
if (errDef != null) {
throw new WRuntimeException(e, errDef);
} else {
throw new WRuntimeException(e, new WErrorDefinition());
}
throw new WRuntimeException(e, Objects.requireNonNullElseGet(errDef, WErrorDefinition::new));
}
}
@ -65,10 +61,8 @@ public class SPayClient {
try {
OkHttpClient client = prepareClient();
log.debug("Http client prepared");
Request request = prepareGetRequest(credentialsTemplate.expand(new HashMap() {{
put("id", refId);
put("serviceId", serviceId);
}}).toURL());
Map<String, String> uriVar = Map.of("id", refId, "serviceId", serviceId);
Request request = prepareGetRequest(credentialsTemplate.expand(uriVar).toURL());
Response response = client.newCall(request).execute();
if (!response.isSuccessful()) {
throw new SPException("Unsuccessful call result", response.body().string());
@ -78,11 +72,7 @@ public class SPayClient {
return result;
} catch (IOException e) {
WErrorDefinition errDef = errorMapper.mapToDef(e, TraceContext.getCurrentTraceData().getActiveSpan());
if (errDef != null) {
throw new WRuntimeException(e, errDef);
} else {
throw new WRuntimeException(e, new WErrorDefinition());
}
throw new WRuntimeException(e, Objects.requireNonNullElseGet(errDef, WErrorDefinition::new));
}
}

View File

@ -5,8 +5,7 @@ import com.rbkmoney.provider.samsungpay.domain.CredentialsResponse;
import com.rbkmoney.provider.samsungpay.domain.PData3DS;
import com.rbkmoney.provider.samsungpay.domain.ResultStatus;
import com.rbkmoney.provider.samsungpay.store.SPKeyStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.AbstractMap;
@ -15,8 +14,8 @@ import java.util.Map;
/**
* Created by vpankrashkin on 03.07.18.
*/
@Slf4j
public class SPayService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final SPayClient sPayClient;
private final SPKeyStore keyStore;
@ -46,7 +45,7 @@ public class SPayService {
String respBody = sPayClient.requestCredentials(serviceId, refId);
ResultStatus status = mapper.readValue(respBody, ResultStatus.class);
if (!"0".equals(status.code)) {
log.error("Unsuccessful SP response code:" + status, respBody);
log.error("Unsuccessful SP response code: {}. Body: {}", status, respBody);
throw new SPException("Unsuccessful SP response code", respBody);
}
CredentialsResponse credResp = mapper.readValue(respBody, CredentialsResponse.class);

View File

@ -4,7 +4,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.GeneralSecurityException;
import java.security.KeyFactory;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
@ -42,8 +41,7 @@ public class SPKeyStore {
pemKey = pemKey.replace("-----END PRIVATE KEY-----", "");
pemKey = pemKey.replace("\n", "");
byte[] encoded = Base64.getDecoder().decode(pemKey);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
return keySpec;
return new PKCS8EncodedKeySpec(encoded);
}
private String buildCertFileName(String serviceId, String suffix) {

View File

@ -1,14 +0,0 @@
package com.rbkmoney.provider.samsungpay;
import org.junit.Test;
/**
* Created by vpankrashkin on 04.07.18.
*/
public class IntegrationTest {
@Test
public void testCreateTransaction() {
}
}