changeset 18:57d4d4a63175

Compatibility with OpenJDK 11
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 31 Oct 2018 08:11:12 +0100 (2018-10-31)
parents 0fd8d13648e3
children f787efc6d7f8 43b240e50113
files AUTHORS NEWS com/orthancserver/OrthancConnection.java com/orthancserver/SelectImageDialog.java
diffstat 4 files changed, 30 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/AUTHORS	Fri May 04 10:39:35 2018 +0200
+++ b/AUTHORS	Wed Oct 31 08:11:12 2018 +0100
@@ -14,7 +14,8 @@
   4000 Liege
   Belgium
 
-* Osimis S.A. <info@osimis.io>
-  Rue des Chasseurs Ardennais 3
-  4031 Liege 
+* Osimis S.A.
+  Rue du Bois Saint-Jean 15/1
+  4102 Seraing
   Belgium
+  http://www.osimis.io/
--- a/NEWS	Fri May 04 10:39:35 2018 +0200
+++ b/NEWS	Wed Oct 31 08:11:12 2018 +0100
@@ -1,6 +1,8 @@
 Pending changes in the mainline
 ===============================
 
+* Compatibility with OpenJDK 11 (fix Debian bug #912363)
+
 
 Version 1.1 (2016/04/15)
 ========================
--- a/com/orthancserver/OrthancConnection.java	Fri May 04 10:39:35 2018 +0200
+++ b/com/orthancserver/OrthancConnection.java	Wed Oct 31 08:11:12 2018 +0100
@@ -29,8 +29,8 @@
 import java.net.ConnectException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.Base64;
 import javax.imageio.ImageIO;
-import javax.xml.bind.DatatypeConverter;
 import org.json.simple.JSONObject;
 import org.json.simple.JSONValue;
 
@@ -40,6 +40,21 @@
 	private String authentication_;
   private String name_;
   private boolean insecure_;
+
+
+  public static String EncodeBase64(String content)
+  {
+    // https://stackoverflow.com/a/13109632/881731
+    return new String(Base64.getEncoder().encode(content.getBytes()));
+  }
+
+
+  public static String DecodeBase64(String content)
+  {
+    // https://stackoverflow.com/a/13109632/881731
+    return new String(Base64.getDecoder().decode(content.getBytes()));
+  }
+  
 	
 	OrthancConnection()
 	{
@@ -97,8 +112,7 @@
                                               String password)
   {
 		String auth = (new StringBuffer(username).append(":").append(password)).toString();
-		// http://stackoverflow.com/a/14413290/881731
-		return DatatypeConverter.printBase64Binary(auth.getBytes());
+    return EncodeBase64(auth);
   }
 
   
--- a/com/orthancserver/SelectImageDialog.java	Fri May 04 10:39:35 2018 +0200
+++ b/com/orthancserver/SelectImageDialog.java	Wed Oct 31 08:11:12 2018 +0100
@@ -26,6 +26,7 @@
 import org.json.simple.JSONObject;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Base64;
 import java.util.List;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -50,7 +51,6 @@
 import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
 
-import javax.xml.bind.DatatypeConverter;
 import javax.swing.event.TreeExpansionEvent;
 import javax.swing.event.TreeWillExpandListener;
 import javax.swing.event.TreeSelectionEvent;
@@ -553,7 +553,9 @@
     }
     else
     {
-      String decoded = new String(DatatypeConverter.parseBase64Binary(s));
+      // https://stackoverflow.com/a/13109632/881731
+      String decoded = OrthancConnection.DecodeBase64(s);
+      
       JSONArray config = (JSONArray) JSONValue.parse(decoded);
       if (config != null)
       {
@@ -576,6 +578,8 @@
     }
 
     String config = servers.toJSONString();
-    return DatatypeConverter.printBase64Binary(config.getBytes());
+
+    // https://stackoverflow.com/a/13109632/881731
+    return new String(Base64.getEncoder().encode(config.getBytes()));
   }
 }