Skip to content

Commit 9f3929d

Browse files
authored
Merge pull request #180 from CyberSource/masking-password
Added code to mask password in log
2 parents 54b2dfe + f8889fe commit 9f3929d

File tree

10 files changed

+79
-12
lines changed

10 files changed

+79
-12
lines changed

java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<junit.version>4.13.1</junit.version>
4444
<xmlsec.version>2.3.4</xmlsec.version>
4545
<httpclient.version>4.5.13</httpclient.version>
46-
<bouncycastle.version>1.74</bouncycastle.version>
46+
<bouncycastle.version>1.78</bouncycastle.version>
4747
<wss4j.version>2.4.1</wss4j.version>
4848
<commonlang3.version>3.4</commonlang3.version>
4949
<mockito.version>1.10.19</mockito.version>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ public String getLogString() {
767767
appendPair(sb, "merchantID", merchantID);
768768
appendPair(sb, "keysDirectory", keysDirectory);
769769
appendPair(sb, "keyAlias", keyAlias);
770-
appendPair(sb, "keyPassword", keyPassword);
770+
appendPair(sb, "keyPassword", keyPassword != null ? "(masked)" : null);
771771
appendPair(sb, "sendToProduction", sendToProduction);
772772
appendPair(sb, "sendToAkamai", sendToAkamai);
773773
appendPair(sb, "targetAPIVersion", targetAPIVersion);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private Utility() {
4747
*/
4848
public static final String SERVER_ALIAS = "CyberSource_SJC_US";
4949
public static final String CYBS_CERT_AUTH = "CyberSourceCertAuth";
50-
public static final String VERSION = "6.2.14";
50+
public static final String VERSION = "6.2.15";
5151
public static final String ORIGIN_TIMESTAMP = "v-c-client-iat";
5252
public static final String SDK_ELAPSED_TIMESTAMP = "v-c-client-computetime";
5353
public static final String RESPONSE_TIME_REPLY = "v-c-response-time";

java/src/test/java/com/cybersource/ws/client/UtilityTest.java

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
package com.cybersource.ws.client;
22

33
import org.junit.Before;
4+
import org.junit.Rule;
45
import org.junit.Test;
56
import static org.junit.Assert.*;
7+
8+
import org.junit.function.ThrowingRunnable;
9+
import org.junit.rules.ExpectedException;
610
import org.w3c.dom.Document;
711
import org.w3c.dom.Node;
12+
import org.w3c.dom.Text;
13+
import org.xml.sax.SAXException;
14+
import org.xml.sax.SAXParseException;
815

16+
import javax.xml.parsers.DocumentBuilder;
17+
import javax.xml.parsers.ParserConfigurationException;
918
import java.io.*;
1019
import java.net.URL;
1120
import java.util.*;
1221

1322
public class UtilityTest extends BaseTest {
1423
String propertiesFilename;
1524
Properties properties;
25+
private static final String ELEM_NVP_REPLY = "nvpReply";
1626

1727
@Before
1828
public void setUp() {
@@ -128,7 +138,64 @@ public void testMapToString_error() {
128138
assertTrue(result.isEmpty());
129139
}
130140

141+
@Test
142+
public void testNewDocumentBuilder_validate() {
143+
String testData1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
144+
"<!DOCTYPE example [\n" +
145+
" <!ENTITY file SYSTEM \"file:///secrets.txt\" >\n" +
146+
"]>\n" +
147+
"<example>&file;</example>";
148+
149+
String testData2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
150+
"<!DOCTYPE example [\n" +
151+
" <!ENTITY file SYSTEM \"file:////etc/shadow\" >\n" +
152+
"]>\n" +
153+
"<example>&file;</example>";
154+
155+
String testData3 = "<?xml version=\"1.0\"?>" +
156+
"<w3resource>" +
157+
"<design>html xhtml css svg xml</design>" +
158+
"<programming>php mysql</programming>" +
159+
"</w3resource>";
160+
161+
try {
162+
DocumentBuilder docBuilder = Utility.newDocumentBuilder();
163+
164+
InputStream testStream = new ByteArrayInputStream(testData1.getBytes());
165+
Document testDoc = docBuilder.parse(testStream);
166+
} catch (ParserConfigurationException e) {
167+
throw new RuntimeException(e);
168+
} catch (IOException e) {
169+
throw new RuntimeException(e);
170+
} catch (SAXException e) {
171+
assertSame(e.getClass(), SAXParseException.class);
172+
}
131173

174+
try {
175+
DocumentBuilder docBuilder = Utility.newDocumentBuilder();
176+
177+
InputStream testStream = new ByteArrayInputStream(testData2.getBytes());
178+
Document testDoc = docBuilder.parse(testStream);
179+
} catch (ParserConfigurationException e) {
180+
throw new RuntimeException(e);
181+
} catch (IOException e) {
182+
throw new RuntimeException(e);
183+
} catch (SAXException e) {
184+
assertSame(e.getClass(), SAXParseException.class);
185+
}
132186

133-
187+
try {
188+
DocumentBuilder docBuilder = Utility.newDocumentBuilder();
189+
190+
InputStream testStream = new ByteArrayInputStream(testData3.getBytes());
191+
Document testDoc = docBuilder.parse(testStream);
192+
assertNotNull(testDoc);
193+
} catch (ParserConfigurationException e) {
194+
throw new RuntimeException(e);
195+
} catch (IOException e) {
196+
throw new RuntimeException(e);
197+
} catch (SAXException e) {
198+
throw new RuntimeException(e);
199+
}
200+
}
134201
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>com.cybersource</groupId>
1414
<artifactId>cybersource-sdk-master</artifactId>
15-
<version>6.2.14-SNAPSHOT</version>
15+
<version>6.2.15-SNAPSHOT</version>
1616
<name>cybersource-sdk-java-master</name>
1717
<packaging>pom</packaging>
1818

samples/nvp/compileSample.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ rem If using this scripts outside zip package then give maven clean install.
77
rem This will generate all required dependencies under target/dependencies.These dependencies are used in CLASSPATH.
88
rem ----------------------------------------------------------------------------
99

10-
if exist ../../lib set LOCAL_CP=%LOCAL_CP%;../../lib/cybersource-sdk-java-6.2.14.jar
10+
if exist ../../lib set LOCAL_CP=%LOCAL_CP%;../../lib/cybersource-sdk-java-6.2.15.jar
1111
if not exist ../../lib (
1212
if not exist target goto error
13-
set LOCAL_CP=%LOCAL_CP%;target/dependencies/cybersource-sdk-java-6.2.14.jar
13+
set LOCAL_CP=%LOCAL_CP%;target/dependencies/cybersource-sdk-java-6.2.15.jar
1414
)
1515

1616
if not exist classes mkdir classes

samples/nvp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<name>RunSample</name>
99
<url>http://maven.apache.org</url>
1010
<properties>
11-
<javasdk.version>[6.2.0, 6.2.14-SNAPSHOT]</javasdk.version>
11+
<javasdk.version>[6.2.0, 6.2.15-SNAPSHOT]</javasdk.version>
1212
<httpclient.version>4.5.13</httpclient.version>
1313
<bouncycastle.version>1.67</bouncycastle.version>
1414
<wss4j.version>2.4.1</wss4j.version>

samples/xml/compileSample.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ rem If using this scripts outside zip package then give maven clean install.
77
rem This will generate all required dependencies under target/dependencies.These dependencies are used in CLASSPATH.
88
rem ----------------------------------------------------------------------------
99

10-
if exist ../../lib set LOCAL_CP=%LOCAL_CP%;../../lib/cybersource-sdk-java-6.2.14.jar
10+
if exist ../../lib set LOCAL_CP=%LOCAL_CP%;../../lib/cybersource-sdk-java-6.2.15-SNAPSHOT.jar
1111
if not exist ../../lib (
1212
if not exist target goto error
13-
set LOCAL_CP=%LOCAL_CP%;target/dependencies/cybersource-sdk-java-6.2.14.jar
13+
set LOCAL_CP=%LOCAL_CP%;target/dependencies/cybersource-sdk-java-6.2.15-SNAPSHOT.jar
1414
)
1515

1616
if not exist classes mkdir classes

samples/xml/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<name>RunSample</name>
99
<url>http://maven.apache.org</url>
1010
<properties>
11-
<javasdk.version>[6.2.0, 6.2.14-SNAPSHOT]</javasdk.version>
11+
<javasdk.version>[6.2.0, 6.2.15-SNAPSHOT]</javasdk.version>
1212
<httpclient.version>4.5.13</httpclient.version>
1313
<bouncycastle.version>1.67</bouncycastle.version>
1414
<wss4j.version>2.4.1</wss4j.version>

zip/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>cybersource-sdk-master</artifactId>
77
<groupId>com.cybersource</groupId>
8-
<version>6.2.14-SNAPSHOT</version>
8+
<version>6.2.15-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

0 commit comments

Comments
 (0)