Skip to content

Commit 04eb83d

Browse files
committed
CYBS-737: Pom refactor
1 parent e3b7a21 commit 04eb83d

3 files changed

Lines changed: 51 additions & 26 deletions

File tree

java/pom.xml

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33

44
<modelVersion>4.0.0</modelVersion>
5+
56
<parent>
6-
<groupId>org.sonatype.oss</groupId>
7-
<artifactId>oss-parent</artifactId>
8-
<version>7</version>
7+
<artifactId>cybersource-sdk-master</artifactId>
8+
<groupId>com.cybersource</groupId>
9+
<version>6.2.12-SNAPSHOT</version>
910
</parent>
11+
1012
<groupId>com.cybersource</groupId>
1113
<artifactId>cybersource-sdk-java</artifactId>
1214
<version>6.2.12-SNAPSHOT</version>
1315
<name>cybersource-sdk-java</name>
1416
<description>Simple Order API Client</description>
1517
<url>http://www.cybersource.com</url>
18+
1619
<licenses>
1720
<license>
1821
<name>CyberSource SDK License Agreement</name>
@@ -34,10 +37,6 @@
3437
</developer>
3538
</developers>
3639

37-
<properties>
38-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
39-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
40-
</properties>
4140
<packaging>jar</packaging>
4241

4342
<profiles>
@@ -219,23 +218,23 @@
219218
<dependency>
220219
<groupId>junit</groupId>
221220
<artifactId>junit</artifactId>
222-
<version>4.13.1</version>
221+
<version>${junit.version}</version>
223222
<scope>test</scope>
224223
</dependency>
225224
<dependency>
226225
<groupId>xalan</groupId>
227226
<artifactId>xalan</artifactId>
228-
<version>2.7.2</version>
227+
<version>${xalan.version}</version>
229228
</dependency>
230229
<dependency>
231230
<groupId>org.apache.santuario</groupId>
232231
<artifactId>xmlsec</artifactId>
233-
<version>2.3.0</version>
232+
<version>${xmlsec.version}</version>
234233
</dependency>
235234
<dependency>
236235
<groupId>org.apache.httpcomponents</groupId>
237236
<artifactId>httpclient</artifactId>
238-
<version>4.5.13</version>
237+
<version>${httpclient.version}</version>
239238
<exclusions>
240239
<exclusion>
241240
<groupId>commons-logging</groupId>
@@ -246,34 +245,38 @@
246245
<dependency>
247246
<groupId>org.bouncycastle</groupId>
248247
<artifactId>bcprov-jdk15on</artifactId>
249-
<version>1.61</version>
248+
<version>${bouncycastle.version}</version>
250249
</dependency>
251250
<dependency>
252251
<groupId>org.apache.wss4j</groupId>
253252
<artifactId>wss4j-ws-security-common</artifactId>
254-
<version>2.4.1</version>
253+
<version>${wss4j.version}</version>
255254
</dependency>
256255
<dependency>
257256
<groupId>org.apache.wss4j</groupId>
258257
<artifactId>wss4j-ws-security-dom</artifactId>
259-
<version>2.4.1</version>
258+
<version>${wss4j.version}</version>
260259
</dependency>
261260
<dependency>
262261
<groupId>org.apache.commons</groupId>
263262
<artifactId>commons-lang3</artifactId>
264-
<version>3.4</version>
263+
<version>${commonlang3.version}</version>
265264
</dependency>
266265
<dependency>
267266
<groupId>org.mockito</groupId>
268267
<artifactId>mockito-all</artifactId>
269-
<version>1.10.19</version>
268+
<version>${mockito.version}</version>
270269
<scope>test</scope>
271270
</dependency>
272271
<dependency>
273-
<groupId>org.apache.wss4j</groupId>
274-
<artifactId>wss4j-ws-security-dom</artifactId>
275-
<version>2.4.1</version>
276-
<scope>compile</scope>
272+
<groupId>org.slf4j</groupId>
273+
<artifactId>slf4j-api</artifactId>
274+
<version>${slf4j.version}</version>
275+
</dependency>
276+
<dependency>
277+
<groupId>org.slf4j</groupId>
278+
<artifactId>slf4j-simple</artifactId>
279+
<version>${slf4j.version}</version>
277280
</dependency>
278281
</dependencies>
279282
</project>

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.w3c.dom.Document;
1212

