Skip to content

Commit 17f061d

Browse files
committed
Merge branch 'future' of https://github.com/Mayuri-Kumar93/cybersource-sdk-java into future
sync
2 parents 01ea0b0 + 9194831 commit 17f061d

36 files changed

Lines changed: 2118 additions & 373 deletions

README.md

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,33 @@ You do not need to download and build the source to use the SDK but if you want
6262
- To know how to convert p12 to JKS refer the JKS creation section of this document.
6363
- If 'enableCacert' property parameter is set to true, certificates will be read from the cacerts file specified at keysDirectory location.If keysDirectory path is not set,certificate will be loaded from Java Installation cacerts file. The cacerts file should be of the same name as specified in keyFilename.
6464
- If `certificateCacheEnabled` parameter is set to false (default is true), the p12 certificate of a merchant will be reloaded from filesystem every time a transaction is made
65-
- `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.
66-
- Set integer values for config parameter `numberOfRetries` *and* `retryInterval`. Retry Interval is time delay for next retry in seconds.
65+
- If `useHttpClient` parameter is set to true (default is false), then simple HttpClientConnection will be enabled
66+
- If `useHttpClientWithConnectionPool` parameter is set to true (default is false), then poolingHttpClientConnection will be enabled
67+
- In case of poolingHttpConnection, we are initializing connection manager and httpclient once, If any change in value in between the application is running, it will not reflect. need to restart it.
68+
- Refer to the [PoolingHttpClient Shutdown](README.md#poolinghttpclientshutdown) section below.
69+
- If`enabledShutdownHook` is true (default is true), enables JVM runtime shutdown hook and execute our shutdown api. This is applicable only when useHttpClientWithConnectionPool is true.
70+
- Below properties are specific to poolinghttpclient connection, If it is not added in properties file, it will throw config exception.
71+
Note : Below default values used in properties files are based on our testing application factors such as TPS, CPU, JVM, OS etc
72+
Before using these values in actual real time application, please consider all real time factors. Refer this link for more detailed explanation.
73+
- `maxConnections` set the maximum number of total open connections. default value is 200
74+
- `defaultMaxConnectionsPerRoute` Set the maximum number of concurrent connections per route. default value is 200
75+
- `maxConnectionsPerRoute` Set the total number of concurrent connections to a specific route. default value is 200
76+
- `connectionRequestTimeoutMs` the time to wait for a connection from the connection manager/pool. default value is 1000
77+
- `connectionTimeoutMs` the time to establish the connection with the remote host. default value is 2000
78+
- `socketTimeoutMs` the time waiting for data – after establishing the connection; maximum time of inactivity between two data packets. default value is 2000
79+
- `evictThreadSleepTimeMs` amount of time in milliseconds between sweeps by the idle connection evictor thread. default value is 3000
80+
- `maxKeepAliveTimeMs` maximum amount of time in milliseconds that a connection can be idle before it is evicted from the pool. default value is 30000
81+
- `allowRetry` config parameter will only work for HttpClient and PoolingHttpClient. Set `allowRetry` config parameter to "true" to enable retry mechanism and set merchant specific values for the retry.
82+
- Set integer values and long values for config parameter `numberOfRetries` *and* `retryInterval` respectively. Retry Interval is time delay for next retry in milliSeconds.
6783
- Number of retry parameter should be set between 1 to 5. Any other value will throw an Error Message.
6884
- Refer to the [Retry Pattern](README.md#retry-pattern) section below.
6985
- Please refer to the accompanying documentation for the other optional properties that you may wish to specify.
7086
- Set customHttpClassEnabled to true to make use of Custom Http Library.
7187
- Enter the custom class name in customHttpClass field. Provide the full package name along with the class name.
7288
example customHttpClass= <packagename.customHttpClass>
7389
- The custom HTTP Class must have a three argument constructor which accepts MerchantConfig, DocumentBuilder and LoggerWrapper as argument. Then it should call the constructor of the parent class.
90+
- `merchantConfigCacheEnabled` If this property is set to true (default value is false) it will cache the merchantConfig object based on keyAlias/merchantID
91+
-If cache enabled is true, for single merchant id, if you change any properties after first initialization, it will not reflect.
7492
- Build this project using Maven.
7593
- `mvn clean` - Cleans the Project
7694
- `mvn install` - Builds the project and creates a jar file of client SDK. Includes running all unit tests and integration tests
@@ -138,7 +156,9 @@ keytool -list -v -keystore <Your_keystore_name>`
138156
- The first entry should contain a chain of two certificates - `CyberSourceCertAuth` and <Merchant_ID> with alias name <Merchant_ID>
139157
- Second entry should be for `CyberSource_SJC_US` certificate with alias name as CyberSource_SJC_US
140158

141-
159+
## PoolingHttpClient
160+
To get more information please refer wiki.
161+
142162
## Message Level Encryption
143163
CyberSource supports Message Level Encryption (MLE) for Simple Order API. Message level encryption conforms to the SOAP Security 1.0 specification published by the OASIS standards group.
144164

@@ -156,10 +176,10 @@ CyberSource supports Message Level Encryption (MLE) for Simple Order API. Messag
156176

157177
## Retry Pattern
158178

