Skip to content

Commit 63d9cca

Browse files
authored
Merge pull request #47 from CyberSource/future
Merging upgraded 3rd party dependencies jars
2 parents 77b511b + 2e9aa03 commit 63d9cca

26 files changed

+294
-180
lines changed

README.md

Lines changed: 91 additions & 4 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=master)]
3+
[![Build Status](https://travis-ci.org/CyberSource/cybersource-sdk-java.png?branch=future)]
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.1</version>
14+
<version>6.2.2</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.1'
23+
compile 'com.cybersource:cybersource-sdk-java:6.2.2'
2424
}
2525
````
2626
##Requirements
@@ -103,6 +103,62 @@ You do not need to download and build the source to use the SDK but if you want
103103
d. mvn failsafe:integration-test
104104
// Runs unit and integration tests. Note that integration tests require proper setup of test_cybs.properties
105105

106+
##Testing the SDK
107+
108+
We have two ways to test, One is using maven tool and other is to download the zip and use scripts to test.
109+
110+
1.) Unzip the downloaded zip file into a directory of your choice. It will create a directory called
111+
cybersource-sdk-java-master.
112+
113+
a. TESTING THE NAME-VALUE PAIR SAMPLE
114+
. Go to the cybersource-sdk-java-master/sample/nvp directory.
115+
. Use compileSample scripts to create classes directory.As it is not included in SDK.
116+
. Then at a command prompt, type this line:
117+
Windows runSample.bat
118+
Unix or Linux runSample.sh
119+
120+
If JAVA_HOME is defined, the script uses <JAVA_HOME>/bin/java. Otherwise, it uses
121+
whatever java is in the path.
122+
If the client is installed correctly, the requests and replies for a credit card authorization
123+
and a follow-on capture appear.
124+
125+
. If you make any changes to the AuthCaptureSample.java sample, you
126+
must rebuild the sample before using it. Use the compileSample batch file or
127+
shell script provided in the sample directory.
128+
129+
b. TESTING THE XML SAMPLE
130+
. Go to the cybersource-sdk-java-master/sample/xml directory.
131+
. Use compileSample scripts to create classes directory.As it is not included in SDK.
132+
. At a command prompt, type this line:
133+
Windows runSample.bat
134+
Unix or Linux runSample.sh
135+
136+
If JAVA_HOME is defined, the script uses <JAVA_HOME>/bin/java. Otherwise, it uses
137+
whatever java is in the path.
138+
If the client is installed correctly, the requests and replies for a credit card authorization
139+
and a follow-on capture appear.
140+
141+
. If you make any changes to the AuthSample.java sample, you
142+
must rebuild the sample before using it. Use the compileSample batch file or
143+
shell script provided in the sample directory.
144+
145+
2.) Using samples and maven tool. samples is present at the same directory level as java and zip.
146+
a.) Clone/Download the code from GitHub.
147+
148+
b.) Go to the samples directory. then cd to nvp or xml which are present inside samples dir, choose any one and do the same thing with other.
149+
150+
c.) Sample project nvp and xml uses cybersource-sdk-java and 3rd party jars as dependent jar files.
151+
152+
d.) Build this project using Maven.
153+
mvn install
154+
155+
e.) If build is successful then it will put all jars inside cybersource-sdk-java/samples/nvp/target/dependencies
156+
folder.
157+
158+
f.) Edit cybs.properties and make the required changes:
159+
160+
g.) Now use scripts to test.
161+
106162
##Message Level Encryption
107163

108164
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.
@@ -117,8 +173,39 @@ You do not need to download and build the source to use the SDK but if you want
117173
5. If merchant is reseller, the merchant must allow reseller to act upon their behalf and reseller must be configured as a reseller and the provided merchant must be configured as a merchant of this reseller. Additionally all above authorizations apply.
118174

119175
Cryptography Algorithms
120-
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 128 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.
176+
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.
121177

178+
##Third Party jars
179+
1.) org.apache.ws.security.wss4j:1.6.19
180+
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
181+
from the OASIS Web Services Security TC.
182+
183+
2.) org.bouncycastle:bcprov-jdk15on:1.55
184+
This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.
185+
186+
3.) org.apache.santuario:xmlsec:1.5.8
187+
The XML Security project is aimed at providing implementation of security standards for XML,supports XML-Signature Syntax and Processing,XML Encryption Syntax and Processing,
188+
and supports XML Digital Signature APIs.
189+
190+
4.) org.apache.commons:commons-lang3:3.4
191+
Apache Commons Lang, a package of Java utility classes for the classes that are in java.lang's hierarchy, or are considered to be so standard as to justify existence in
192+
java.lang.
193+
194+
5.) commons-httpclient:commons-httpclient:3.1
195+
provides a framework by which new request types (methods) or HTTP extensions can be created easily.
196+
197+
6.) commons-logging:commons-logging:jar:1.1.1
198+
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
199+
systems.
200+
201+
7.) org.slf4j:slf4j-api:1.7.21 and org.slf4j:slf4j-jcl:1.7.21 .
202+
slf4j-api is getting used as a dependency for wss4j. Modified to latest version.
203+
204+
8.) junit:junit:4.12
205+
JUnit is a unit testing framework for Java.
206+
207+
9.) org.mockito:mockito-all:1.10.19
208+
Mock objects library for java
122209

