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
172 changes: 172 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<!--

Checkstyle configuration that checks the sun coding conventions from:

- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html

- the Sun Code Conventions at http://java.sun.com/docs/codeconv/

- the Javadoc guidelines at
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html

- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html

- some best practices

Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).

Most Checks are configurable, be sure to consult the documentation.

To completely disable a check, just comment it out or delete it from the file.

Finally, it is worth reading the documentation.

-->

<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
http://checkstyle.sourceforge.net/5.x/config.html#Checker

<property name="basedir" value="${basedir}"/>
-->

<property name="fileExtensions" value="java, properties, xml"/>

<!-- Checks that a package-info.java file exists for each package. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
<!--<module name="JavadocPackage"/>-->

<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
<!--<module name="NewlineAtEndOfFile"/>-->

<!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<module name="Translation"/>

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="FileLength"/>

<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter"/>

<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>

<!-- Checks for Headers -->
<!-- See http://checkstyle.sf.net/config_header.html -->
<!-- <module name="Header"> -->
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
<!-- <property name="fileExtensions" value="java"/> -->
<!-- </module> -->

<module name="TreeWalker">

<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<!--<module name="JavadocMethod"/>-->
<!--<module name="JavadocType"/>-->
<!--<module name="JavadocVariable"/>-->
<!--<module name="JavadocStyle"/>-->

<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>

<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="false"/>
</module>

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<!--<module name="LineLength"/>-->
<module name="MethodLength"/>
<module name="ParameterNumber"/>

<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<!--<module name="NoWhitespaceAfter"/>-->
<module name="NoWhitespaceBefore"/>
<!--<module name="OperatorWrap"/>-->
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>

<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>

<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>

<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<!--<module name="AvoidInlineConditionals"/>-->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<!--<module name="HiddenField"/>-->
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<!--<module name="MagicNumber"/>-->
<module name="MissingSwitchDefault"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>

<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<!--<module name="DesignForExtension"/>-->
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<!--<module name="InterfaceIsType"/>-->
<!--<module name="VisibilityModifier"/>-->

<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<!--<module name="FinalParameters"/>-->
<module name="TodoComment"/>
<module name="UpperEll"/>

</module>

</module>
55 changes: 43 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,11 @@
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -126,6 +118,45 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<instructions>
<Export-Package>com.adyen</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down
19 changes: 8 additions & 11 deletions src/main/java/com/adyen/Util/HMACValidator.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
Expand All @@ -20,10 +20,6 @@
*/
package com.adyen.Util;

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

import com.adyen.model.Amount;
import com.adyen.model.notification.NotificationRequestItem;
import java.nio.charset.Charset;
import java.security.SignatureException;
import java.util.ArrayList;
Expand All @@ -33,10 +29,13 @@
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 final static String HMAC_SHA256_ALGORITHM = "HmacSHA256";
public final static Charset C_UTF8 = Charset.forName("UTF8");
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 Down Expand Up @@ -64,13 +63,11 @@ public String calculateHMAC(String data, String key) throws java.security.Signat
}

// To calculate the HMAC SHA-256
public String calculateHMAC(NotificationRequestItem notificationRequestItem, String key)
throws SignatureException {
public String calculateHMAC(NotificationRequestItem notificationRequestItem, String key) throws SignatureException {
return calculateHMAC(getDataToSign(notificationRequestItem), key);
}

public boolean validateHMAC(NotificationRequestItem notificationRequestItem, String key)
throws SignatureException {
public boolean validateHMAC(NotificationRequestItem notificationRequestItem, String key) throws SignatureException {

final String expectedSign = calculateHMAC(notificationRequestItem, key);
final String merchantSign = notificationRequestItem.getAdditionalData().get(HMAC_SIGNATURE);
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/adyen/constants/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ interface PaymentMethodType {
String TYPE_SCHEME = "scheme";
}

interface RequestProperty
{
interface RequestProperty {
String IDEMPOTENCY_KEY = "Idempotency-Key";
String ACCEPT_CHARSET = "Accept-Charset";
String USER_AGENT = "User-Agent";
String METHOD_POST ="POST";
String CONTENT_TYPE ="Content-Type";
String METHOD_POST = "POST";
String CONTENT_TYPE = "Content-Type";
String API_KEY = "x-api-key";
String APPLICATION_JSON_TYPE ="application/json";
String APPLICATION_JSON_TYPE = "application/json";
}
}
22 changes: 11 additions & 11 deletions src/main/java/com/adyen/enums/Environment.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
Expand All @@ -21,14 +21,14 @@
package com.adyen.enums;

public enum Environment {
TEST {
public String toString(){
return "TEST";
}
},
LIVE{
public String toString(){
return "LIVE";
}
}
TEST {
public String toString() {
return "TEST";
}
},
LIVE {
public String toString() {
return "LIVE";
}
}
}
8 changes: 4 additions & 4 deletions src/main/java/com/adyen/enums/VatCategory.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
Expand All @@ -22,17 +22,17 @@

public enum VatCategory {
HIGH {
public String toString(){
public String toString() {
return "High";
}
},
LOW {
public String toString(){
public String toString() {
return "Low";
}
},
NONE {
public String toString(){
public String toString() {
return "None";
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/adyen/httpclient/HTTPClientException.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
Expand Down Expand Up @@ -28,7 +28,8 @@ public class HTTPClientException extends Exception {
private Map<String, List<String>> responseHeaders = null;
private String responseBody = null;

public HTTPClientException() {}
public HTTPClientException() {
}

public HTTPClientException(Throwable throwable) {
super(throwable);
Expand Down
Loading