From ae742dfca9348b17e017d73c82a99d2f0d65d7b2 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 22 Apr 2016 16:38:13 +0000
Subject: [PATCH] TrustedSocketFactory.java: Reverted restraining visibility. InitialLdapContext requires the class and its constructor to be public.

---
 opendj-server-legacy/src/main/java/org/opends/admin/ads/util/TrustedSocketFactory.java               |   21 +++++-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java |  159 ++++++++++++++++++++++++----------------------------
 2 files changed, 90 insertions(+), 90 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/TrustedSocketFactory.java b/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/TrustedSocketFactory.java
index f404a36..3238f63 100644
--- a/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/TrustedSocketFactory.java
+++ b/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/TrustedSocketFactory.java
@@ -30,8 +30,13 @@
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
 
-/** An implementation of SSLSocketFactory. */
-class TrustedSocketFactory extends SSLSocketFactory
+/**
+ * An implementation of SSLSocketFactory.
+ * <p>
+ * Note: The class must be public so it can be instantiated by the
+ * {@link javax.naming.ldap.InitialLdapContext}.
+ */
+public class TrustedSocketFactory extends SSLSocketFactory
 {
   private static final Map<Thread, TrustManager> hmTrustManager = new HashMap<>();
   private static final Map<Thread, KeyManager> hmKeyManager = new HashMap<>();
@@ -45,10 +50,16 @@
 
   /**
    * Constructor of the TrustedSocketFactory.
-   * @param trustManager the trust manager to use.
-   * @param keyManager   the key manager to use.
+   * <p>
+   * Note: The class must be public so it can be instantiated by the
+   * {@link javax.naming.ldap.InitialLdapContext}.
+   *
+   * @param trustManager
+   *          the trust manager to use.
+   * @param keyManager
+   *          the key manager to use.
    */
-  TrustedSocketFactory(TrustManager trustManager, KeyManager keyManager)
+  public TrustedSocketFactory(TrustManager trustManager, KeyManager keyManager)
   {
     this.trustManager = trustManager;
     this.keyManager   = keyManager;
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
index 43ddeee..9034f57 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -98,7 +98,7 @@
 import org.opends.server.util.ServerConstants;
 
 /** The panel displaying a simplified view of an entry. */
-public class SimplifiedViewEntryPanel extends ViewEntryPanel
+class SimplifiedViewEntryPanel extends ViewEntryPanel
 {
   private static final long serialVersionUID = 2775960608128921072L;
   private JPanel attributesPanel;
@@ -117,30 +117,30 @@
   private GenericDialog browseEntriesDlg;
   private LDAPEntrySelectionPanel browseEntriesPanel;
 
-  private Map<String, List<String>> lastUserPasswords = new HashMap<>();
+  private final Map<String, List<String>> lastUserPasswords = new HashMap<>();
 
   private CustomSearchResult searchResult;
   private boolean isReadOnly;
   private TreePath treePath;
   private JScrollPane scrollAttributes;
 
-  private LinkedHashMap<String, List<EditorComponent>> hmEditors = new LinkedHashMap<>();
+  private final Map<String, List<EditorComponent>> hmEditors = new LinkedHashMap<>();
 
-  private Set<String> requiredAttrs = new HashSet<>();
-  private Map<String, JComponent> hmLabels = new HashMap<>();
-  private Map<String, String> hmDisplayedNames = new HashMap<>();
-  private Map<String, JComponent> hmComponents = new HashMap<>();
+  private final Set<String> requiredAttrs = new HashSet<>();
+  private final Map<String, JComponent> hmLabels = new HashMap<>();
+  private final Map<String, String> hmDisplayedNames = new HashMap<>();
+  private final Map<String, JComponent> hmComponents = new HashMap<>();
 
   private final String CONFIRM_PASSWORD = "confirm password";
 
   /** Map containing as key the attribute name and as value a localizable message. */
-  static Map<String, LocalizableMessage> hmFriendlyAttrNames = new HashMap<>();
+  private final static Map<String, LocalizableMessage> hmFriendlyAttrNames = new HashMap<>();
   /**
    * Map containing as key an object class and as value the preferred naming
    * attribute for the objectclass.
    */
-  static Map<String, String> hmNameAttrNames = new HashMap<>();
-  static Map<String, String[]> hmOrdereredAttrNames = new HashMap<>();
+  private static final Map<String, String> hmNameAttrNames = new HashMap<>();
+  private static final Map<String, String[]> hmOrdereredAttrNames = new HashMap<>();
   static
   {
     hmFriendlyAttrNames.put(ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME,
@@ -243,7 +243,7 @@
     hmOrdereredAttrNames.put("domain", new String[]{"dc", "description"});
   }
 
-  private LocalizableMessage NAME = INFO_CTRL_PANEL_NAME_LABEL.get();
+  private static final LocalizableMessage NAME = INFO_CTRL_PANEL_NAME_LABEL.get();
 
   /** Default constructor. */
   public SimplifiedViewEntryPanel()
@@ -445,23 +445,7 @@
         List<Object> values = sr.getAttributeValues(attr);
         JComponent comp = getReadOnlyComponent(attr, values);
         gbc.weightx = 0.0;
-        if (values.size() > 1)
-        {
-          gbc.anchor = GridBagConstraints.NORTHWEST;
-        }
-        else
-        {
-          gbc.anchor = GridBagConstraints.WEST;
-          if (values.size() == 1)
-          {
-            Object v = values.get(0);
-            if (v instanceof String
-                && ((String) v).contains("\n"))
-            {
-              gbc.anchor = GridBagConstraints.NORTHWEST;
-            }
-          }
-        }
+        gbc.anchor = anchor1(values);
         gbc.insets.left = 0;
         gbc.gridwidth = GridBagConstraints.RELATIVE;
         attributesPanel.add(label, gbc);
@@ -474,7 +458,7 @@
     }
     else
     {
-      for (String attr : sortedAttributes)
+      for (final String attr : sortedAttributes)
       {
         JLabel label = getLabelForAttribute(attr, sr);
         if (isRequired(attr, sr))
@@ -496,7 +480,8 @@
           }
         }
 
-        if (isPassword(attr))
+        final boolean isPasswordAttr = isPassword(attr);
+        if (isPasswordAttr)
         {
           List<String> pwds = new ArrayList<>();
           for (Object o : values)
@@ -507,40 +492,8 @@
         }
 
         JComponent comp = getReadWriteComponent(attr, values);
-
         gbc.weightx = 0.0;
-        if (ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME.equalsIgnoreCase(attr))
-        {
-          int nOcs = 0;
-          for (Object o : values)
-          {
-            if (!"top".equals(o))
-            {
-              nOcs ++;
-            }
-          }
-          if (nOcs > 1)
-          {
-            gbc.anchor = GridBagConstraints.NORTHWEST;
-          }
-          else
-          {
-            gbc.anchor = GridBagConstraints.WEST;
-          }
-        }
-        else if (isSingleValue(attr))
-        {
-          gbc.anchor = GridBagConstraints.WEST;
-        }
-        else if (values.size() <= 1 &&
-                (hasBinaryValue(values) || isBinary(attr)))
-        {
-          gbc.anchor = GridBagConstraints.WEST;
-        }
-        else
-        {
-          gbc.anchor = GridBagConstraints.NORTHWEST;
-        }
+        gbc.anchor = anchor2(attr, values);
         gbc.insets.left = 0;
         gbc.gridwidth = GridBagConstraints.RELATIVE;
         attributesPanel.add(label, gbc);
@@ -552,7 +505,7 @@
         hmLabels.put(attr.toLowerCase(), label);
         hmComponents.put(attr.toLowerCase(), comp);
 
-        if (isPassword(attr))
+        if (isPasswordAttr)
         {
           label = Utilities.createPrimaryLabel(
               INFO_CTRL_PANEL_PASSWORD_CONFIRM_LABEL.get());
@@ -563,14 +516,7 @@
           hmComponents.put(key, comp);
 
           gbc.weightx = 0.0;
-          if (isSingleValue(attr))
-          {
-            gbc.anchor = GridBagConstraints.WEST;
-          }
-          else
-          {
-            gbc.anchor = GridBagConstraints.NORTHWEST;
-          }
+          gbc.anchor = isSingleValue(attr) ? GridBagConstraints.WEST : GridBagConstraints.NORTHWEST;
           gbc.insets.left = 0;
           gbc.gridwidth = GridBagConstraints.RELATIVE;
           attributesPanel.add(label, gbc);
@@ -612,6 +558,51 @@
     });
   }
 
+  private int anchor2(final String attr, List<Object> values)
+  {
+    if (ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME.equalsIgnoreCase(attr))
+    {
+      int nOcs = 0;
+      for (Object o : values)
+      {
+        if (!"top".equals(o))
+        {
+          nOcs++;
+        }
+      }
+      return nOcs > 1 ? GridBagConstraints.NORTHWEST : GridBagConstraints.WEST;
+    }
+    else if (isSingleValue(attr))
+    {
+      return GridBagConstraints.WEST;
+    }
+    else if (values.size() <= 1 && (hasBinaryValue(values) || isBinary(attr)))
+    {
+      return GridBagConstraints.WEST;
+    }
+    else
+    {
+      return GridBagConstraints.NORTHWEST;
+    }
+  }
+
+  private int anchor1(List<Object> values)
+  {
+    if (values.size() > 1)
+    {
+      return GridBagConstraints.NORTHWEST;
+    }
+    if (values.size() == 1)
+    {
+      Object v = values.get(0);
+      if (v instanceof String && ((String) v).contains("\n"))
+      {
+        return GridBagConstraints.NORTHWEST;
+      }
+    }
+    return GridBagConstraints.WEST;
+  }
+
   private JLabel getLabelForAttribute(String attrName, CustomSearchResult sr)
   {
     LocalizableMessageBuilder l = new LocalizableMessageBuilder();
@@ -713,7 +704,7 @@
     if (isRootEntry)
     {
       List<String> attrsNotToAdd = Arrays.asList("entryuuid", "hassubordinates",
-          "numsubordinates", "subschemasubentry", "entrydn", "hassubordinates");
+          "numsubordinates", "subschemasubentry", "entrydn");
       for (String attr : sr.getAttributeNames())
       {
         if (!find(attrNames, attr) && !find(attrsNotToAdd, attr))
@@ -1765,15 +1756,15 @@
    * BinaryCellValue...) and the associated value that will be used to create
    * the modified entry corresponding to the contents of the panel.
    */
-  class EditorComponent
+  private class EditorComponent
   {
-    private Component comp;
+    private final Component comp;
 
     /**
      * Creates an EditorComponent using a text component.
      * @param tf the text component.
      */
-    public EditorComponent(JTextComponent tf)
+    private EditorComponent(JTextComponent tf)
     {
       comp = tf;
       tf.getDocument().addDocumentListener(new DocumentListener()
@@ -1802,7 +1793,7 @@
      * Creates an EditorComponent using a BinaryCellPanel.
      * @param binaryPanel the BinaryCellPanel.
      */
-    public EditorComponent(BinaryCellPanel binaryPanel)
+    private EditorComponent(BinaryCellPanel binaryPanel)
     {
       comp = binaryPanel;
     }
@@ -1811,7 +1802,7 @@
      * Creates an EditorComponent using a ObjectClassCellPanel.
      * @param ocPanel the ObjectClassCellPanel.
      */
-    public EditorComponent(ObjectClassCellPanel ocPanel)
+    private EditorComponent(ObjectClassCellPanel ocPanel)
     {
       comp = ocPanel;
     }
@@ -1826,7 +1817,6 @@
      */
     public Object getValue()
     {
-      Object returnValue;
       if (comp instanceof ObjectClassCellPanel)
       {
         ObjectClassValue ocDesc = ((ObjectClassCellPanel)comp).getValue();
@@ -1846,7 +1836,7 @@
             values.addAll(getObjectClassSuperiorValues(oc));
           }
         }
-        returnValue = values;
+        return values;
       } else if (comp instanceof JTextArea)
       {
         LinkedHashSet<String> values = new LinkedHashSet<>();
@@ -1860,11 +1850,11 @@
             values.add(line);
           }
         }
-        returnValue = values;
+        return values;
       }
       else if (comp instanceof JTextComponent)
       {
-        returnValue = ((JTextComponent)comp).getText();
+        return ((JTextComponent) comp).getText();
       }
       else
       {
@@ -1873,7 +1863,7 @@
         {
           try
           {
-            returnValue = ((BinaryValue)o).getBytes();
+            return ((BinaryValue) o).getBytes();
           }
           catch (ParseException pe)
           {
@@ -1882,10 +1872,9 @@
         }
         else
         {
-          returnValue = o;
+          return o;
         }
       }
-      return returnValue;
     }
   }
 }

--
Gitblit v1.10.0