You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2017/09/20 15:13:53 UTC
[myfaces-tobago] 02/02: TOBAGO-1795: Set Java Source to Java 8 *
Base64 encode is included in JDK 8
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
commit 520c6b1d18b8a3b7058674e10b515efbfc5e42e5
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Wed Sep 20 17:13:42 2017 +0200
TOBAGO-1795: Set Java Source to Java 8
* Base64 encode is included in JDK 8
---
pom.xml | 5 -----
tobago-core/pom.xml | 4 ----
.../myfaces/tobago/internal/util/RandomUtils.java | 26 +++-------------------
3 files changed, 3 insertions(+), 32 deletions(-)
diff --git a/pom.xml b/pom.xml
index 41407d0..0a766af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -445,11 +445,6 @@
<version>1.9.3</version>
</dependency>
<dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.10</version>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
diff --git a/tobago-core/pom.xml b/tobago-core/pom.xml
index a9881ec..c019dd9 100644
--- a/tobago-core/pom.xml
+++ b/tobago-core/pom.xml
@@ -177,10 +177,6 @@
<artifactId>myfaces-test20</artifactId>
</dependency>
<dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- </dependency>
- <dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/RandomUtils.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/RandomUtils.java
index b8020f3..0eb7b25 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/RandomUtils.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/RandomUtils.java
@@ -22,9 +22,8 @@ either express or implied. See the License for the
package org.apache.myfaces.tobago.internal.util;
-import org.apache.commons.codec.binary.Base64;
-
import java.security.SecureRandom;
+import java.util.Base64;
/**
* Helps to get a random string.
@@ -35,33 +34,14 @@ public class RandomUtils {
private static final int SECRET_LENGTH = 16;
- private static final boolean COMMONS_CODEC_AVAILABLE = commonsCodecAvailable();
-
- private static boolean commonsCodecAvailable() {
- try {
- Base64.encodeBase64URLSafeString(new byte[0]);
- return true;
- } catch (final Error e) {
- return false;
- }
- }
-
private static String encodeBase64(final byte[] bytes) {
- return Base64.encodeBase64URLSafeString(bytes);
- }
-
- private static String encodeHex(final byte[] bytes) {
- final StringBuilder builder = new StringBuilder(SECRET_LENGTH * 2);
- for (final byte b : bytes) {
- builder.append(String.format("%02x", b));
- }
- return builder.toString();
+ return Base64.getEncoder().encodeToString(bytes);
}
public static String nextString() {
final byte[] bytes = new byte[SECRET_LENGTH];
RANDOM.nextBytes(bytes);
- return COMMONS_CODEC_AVAILABLE ? encodeBase64(bytes) : encodeHex(bytes);
+ return encodeBase64(bytes);
}
}
--
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.