mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
02.44.2008 33f618629c8cfa8b92b913b047575d4166a091f3
Fix for issue 3307 (NullPointerException in ADSContext when no certificate defined)

Do not assume that we always have a search result (this generated the NullPointerException).
1 files modified
23 ■■■■■ changed files
opends/src/ads/org/opends/admin/ads/ADSContext.java 23 ●●●●● patch | view | raw | blame | history
opends/src/ads/org/opends/admin/ads/ADSContext.java
@@ -789,16 +789,25 @@
          try
          {
            SearchControls sc1 = new SearchControls();
            sc1.setSearchScope(SearchControls.ONELEVEL_SCOPE);
            final String attrIDs[] = { "ds-cfg-public-key-certificate;binary" };
            sc1.setReturningAttributes(attrIDs);
            SearchResult certEntry =
              dirContext.search(getInstanceKeysContainerDN(),
              "(ds-cfg-key-id="+keyId+")", sc).next();
            Attribute certAttr = certEntry.getAttributes().get(attrIDs[0]);
            properties.put(ServerProperty.INSTANCE_PUBLIC_KEY_CERTIFICATE,
                certAttr.get());
            NamingEnumeration<SearchResult> ne2 = dirContext.search(
                getInstanceKeysContainerDN(),
                "(ds-cfg-key-id="+keyId+")", sc);
            if (ne2.hasMore())
            {
              SearchResult certEntry = ne2.next();
              Attribute certAttr = certEntry.getAttributes().get(attrIDs[0]);
              properties.put(ServerProperty.INSTANCE_PUBLIC_KEY_CERTIFICATE,
                  certAttr.get());
            }
            else
            {
              LOG.log(Level.WARNING, "Could not find public key for "+
                  properties);
            }
          }
          catch (NameNotFoundException x)
          {