diff --git a/README.md b/README.md index 8c600651a1..880baac2cc 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ This README provides the usage manual for the SDK itself. For the full documenta To integrate the Adyen SDK into your project, import the **core**, **utils** and **ui** module by adding the following lines to your build.gradle file. ``` -compile 'com.adyen.checkout:core:1.9.0' -compile 'com.adyen.checkout:utils:1.9.0' -compile 'com.adyen.checkout:ui:1.9.0' -compile 'com.adyen.checkout:cardscan:1.9.0' +compile 'com.adyen.checkout:core:1.10.0' +compile 'com.adyen.checkout:utils:1.10.0' +compile 'com.adyen.checkout:ui:1.10.0' +compile 'com.adyen.checkout:cardscan:1.10.0' ``` > For implementing Custom integration, only the **core** module is required. However, you might also want to include the **utils** module to use Adyen's utility methods such as Luhn check, credit card type detection, etc. diff --git a/adyen-core/src/main/java/com/adyen/core/internals/HttpClient.java b/adyen-core/src/main/java/com/adyen/core/internals/HttpClient.java index 3456bd190e..2461a5f34d 100644 --- a/adyen-core/src/main/java/com/adyen/core/internals/HttpClient.java +++ b/adyen-core/src/main/java/com/adyen/core/internals/HttpClient.java @@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit; import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; import javax.net.ssl.SSLException; import javax.net.ssl.SSLSocketFactory; @@ -53,9 +52,7 @@ public HttpClient() { readTimeout = (int) TimeUnit.SECONDS.toMillis(60); try { - SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); - sslContext.init(null, null, null); - sslSocketFactory = sslContext.getSocketFactory(); + sslSocketFactory = new TLSSocketFactory(); } catch (final @NonNull NoSuchAlgorithmException | KeyManagementException e) { e.printStackTrace(); sslSocketFactory = null; diff --git a/adyen-core/src/main/java/com/adyen/core/internals/TLSSocketFactory.java b/adyen-core/src/main/java/com/adyen/core/internals/TLSSocketFactory.java new file mode 100644 index 0000000000..9a24ad5e77 --- /dev/null +++ b/adyen-core/src/main/java/com/adyen/core/internals/TLSSocketFactory.java @@ -0,0 +1,72 @@ +package com.adyen.core.internals; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.Socket; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; + +/** + * An SSL Socket factory that only supports TLSv1.2. + */ +public class TLSSocketFactory extends SSLSocketFactory { + + private SSLSocketFactory internalSSLSocketFactory; + + public TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException { + SSLContext context = SSLContext.getInstance("TLSv1.2"); + context.init(null, null, null); + internalSSLSocketFactory = context.getSocketFactory(); + } + + @Override + public String[] getDefaultCipherSuites() { + return internalSSLSocketFactory.getDefaultCipherSuites(); + } + + @Override + public String[] getSupportedCipherSuites() { + return internalSSLSocketFactory.getSupportedCipherSuites(); + } + + @Override + public Socket createSocket() throws IOException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket()); + } + + @Override + public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket(s, host, port, autoClose)); + } + + @Override + public Socket createSocket(String host, int port) throws IOException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port)); + } + + @Override + public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port, localHost, localPort)); + } + + @Override + public Socket createSocket(InetAddress host, int port) throws IOException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port)); + } + + @Override + public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket(address, port, localAddress, localPort)); + } + + private Socket enableTLSOnSocket(Socket socket) { + if (socket != null && (socket instanceof SSLSocket)) { + ((SSLSocket) socket).setEnabledProtocols(new String[]{"TLSv1.2"}); + } + return socket; + } +} diff --git a/app/src/androidTest/java/com/adyen/checkout/PaymentAppTest.java b/app/src/androidTest/java/com/adyen/checkout/PaymentAppTest.java index 4454e8710c..c6001c968e 100644 --- a/app/src/androidTest/java/com/adyen/checkout/PaymentAppTest.java +++ b/app/src/androidTest/java/com/adyen/checkout/PaymentAppTest.java @@ -252,7 +252,7 @@ public void testIdealPayment() throws Exception { @Test public void testSepaDirectDebitPayment() throws Exception { - checkSepaPayment(AMOUNT, EUR, IBAN, ACCOUNT_OWNER_NAME, Payment.PaymentStatus.RECEIVED.toString()); + checkSepaPayment(AMOUNT, EUR, IBAN, ACCOUNT_OWNER_NAME, Payment.PaymentStatus.AUTHORISED.toString()); } @Test @@ -269,7 +269,7 @@ public void testOrientationChangeOnSEPADirectDebitScreen() throws Exception { onView(withId(R.id.consent_direct_debit_checkbox)).perform(click()); EspressoTestUtils.rotateScreen(); onView(withId(R.id.collect_direct_debit_data)).perform(click()); - checkResultString(Payment.PaymentStatus.RECEIVED.toString()); + checkResultString(Payment.PaymentStatus.AUTHORISED.toString()); } @Test diff --git a/build.gradle b/build.gradle index 7d6af5c315..06fb4f4e6d 100644 --- a/build.gradle +++ b/build.gradle @@ -28,10 +28,10 @@ ext { supportAnnotationsVersion = "25.3.1" jUnitVersion = "4.12" - minSdkVersion = 15 + minSdkVersion = 16 targetSdkVersion = 25 - versionCode = 11 - versionName = "1.9.0" + versionCode = 12 + versionName = "1.10.0" release_debuggable = false release_minifyEnabled = false diff --git a/checkoutdemo/build.gradle b/checkoutdemo/build.gradle index 5b562fa181..862f7cbce0 100644 --- a/checkoutdemo/build.gradle +++ b/checkoutdemo/build.gradle @@ -37,8 +37,8 @@ dependencies { }) compile "com.android.support:appcompat-v7:${rootProject.supportLibVersion}" testCompile "junit:junit:${rootProject.jUnitVersion}" - compile 'com.adyen.checkout:core:1.9.0' - compile 'com.adyen.checkout:ui:1.9.0' - compile 'com.adyen.checkout:utils:1.9.0' - compile 'com.adyen.checkout:cardscan:1.9.0' + compile 'com.adyen.checkout:core:1.10.0' + compile 'com.adyen.checkout:ui:1.10.0' + compile 'com.adyen.checkout:utils:1.10.0' + compile 'com.adyen.checkout:cardscan:1.10.0' }