Skip to content

Commit 7254410

Browse files
committed
Drop dependency on commons-codec
Since we have updated to Java 8 we can use JDK facilities to perform Base64 encoding. There's no need to keep commons-codec.
1 parent cdb826d commit 7254410

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

edgegrid-signer-core/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
<groupId>ch.qos.logback</groupId>
1919
<artifactId>logback-classic</artifactId>
2020
</dependency>
21-
<dependency>
22-
<groupId>commons-codec</groupId>
23-
<artifactId>commons-codec</artifactId>
24-
</dependency>
2521
<dependency>
2622
<groupId>org.apache.commons</groupId>
2723
<artifactId>commons-lang3</artifactId>

edgegrid-signer-core/src/main/java/com/akamai/edgegrid/signer/EdgeGridV1Signer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.security.NoSuchAlgorithmException;
2424
import java.text.SimpleDateFormat;
2525
import java.util.ArrayList;
26+
import java.util.Base64;
2627
import java.util.Date;
2728
import java.util.List;
2829
import java.util.Map;
@@ -34,7 +35,6 @@
3435
import javax.crypto.Mac;
3536
import javax.crypto.spec.SecretKeySpec;
3637

37-
import org.apache.commons.codec.binary.Base64;
3838
import org.apache.commons.lang3.StringEscapeUtils;
3939
import org.apache.commons.lang3.StringUtils;
4040
import org.apache.commons.lang3.Validate;
@@ -195,12 +195,12 @@ private String getSignature(Request request, ClientCredential credential, String
195195

196196
private String signAndEncode(String stringToSign, String signingKey) throws RequestSigningException {
197197
byte[] signatureBytes = sign(stringToSign, signingKey);
198-
return Base64.encodeBase64String(signatureBytes);
198+
return Base64.getEncoder().encodeToString(signatureBytes);
199199
}
200200

201201
private String getSigningKey(String timeStamp, String clientSecret) throws RequestSigningException {
202202
byte[] signingKeyBytes = sign(timeStamp, clientSecret);
203-
return Base64.encodeBase64String(signingKeyBytes);
203+
return Base64.getEncoder().encodeToString(signingKeyBytes);
204204
}
205205

206206
private String getDataToSign(String canonicalizedRequest, String authData) {
@@ -315,15 +315,15 @@ private String getContentHash(String requestMethod, byte[] requestBody, int maxB
315315
lengthToHash = maxBodySize;
316316
} else {
317317
if (log.isTraceEnabled()) {
318-
log.trace("Content (Base64): {}", Base64.encodeBase64String(requestBody));
318+
log.trace("Content (Base64): {}", Base64.getEncoder().encodeToString(requestBody));
319319
}
320320
}
321321

322322
byte[] digestBytes = getHash(requestBody, 0, lengthToHash);
323-
log.debug("Content hash (Base64): {}", Base64.encodeBase64String(digestBytes));
323+
log.debug("Content hash (Base64): {}", Base64.getEncoder().encodeToString(digestBytes));
324324

325325
// (mgawinec) I removed support for non-retryable content, that used to reset the content for downstream handlers
326-
return Base64.encodeBase64String(digestBytes);
326+
return Base64.getEncoder().encodeToString(digestBytes);
327327
}
328328

329329
}

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@
8484
<version>1.1.7</version>
8585
<scope>test</scope>
8686
</dependency>
87-
<dependency>
88-
<groupId>commons-codec</groupId>
89-
<artifactId>commons-codec</artifactId>
90-
<version>1.10</version>
91-
</dependency>
9287
<dependency>
9388
<groupId>com.github.tomakehurst</groupId>
9489
<artifactId>wiremock</artifactId>

0 commit comments

Comments
 (0)