Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd5e3af

Browse files
committed
check for java.util.Base64 presence
1 parentba12ff6 commitcd5e3af

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎scribejava-core/src/main/java/com/github/scribejava/core/base64/Base64.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ public static Base64 getInstance() {
1919
}
2020

2121
privatestaticBase64createInstance() {
22-
returnnewJava8Base64();
22+
if (Java8Base64.isAvailable()) {
23+
returnnewJava8Base64();
24+
}
25+
thrownewIllegalStateException(
26+
"No Base64 implementation was provided. Java 8 Base64, Apache commons codec or JAXB is needed");
2327
}
2428

2529
publicstaticvoidinit(Base64base64) {

‎scribejava-core/src/main/java/com/github/scribejava/core/base64/Java8Base64.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,12 @@ protected byte[] internalDecodeMime(String string) {
2020
returnJAVA8_BASE64.internalDecodeMime(string);
2121
}
2222

23+
staticbooleanisAvailable() {
24+
try {
25+
Class.forName("java.util.Base64",false,Java8Base64.class.getClassLoader());
26+
returntrue;
27+
}catch (ClassNotFoundExceptioncnfE) {
28+
returnfalse;
29+
}
30+
}
2331
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp