Commit 9f163263 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #13378 from dreis2211:remove-commons-codec-imports

* pr/13378:
  Polish "Replace commons-codec Base64 usage"
  Replace commons-codec Base64 usage
parents e3bf5188 68380b68
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -29,7 +29,6 @@ import java.util.Collections; ...@@ -29,7 +29,6 @@ import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.codec.binary.Base64;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mock; import org.mockito.Mock;
...@@ -337,7 +336,8 @@ public class ReactiveTokenValidatorTests { ...@@ -337,7 +336,8 @@ public class ReactiveTokenValidatorTests {
+ "J/OOn5zOs8yf26os0q3+JUM=\n-----END PRIVATE KEY-----"; + "J/OOn5zOs8yf26os0q3+JUM=\n-----END PRIVATE KEY-----";
String privateKey = signingKey.replace("-----BEGIN PRIVATE KEY-----\n", ""); String privateKey = signingKey.replace("-----BEGIN PRIVATE KEY-----\n", "");
privateKey = privateKey.replace("-----END PRIVATE KEY-----", ""); privateKey = privateKey.replace("-----END PRIVATE KEY-----", "");
byte[] pkcs8EncodedBytes = Base64.decodeBase64(privateKey); privateKey = privateKey.replace("\n", "");
byte[] pkcs8EncodedBytes = Base64Utils.decodeFromString(privateKey);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8EncodedBytes); PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8EncodedBytes);
KeyFactory keyFactory = KeyFactory.getInstance("RSA"); KeyFactory keyFactory = KeyFactory.getInstance("RSA");
return keyFactory.generatePrivate(keySpec); return keyFactory.generatePrivate(keySpec);
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -28,7 +28,6 @@ import java.security.spec.PKCS8EncodedKeySpec; ...@@ -28,7 +28,6 @@ import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
...@@ -248,7 +247,8 @@ public class TokenValidatorTests { ...@@ -248,7 +247,8 @@ public class TokenValidatorTests {
+ "J/OOn5zOs8yf26os0q3+JUM=\n-----END PRIVATE KEY-----"; + "J/OOn5zOs8yf26os0q3+JUM=\n-----END PRIVATE KEY-----";
String privateKey = signingKey.replace("-----BEGIN PRIVATE KEY-----\n", ""); String privateKey = signingKey.replace("-----BEGIN PRIVATE KEY-----\n", "");
privateKey = privateKey.replace("-----END PRIVATE KEY-----", ""); privateKey = privateKey.replace("-----END PRIVATE KEY-----", "");
byte[] pkcs8EncodedBytes = Base64.decodeBase64(privateKey); privateKey = privateKey.replace("\n", "");
byte[] pkcs8EncodedBytes = Base64Utils.decodeFromString(privateKey);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8EncodedBytes); PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8EncodedBytes);
KeyFactory keyFactory = KeyFactory.getInstance("RSA"); KeyFactory keyFactory = KeyFactory.getInstance("RSA");
return keyFactory.generatePrivate(keySpec); return keyFactory.generatePrivate(keySpec);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<module name="io.spring.javaformat.checkstyle.SpringChecks" /> <module name="io.spring.javaformat.checkstyle.SpringChecks" />
<module name="com.puppycrawl.tools.checkstyle.TreeWalker"> <module name="com.puppycrawl.tools.checkstyle.TreeWalker">
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck"> <module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
<property name="illegalPkgs" value="sun, org.apache.commons.(?!codec|compress|dbcp2|lang|lang3|logging|pool2).*, com.google.common, org.flywaydb.core.internal, reactor.core.support.Assert"/> <property name="illegalPkgs" value="sun, org.apache.commons.(?!compress|dbcp2|lang|lang3|logging|pool2).*, com.google.common, org.flywaydb.core.internal, reactor.core.support.Assert"/>
<property name="regexp" value="true"/> <property name="regexp" value="true"/>
</module> </module>
</module> </module>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment