Skip to content

Commit 9b21f0b

Browse files
author
adkumar3
committed
Merge remote-tracking branch 'upstream/master'
2 parents c5ec0ca + 80aa073 commit 9b21f0b

33 files changed

Lines changed: 386 additions & 748 deletions

README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#CyberSource Simple Order API for Java
22

3-
[![Build Status](https://travis-ci.org/CyberSource/cybersource-sdk-java.png?branch=future)]
3+
[![Build Status](https://travis-ci.org/CyberSource/cybersource-sdk-java.png?branch=master)]
44
(https://travis-ci.org/CyberSource/cybersource-sdk-java)
55

66
##Package Managers
@@ -11,7 +11,7 @@ To install the cybersource-sdk-java from central repository,add dependency to yo
1111
<dependency>
1212
<groupId>com.cybersource</groupId>
1313
<artifactId>cybersource-sdk-java</artifactId>
14-
<version>6.2.3</version>
14+
<version>6.2.4</version>
1515
</dependency>
1616
````
1717
Run mvn install, to install dependency
@@ -20,7 +20,7 @@ To install the cybersource-sdk-java from central repository,add dependency to yo
2020
Add the dependency to your build.gradle
2121
````
2222
dependencies {
23-
compile 'com.cybersource:cybersource-sdk-java:6.2.3'
23+
compile 'com.cybersource:cybersource-sdk-java:6.2.4'
2424
}
2525
````
2626
##Requirements
@@ -86,12 +86,20 @@ You do not need to download and build the source to use the SDK but if you want
8686
8787
h. "serverURL" config parameter will take precedence over sendToProduction and sendToAkamai config parameters. By default the "serverURL" configuration is commented out.
8888

89+
<<<<<<< HEAD
8990
i. "enablejdkcert" parameter if set to true then it will read the JKS file specified at keysDirectory location. The file should be of the same name as specified in keyFilename.
9091

9192
j. cacerts this property will be considered only if "enablejdkcert" is set to true. If it is set to true then it means the JKS file is under cacerts folder of the JDK and
9293
it will read the JKS file from cacerts.
9394

9495
k. Please refer to the accompanying documentation for the other optional properties that you may wish to specify.
96+
=======
97+
i. "allowRetry" config parameter will only work for HttpClient. Set allowRetry config parameter to "true" to enable retry mechanism and set merchant specific values for the retry.
98+
Set integer values for config parameter numberOfRetries & retryInterval. Retry Interval is time delay for next retry in seconds. number of retry parameter should be set between
99+
1 to 5 any other value will throw an Error Message. Refer to the "Retry Pattern" section below.
100+
101+
j. Please refer to the accompanying documentation for the other optional properties that you may wish to specify.
102+
>>>>>>> upstream/master
95103
96104

97105
4. Build this project using Maven.
@@ -189,6 +197,15 @@ We have two ways to test, One is using maven tool and other is to download the z
189197
Cryptography Algorithms
190198
CyberSource utilizes the following algorithms for this implementation. While others may work, the following are validated and recommended. SSL is used for transport security even with encrypted messages. CyberSource asymmetric keys are RSA 2048 keys and therefore your cryptography API should support 2048 bit RSA keys and signatures create with them. The messages are encrypted with a temporary derived key which is used per message. This derived key is AES 256 bit and utilizes CBC blocking mode for encryption. The derived key is encrypted with the recipient ( CyberSource ) public key. The key exchange algorithm used is RSA-OAEP.
191199

200+
##RETRY PATTERN
201+
202+
Retry Pattern Allows to retry sending a failed request and it will only work with useHttpClient=true, allowRetry flag enables the retry mechanism.
203+
set the value of allowRetry parameter to "TRUE/FALSE". Then the system will retry the failed request as many times as configured by the merchant
204+
in the config parameter 'numberOfRetries'.
205+
206+
numberOfRetries parameter value should be set between 0 to 5. By default the value for numberOfRetries will be 5. User can set a delay in between the retry attempts.
207+
Config parameter for this property is 'retryInterval' in cybs.property file. The default value for 'retryInterval' parameter is 5 which means a delay of 5 seconds.
208+
192209
##Third Party jars
193210
1.) org.apache.ws.security.wss4j:1.6.19
194211
The Apache WSS4J project provides a Java implementation of the primary security standards for Web Services, namely the OASIS Web Services Security (WS-Security) specifications
@@ -211,14 +228,11 @@ We have two ways to test, One is using maven tool and other is to download the z
211228
6.) commons-logging:commons-logging:jar:1.1.1
212229
This is getting downloaded as compile time dependency of wss4j:1.6.19.Apache Commons Logging is a thin adapter allowing configurable bridging to other, well known logging
213230
systems.
214-
215-
7.) org.slf4j:slf4j-api:1.7.21 and org.slf4j:slf4j-jcl:1.7.21 .
216-
slf4j-api is getting used as a dependency for wss4j. Modified to latest version.
217231

218-
8.) junit:junit:4.12
232+
7.) junit:junit:4.12
219233
JUnit is a unit testing framework for Java.
220234

