Skip to content

Commit 3ed9f56

Browse files
Merge pull request #87 from CyberSource/revert-86-future
Revert "added changelog; allowed custom http library"
2 parents 9a490b7 + ba4eafa commit 3ed9f56

File tree

15 files changed

+39
-391
lines changed

15 files changed

+39
-391
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
language: java
2-
"dist": "precise"
32
jdk:
4-
- oraclejdk8
53
- oraclejdk7
64
- openjdk7
7-
- openjdk6
5+
- openjdk6

README.md

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ You do not need to download and build the source to use the SDK but if you want
6666
- Number of retry parameter should be set between 1 to 5. Any other value will throw an Error Message.
6767
- Refer to the [Retry Pattern](README.md#retry-pattern) section below.
6868
- Please refer to the accompanying documentation for the other optional properties that you may wish to specify.
69-
- Set customHttpClassEnabled to true to make use of Custom Http Library.
70-
- Enter the custom class name in customHttpClass field. Provide the full package name along with the class name.
71-
example customHttpClass= <packagename.customHttpClass>
72-
- 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.
69+
7370
- Build this project using Maven.
7471
- `mvn clean` - Cleans the Project
7572
- `mvn install` - Builds the project and creates a jar file of client SDK. Includes running all unit tests and integration tests
@@ -96,7 +93,6 @@ Unix or Linux: runSample.sh <service_name>
9693
- If you make any changes to the `RunSample.java` sample, you must rebuild the sample before using it. Use the `compileSample` batch file or shell script provided in the sample directory.
9794

9895
### Using samples and maven tool
99-
10096
- Clone/Download the code from GitHub.
10197
- Choosing which sample to test:
10298
- If you want to test Name-Value Pair, `cd` to the `cybersource-sdk-java-master/samples/nvp` directory.
@@ -111,31 +107,31 @@ Unix or Linux: runSample.sh <service_name>
111107

112108
- To convert the p12 file to JKS follow the steps mentioned below.
113109
- These commands will take out all the certs from the p12 file. 
114-
1. `openssl pkcs12 -in <Merchant_ID>.p12 -nocerts -out <Merchant_ID>.key`
115-
2. `openssl pkcs12 -in <Merchant_ID>.p12 -cacerts -nokeys -out <Merchant_ID>.crt`
116-
3. `openssl pkcs12 -in <Merchant_ID>.p12 -cacerts -nokeys -out CyberSourceCertAuth.crt`
117-
4. `openssl pkcs12 -in <Merchant_ID>.p12 -cacerts -nokeys -out CyberSource_SJC_US.crt`
118-
119-
- Create a new p12. Here Identity.p12 is the new p12 file
110+
```
111+
openssl pkcs12 -in <Merchant_ID>.p12 -nocerts -out <Merchant_ID>.key
112+
openssl pkcs12 -in <Merchant_ID>.p12 -clcerts -nokeys -out <Merchant_ID>.crt
113+
openssl pkcs12 -in <Merchant_ID>.p12 -cacerts -nokeys -out CyberSourceCertAuth.crt
114+
openssl pkcs12 -in <Merchant_ID>.p12 -cacerts -nokeys -out CyberSource_SJC_US.crt
115+
```
116+
- Create a new p12. Here `Identity.p12` is the new p12 file
120117
```
121118
openssl pkcs12 -export -certfile CyberSourceCertAuth.crt -in <Merchant_ID>.crt -inkey <Merchant_ID>.key -out identity.p12 -name "<Merchant_ID>"
122119
```
123-
124120
- Create JKS from p12 using keytool
125121
```
126-
keytool -importkeystore -destkeystore <Your_keystore_name> -deststorepass <your_password> -srckeystore identity.p12 -srcstoretype PKCS12 -srcstorepass <Merchant_ID>`
122+
keytool -importkeystore -destkeystore <Your_keystore_name> -deststorepass <your_password> -srckeystore identity.p12 -srcstoretype PKCS12 -srcstorepass <Merchant_ID>
127123
```
128124
- Now import the CyberSource_SJC_US.crt to your keystore
129125
```
130-
keytool -importcert -trustcacerts -file CyberSource_SJC_US.crt -alias CyberSource_SJC_US -keystore <Your_keystore_name>.jks`
126+
keytool -importcert -trustcacerts -file CyberSource_SJC_US.crt -alias CyberSource_SJC_US -keystore <Your_keystore_name>.jks
131127
```
132128
- List the entries of your keystore
133129
```
134-
keytool -list -v -keystore <Your_keystore_name>`
130+
keytool -list -v -keystore <Your_keystore_name>
135131
```
136132
- It should have two entries.
137133
- The first entry should contain a chain of two certificates - `CyberSourceCertAuth` and <Merchant_ID> with alias name <Merchant_ID>
138-
- Second entry should be for `CyberSource_SJC_US` certificate with alias name as CyberSource_SJC_US
134+
- Second entry should be for `CyberSource_SJC_US` certificate with alias name as `CyberSource_SJC_US`
139135

140136
## Message Level Encryption
141137
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.
@@ -155,7 +151,7 @@ CyberSource supports Message Level Encryption (MLE) for Simple Order API. Messag
155151
## Retry Pattern
156152

157153
Retry Pattern allows to retry sending a failed request and it will only work with `useHttpClient=true`. `allowRetry` flag enables the retry mechanism.
158-
- 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'.
154+
- 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'.
159155
- 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.
160156
- 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.
161157

@@ -179,47 +175,6 @@ Retry Pattern allows to retry sending a failed request and it will only work wit
179175
9. org.mockito:mockito-all:1.10.19
180176
Mock objects library for java
181177

182-
## Changes
183-
184-
Version Cybersource-sdk-java 6.2.5 (TBD)
185-
_______________________________
186-
1) Merchant cert to be read from JAVA key store. Flag is added to enable reading cert from Java keystore.
187-
2) Added Custom HttpClient feature. Merchants can use there own http client instead of defaults which comes with SDK.
188-
3) Http Client connection reuse issue.
189-
4) Changed clientLibrary version to 6.2.5; in 6.2.4 release it was missed. So, in 6.2.4 release, clientLibrary version was pointing to 6.2.3.
190-
_______________________________
191-
Version Cybersource-sdk-java 6.2.4 (Dec 15, 2016)
192-
_______________________________
193-
1) RetryPattern config for http client.
194-
2) Code review comments.
195-
3) Added timers to log the method execution time.
196-
4) Sample added to support other services.
197-
_______________________________
198-
Version Cybersource-sdk-java 6.2.3 (Oct 17, 2016)
199-
_______________________________
200-
1) Fixed performance issue; in case of multiple merchantIDs, p12 was getting loaded for every request.
201-
2) p12 will be loaded once per merchantId.
202-
_______________________________
203-
Version Cybersource-sdk-java 6.2.2 (Sep 15, 2016)
204-
_______________________________
205-
1)Upgraded 3rd party dependencies jars including wss4j.
206-
_______________________________
207-
Version Cybersource-sdk-java 6.2.1 (Aug 4, 2016)
208-
_______________________________
209-
1) AkamaiSureroute config parameter introduced
210-
2) i18n fix for NVP sample.
211-
3) In `Sample/cybs.properties` file, `targetAPIVersion` changed to latest 1.129.
212-
_______________________________
213-
Version Cybersource-sdk-java 6.2.0 (Jul 28, 2016)
214-
_______________________________
215-
1) MLE[Message Level Encryption] is enabled.
216-
2) published zip file with samples and packaged compiled cybersoruce-sdk-java jar file.
217-
3) `Bouncycastle` jar issue; changed scope from provided to default"scope"
218-
_______________________________
219-
Version Cybersource-sdk-java 6.1.0 (Feb 24,2016)
220-
_______________________________
221-
1) SHA256 changes which are required to signed the request with SHA256.
222-
223178
## Documentation
224179
- For more information about CyberSource services, see <http://www.cybersource.com/developers/documentation>.
225180
- For all other support needs, see <http://www.cybersource.com/support>.

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

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import java.io.FileInputStream;
3535
import java.io.IOException;
3636
import java.io.StringReader;
37-
import java.lang.reflect.InvocationTargetException;
3837
import java.security.KeyStore;
3938
import java.security.cert.PKIXParameters;
4039
import java.security.cert.TrustAnchor;
@@ -91,16 +90,14 @@ public static Map runTransaction(Map<String,String> request, Properties props)
9190
* @throws FaultException if a fault occurs.
9291
* @throws ClientException if any other exception occurs.
9392
*/
94-
@SuppressWarnings("unchecked")
95-
public static Map runTransaction(
93+
public static Map runTransaction(
9694
Map<String, String> request, Properties props,
9795
Logger _logger, boolean prepare, boolean logTranStart)
9896
throws FaultException, ClientException {
9997
MerchantConfig mc;
10098
LoggerWrapper logger = null;
10199
Connection con = null;
102100

103-
104101
try {
105102
setVersionInformation(request);
106103

@@ -125,39 +122,8 @@ public static Map runTransaction(
125122
// FileWriter writer = new FileWriter(new File("signedDoc.xml"));
126123
// writer.write(XMLUtils.PrettyDocumentToString(signedDoc));
127124
// writer.close();
128-
if(mc.isCustomHttpClassEnabled()){
129-
Class<Connection> customConnectionClass;
130-
try {
131-
customConnectionClass = (Class<Connection>) Class.forName(mc.getcustomHttpClass());
132-
Class[] constructor_Args = new Class[] {com.cybersource.ws.client.MerchantConfig.class, javax.xml.parsers.DocumentBuilder.class, com.cybersource.ws.client.LoggerWrapper.class};
133-
con=customConnectionClass.getDeclaredConstructor(constructor_Args).newInstance(mc, builder, logger);
134-
135-
} catch (InstantiationException e) {
136-
logger.log(Logger.LT_INFO, "Failed to Instantiate the class "+e);
137-
throw new ClientException(e, false, null);
138-
} catch (IllegalAccessException e) {
139-
logger.log(Logger.LT_INFO, "Could not Access the method invoked "+e);
140-
throw new ClientException(e, false, null);
141-
} catch (ClassNotFoundException e) {
142-
logger.log(Logger.LT_INFO, "Could not load the custom HTTP class ");
143-
throw new ClientException(e, false, null);
144-
} catch (IllegalArgumentException e) {
145-
logger.log(Logger.LT_INFO, "Method invoked with Illegal Argument list "+e);
146-
throw new ClientException(e, false, null);
147-
} catch (SecurityException e) {
148-
logger.log(Logger.LT_INFO, "Security Exception "+e);
149-
throw new ClientException(e, false, null);
150-
} catch (InvocationTargetException e) {
151-
logger.log(Logger.LT_INFO, "Exception occured while calling the method "+e);
152-
throw new ClientException(e, false, null);
153-
} catch (NoSuchMethodException e) {
154-
logger.log(Logger.LT_INFO, "Method not found ");
155-
throw new ClientException(e, false, null);
156-
}
157-
}
158-
else{
159-
con = Connection.getInstance(mc, builder, logger);
160-
}
125+
126+
con = Connection.getInstance(mc, builder, logger);
161127
Document wrappedReply = con.post(signedDoc);
162128
Map<String, String> replyMap = soapUnwrap(wrappedReply, mc, logger);
163129
logger.log(Logger.LT_INFO, "Client, End of runTransaction Call ",false);

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,8 @@ abstract class Connection {
4747
final MerchantConfig mc;
4848
private final DocumentBuilder builder;
4949
final LoggerWrapper logger;
50-
51-
/**
52-
* It initializes three arguments MerchantConfig, DocumentBuilder and Logger
53-
* Any class extending this class must implement three argument constructor
54-
* @param mc
55-
* @param builder
56-
* @param logger
57-
*/
58-
protected Connection(MerchantConfig mc, DocumentBuilder builder,
50+
51+
Connection(MerchantConfig mc, DocumentBuilder builder,
5952
LoggerWrapper logger) {
6053
this.mc = mc;
6154
this.builder = builder;

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,7 @@ void postDocument(Document request)
6060
throws IOException, TransformerConfigurationException,
6161
TransformerException, MalformedURLException,
6262
ProtocolException {
63-
64-
/*
65-
* SimpleHttpConnectionManager(boolean alwaysClose) :
66-
* alwaysClose - if set true, the connection manager will always close connections upon release.
67-
*/
68-
69-
HttpClient httpClient = new HttpClient(new SimpleHttpConnectionManager(true));
63+
HttpClient httpClient = new HttpClient();
7064
setTimeout(httpClient, mc.getTimeout() * 1000);
7165
setProxy(httpClient);
7266

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ public class MerchantConfig {
6464
private String proxyUser;
6565
private String proxyPassword;
6666
private String cacertPassword;
67-
private String customHttpClass;
68-
private boolean customHttpClassEnabled;
67+
private String useClientHttpFactory;
68+
private boolean useClientHttpFactoryFlag;
6969

70-
public String getcustomHttpClass() {
71-
return customHttpClass;
70+
public String getUseClientHttpFactory() {
71+
return useClientHttpFactory;
7272
}
73-
public boolean isCustomHttpClassEnabled() {
74-
return customHttpClassEnabled;
73+
public boolean getUseClientHttpFactoryFlag() {
74+
return useClientHttpFactoryFlag;
7575
}
7676
// computed values
7777
private String effectiveServerURL;
@@ -261,7 +261,7 @@ public MerchantConfig(Properties _props, String _merchantID)
261261
logFilename = getProperty(merchantID, "logFilename");
262262
logMaximumSize = getIntegerProperty(merchantID, "logMaximumSize", 10);
263263
useHttpClient = getBooleanProperty(merchantID, "useHttpClient", ConnectionHelper.getDefaultUseHttpClient());
264-
customHttpClass = getProperty(merchantID, "customHttpClass");
264+
useClientHttpFactory = getProperty(merchantID, "useClientHttpFactory");
265265
timeout = getIntegerProperty(merchantID, "timeout", DEFAULT_TIMEOUT);
266266
proxyHost = getProperty(merchantID, "proxyHost");
267267
proxyPort = getIntegerProperty(merchantID, "proxyPort", DEFAULT_PROXY_PORT);
@@ -270,7 +270,7 @@ public MerchantConfig(Properties _props, String _merchantID)
270270
enableJdkCert = getBooleanProperty(merchantID, "enableJdkCert", false);
271271
enableCacert=getBooleanProperty(merchantID, "enableCacert", false);
272272
cacertPassword=getProperty(merchantID,"cacertPassword","changeit");
273-
customHttpClassEnabled=getBooleanProperty(merchantID,"customHttpClassEnabled",false);
273+
useClientHttpFactoryFlag=getBooleanProperty(merchantID,"useClientHttpFactoryFlag",false);
274274
// compute and store effective namespace URI
275275

276276
if (namespaceURI == null && targetAPIVersion == null) {
@@ -473,8 +473,8 @@ public String getLogString() {
473473
appendPair(sb, "logDirectory", logDirectory);
474474
appendPair(sb, "logFilename", logFilename);
475475
appendPair(sb, "logMaximumSize", logMaximumSize);
476-
appendPair(sb, "customHttpClass", customHttpClass);
477-
appendPair(sb, "customHttpClassEnabled", customHttpClassEnabled);
476+
appendPair(sb, "useClientHttpFactory", useClientHttpFactory);
477+
appendPair(sb, "useClientHttpFactoryFlag", useClientHttpFactoryFlag);
478478
appendPair(sb, "useHttpClient", useHttpClient);
479479
appendPair(sb, "enableJdkCert", enableJdkCert);
480480
appendPair(sb, "enableCacert", enableCacert);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private Utility() {
4848
/**
4949
* Version number of this release.
5050
*/
51-
public static final String VERSION = "6.2.5";
51+
public static final String VERSION = "6.2.3";
5252

5353
/**
5454
* If in the Request map, a key called "_has_escapes" is present and is set

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

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.io.ByteArrayOutputStream;
3636
import java.io.IOException;
3737
import java.io.StringReader;
38-
import java.lang.reflect.InvocationTargetException;
3938
import java.util.Properties;
4039

4140
/**
@@ -65,8 +64,7 @@ public class XMLClient {
6564

6665
private static Document soapEnvelope;
6766
private static Exception initException = null;
68-
69-
67+
7068
static {
7169
try {
7270
// load the SOAP envelope document.
@@ -139,8 +137,7 @@ public static Document runTransaction(Document request, Properties props)
139137
* @throws FaultException if a fault occurs.
140138
* @throws ClientException if any other exception occurs.
141139
*/
142-
@SuppressWarnings("unchecked")
143-
public static Document runTransaction(
140+
public static Document runTransaction(
144141
Document request, Properties props,
145142
Logger _logger, boolean prepare, boolean logTranStart)
146143
throws FaultException, ClientException {
@@ -180,39 +177,8 @@ public static Document runTransaction(
180177

181178
Document signedDoc
182179
= soapWrapAndSign(request, mc, builder, logger);
183-
if(mc.isCustomHttpClassEnabled()){
184-
Class<Connection> customConnectionClass;
185-
try {
186-
customConnectionClass = (Class<Connection>) Class.forName(mc.getcustomHttpClass());
187-
Class[] constructor_Args = new Class[] {com.cybersource.ws.client.MerchantConfig.class, javax.xml.parsers.DocumentBuilder.class, com.cybersource.ws.client.LoggerWrapper.class};
188-
con=customConnectionClass.getDeclaredConstructor(constructor_Args).newInstance(mc, builder, logger);
189-
190-
} catch (InstantiationException e) {
191-
logger.log(Logger.LT_INFO, "Failed to Instantiate the class "+e);
192-
throw new ClientException(e, false, null);
193-
} catch (IllegalAccessException e) {
194-
logger.log(Logger.LT_INFO, "Could not Access the method invoked "+e);
195-
throw new ClientException(e, false, null);
196-
} catch (ClassNotFoundException e) {
197-
logger.log(Logger.LT_INFO, "Could not load the custom HTTP class ");
198-
throw new ClientException(e, false, null);
199-
} catch (IllegalArgumentException e) {
200-
logger.log(Logger.LT_INFO, "Method invoked with Illegal Argument list "+e);
201-
throw new ClientException(e, false, null);
202-
} catch (SecurityException e) {
203-
logger.log(Logger.LT_INFO, "Security Exception "+e);
204-
throw new ClientException(e, false, null);
205-
} catch (InvocationTargetException e) {
206-
logger.log(Logger.LT_INFO, "Exception occured while calling the method "+e);
207-
throw new ClientException(e, false, null);
208-
} catch (NoSuchMethodException e) {
209-
logger.log(Logger.LT_INFO, "Method not found ");
210-
throw new ClientException(e, false, null);
211-
}
212-
}
213-
else{
214-
con = Connection.getInstance(mc, builder, logger);
215-
}
180+
181+
con = Connection.getInstance(mc, builder, logger);
216182
Document wrappedReply = con.post(signedDoc);
217183

218184
Document doc = soapUnwrap(wrappedReply, mc, builder, logger);

java/src/main/resources/cybs.properties

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ sendToAkamai=true
1717

1818
#To use your own Http library set useClientHttpFactoryFlag to true
1919
# set useClientHttpFactory field with the class name which has Http implementation
20-
#useClientHttpFactory=
21-
#useClientHttpFactoryFlag=false
20+
#useClientHttpFactory=AmazonHttpConnection
21+
#useClientHttpFactoryFlag=true
2222

2323
#useHttpClient=false
2424

@@ -32,12 +32,6 @@ allowRetry=true
3232
numberOfRetries=5
3333
retryInterval=5
3434

35-
36-
#To use your own Http library set customHttpClassEnabled to true
37-
# set customHttpClass field with the class name which has Http implementation. Provide the full class with package name.
38-
#customHttpClassEnabled=
39-
#customHttpClass=
40-
4135
# If This property is set to true then the p12 certificate must be stored in JKS format
4236
# program will read it from there. If it is set to false then the certificate will be read from
4337
# the location specified above from the key directory location

0 commit comments

Comments
 (0)