159-
Retry Pattern allows to retry sending a failed request and it will only work with `useHttpClient=true`. `allowRetry` flag enables the retry mechanism.
179+
Retry Pattern allows to retry sending a failed request and it will only work with `useHttpClient=true` or `useHttpClientWithConnectionPool. `allowRetry` flag enables the retry mechanism.
160180
- 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 in the config parameter 'numberOfRetries'.
161-
- 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.
162-
- 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.
181+
- numberOfRetries parameter value should be set between 0 to 5. By default the value for numberOfRetries will be 3. User can set a delay in between the retry attempts.
182+
- Config parameter for this property is 'retryInterval' in `cybs.property` file. The default value for 'retryInterval' parameter is 1000 which means a delay of 1000 milliSeconds.
163183

164184
## Third Party jars
165185
1. org.apache.ws.security.wss4j:1.6.19
@@ -180,12 +200,25 @@ Retry Pattern allows to retry sending a failed request and it will only work wit
180200
JUnit is a unit testing framework for Java.
181201
9. org.mockito:mockito-all:1.10.19
182202
Mock objects library for java
203+
10. org.apache.httpcomponents:httpclient:4.5.11
204+
Provides reusable components for client-side authentication, HTTP state management, and HTTP connection management. It is used for poolinghttpclientconnectionmanager feature.
205+
183206

184207
## Changes
185208

186-
Version Cybersource-sdk-java 6.2.9 (APR,2020)
209+
Version Cybersource-sdk-java 6.2.10 (APR,2020)
187210
_______________________________
188211

212+
1)MerchantConfig Object Caching based on KeyAlias/Merchant Id
213+
214+
2)Added PoolingHttpClientConnection implementation
215+
216+
3)Changed retry interval from second to millisecond
217+
218+
4)Added one more request header "v-c-client-computetime" to calculate time taken to send request to cybersource
219+
220+
Version Cybersource-sdk-java 6.2.9 (APR,2020)
221+
_______________________________
189222
1)Corrected request header name
190223

191224
Version Cybersource-sdk-java 6.2.8 (FEB,2020)
@@ -250,6 +283,35 @@ Version Cybersource-sdk-java 6.1.0 (Feb 24,2016)
250283
_______________________________
251284
1) SHA256 changes which are required to signed the request with SHA256.
252285

286+
## Troubleshooting
287+
- If you get an exception **`java.lang.SecurityException: JCE cannot authenticate the provider BC`**. This could be because of
288+
many reasons. bcprov*.jar is a signed jar if java fails to validate the signature, it throws this exception. Make sure
289+
you run below java command to verify this signature.
290+
291+
`jarsigner -verify bcprov-jdk15on-1.61.jar`
292+
293+
when above command fails it says "jar is unsigned. (signatures missing or not parsable)", this could be because of many
294+
reasons. e.g
295+
296+
1) When we unpack it and include in our own jar file. Including bcprov*.jar separately in the CLASSPATH should solve this issue.
297+
2) May be changes in Oracle jar signer. If using Java SDK 1.6 or 1.7 with cybersource-sdk-java:6.2.7 and higher
298+
(ships with org.bouncycastle:bcprov-jdk15on:1.61). Upgrading version to bcprov-jdk15to18-1.63.jar should solve this issue.
299+
3) If you are using some old version of JBOSS and have copied bcprov*.jar under $JBOSS_HOME/server/default/lib/.
300+
copying bcprov*.jar in $JBOSS_HOME/server/default/lib/ instead of $JBOSS_HOME/server/servername/lib/ should solve this issue.
301+
302+
- If you get an exception **`exception decrypting data - java.security.InvalidKeyException: Illegal key size`**.
303+
It is recommended to download Unlimited Strength Jurisdiction Policy files from Oracle (US_export_policy.jar and local_policy.jar)
304+
for appropriate JAVA version. I meant if merchant are using java 6 then download these policy file only for java6.
305+
You need to copy security jars (US_export_policy.jar, local_policy.jar) in the $JAVA_HOME/jre/lib/security directory not in $JAVA_HOME/jre/lib/ext/).
306+
307+
- Put below block of code to handle the ClientException to print the complete stacktrace.
308+
309+
try{
310+
Client.runTransaction(requestMap, merchantProperties);
311+
}catch (ClientException e){
312+
e.getInnerException().printStackTrace();
313+
}
314+
253315
## Documentation
254316
- For more information about CyberSource services, see <http://www.cybersource.com/developers/documentation>.
255317
- For all other support needs, see <http://www.cybersource.com/support>.

java/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@
190190
<artifactId>xmlsec</artifactId>
191191
<version>1.5.6</version>
192192
</dependency>
193+
<dependency>
194+
<groupId>org.apache.httpcomponents</groupId>
195+
<artifactId>httpclient</artifactId>
196+
<version>4.5.11</version>
197+
<exclusions>
198+
<exclusion>
199+
<groupId>commons-logging</groupId>
200+
<artifactId>commons-logging</artifactId>
201+
</exclusion>
202+
</exclusions>
203+
</dependency>
193204
<dependency>
194205
<groupId>commons-httpclient</groupId>
195206
<artifactId>commons-httpclient</artifactId>

0 commit comments

Comments
 (0)