From a5bc33db702ca8c7f53db2fc9ace34c9f3747e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobi=20Sch=C3=A4fer?= Date: Fri, 10 Apr 2020 20:24:33 +0200 Subject: [PATCH] fix: remaining references to obsolete sun.misc.Base64Encoder --- modules/core/String.js | 8 ++++---- modules/helma/Http.js | 4 ++-- modules/jala/code/XmlRpcRequest.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/core/String.js b/modules/core/String.js index 1dacce10..9348d7b2 100644 --- a/modules/core/String.js +++ b/modules/core/String.js @@ -536,8 +536,8 @@ String.prototype.count = function(str) { * @memberof {String} */ String.prototype.enbase64 = function() { - var bytes = new java.lang.String(this) . getBytes(); - return new Packages.sun.misc.BASE64Encoder().encode(bytes); + var bytes = java.lang.String(this).getBytes('utf-8'); + return String(java.lang.String(Packages.org.apache.commons.codec.binary.Base64.encodeBase64(bytes), 'utf-8')); }; @@ -547,8 +547,8 @@ String.prototype.enbase64 = function() { * @memberof {String} */ String.prototype.debase64 = function() { - var bytes = new Packages.sun.misc.BASE64Decoder().decodeBuffer(this); - return String(new java.lang.String(bytes)); + var bytes = Packages.org.apache.commons.codec.binary.Base64.decodeBase64(this); + return String(java.lang.String(bytes, 'utf-8')); }; diff --git a/modules/helma/Http.js b/modules/helma/Http.js index b2932a5d..3cc19ae0 100644 --- a/modules/helma/Http.js +++ b/modules/helma/Http.js @@ -159,8 +159,8 @@ helma.Http = function() { * @param {String} password The password */ this.setCredentials = function(username, password) { - var str = new java.lang.String(username + ":" + password); - credentials = (new Packages.sun.misc.BASE64Encoder()).encode(str.getBytes()); + var str = username + ":" + password; + credentials = str.enbase64(); return; } diff --git a/modules/jala/code/XmlRpcRequest.js b/modules/jala/code/XmlRpcRequest.js index 575a12aa..df55778a 100644 --- a/modules/jala/code/XmlRpcRequest.js +++ b/modules/jala/code/XmlRpcRequest.js @@ -123,11 +123,11 @@ jala.XmlRpcRequest = function(url, methodName) { * @param {String} password The password */ this.setCredentials = function(username, password) { - var str = new java.lang.String(username + ":" + password); - credentials = (new Packages.sun.misc.BASE64Encoder()).encode(str.getBytes()); + var str = username + ":" + password; + credentials = str.enbase64(); return; }; - + /** * Returns the credentials of this request * @returns The base46 encoded credentials of this request