1313
import javax.crypto.KeyGenerator;
14+
import javax.crypto.SecretKey;
1415
import java.io.FileInputStream;
1516
import java.io.FileNotFoundException;
1617
import java.io.IOException;
@@ -230,8 +231,14 @@ public static Document handleMessageCreation(Document signedDoc, String merchant
230231
// If no external key (symmetricalKey) was set ,generate an encryption
231232
// key (session key) for this Encrypt element. This key will be
232233
// encrypted using the public key of the receiver
233-
signedEncryptedDoc = encrBuilder.build(localKeyStoreHandler, KeyGenerator.getInstance(SYM_KEY_ALGO).generateKey());
234-
} catch (WSSecurityException | NoSuchAlgorithmException e) {
234+
SecretKey symmetricKey;
235+
try {
236+
symmetricKey = KeyGenerator.getInstance(SYM_KEY_ALGO).generateKey();
237+
} catch (NoSuchAlgorithmException e) {
238+
throw new WSSecurityException(WSSecurityException.ErrorCode.UNSUPPORTED_ALGORITHM, e, "Failed to generate SecretKey");
239+
}
240+
signedEncryptedDoc = encrBuilder.build(localKeyStoreHandler, symmetricKey);
241+
} catch (WSSecurityException e) {
235242
logger.log(Logger.LT_EXCEPTION, "Failed while encrypting signed requeest for , '" + merchantId + "'" + " with " + SERVER_ALIAS);
236243
throw new SignEncryptException("Failed while encrypting signed requeest for , '" + merchantId + "'" + " with " + SERVER_ALIAS, e);
237244
}
@@ -241,18 +248,18 @@ public static Document handleMessageCreation(Document signedDoc, String merchant
241248

242249
/**
243250
* Create signed document
244-
* @param signedDoc
251+
* @param workingDocument
245252
* @param keyAlias
246253
* @param password
247254
* @param logger
248255
* @return Document
249256
* @throws SignException
250257
*/
251-
public static Document createSignedDoc(Document signedDoc,String keyAlias, String password,Logger logger) throws SignException {
258+
public static Document createSignedDoc(Document workingDocument,String keyAlias, String password,Logger logger) throws SignException {
252259

253260
logger.log(Logger.LT_INFO, "Signing request...");
254261
long startTime = System.nanoTime();
255-
WSSecHeader secHeader = new WSSecHeader(signedDoc);
262+
WSSecHeader secHeader = new WSSecHeader(workingDocument);
256263
try {
257264
secHeader.insertSecurityHeader();
258265
} catch (WSSecurityException e) {
@@ -269,7 +276,7 @@ public static Document createSignedDoc(Document signedDoc,String keyAlias, Strin
269276
sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
270277
sign.setUseSingleCertificate(true);
271278
//
272-
sign.setWsDocInfo(new WSDocInfo(signedDoc));
279+
sign.setWsDocInfo(new WSDocInfo(workingDocument));
273280

274281
//Set which parts of the message to encrypt/sign.
275282
WSEncryptionPart msgBodyPart = new WSEncryptionPart(WSConstants.ELEM_BODY, WSConstants.URI_SOAP11_ENV, "");

pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,19 @@
2020
<module>zip</module>
2121
<module>java</module>
2222
</modules>
23+
24+
<properties>
25+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
26+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
27+
<junit.version>4.13.1</junit.version>
28+
<xalan.version>2.7.2</xalan.version>
29+
<xmlsec.version>2.3.0</xmlsec.version>
30+
<httpclient.version>4.5.13</httpclient.version>
31+
<bouncycastle.version>1.61</bouncycastle.version>
32+
<wss4j.version>2.4.1</wss4j.version>
33+
<commonlang3.version>3.4</commonlang3.version>
34+
<mockito.version>1.10.19</mockito.version>
35+
<slf4j.version>1.7.32</slf4j.version>
36+
</properties>
37+
2338
</project>

0 commit comments

Comments
 (0)