123210
##Documentation
124211

java/pom.xml

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -177,53 +177,49 @@
177177
<dependency>
178178
<groupId>junit</groupId>
179179
<artifactId>junit</artifactId>
180-
<version>4.11</version>
180+
<version>4.12</version>
181181
<scope>test</scope>
182182
</dependency>
183183
<dependency>
184184
<groupId>commons-httpclient</groupId>
185185
<artifactId>commons-httpclient</artifactId>
186-
<version>3.0.1</version>
186+
<version>3.1</version>
187+
<exclusions>
188+
<exclusion>
189+
<groupId>commons-logging</groupId>
190+
<artifactId>commons-logging</artifactId>
191+
</exclusion>
192+
</exclusions>
187193
</dependency>
188194
<dependency>
189195
<groupId>org.bouncycastle</groupId>
190-
<artifactId>bcprov-jdk16</artifactId>
191-
<version>1.45</version>
196+
<artifactId>bcprov-jdk15on</artifactId>
197+
<version>1.55</version>
192198
</dependency>
193199
<dependency>
194-
<groupId>wss4j</groupId>
200+
<groupId>org.apache.ws.security</groupId>
195201
<artifactId>wss4j</artifactId>
196-
<version>1.5.0</version>
197-
</dependency>
198-
<dependency>
199-
<groupId>xml-security</groupId>
200-
<artifactId>xmlsec</artifactId>
201-
<version>1.3.0</version>
202-
</dependency>
203-
<dependency>
204-
<groupId>xalan</groupId>
205-
<artifactId>xalan</artifactId>
206-
<version>2.7.0</version>
207-
</dependency>
202+
<version>1.6.19</version>
203+
</dependency>
208204
<dependency>
209205
<groupId>org.slf4j</groupId>
210206
<artifactId>slf4j-api</artifactId>
211-
<version>1.7.7</version>
207+
<version>1.7.21</version>
212208
</dependency>
213209
<dependency>
214210
<groupId>org.slf4j</groupId>
215211
<artifactId>slf4j-jcl</artifactId>
216-
<version>1.7.7</version>
212+
<version>1.7.21</version>
217213
</dependency>
218214
<dependency>
219-
<groupId>commons-lang</groupId>
220-
<artifactId>commons-lang</artifactId>
221-
<version>2.6</version>
215+
<groupId>org.apache.commons</groupId>
216+
<artifactId>commons-lang3</artifactId>
217+
<version>3.4</version>
222218
</dependency>
223219
<dependency>
224220
<groupId>org.mockito</groupId>
225221
<artifactId>mockito-all</artifactId>
226-
<version>1.8.5</version>
222+
<version>1.10.19</version>
227223
<scope>test</scope>
228224
</dependency>
229225
</dependencies>

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import java.io.StringReader;
3434
import java.text.MessageFormat;
3535
import java.util.HashMap;
36-
import java.util.Iterator;
3736
import java.util.Map;
3837
import java.util.Properties;
3938

@@ -182,7 +181,6 @@ private static Document soapWrapAndSign(
182181
Logger.LT_REQUEST,
183182
mapToString(request, true, PCI.REQUEST));
184183
}
185-
Document doc;
186184

187185
// wrap in SOAP envelope
188186
Object[] arguments
@@ -201,14 +199,14 @@ private static Document soapWrapAndSign(
201199
if ( !mc.getUseSignAndEncrypted() ) {
202200
// sign Document object
203201
logger.log(Logger.LT_INFO, "Signing request...");
204-
resultDocument = handler.createSignedDoc(wrappedDoc,mc.getMerchantID(),null);
202+
resultDocument = handler.createSignedDoc(wrappedDoc,mc.getMerchantID(),mc.getKeyPassword(),null);
205203
if (logSignedData) {
206204
logger.log(Logger.LT_REQUEST,
207205
Utility.nodeToString(resultDocument, PCI.REQUEST));
208206
}
209207
} else {
210208
logger.log(Logger.LT_INFO, "Signing and encrypting request...");
211-
resultDocument = handler.handleMessageCreation(wrappedDoc,mc.getMerchantID());
209+
resultDocument = handler.handleMessageCreation(wrappedDoc,mc.getMerchantID(),mc.getKeyPassword());
212210
if (logSignedData) {
213211
logger.log(Logger.LT_REQUEST,XMLUtils.PrettyDocumentToString(resultDocument));
214212
}

0 commit comments

Comments
 (0)