You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2022/01/06 17:11:26 UTC

[directory-studio] branch 2.0.0.v20200411-M15-prepare updated: Get rid of the LDAP API Base64 class, using the java.util.Base64 class instead.

This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch 2.0.0.v20200411-M15-prepare
in repository https://gitbox.apache.org/repos/asf/directory-studio.git


The following commit(s) were added to refs/heads/2.0.0.v20200411-M15-prepare by this push:
     new 54f0962  Get rid of the LDAP API Base64 class, using the java.util.Base64 class instead.
54f0962 is described below

commit 54f0962b2626e9ae8604bf8e7b2f153a406542cd
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Thu Jan 6 18:11:12 2022 +0100

    Get rid of the LDAP API Base64 class, using the java.util.Base64 class
    instead.
---
 .../directory/studio/ldapbrowser/core/BrowserConnectionIO.java   | 9 +++++----
 .../studio/templateeditor/editor/widgets/EditorFileChooser.java  | 4 ++--
 .../studio/templateeditor/editor/widgets/EditorImage.java        | 4 ++--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionIO.java b/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionIO.java
index 46e984f..a6f55c1 100644
--- a/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionIO.java
+++ b/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionIO.java
@@ -25,7 +25,9 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
+import java.util.Base64;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -34,7 +36,6 @@ import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.model.message.SearchScope;
 import org.apache.directory.api.ldap.model.name.Dn;
-import org.apache.directory.api.util.Base64;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.Controls;
 import org.apache.directory.studio.connection.core.StudioControl;
@@ -357,7 +358,7 @@ public class BrowserConnectionIO
                 {
                     if ( oidAttribute != null && isCriticalAttribute != null && valueAttribute != null )
                     {
-                        byte[] bytes = Base64.decode( valueAttribute.getValue().toCharArray() );
+                        byte[] bytes = Base64.getDecoder().decode( valueAttribute.getValue() );
                         Control control = Controls.create( oidAttribute.getValue(),
                             Boolean.valueOf( isCriticalAttribute.getValue() ), bytes );
                         searchParameter.getControls().add( control );
@@ -365,7 +366,7 @@ public class BrowserConnectionIO
                     else if ( valueAttribute != null )
                     {
                         // Backward compatibility: read objects using Java serialization
-                        byte[] bytes = Base64.decode( valueAttribute.getValue().toCharArray() );
+                        byte[] bytes = Base64.getDecoder().decode( valueAttribute.getValue() );
                         ByteArrayInputStream bais = null;
                         ObjectInputStream ois = null;
                         bais = new ByteArrayInputStream( bytes );
@@ -541,7 +542,7 @@ public class BrowserConnectionIO
         for ( Control control : searchParameter.getControls() )
         {
             byte[] bytes = Controls.getEncodedValue( control );
-            String controlsValue = new String( Base64.encode( bytes ) );
+            String controlsValue = new String( Base64.getEncoder().encode( bytes ), StandardCharsets.UTF_8 );
 
             Element controlElement = controlsElement.addElement( CONTROL_TAG );
             controlElement.addAttribute( OID_TAG, control.getOid() );
diff --git a/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/widgets/EditorFileChooser.java b/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/widgets/EditorFileChooser.java
index c8b54aa..c3c6982 100644
--- a/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/widgets/EditorFileChooser.java
+++ b/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/widgets/EditorFileChooser.java
@@ -25,8 +25,8 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.util.Base64;
 
-import org.apache.directory.api.util.Base64;
 import org.apache.directory.studio.entryeditors.IEntryEditor;
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -147,7 +147,7 @@ public class EditorFileChooser extends EditorWidget<TemplateFileChooser>
             {
                 try
                 {
-                    iconData = new ImageData( new ByteArrayInputStream( Base64.decode( icon.toCharArray() ) ) );
+                    iconData = new ImageData( new ByteArrayInputStream( Base64.getDecoder().decode( icon ) ) );
                 }
                 catch ( SWTException e )
                 {
diff --git a/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/widgets/EditorImage.java b/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/widgets/EditorImage.java
index 5101d0b..aeddf3a 100644
--- a/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/widgets/EditorImage.java
+++ b/plugins/templateeditor/src/main/java/org/apache/directory/studio/templateeditor/editor/widgets/EditorImage.java
@@ -25,8 +25,8 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.util.Base64;
 
-import org.apache.directory.api.util.Base64;
 import org.apache.directory.studio.entryeditors.IEntryEditor;
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -239,7 +239,7 @@ public class EditorImage extends EditorWidget<TemplateImage>
             String imageDataString = getWidget().getImageData();
             if ( ( imageDataString != null ) && ( !imageDataString.equals( "" ) ) ) //$NON-NLS-1$
             {
-                imageBytes = Base64.decode( imageDataString.toCharArray() );
+                imageBytes = Base64.getDecoder().decode( imageDataString );
             }
         }
     }

Re: [directory-studio] branch 2.0.0.v20200411-M15-prepare updated: Get rid of the LDAP API Base64 class, using the java.util.Base64 class instead.

Posted by Emmanuel Lécharny <el...@gmail.com>.
Hi Stefan

no, it's a mistake :-)

I used a branch that was on my disk, not checking if there were a new 
branch.

Let me port the change on the main branch !

On 07/01/2022 12:04, Stefan Seelmann wrote:
> did you on purpose make that change on an old release branch rather then 
> master branch?

-- 
*Emmanuel Lécharny - CTO* 205 Promenade des Anglais – 06200 NICE
T. +33 (0)4 89 97 36 50
P. +33 (0)6 08 33 32 61
emmanuel.lecharny@busit.com https://www.busit.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@directory.apache.org
For additional commands, e-mail: dev-help@directory.apache.org