diff --git a/README.md b/README.md index 0c249e3..457294c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Add this dependency to your project's POM: ch.postfinance postfinancecheckout-java-sdk - 7.1.0 + 7.2.0 compile ``` @@ -33,7 +33,7 @@ Add this dependency to your project's POM: Add this dependency to your project's build file: ```groovy -compile "ch.postfinance:postfinancecheckout-java-sdk:7.1.0" +compile "ch.postfinance:postfinancecheckout-java-sdk:7.2.0" ``` ### Others @@ -46,7 +46,7 @@ mvn clean package Then manually install the following JARs: -* `target/postfinancecheckout-java-sdk-7.1.0.jar` +* `target/postfinancecheckout-java-sdk-7.2.0.jar` * `target/lib/*.jar` ## Usage diff --git a/build.gradle b/build.gradle index 011650e..a146100 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'idea' apply plugin: 'eclipse' group = 'ch.postfinance' -version = '7.1.0' +version = '7.2.0' buildscript { repositories { @@ -98,9 +98,9 @@ ext { jackson_version = "2.14.1" google_api_client_version = "2.2.0" guava_version = "32.1.2-jre" - jodatime_version = "2.9.9" junit_version = "4.13.2" httpclient_version = "4.5.14" + bouncycastle_version = "1.77" } dependencies { @@ -117,5 +117,6 @@ dependencies { exclude group: 'commons-codec', module: 'commons-codec' } compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version" + compile "org.bouncycastle:bcprov-jdk18on:$bouncycastle_version" testCompile "junit:junit:$junit_version" } diff --git a/build.sbt b/build.sbt index b076a26..5ef48e2 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "ch.postfinance", name := "postfinancecheckout-java-sdk", - version := "7.1.0", + version := "7.2.0", scalaVersion := "2.11.4", scalacOptions ++= Seq("-feature"), javacOptions in compile ++= Seq("-Xlint:deprecation"), diff --git a/pom.xml b/pom.xml index 9182f2d..901f82b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ postfinancecheckout-java-sdk jar postfinancecheckout-java-sdk - 7.1.0 + 7.2.0 https://postfinance.ch/en/business/products/e-commerce/postfinance-checkout-all-in-one.html The SDK for simplifying the integration with PostFinance Checkout API. diff --git a/src/main/java/ch/postfinance/sdk/DefaultHeaders.java b/src/main/java/ch/postfinance/sdk/DefaultHeaders.java index c91dade..da3a85d 100644 --- a/src/main/java/ch/postfinance/sdk/DefaultHeaders.java +++ b/src/main/java/ch/postfinance/sdk/DefaultHeaders.java @@ -34,7 +34,7 @@ public void intercept(HttpRequest request) throws IOException { private HttpHeaders getDefaultHeaders() { HttpHeaders headers = new HttpHeaders(); - headers.put("x-meta-sdk-version", "7.1.0"); + headers.put("x-meta-sdk-version", "7.2.0"); headers.put("x-meta-sdk-language", "java"); headers.put("x-meta-sdk-provider", "PostFinance Checkout"); headers.put("x-meta-sdk-language-version", System.getProperty("java.version")); diff --git a/src/main/java/ch/postfinance/sdk/EncryptionUtil.java b/src/main/java/ch/postfinance/sdk/EncryptionUtil.java index 1a7ed9e..0192fd4 100644 --- a/src/main/java/ch/postfinance/sdk/EncryptionUtil.java +++ b/src/main/java/ch/postfinance/sdk/EncryptionUtil.java @@ -31,7 +31,7 @@ import java.security.spec.X509EncodedKeySpec; import java.util.Base64; -import com.wallee.sdk.model.WebhookEncryptionPublicKey; +import ch.postfinance.sdk.model.WebhookEncryptionPublicKey; /** * Helper class to verify content body with signature @@ -57,19 +57,19 @@ public static boolean isContentValid(String contentToVerify, String contentSigna try { verifier.initVerify(publicKey); } catch (InvalidKeyException e) { - throw new WalleeSdkException(ErrorCode.WEBHOOK_ENCRYPTION_GENERAL_ERROR, + throw new PostFinanceCheckoutSdkException(ErrorCode.WEBHOOK_ENCRYPTION_GENERAL_ERROR, "Could not verify content due to public key issue: " + e.getLocalizedMessage()); } try { verifier.update(contentToVerify.getBytes(StandardCharsets.UTF_8)); } catch (SignatureException e) { - throw new WalleeSdkException(ErrorCode.WEBHOOK_ENCRYPTION_GENERAL_ERROR, + throw new PostFinanceCheckoutSdkException(ErrorCode.WEBHOOK_ENCRYPTION_GENERAL_ERROR, "Could not verify content due to verifier issue: " + e.getLocalizedMessage()); } try { return verifier.verify(Base64.getDecoder().decode(contentSignature)); } catch (SignatureException e) { - throw new WalleeSdkException(ErrorCode.WEBHOOK_ENCRYPTION_GENERAL_ERROR, + throw new PostFinanceCheckoutSdkException(ErrorCode.WEBHOOK_ENCRYPTION_GENERAL_ERROR, "Could not verify content due to unknown issue: " + e.getLocalizedMessage()); } @@ -83,13 +83,13 @@ private static PublicKey getPublicKey(String publicKeyId, byte[] publicKeyBytes, .generatePublic( new X509EncodedKeySpec(publicKeyBytes)); } catch (InvalidKeySpecException e) { - throw new WalleeSdkException(ErrorCode.WEBHOOK_ENCRYPTION_UNKNOWN_ALGORITHM, + throw new PostFinanceCheckoutSdkException(ErrorCode.WEBHOOK_ENCRYPTION_UNKNOWN_ALGORITHM, "Invalid public key with ID: " + publicKeyId); } catch (NoSuchAlgorithmException e) { - throw new WalleeSdkException(ErrorCode.WEBHOOK_ENCRYPTION_UNKNOWN_ALGORITHM, + throw new PostFinanceCheckoutSdkException(ErrorCode.WEBHOOK_ENCRYPTION_UNKNOWN_ALGORITHM, "Unknown webhook signature encryption algorithm: " + signatureAlgorithm); } catch (NoSuchProviderException e) { - throw new WalleeSdkException(ErrorCode.WEBHOOK_ENCRYPTION_UNKNOWN_PROVIDER, + throw new PostFinanceCheckoutSdkException(ErrorCode.WEBHOOK_ENCRYPTION_UNKNOWN_PROVIDER, "Unknown webhook signature encryption provider: " + encryptionProvider); } } @@ -98,7 +98,7 @@ private static Signature getSignature(String signatureAlgorithm) { try { return Signature.getInstance(signatureAlgorithm); } catch (NoSuchAlgorithmException e) { - throw new WalleeSdkException(ErrorCode.WEBHOOK_ENCRYPTION_UNKNOWN_ALGORITHM, + throw new PostFinanceCheckoutSdkException(ErrorCode.WEBHOOK_ENCRYPTION_UNKNOWN_ALGORITHM, "Unknown signature algorithm: " + signatureAlgorithm); } } @@ -110,7 +110,7 @@ private static String getPublicKeyAlgorithm(String signatureAlgorithm) { publicKeyAlgorithm = "ECDSA"; break; default: - throw new WalleeSdkException(ErrorCode.WEBHOOK_ENCRYPTION_UNKNOWN_ALGORITHM, + throw new PostFinanceCheckoutSdkException(ErrorCode.WEBHOOK_ENCRYPTION_UNKNOWN_ALGORITHM, "Unknown webhook signature encryption algorithm: " + signatureAlgorithm); } return publicKeyAlgorithm; diff --git a/src/main/java/ch/postfinance/sdk/service/WebhookEncryptionService.java b/src/main/java/ch/postfinance/sdk/service/WebhookEncryptionService.java index ebdeb21..7e5fe24 100644 --- a/src/main/java/ch/postfinance/sdk/service/WebhookEncryptionService.java +++ b/src/main/java/ch/postfinance/sdk/service/WebhookEncryptionService.java @@ -186,11 +186,11 @@ public boolean isContentValid(String signatureHeader, String contentToVerify, St try { publicKey = this.read(publicKeyId); } catch (IOException e) { - throw new WalleeSdkException(ErrorCode.WEBHOOK_ENCRYPTION_GENERAL_ERROR, + throw new PostFinanceCheckoutSdkException(ErrorCode.WEBHOOK_ENCRYPTION_GENERAL_ERROR, "Could not retrieve public key with ID: " + publicKeyId); - } catch (WalleeSdkException e) { + } catch (PostFinanceCheckoutSdkException e) { if (e.getCode() == ENTITY_NOT_FOUND) { - throw new WalleeSdkException( + throw new PostFinanceCheckoutSdkException( ErrorCode.WEBHOOK_ENCRYPTION_PUBLIC_KEY_UNKNOWN, "Unknown public key with ID: " + publicKeyId); } @@ -200,7 +200,7 @@ public boolean isContentValid(String signatureHeader, String contentToVerify, St } return EncryptionUtil.isContentValid(contentToVerify, contentSignature, publicKey, encryptionProviderName, signatureAlgorithm); } else { - throw new WalleeSdkException(WEBHOOK_ENCRYPTION_SIGNATURE_HEADER_INVALID, "Invalid webhook signature header. Expected format: 'algorithm=, keyId=, signature='"); + throw new PostFinanceCheckoutSdkException(WEBHOOK_ENCRYPTION_SIGNATURE_HEADER_INVALID, "Invalid webhook signature header. Expected format: 'algorithm=, keyId=, signature='"); } }