File tree Expand file tree Collapse file tree
scribejava-core/src/main/java/com/github/scribejava/core/base64 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,7 +19,11 @@ public static Base64 getInstance() {
1919 }
2020
2121 private static Base64 createInstance () {
22- return new Java8Base64 ();
22+ if (Java8Base64 .isAvailable ()) {
23+ return new Java8Base64 ();
24+ }
25+ throw new IllegalStateException (
26+ "No Base64 implementation was provided. Java 8 Base64, Apache commons codec or JAXB is needed" );
2327 }
2428
2529 public static void init (Base64 base64 ) {
Original file line number Diff line number Diff line change @@ -20,4 +20,12 @@ protected byte[] internalDecodeMime(String string) {
2020 return JAVA8_BASE64 .internalDecodeMime (string );
2121 }
2222
23+ static boolean isAvailable () {
24+ try {
25+ Class .forName ("java.util.Base64" , false , Java8Base64 .class .getClassLoader ());
26+ return true ;
27+ } catch (ClassNotFoundException cnfE ) {
28+ return false ;
29+ }
30+ }
2331}
You can’t perform that action at this time.
0 commit comments