File tree Expand file tree Collapse file tree
src/main/java/com/maxmind/minfraud/request Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ CHANGELOG
6262 * ` Mastercard `
6363 * ` UnionPay `
6464 * ` Visa `
65+ * Apache Commons Codec is no longer used for generating MD5s.
6566
66671.18.0 (2021-08-31)
6768-------------------
Original file line number Diff line number Diff line change 6565 <artifactId >geoip2</artifactId >
6666 <version >3.0.0</version >
6767 </dependency >
68- <dependency >
69- <groupId >commons-codec</groupId >
70- <artifactId >commons-codec</artifactId >
71- <version >1.15</version >
72- </dependency >
7368 <dependency >
7469 <groupId >commons-validator</groupId >
7570 <artifactId >commons-validator</artifactId >
Original file line number Diff line number Diff line change 22
33import com .fasterxml .jackson .annotation .JsonProperty ;
44import com .maxmind .minfraud .AbstractModel ;
5- import org .apache .commons .codec .digest .DigestUtils ;
5+
6+ import java .math .BigInteger ;
7+ import java .nio .charset .Charset ;
8+ import java .security .MessageDigest ;
9+ import java .security .NoSuchAlgorithmException ;
610
711/**
812 * Account related data for the minFraud request
@@ -46,8 +50,15 @@ public Account.Builder userId(String id) {
4650 * @return The builder object.
4751 */
4852 public Account .Builder username (String username ) {
49- this .usernameMd5 = DigestUtils .md5Hex (username );
50- return this ;
53+ try {
54+ MessageDigest d = MessageDigest .getInstance ("MD5" );
55+ d .update (username .getBytes (Charset .forName ("UTF8" )));
56+ BigInteger i = new BigInteger (1 , d .digest ());
57+ this .usernameMd5 = String .format ("%032x" , i );
58+ return this ;
59+ } catch (NoSuchAlgorithmException e ) {
60+ throw new RuntimeException ("No MD5 algorithm for MessageDigest!" , e );
61+ }
5162 }
5263
5364 /**
Original file line number Diff line number Diff line change 22
33import com .fasterxml .jackson .annotation .JsonProperty ;
44import com .maxmind .minfraud .AbstractModel ;
5- import org .apache .commons .codec .digest .DigestUtils ;
65import org .apache .commons .validator .routines .DomainValidator ;
76import org .apache .commons .validator .routines .EmailValidator ;
87
8+ import java .math .BigInteger ;
99import java .net .IDN ;
10+ import java .nio .charset .Charset ;
11+ import java .security .MessageDigest ;
12+ import java .security .NoSuchAlgorithmException ;
1013import java .util .Collections ;
1114import java .util .HashMap ;
1215import java .util .Map ;
@@ -150,7 +153,15 @@ public String getAddress() {
150153 return null ;
151154 }
152155 if (hashAddress ) {
153- return DigestUtils .md5Hex (cleanAddress (address ));
156+ String cleanAddress = cleanAddress (address );
157+ try {
158+ MessageDigest d = MessageDigest .getInstance ("MD5" );
159+ d .update (cleanAddress .getBytes (Charset .forName ("UTF8" )));
160+ BigInteger i = new BigInteger (1 , d .digest ());
161+ return String .format ("%032x" , i );
162+ } catch (NoSuchAlgorithmException e ) {
163+ throw new RuntimeException ("No MD5 algorithm for MessageDigest!" , e );
164+ }
154165 }
155166 return address ;
156167 }
You can’t perform that action at this time.
0 commit comments