221-
9.) org.mockito:mockito-all:1.10.19
235+
8.) org.mockito:mockito-all:1.10.19
222236
Mock objects library for java
223237

224238
##Documentation

java/pom.xml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</parent>
1010
<groupId>com.cybersource</groupId>
1111
<artifactId>cybersource-sdk-java</artifactId>
12-
<version>6.2.4-SNAPSHOT</version>
12+
<version>6.2.5-SNAPSHOT</version>
1313
<name>cybersource-sdk-java</name>
1414
<description>Simple Order API Client</description>
1515
<url>http://www.cybersource.com</url>
@@ -201,16 +201,6 @@
201201
<artifactId>wss4j</artifactId>
202202
<version>1.6.19</version>
203203
</dependency>
204-
<dependency>
205-
<groupId>org.slf4j</groupId>
206-
<artifactId>slf4j-api</artifactId>
207-
<version>1.7.21</version>
208-
</dependency>
209-
<dependency>
210-
<groupId>org.slf4j</groupId>
211-
<artifactId>slf4j-jcl</artifactId>
212-
<version>1.7.21</version>
213-
</dependency>
214204
<dependency>
215205
<groupId>org.apache.commons</groupId>
216206
<artifactId>commons-lang3</artifactId>

java/src/main/java/com/cybersource/ws/client/ApacheSignatureWrapper.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

java/src/main/java/com/cybersource/ws/client/BaseMessageHandler.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

