Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dist: trusty

jdk:
- oraclejdk8
- openjdk7

install: mvn install -Dgpg.skip=true

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The Library supports all APIs under the following services:

## Requirements

* Java 7 or higher
* Java 8 or higher

## Installation

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/com/adyen/Util/HMACValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,23 @@
*/
package com.adyen.Util;

import java.nio.charset.Charset;
import com.adyen.model.Amount;
import com.adyen.model.notification.NotificationRequestItem;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.SignatureException;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedMap;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import com.adyen.model.Amount;
import com.adyen.model.notification.NotificationRequestItem;

import static com.adyen.constants.ApiConstants.AdditionalData.HMAC_SIGNATURE;

public class HMACValidator {
public static final String HMAC_SHA256_ALGORITHM = "HmacSHA256";
public static final Charset C_UTF8 = Charset.forName("UTF8");
public static final String DATA_SEPARATOR = ":";

// To calculate the HMAC SHA-256
Expand All @@ -54,7 +53,7 @@ public String calculateHMAC(String data, String key) throws java.security.Signat
mac.init(signingKey);

// Compute the hmac on input data bytes
byte[] rawHmac = mac.doFinal(data.getBytes(C_UTF8));
byte[] rawHmac = mac.doFinal(data.getBytes(StandardCharsets.UTF_8));

// Base64-encode the hmac
return new String(Base64.encodeBase64(rawHmac));
Expand Down
25 changes: 11 additions & 14 deletions src/main/java/com/adyen/httpclient/HttpURLConnectionClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import java.io.FileInputStream;
Expand Down Expand Up @@ -301,20 +300,18 @@ private void installCertificateCommonNameValidator(HttpURLConnection connection,
if (connection instanceof HttpsURLConnection) {
HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;

HostnameVerifier terminalHostsValid = new HostnameVerifier() {
public boolean verify(String host, SSLSession session) {
try {
if (session.getPeerCertificates() != null && session.getPeerCertificates().length > 0) {
// Assume the first certificate is the leaf, since chain will be ordered, according to Java documentation:
// https://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLSession.html#getPeerCertificates()
X509Certificate certificate = (X509Certificate) session.getPeerCertificates()[0];
return TerminalCommonNameValidator.validateCertificate(certificate, environment);
}
return false;
} catch (SSLPeerUnverifiedException e) {
e.printStackTrace();
return false;
HostnameVerifier terminalHostsValid = (host, session) -> {
try {
if (session.getPeerCertificates() != null && session.getPeerCertificates().length > 0) {
// Assume the first certificate is the leaf, since chain will be ordered, according to Java documentation:
// https://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLSession.html#getPeerCertificates()
X509Certificate certificate = (X509Certificate) session.getPeerCertificates()[0];
return TerminalCommonNameValidator.validateCertificate(certificate, environment);
}
return false;
} catch (SSLPeerUnverifiedException e) {
e.printStackTrace();
return false;
}
};
// Install the terminal-trusting host verifier
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/adyen/model/AbstractPaymentRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public T setBrowserInfoData(String userAgent, String acceptHeader) {
*/
public Map<String, String> getOrCreateAdditionalData() {
if (this.getAdditionalData() == null) {
this.setAdditionalData(new HashMap<String, String>());
this.setAdditionalData(new HashMap<>());
}

return this.getAdditionalData();
Expand Down Expand Up @@ -994,7 +994,7 @@ private String stringifyAdditionalData() {
return null;
}

Map<String, String> nonSensitiveAdditionalData = new HashMap<String, String>(additionalData);
Map<String, String> nonSensitiveAdditionalData = new HashMap<>(additionalData);
List<String> keys = Arrays.asList(ApiConstants.AdditionalData.Card.Encrypted.JSON,
ApiConstants.AdditionalData.ENCRYPTED_CARD_NUMBER,
ApiConstants.AdditionalData.ENCRYPTED_EXPIRY_MONTH,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/adyen/model/DeviceRenderOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public DeviceRenderOptions sdkUiType(List<SdkUiTypeEnum> sdkUiType) {
public DeviceRenderOptions addSdkUiTypeItem(SdkUiTypeEnum sdkUiTypeItem) {

if (this.sdkUiType == null) {
this.sdkUiType = new ArrayList<SdkUiTypeEnum>();
this.sdkUiType = new ArrayList<>();
}

this.sdkUiType.add(sdkUiTypeItem);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/adyen/model/FraudResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class FraudResult {
private Integer accountScore = null;

@SerializedName("results")
private List<FraudCheckResultContainer> results = new ArrayList<FraudCheckResultContainer>();
private List<FraudCheckResultContainer> results = new ArrayList<>();

public FraudResult accountScore(Integer accountScore) {
this.accountScore = accountScore;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/adyen/model/PaymentRequest3ds2.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void setMerchantRiskIndicator(MerchantRiskIndicator merchantRiskIndicator
public PaymentRequest3ds2 addSplitsItem(Split splitsItem) {

if (this.splits == null) {
this.splits = new ArrayList<Split>();
this.splits = new ArrayList<>();
}

this.splits.add(splitsItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
package com.adyen.model.binlookup;

import java.util.Arrays;
import java.util.Objects;

import com.adyen.serializer.ByteArrayToStringAdapter;
Expand Down Expand Up @@ -108,8 +109,8 @@ public boolean equals(Object o) {
return false;
}
DSPublicKeyDetail dsPublicKeyDetail = (DSPublicKeyDetail) o;
return Objects.equals(this.brand, dsPublicKeyDetail.brand) && Objects.equals(this.directoryServerId, dsPublicKeyDetail.directoryServerId) && Objects.equals(this.publicKey,
dsPublicKeyDetail.publicKey);
return Objects.equals(this.brand, dsPublicKeyDetail.brand) && Objects.equals(this.directoryServerId, dsPublicKeyDetail.directoryServerId) && Arrays.equals(this.publicKey,
dsPublicKeyDetail.publicKey);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ThreeDSAvailabilityRequest {
private Object additionalData = null;

@SerializedName("brands")
private List<String> brands = new ArrayList<String>();
private List<String> brands = new ArrayList<>();

@SerializedName("cardNumber")
private String cardNumber = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ThreeDSAvailabilityResponse dsPublicKeys(List<DSPublicKeyDetail> dsPublic

public ThreeDSAvailabilityResponse addDsPublicKeysItem(DSPublicKeyDetail dsPublicKeysItem) {
if (this.dsPublicKeys == null) {
this.dsPublicKeys = new ArrayList<DSPublicKeyDetail>();
this.dsPublicKeys = new ArrayList<>();
}
this.dsPublicKeys.add(dsPublicKeysItem);
return this;
Expand Down Expand Up @@ -115,7 +115,7 @@ public ThreeDSAvailabilityResponse threeDS2CardRangeDetails(List<ThreeDS2CardRan

public ThreeDSAvailabilityResponse addThreeDS2CardRangeDetailsItem(ThreeDS2CardRangeDetail threeDS2CardRangeDetailsItem) {
if (this.threeDS2CardRangeDetails == null) {
this.threeDS2CardRangeDetails = new ArrayList<ThreeDS2CardRangeDetail>();
this.threeDS2CardRangeDetails = new ArrayList<>();
}
this.threeDS2CardRangeDetails.add(threeDS2CardRangeDetailsItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public CreatePaymentLinkRequest allowedPaymentMethods(List<String> allowedPaymen

public CreatePaymentLinkRequest addAllowedPaymentMethodsItem(String allowedPaymentMethodsItem) {
if (this.allowedPaymentMethods == null) {
this.allowedPaymentMethods = new ArrayList<String>();
this.allowedPaymentMethods = new ArrayList<>();
}
this.allowedPaymentMethods.add(allowedPaymentMethodsItem);
return this;
Expand Down Expand Up @@ -146,7 +146,7 @@ public CreatePaymentLinkRequest blockedPaymentMethods(List<String> blockedPaymen

public CreatePaymentLinkRequest addBlockedPaymentMethodsItem(String blockedPaymentMethodsItem) {
if (this.blockedPaymentMethods == null) {
this.blockedPaymentMethods = new ArrayList<String>();
this.blockedPaymentMethods = new ArrayList<>();
}
this.blockedPaymentMethods.add(blockedPaymentMethodsItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public PaymentMethodsResponse oneClickPaymentMethods(List<RecurringDetail> oneCl
public PaymentMethodsResponse addOneClickPaymentMethodsItem(RecurringDetail oneClickPaymentMethodsItem) {

if (this.oneClickPaymentMethods == null) {
this.oneClickPaymentMethods = new ArrayList<RecurringDetail>();
this.oneClickPaymentMethods = new ArrayList<>();
}

this.oneClickPaymentMethods.add(oneClickPaymentMethodsItem);
Expand Down Expand Up @@ -80,7 +80,7 @@ public PaymentMethodsResponse paymentMethods(List<PaymentMethod> paymentMethods)
public PaymentMethodsResponse addPaymentMethodsItem(PaymentMethod paymentMethodsItem) {

if (this.paymentMethods == null) {
this.paymentMethods = new ArrayList<PaymentMethod>();
this.paymentMethods = new ArrayList<>();
}

this.paymentMethods.add(paymentMethodsItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public PaymentSessionRequest allowedPaymentMethods(List<String> allowedPaymentMe
public PaymentSessionRequest addAllowedPaymentMethodsItem(String allowedPaymentMethodsItem) {

if (this.allowedPaymentMethods == null) {
this.allowedPaymentMethods = new ArrayList<String>();
this.allowedPaymentMethods = new ArrayList<>();
}

this.allowedPaymentMethods.add(allowedPaymentMethodsItem);
Expand Down Expand Up @@ -591,7 +591,7 @@ public PaymentSessionRequest blockedPaymentMethods(List<String> blockedPaymentMe
public PaymentSessionRequest addBlockedPaymentMethodsItem(String blockedPaymentMethodsItem) {

if (this.blockedPaymentMethods == null) {
this.blockedPaymentMethods = new ArrayList<String>();
this.blockedPaymentMethods = new ArrayList<>();
}

this.blockedPaymentMethods.add(blockedPaymentMethodsItem);
Expand Down Expand Up @@ -901,7 +901,7 @@ public PaymentSessionRequest lineItems(List<LineItem> lineItems) {
public PaymentSessionRequest addLineItemsItem(LineItem lineItemsItem) {

if (this.lineItems == null) {
this.lineItems = new ArrayList<LineItem>();
this.lineItems = new ArrayList<>();
}

this.lineItems.add(lineItemsItem);
Expand Down Expand Up @@ -1319,7 +1319,7 @@ public PaymentSessionRequest splits(List<Split> splits) {
public PaymentSessionRequest addSplitsItem(Split splitsItem) {

if (this.splits == null) {
this.splits = new ArrayList<Split>();
this.splits = new ArrayList<>();
}

this.splits.add(splitsItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public PaymentSessionResponse lineItems(List<LineItem> lineItems) {
public PaymentSessionResponse addLineItemsItem(LineItem lineItemsItem) {

if (this.lineItems == null) {
this.lineItems = new ArrayList<LineItem>();
this.lineItems = new ArrayList<>();
}

this.lineItems.add(lineItemsItem);
Expand Down Expand Up @@ -233,7 +233,7 @@ public PaymentSessionResponse oneClickPaymentMethods(List<RecurringDetail> oneCl
public PaymentSessionResponse addOneClickPaymentMethodsItem(RecurringDetail oneClickPaymentMethodsItem) {

if (this.oneClickPaymentMethods == null) {
this.oneClickPaymentMethods = new ArrayList<RecurringDetail>();
this.oneClickPaymentMethods = new ArrayList<>();
}

this.oneClickPaymentMethods.add(oneClickPaymentMethodsItem);
Expand Down Expand Up @@ -337,7 +337,7 @@ public PaymentSessionResponse paymentMethods(List<PaymentMethod> paymentMethods)
public PaymentSessionResponse addPaymentMethodsItem(PaymentMethod paymentMethodsItem) {

if (this.paymentMethods == null) {
this.paymentMethods = new ArrayList<PaymentMethod>();
this.paymentMethods = new ArrayList<>();
}

this.paymentMethods.add(paymentMethodsItem);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/adyen/model/checkout/PaymentsRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,8 @@ public PaymentsRequest addCardData(String cardNumber, String expiryMonth, String

public PaymentsRequest addOneClickData(String recurringDetailReference, String encryptedSecurityCode) {
DefaultPaymentMethodDetails paymentMethodDetails = new DefaultPaymentMethodDetails();
paymentMethodDetails.type(TYPE_SCHEME).recurringDetailReference(recurringDetailReference).encryptedSecurityCode(encryptedSecurityCode);
paymentMethodDetails.type(TYPE_SCHEME).setStoredPaymentMethodId(recurringDetailReference);
paymentMethodDetails.type(TYPE_SCHEME).encryptedSecurityCode(encryptedSecurityCode);

paymentMethod = paymentMethodDetails;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public PaymentsResponse details(List<InputDetail> details) {
public PaymentsResponse addDetailsItem(InputDetail detailsItem) {

if (this.details == null) {
this.details = new ArrayList<InputDetail>();
this.details = new ArrayList<>();
}

this.details.add(detailsItem);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/adyen/model/checkout/SubInputDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public SubInputDetail items(List<Item> items) {
public SubInputDetail addItemsItem(Item itemsItem) {

if (this.items == null) {
this.items = new ArrayList<Item>();
this.items = new ArrayList<>();
}

this.items.add(itemsItem);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/adyen/model/checkout/ThreeDSecureData.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.gson.stream.JsonWriter;

import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;

/**
Expand Down Expand Up @@ -174,13 +175,13 @@ public boolean equals(java.lang.Object o) {
}
ThreeDSecureData threeDSecureData = (ThreeDSecureData) o;
return Objects.equals(this.authenticationResponse, threeDSecureData.authenticationResponse)
&& Objects.equals(this.cavv, threeDSecureData.cavv)
&& Arrays.equals(this.cavv, threeDSecureData.cavv)
&& Objects.equals(this.cavvAlgorithm,
threeDSecureData.cavvAlgorithm)
&& Objects.equals(this.directoryResponse, threeDSecureData.directoryResponse)
&& Objects.equals(this.eci, threeDSecureData.eci)
&& Objects.equals(this.threeDSVersion, threeDSecureData.threeDSVersion)
&& Objects.equals(this.xid, threeDSecureData.xid)
&& Arrays.equals(this.xid, threeDSecureData.xid)
&& Objects.equals(this.dsTransID, threeDSecureData.dsTransID);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class OriginKeysRequest {

@SerializedName("originDomains")
private List<String> originDomains = new ArrayList<String>();
private List<String> originDomains = new ArrayList<>();

public OriginKeysRequest originDomains(List<String> originDomains) {
this.originDomains = originDomains;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public AccountHolderBalanceResponse balancePerAccount(List<AccountDetailBalance>

public AccountHolderBalanceResponse addBalancePerAccountItem(AccountDetailBalance balancePerAccountItem) {
if (this.balancePerAccount == null) {
this.balancePerAccount = new ArrayList<AccountDetailBalance>();
this.balancePerAccount = new ArrayList<>();
}
this.balancePerAccount.add(balancePerAccountItem);
return this;
Expand All @@ -80,7 +80,7 @@ public AccountHolderBalanceResponse invalidFields(List<ErrorFieldType> invalidFi

public AccountHolderBalanceResponse addInvalidFieldsItem(ErrorFieldType invalidFieldsItem) {
if (this.invalidFields == null) {
this.invalidFields = new ArrayList<ErrorFieldType>();
this.invalidFields = new ArrayList<>();
}
this.invalidFields.add(invalidFieldsItem);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public AccountHolderDetails bankAccountDetails(List<BankAccountDetail> bankAccou

public AccountHolderDetails addBankAccountDetailsItem(BankAccountDetail bankAccountDetailsItem) {
if (this.bankAccountDetails == null) {
this.bankAccountDetails = new ArrayList<BankAccountDetail>();
this.bankAccountDetails = new ArrayList<>();
}
this.bankAccountDetails.add(bankAccountDetailsItem);
return this;
Expand Down Expand Up @@ -225,7 +225,7 @@ public AccountHolderDetails payoutMethods(List<PayoutMethod> payoutMethods) {

public AccountHolderDetails addPayoutMethodsItem(PayoutMethod payoutMethodsItem) {
if (this.payoutMethods == null) {
this.payoutMethods = new ArrayList<PayoutMethod>();
this.payoutMethods = new ArrayList<>();
}
this.payoutMethods.add(payoutMethodsItem);
return this;
Expand Down
Loading