private String base64Encode()

in maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java [118:138]


    private String base64Encode(String userInfo) {
        ClassLoader loader = getClass().getClassLoader();
        try {
            Method getEncoderMethod = loader.loadClass("java.util.Base64").getMethod("getEncoder");
            Method encodeMethod =
                    loader.loadClass("java.util.Base64$Encoder").getMethod("encodeToString", byte[].class);
            Object encoder = getEncoderMethod.invoke(null);
            return (String) encodeMethod.invoke(encoder, new Object[] {userInfo.getBytes(StandardCharsets.UTF_8)});
        } catch (Exception java7OrEarlier) {
            try {
                Method encodeMethod = loader.loadClass("javax.xml.bind.DatatypeConverter")
                        .getMethod("printBase64Binary", byte[].class);
                return (String) encodeMethod.invoke(null, new Object[] {userInfo.getBytes(StandardCharsets.UTF_8)});
            } catch (Exception java5OrEarlier) {
                throw new RuntimeException(
                        "Downloading Maven distributions with HTTP Basic Authentication"
                                + " is not supported on your JVM.",
                        java5OrEarlier);
            }
        }
    }