java/src/main/java/com/cybersource/ws/client/Client.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ private static Document soapWrapAndSign(
198198
logger.log(Logger.LT_INFO, "Client, End of soapWrap ",true);
199199

200200
Document resultDocument = null;
201+
<<<<<<< HEAD
201202
if(mc.getEnablejdkcert()){
202203
SecurityUtil.readJdkCert(mc,logger);
203204
}
@@ -214,6 +215,20 @@ private static Document soapWrapAndSign(
214215
resultDocument = SecurityUtil.handleMessageCreation(resultDocument, mc.getMerchantID(), logger);
215216
logger.log(Logger.LT_INFO, "Client, End of handleMessageCreation ", true);
216217
}
218+
=======
219+
SecurityUtil.loadMerchantP12File(mc,logger);
220+
logger.log(Logger.LT_INFO, "Client, End of loadMerchantP12File ", true);
221+
222+
// sign Document object
223+
resultDocument = SecurityUtil.createSignedDoc(wrappedDoc, mc.getMerchantID(), mc.getKeyPassword(), logger);
224+
logger.log(Logger.LT_INFO, "Client, End of createSignedDoc ", true);
225+
226+
if ( mc.getUseSignAndEncrypted() ) {
227+
// Encrypt signed Document
228+
resultDocument = SecurityUtil.handleMessageCreation(resultDocument, mc.getMerchantID(), logger);
229+
logger.log(Logger.LT_INFO, "Client, End of handleMessageCreation ", true);
230+
}
231+
>>>>>>> upstream/master
217232
if (logSignedData) {
218233
logger.log(Logger.LT_REQUEST,Utility.nodeToString(resultDocument, PCI.REQUEST));
219234
//logger.log(Logger.LT_REQUEST,XMLUtils.PrettyDocumentToString(resultDocument));

java/src/main/java/com/cybersource/ws/client/Connection.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public Document post(Document request)
107107

108108
}
109109

110+
110111
/**
111112
* Validate the Http response for any faults returned from the server.
112113
* @throws FaultException

java/src/main/java/com/cybersource/ws/client/HttpClientConnection.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ private static String documentToString(Document doc)
189189
*/
190190
private class MyRetryHandler implements HttpMethodRetryHandler {
191191

192-
//
192+
long retryWaitInterval=mc.getRetryInterval();
193+
int maxRetries= mc.getNumberOfRetries();
194+
193195
// I copied this code from
194196
// http://jakarta.apache.org/commons/httpclient/exception-handling.html#HTTP%20transport%20safety
195197
// and changed the NoHttpResponseException case to
@@ -198,7 +200,7 @@ public boolean retryMethod(
198200
final HttpMethod method,
199201
final IOException exception,
200202
int executionCount) {
201-
if (executionCount > 5) {
203+
if (executionCount > maxRetries) {
202204
// Do not retry if over max retry count
203205
return false;
204206
}
@@ -210,6 +212,13 @@ public boolean retryMethod(
210212
if (!method.isRequestSent()) {
211213
// Retry if the request has not been sent fully or
212214
// if it's OK to retry methods that have been sent
215+
try {
216+
Thread.sleep(retryWaitInterval);
217+
logger.log( Logger.LT_INFO+" Retrying Request -- ",mc.getUniqueKey().toString()+ " Retry Count -- "+executionCount);
218+
} catch (InterruptedException e) {
219+
// TODO Auto-generated catch block
220+
e.printStackTrace();
221+
}
213222
return true;
214223
}
215224
// otherwise do not retry

java/src/main/java/com/cybersource/ws/client/Identity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@
2222
public class Identity {
2323

2424
//Our p12 files do not contain an alias as a normal name, its the common name and serial number
25-
private String name = null;
25+
private String name;
2626

2727
// we need to create alias for our keystores, it looks like "serialNumber=4032987129910179089277,CN=jasoneatoncorp"
28-
private String keyAlias = null;
28+
private String keyAlias;
2929

3030
// for an unknown reason the serial number of the certificate is set incorrectly, we must parse it from DN
31-
private String serialNumber = null;
31+
private String serialNumber;
3232

33-
private X509Certificate x509Cert =null;
33+
private X509Certificate x509Cert;
3434

35-
private PrivateKey privateKey = null;
35+
private PrivateKey privateKey;
3636

37-
private MerchantConfig merchantConfig = null;
37+
private MerchantConfig merchantConfig;
3838

3939
private static final String SERVER_ALIAS = "CyberSource_SJC_US";
4040

java/src/main/java/com/cybersource/ws/client/MerchantConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ public void setAllowRetry(boolean allowRetry) {
558558
this.allowRetry = allowRetry;
559559
}
560560

561+
<<<<<<< HEAD
561562
public boolean getcacert() {
562563
return cacert;
563564
}
@@ -568,4 +569,6 @@ public boolean getEnablejdkcert() {
568569
public String getcacertpassword(){
569570
return cacertpassword;
570571
}
572+
=======
573+
>>>>>>> upstream/master
571574
}

java/src/main/java/com/cybersource/ws/client/MessageHandlerKeyStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public void addIdentityToKeyStore(Identity id, Logger logger) throws SignEncrypt
2626
try {
2727
if (privateKey != null) {
2828
X509Certificate[] certChain = {certificate};
29-
getKeyStore().setKeyEntry(id.getName(), privateKey, id.getName().toCharArray(), certChain);
29+
getKeyStore().setKeyEntry(id.getKeyAlias(), privateKey, id.getName().toCharArray(), certChain);
3030
} else {
31-
getKeyStore().setCertificateEntry(id.getName(), certificate);
31+
getKeyStore().setCertificateEntry(id.getKeyAlias(), certificate);
3232
}
3333
} catch (KeyStoreException e) {
3434
logger.log(Logger.LT_EXCEPTION, "MessageHandlerKeyStore cannot parse identity, " + id + "'");

0 commit comments

Comments
 (0)