Skip to content

Commit c549f7b

Browse files
wboereboomdependabot[bot]jillingkmichaelpaul
authored
Release 18.1.2 (#850)
* Update MakeFile to generate Checkout Files * Bump swagger-annotations from 2.2.2 to 2.2.3 Bumps swagger-annotations from 2.2.2 to 2.2.3. --- updated-dependencies: - dependency-name: io.swagger.core.v3:swagger-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * Bump swagger-annotations from 1.6.5 to 1.6.7 Bumps swagger-annotations from 1.6.5 to 1.6.7. --- updated-dependencies: - dependency-name: io.swagger:swagger-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * Bump swagger-models from 2.2.2 to 2.2.3 Bumps swagger-models from 2.2.2 to 2.2.3. --- updated-dependencies: - dependency-name: io.swagger.core.v3:swagger-models dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * Secure PRNG for ivNonce in NexoCrypto based on strongest non blocking instance (#818) * Added secure PRNG for ivNonce based on non blocking instance * Small fix * AnOtHer SmAlL fIX * add trycatch block to set to nativePRNG for non unix systems * Whitespace after catch * Bump jackson-databind from 2.13.3 to 2.13.4.2 (#837) Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.13.3 to 2.13.4.2. - [Release notes](https://github.com/FasterXML/jackson/releases) - [Commits](https://github.com/FasterXML/jackson/commits) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Pw 7050/update templates (#834) * updte templates * update Makefile * update dependencies for new templates * make dependencies more specific * Bump swagger-models from 2.2.3 to 2.2.4 (#845) Bumps swagger-models from 2.2.3 to 2.2.4. --- updated-dependencies: - dependency-name: io.swagger.core.v3:swagger-models dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump swagger-annotations from 2.2.3 to 2.2.4 (#844) Bumps swagger-annotations from 2.2.3 to 2.2.4. --- updated-dependencies: - dependency-name: io.swagger.core.v3:swagger-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump swagger-annotations from 1.6.7 to 1.6.8 (#843) Bumps swagger-annotations from 1.6.7 to 1.6.8. --- updated-dependencies: - dependency-name: io.swagger:swagger-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * PW-7327: Serialise ByteArray into JSON String (#848) * PW-7327: Serialise ByteArray into JSON String * PW-7327: Update more byte[] fields * Version Bump 18.1.2 Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jillingk <[email protected]> Co-authored-by: Michael Paul <[email protected]>
1 parent d471bbf commit c549f7b

File tree

11 files changed

+1013
-34
lines changed

11 files changed

+1013
-34
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ openapi-generator-cli:=java -jar $(openapi-generator-jar)
55

66
generator:=java
77
library:=okhttp-gson
8-
services:=payments
8+
services:=payments checkout
99
models:=src/main/java/com/adyen/model
1010
output:=target/out
1111

@@ -41,11 +41,11 @@ $(services): target/spec $(openapi-generator-jar)
4141
--skip-validate-spec \
4242
--model-package $(subst /,.,com.adyen.model.$@) \
4343
--library $(library) \
44-
--global-property models \
4544
--global-property modelDocs=false \
4645
--global-property modelTests=false \
4746
--additional-properties=dateLibrary=legacy
4847
mv $(output)/$(models)/$@ $(models)/$@
48+
mv $(output)/$(models)/JSON.java $(models)/$@
4949

5050

5151
# Checkout spec (and patch version)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You can use Maven and add this dependency to your project's POM:
3939
<dependency>
4040
<groupId>com.adyen</groupId>
4141
<artifactId>adyen-java-api-library</artifactId>
42-
<version>18.1.1</version>
42+
<version>18.1.2</version>
4343
</dependency>
4444
```
4545

pom.xml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.adyen</groupId>
55
<artifactId>adyen-java-api-library</artifactId>
66
<packaging>jar</packaging>
7-
<version>18.1.1</version>
7+
<version>18.1.2</version>
88
<name>Adyen Java API Library</name>
99
<description>Adyen API Client Library for Java</description>
1010
<url>https://github.com/adyen/adyen-java-api-library</url>
@@ -25,7 +25,7 @@
2525
<properties>
2626
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2727
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
28-
<swagger-core-version>1.6.5</swagger-core-version>
28+
<swagger-core-version>1.6.8</swagger-core-version>
2929
</properties>
3030
<scm>
3131
<connection>scm:git:[email protected]:Adyen/adyen-java-api-library.git</connection>
@@ -191,7 +191,7 @@
191191
<dependency>
192192
<groupId>com.fasterxml.jackson.core</groupId>
193193
<artifactId>jackson-databind</artifactId>
194-
<version>2.13.3</version>
194+
<version>2.13.4.2</version>
195195
</dependency>
196196
<dependency>
197197
<groupId>org.apache.httpcomponents.client5</groupId>
@@ -224,12 +224,27 @@
224224
<dependency>
225225
<groupId>io.swagger.core.v3</groupId>
226226
<artifactId>swagger-models</artifactId>
227-
<version>2.2.2</version>
227+
<version>2.2.4</version>
228228
</dependency>
229229
<dependency>
230230
<groupId>io.swagger.core.v3</groupId>
231231
<artifactId>swagger-annotations</artifactId>
232-
<version>2.2.2</version>
232+
<version>2.2.4</version>
233+
</dependency>
234+
<dependency>
235+
<groupId>javax.ws.rs</groupId>
236+
<artifactId>javax.ws.rs-api</artifactId>
237+
<version>2.1.1</version>
238+
</dependency>
239+
<dependency>
240+
<groupId>io.gsonfire</groupId>
241+
<artifactId>gson-fire</artifactId>
242+
<version>1.8.5</version>
243+
</dependency>
244+
<dependency>
245+
<groupId>com.squareup.okio</groupId>
246+
<artifactId>okio</artifactId>
247+
<version>3.2.0</version>
233248
</dependency>
234249
<!-- Generated model annotations -->
235250
<dependency>

src/main/java/com/adyen/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class Client {
4747
public static final String MARKETPAY_NOTIFICATION_API_VERSION = "v6";
4848
public static final String MARKETPAY_HOP_API_VERSION = "v6";
4949
public static final String LIB_NAME = "adyen-java-api-library";
50-
public static final String LIB_VERSION = "18.1.1";
50+
public static final String LIB_VERSION = "18.1.2";
5151
public static final String CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout";
5252
public static final String CHECKOUT_ENDPOINT_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout";
5353
public static final String CHECKOUT_ENDPOINT_CERT_LIVE = "https://checkoutcert-live-%s.adyen.com/checkout";

src/main/java/com/adyen/model/ThreeDSecureData.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121
package com.adyen.model;
2222

23+
import com.adyen.serializer.ByteArrayToStringAdapter;
2324
import com.fasterxml.jackson.annotation.JsonValue;
2425
import com.google.gson.TypeAdapter;
2526
import com.google.gson.annotations.JsonAdapter;
@@ -84,6 +85,7 @@ public AuthenticationResponseEnum read(final JsonReader jsonReader) throws IOExc
8485
private AuthenticationResponseEnum authenticationResponse = null;
8586

8687
@SerializedName("cavv")
88+
@JsonAdapter(ByteArrayToStringAdapter.class)
8789
private byte[] cavv = null;
8890

8991
@SerializedName("cavvAlgorithm")
@@ -203,12 +205,14 @@ public DirectoryResponseEnum read(final JsonReader jsonReader) throws IOExceptio
203205
private String threeDSVersion = null;
204206

205207
@SerializedName("tokenAuthenticationVerificationValue")
208+
@JsonAdapter(ByteArrayToStringAdapter.class)
206209
private byte[] tokenAuthenticationVerificationValue = null;
207210

208211
@SerializedName("transStatusReason")
209212
private String transStatusReason = null;
210213

211214
@SerializedName("xid")
215+
@JsonAdapter(ByteArrayToStringAdapter.class)
212216
private byte[] xid = null;
213217

214218
public ThreeDSecureData authenticationResponse(AuthenticationResponseEnum authenticationResponse) {

src/main/java/com/adyen/terminal/security/NexoCrypto.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@
4141
import java.security.InvalidKeyException;
4242
import java.security.MessageDigest;
4343
import java.security.NoSuchAlgorithmException;
44-
import java.util.Random;
44+
import java.security.SecureRandom;
45+
import java.security.Provider;
4546

4647
import static com.adyen.model.terminal.security.NexoDerivedKey.NEXO_IV_LENGTH;
4748

4849
public class NexoCrypto {
4950

51+
private static SecureRandom secureRandom = new SecureRandom();
52+
private static final Provider PROVIDER = secureRandom.getProvider();
53+
5054
public SaleToPOISecuredMessage encrypt(
5155
String saleToPoiMessageJson, MessageHeader messageHeader, SecurityKey securityKey) throws Exception {
5256
validateSecurityKey(securityKey);
@@ -145,11 +149,16 @@ private void validateHmac(byte[] receivedHmac, byte[] decryptedMessage, NexoDeri
145149
}
146150

147151
/**
148-
* Generate a random iv nonce
152+
* Generate a random iv nonce with cryptographically strongest non blocking RNG
149153
*/
150154
private byte[] generateRandomIvNonce() {
151155
byte[] ivNonce = new byte[NEXO_IV_LENGTH];
152-
new Random().nextBytes(ivNonce);
156+
try {
157+
secureRandom = SecureRandom.getInstance("NativePRNGNonBlocking", PROVIDER);
158+
} catch (Exception NoSuchAlgorithmException) {
159+
secureRandom = new SecureRandom();
160+
}
161+
secureRandom.nextBytes(ivNonce);
153162
return ivNonce;
154163
}
155-
}
164+
}

src/test/java/com/adyen/PaymentTest.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,21 @@
2020
*/
2121
package com.adyen;
2222

23+
import com.adyen.constants.ApiConstants;
2324
import com.adyen.constants.ApiConstants.AdditionalData;
2425
import com.adyen.constants.ApiConstants.RefusalReason;
2526
import com.adyen.httpclient.AdyenHttpClient;
27+
import com.adyen.httpclient.ClientInterface;
2628
import com.adyen.httpclient.HTTPClientException;
27-
import com.adyen.model.Address;
28-
import com.adyen.model.AuthenticationResultRequest;
29-
import com.adyen.model.AuthenticationResultResponse;
30-
import com.adyen.model.FraudCheckResult;
31-
import com.adyen.model.Name;
32-
import com.adyen.model.PaymentRequest;
33-
import com.adyen.model.PaymentRequest3d;
34-
import com.adyen.model.PaymentRequest3ds2;
35-
import com.adyen.model.PaymentResult;
36-
import com.adyen.model.RequestOptions;
37-
import com.adyen.model.ThreeDS2ResultRequest;
38-
import com.adyen.model.ThreeDS2ResultResponse;
29+
import com.adyen.model.*;
3930
import com.adyen.model.applicationinfo.ApplicationInfo;
4031
import com.adyen.model.applicationinfo.MerchantDevice;
4132
import com.adyen.service.Payment;
4233
import com.adyen.service.exception.ApiException;
4334
import org.junit.Test;
4435

4536
import java.io.IOException;
37+
import java.nio.charset.StandardCharsets;
4638
import java.text.DateFormat;
4739
import java.text.SimpleDateFormat;
4840
import java.util.HashMap;
@@ -51,18 +43,12 @@
5143

5244
import static com.adyen.constants.ApiConstants.SelectedBrand.BOLETO_SANTANDER;
5345
import static com.adyen.model.PaymentResult.ResultCodeEnum.RECEIVED;
54-
import static org.junit.Assert.assertEquals;
55-
import static org.junit.Assert.assertFalse;
56-
import static org.junit.Assert.assertNotNull;
57-
import static org.junit.Assert.assertNull;
58-
import static org.junit.Assert.assertTrue;
59-
import static org.junit.Assert.fail;
46+
import static org.junit.Assert.*;
6047
import static org.mockito.ArgumentMatchers.any;
6148
import static org.mockito.ArgumentMatchers.anyBoolean;
6249
import static org.mockito.ArgumentMatchers.anyString;
6350
import static org.mockito.ArgumentMatchers.isNull;
64-
import static org.mockito.Mockito.mock;
65-
import static org.mockito.Mockito.when;
51+
import static org.mockito.Mockito.*;
6652

6753
/**
6854
* Tests for /authorise and /authorise3d
@@ -424,4 +410,18 @@ public void TestGetAuthenticationResultErrorNotAllowed() throws IOException {
424410
assertEquals(403, e.getError().getStatus());
425411
}
426412
}
413+
414+
@Test
415+
public void TestByteArrayToJSONString() throws Exception {
416+
Client client = createMockClientFromFile("mocks/authorise-success.json");
417+
Payment payment = new Payment(client);
418+
PaymentRequest paymentRequest = new PaymentRequest();
419+
paymentRequest.mpiData(new ThreeDSecureData().cavv("AQIDBAUGBwgJCgsMDQ4PEBESExQ=".getBytes()));
420+
421+
payment.authorise(paymentRequest);
422+
423+
String expected = "\"mpiData\":{\"cavv\":\"AQIDBAUGBwgJCgsMDQ4PEBESExQ=\"}";
424+
ClientInterface http = client.getHttpClient();
425+
verify(http).request(anyString(), contains(expected), any(), eq(false), isNull(), any());
426+
}
427427
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{{>licenseInfo}}
2+
3+
package {{modelPackage}};
4+
5+
import java.util.Objects;
6+
import java.lang.reflect.Type;
7+
import java.util.Map;
8+
import javax.ws.rs.core.GenericType;
9+
10+
/**
11+
* Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
12+
*/
13+
public abstract class AbstractOpenApiSchema {
14+
15+
// store the actual instance of the schema/object
16+
private Object instance;
17+
18+
// is nullable
19+
private Boolean isNullable;
20+
21+
// schema type (e.g. oneOf, anyOf)
22+
private final String schemaType;
23+
24+
public AbstractOpenApiSchema(String schemaType, Boolean isNullable) {
25+
this.schemaType = schemaType;
26+
this.isNullable = isNullable;
27+
}
28+
29+
/**
30+
* Get the list of oneOf/anyOf composed schemas allowed to be stored in this object
31+
*
32+
* @return an instance of the actual schema/object
33+
*/
34+
public abstract Map<String, GenericType> getSchemas();
35+
36+
/**
37+
* Get the actual instance
38+
*
39+
* @return an instance of the actual schema/object
40+
*/
41+
//@JsonValue
42+
public Object getActualInstance() {return instance;}
43+
44+
/**
45+
* Set the actual instance
46+
*
47+
* @param instance the actual instance of the schema/object
48+
*/
49+
public void setActualInstance(Object instance) {this.instance = instance;}
50+
51+
/**
52+
* Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well
53+
*
54+
* @return an instance of the actual schema/object
55+
*/
56+
public Object getActualInstanceRecursively() {
57+
return getActualInstanceRecursively(this);
58+
}
59+
60+
private Object getActualInstanceRecursively(AbstractOpenApiSchema object) {
61+
if (object.getActualInstance() == null) {
62+
return null;
63+
} else if (object.getActualInstance() instanceof AbstractOpenApiSchema) {
64+
return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance());
65+
} else {
66+
return object.getActualInstance();
67+
}
68+
}
69+
70+
/**
71+
* Get the schema type (e.g. anyOf, oneOf)
72+
*
73+
* @return the schema type
74+
*/
75+
public String getSchemaType() {
76+
return schemaType;
77+
}
78+
79+
@Override
80+
public String toString() {
81+
StringBuilder sb = new StringBuilder();
82+
sb.append("class ").append(getClass()).append(" {\n");
83+
sb.append(" instance: ").append(toIndentedString(instance)).append("\n");
84+
sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n");
85+
sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n");
86+
sb.append("}");
87+
return sb.toString();
88+
}
89+
90+
/**
91+
* Convert the given object to string with each line indented by 4 spaces
92+
* (except the first line).
93+
*/
94+
private String toIndentedString(Object o) {
95+
if (o == null) {
96+
return "null";
97+
}
98+
return o.toString().replace("\n", "\n ");
99+
}
100+
101+
public boolean equals(Object o) {
102+
if (this == o) {
103+
return true;
104+
}
105+
if (o == null || getClass() != o.getClass()) {
106+
return false;
107+
}
108+
AbstractOpenApiSchema a = (AbstractOpenApiSchema) o;
109+
return Objects.equals(this.instance, a.instance) &&
110+
Objects.equals(this.isNullable, a.isNullable) &&
111+
Objects.equals(this.schemaType, a.schemaType);
112+
}
113+
114+
@Override
115+
public int hashCode() {
116+
return Objects.hash(instance, isNullable, schemaType);
117+
}
118+
119+
/**
120+
* Is nullable
121+
*
122+
* @return true if it's nullable
123+
*/
124+
public Boolean isNullable() {
125+
if (Boolean.TRUE.equals(isNullable)) {
126+
return Boolean.TRUE;
127+
} else {
128+
return Boolean.FALSE;
129+
}
130+
}
131+
132+
{{>libraries/jersey2/additional_properties}}
133+
134+
}

0 commit comments

Comments
 (0)