Skip to content

Commit

Permalink
Release 18.1.2 (#850)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
4 people authored Oct 18, 2022
1 parent d471bbf commit c549f7b
Show file tree
Hide file tree
Showing 11 changed files with 1,013 additions and 34 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ openapi-generator-cli:=java -jar $(openapi-generator-jar)

generator:=java
library:=okhttp-gson
services:=payments
services:=payments checkout
models:=src/main/java/com/adyen/model
output:=target/out

Expand Down Expand Up @@ -41,11 +41,11 @@ $(services): target/spec $(openapi-generator-jar)
--skip-validate-spec \
--model-package $(subst /,.,com.adyen.model.$@) \
--library $(library) \
--global-property models \
--global-property modelDocs=false \
--global-property modelTests=false \
--additional-properties=dateLibrary=legacy
mv $(output)/$(models)/$@ $(models)/$@
mv $(output)/$(models)/JSON.java $(models)/$@


# Checkout spec (and patch version)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You can use Maven and add this dependency to your project's POM:
<dependency>
<groupId>com.adyen</groupId>
<artifactId>adyen-java-api-library</artifactId>
<version>18.1.1</version>
<version>18.1.2</version>
</dependency>
```

Expand Down
25 changes: 20 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.adyen</groupId>
<artifactId>adyen-java-api-library</artifactId>
<packaging>jar</packaging>
<version>18.1.1</version>
<version>18.1.2</version>
<name>Adyen Java API Library</name>
<description>Adyen API Client Library for Java</description>
<url>https://github.com/adyen/adyen-java-api-library</url>
Expand All @@ -25,7 +25,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<swagger-core-version>1.6.5</swagger-core-version>
<swagger-core-version>1.6.8</swagger-core-version>
</properties>
<scm>
<connection>scm:git:[email protected]:Adyen/adyen-java-api-library.git</connection>
Expand Down Expand Up @@ -191,7 +191,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
<version>2.13.4.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
Expand Down Expand Up @@ -224,12 +224,27 @@
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
<version>2.2.2</version>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.2</version>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>io.gsonfire</groupId>
<artifactId>gson-fire</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>3.2.0</version>
</dependency>
<!-- Generated model annotations -->
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/adyen/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class Client {
public static final String MARKETPAY_NOTIFICATION_API_VERSION = "v6";
public static final String MARKETPAY_HOP_API_VERSION = "v6";
public static final String LIB_NAME = "adyen-java-api-library";
public static final String LIB_VERSION = "18.1.1";
public static final String LIB_VERSION = "18.1.2";
public static final String CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout";
public static final String CHECKOUT_ENDPOINT_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout";
public static final String CHECKOUT_ENDPOINT_CERT_LIVE = "https://checkoutcert-live-%s.adyen.com/checkout";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/adyen/model/ThreeDSecureData.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
package com.adyen.model;

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

@SerializedName("cavv")
@JsonAdapter(ByteArrayToStringAdapter.class)
private byte[] cavv = null;

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

@SerializedName("tokenAuthenticationVerificationValue")
@JsonAdapter(ByteArrayToStringAdapter.class)
private byte[] tokenAuthenticationVerificationValue = null;

@SerializedName("transStatusReason")
private String transStatusReason = null;

@SerializedName("xid")
@JsonAdapter(ByteArrayToStringAdapter.class)
private byte[] xid = null;

public ThreeDSecureData authenticationResponse(AuthenticationResponseEnum authenticationResponse) {
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/com/adyen/terminal/security/NexoCrypto.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import java.security.SecureRandom;
import java.security.Provider;

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

public class NexoCrypto {

private static SecureRandom secureRandom = new SecureRandom();
private static final Provider PROVIDER = secureRandom.getProvider();

public SaleToPOISecuredMessage encrypt(
String saleToPoiMessageJson, MessageHeader messageHeader, SecurityKey securityKey) throws Exception {
validateSecurityKey(securityKey);
Expand Down Expand Up @@ -145,11 +149,16 @@ private void validateHmac(byte[] receivedHmac, byte[] decryptedMessage, NexoDeri
}

/**
* Generate a random iv nonce
* Generate a random iv nonce with cryptographically strongest non blocking RNG
*/
private byte[] generateRandomIvNonce() {
byte[] ivNonce = new byte[NEXO_IV_LENGTH];
new Random().nextBytes(ivNonce);
try {
secureRandom = SecureRandom.getInstance("NativePRNGNonBlocking", PROVIDER);
} catch (Exception NoSuchAlgorithmException) {
secureRandom = new SecureRandom();
}
secureRandom.nextBytes(ivNonce);
return ivNonce;
}
}
}
40 changes: 20 additions & 20 deletions src/test/java/com/adyen/PaymentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,21 @@
*/
package com.adyen;

import com.adyen.constants.ApiConstants;
import com.adyen.constants.ApiConstants.AdditionalData;
import com.adyen.constants.ApiConstants.RefusalReason;
import com.adyen.httpclient.AdyenHttpClient;
import com.adyen.httpclient.ClientInterface;
import com.adyen.httpclient.HTTPClientException;
import com.adyen.model.Address;
import com.adyen.model.AuthenticationResultRequest;
import com.adyen.model.AuthenticationResultResponse;
import com.adyen.model.FraudCheckResult;
import com.adyen.model.Name;
import com.adyen.model.PaymentRequest;
import com.adyen.model.PaymentRequest3d;
import com.adyen.model.PaymentRequest3ds2;
import com.adyen.model.PaymentResult;
import com.adyen.model.RequestOptions;
import com.adyen.model.ThreeDS2ResultRequest;
import com.adyen.model.ThreeDS2ResultResponse;
import com.adyen.model.*;
import com.adyen.model.applicationinfo.ApplicationInfo;
import com.adyen.model.applicationinfo.MerchantDevice;
import com.adyen.service.Payment;
import com.adyen.service.exception.ApiException;
import org.junit.Test;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
Expand All @@ -51,18 +43,12 @@

import static com.adyen.constants.ApiConstants.SelectedBrand.BOLETO_SANTANDER;
import static com.adyen.model.PaymentResult.ResultCodeEnum.RECEIVED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;

/**
* Tests for /authorise and /authorise3d
Expand Down Expand Up @@ -424,4 +410,18 @@ public void TestGetAuthenticationResultErrorNotAllowed() throws IOException {
assertEquals(403, e.getError().getStatus());
}
}

@Test
public void TestByteArrayToJSONString() throws Exception {
Client client = createMockClientFromFile("mocks/authorise-success.json");
Payment payment = new Payment(client);
PaymentRequest paymentRequest = new PaymentRequest();
paymentRequest.mpiData(new ThreeDSecureData().cavv("AQIDBAUGBwgJCgsMDQ4PEBESExQ=".getBytes()));

payment.authorise(paymentRequest);

String expected = "\"mpiData\":{\"cavv\":\"AQIDBAUGBwgJCgsMDQ4PEBESExQ=\"}";
ClientInterface http = client.getHttpClient();
verify(http).request(anyString(), contains(expected), any(), eq(false), isNull(), any());
}
}
134 changes: 134 additions & 0 deletions templates/libraries/okhttp-gson/AbstractOpenApiSchema.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{{>licenseInfo}}

package {{modelPackage}};

import java.util.Objects;
import java.lang.reflect.Type;
import java.util.Map;
import javax.ws.rs.core.GenericType;

/**
* Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
*/
public abstract class AbstractOpenApiSchema {
// store the actual instance of the schema/object
private Object instance;
// is nullable
private Boolean isNullable;
// schema type (e.g. oneOf, anyOf)
private final String schemaType;
public AbstractOpenApiSchema(String schemaType, Boolean isNullable) {
this.schemaType = schemaType;
this.isNullable = isNullable;
}

/**
* Get the list of oneOf/anyOf composed schemas allowed to be stored in this object
*
* @return an instance of the actual schema/object
*/
public abstract Map<String, GenericType> getSchemas();

/**
* Get the actual instance
*
* @return an instance of the actual schema/object
*/
//@JsonValue
public Object getActualInstance() {return instance;}

/**
* Set the actual instance
*
* @param instance the actual instance of the schema/object
*/
public void setActualInstance(Object instance) {this.instance = instance;}

/**
* Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well
*
* @return an instance of the actual schema/object
*/
public Object getActualInstanceRecursively() {
return getActualInstanceRecursively(this);
}

private Object getActualInstanceRecursively(AbstractOpenApiSchema object) {
if (object.getActualInstance() == null) {
return null;
} else if (object.getActualInstance() instanceof AbstractOpenApiSchema) {
return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance());
} else {
return object.getActualInstance();
}
}

/**
* Get the schema type (e.g. anyOf, oneOf)
*
* @return the schema type
*/
public String getSchemaType() {
return schemaType;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ").append(getClass()).append(" {\n");
sb.append(" instance: ").append(toIndentedString(instance)).append("\n");
sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n");
sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AbstractOpenApiSchema a = (AbstractOpenApiSchema) o;
return Objects.equals(this.instance, a.instance) &&
Objects.equals(this.isNullable, a.isNullable) &&
Objects.equals(this.schemaType, a.schemaType);
}

@Override
public int hashCode() {
return Objects.hash(instance, isNullable, schemaType);
}

/**
* Is nullable
*
* @return true if it's nullable
*/
public Boolean isNullable() {
if (Boolean.TRUE.equals(isNullable)) {
return Boolean.TRUE;
} else {
return Boolean.FALSE;
}
}

{{>libraries/jersey2/additional_properties}}

}
Loading

0 comments on commit c549f7b

Please sign in to comment.