opends/src/ads/org/opends/admin/ads/ADSContext.java
@@ -22,7 +22,7 @@ * CDDL HEADER END * * * Copyright 2007-2009 Sun Microsystems, Inc. * Copyright 2007-2010 Sun Microsystems, Inc. */ package org.opends.admin.ads; @@ -604,9 +604,9 @@ } // Unregister the server in server groups NamingEnumeration<SearchResult> ne = null; try { NamingEnumeration<SearchResult> ne; SearchControls sc = new SearchControls(); String serverID = getServerID(serverProperties); @@ -623,6 +623,8 @@ BasicAttribute newAttr = new BasicAttribute(memberAttrName); NamingEnumeration<? extends Attribute> attrs = sr.getAttributes().getAll(); try { while (attrs.hasMore()) { Attribute attr = attrs.next(); @@ -631,6 +633,8 @@ if (attrID.equalsIgnoreCase(memberAttrName)) { NamingEnumeration<?> ae = attr.getAll(); try { while (ae.hasMore()) { String value = (String)ae.next(); @@ -640,6 +644,16 @@ } } } finally { handleCloseNamingEnumeration(ae); } } } } finally { handleCloseNamingEnumeration(attrs); } BasicAttributes newAttrs = new BasicAttributes(); newAttrs.put(newAttr); @@ -671,6 +685,10 @@ throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, x); } finally { handleCloseNamingEnumeration(ne); } } /** @@ -750,19 +768,20 @@ + getServerGroupContainerDN()); Set<String> result = new HashSet<String>() ; NamingEnumeration<SearchResult> srs = null; NamingEnumeration<? extends Attribute> ne = null; try { SearchControls sc = new SearchControls(); sc.setSearchScope(SearchControls.OBJECT_SCOPE); NamingEnumeration<SearchResult> srs = getDirContext().search(dn, "(objectclass=*)", sc); srs = getDirContext().search(dn, "(objectclass=*)", sc); if (!srs.hasMore()) { return result; } Attributes attrs = srs.next().getAttributes(); NamingEnumeration<? extends Attribute> ne = attrs.getAll(); ne = attrs.getAll(); while (ne.hasMore()) { Attribute attr = (Attribute)ne.next(); @@ -776,10 +795,17 @@ // We have the members list NamingEnumeration<?> ae = attr.getAll(); try { while (ae.hasMore()) { result.add((String)ae.next()); } } finally { handleCloseNamingEnumeration(ae); } break; } } @@ -797,6 +823,11 @@ throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, x); } finally { handleCloseNamingEnumeration(srs); handleCloseNamingEnumeration(ne); } return result; } @@ -814,9 +845,9 @@ { Set<Map<ServerProperty,Object>> result = new HashSet<Map<ServerProperty,Object>>(); NamingEnumeration<SearchResult> ne = null; try { NamingEnumeration<SearchResult> ne; SearchControls sc = new SearchControls(); sc.setSearchScope(SearchControls.ONELEVEL_SCOPE); @@ -829,6 +860,7 @@ Object keyId = properties.get(ServerProperty.INSTANCE_KEY_ID); if (keyId != null) { NamingEnumeration<SearchResult> ne2 = null; try { SearchControls sc1 = new SearchControls(); @@ -836,8 +868,7 @@ final String attrIDs[] = { "ds-cfg-public-key-certificate;binary" }; sc1.setReturningAttributes(attrIDs); NamingEnumeration<SearchResult> ne2 = dirContext.search( getInstanceKeysContainerDN(), ne2 = dirContext.search(getInstanceKeysContainerDN(), "(ds-cfg-key-id="+keyId+")", sc); if (ne2.hasMore()) { @@ -856,6 +887,10 @@ { LOG.log(Level.WARNING, "Could not find public key for "+properties); } finally { handleCloseNamingEnumeration(ne2); } } result.add(properties); } @@ -875,6 +910,10 @@ throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, x); } finally { handleCloseNamingEnumeration(ne); } return result; } @@ -1038,9 +1077,9 @@ { Set<Map<ServerGroupProperty, Object>> result = new HashSet<Map<ServerGroupProperty, Object>>(); NamingEnumeration<SearchResult> ne = null; try { NamingEnumeration<SearchResult> ne; SearchControls sc = new SearchControls(); sc.setSearchScope(SearchControls.ONELEVEL_SCOPE); @@ -1069,6 +1108,10 @@ throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, x); } finally { handleCloseNamingEnumeration(ne); } return result; } @@ -1083,8 +1126,8 @@ { Set<Map<AdministratorProperty, Object>> result = new HashSet<Map<AdministratorProperty, Object>>(); NamingEnumeration<SearchResult> ne = null; try { NamingEnumeration<SearchResult> ne; SearchControls sc = new SearchControls(); sc.setSearchScope(SearchControls.ONELEVEL_SCOPE); @@ -1119,6 +1162,10 @@ throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, x); } finally { handleCloseNamingEnumeration(ne); } return result; } @@ -1339,6 +1386,8 @@ boolean updatePassword = adminProperties .containsKey(AdministratorProperty.PASSWORD); NamingEnumeration<?> currentPrivileges = null; try { // Entry renaming @@ -1355,7 +1404,6 @@ // if modification includes 'privilege', we have to get first the // current privileges list. NamingEnumeration<?> currentPrivileges = null; if (adminProperties.containsKey(AdministratorProperty.PRIVILEGE)) { SearchControls sc = new SearchControls(); @@ -1370,6 +1418,7 @@ .getAll(); } // Replace properties, if needed. if (adminProperties.size() > 1) { @@ -1395,6 +1444,10 @@ throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, x); } finally { handleCloseNamingEnumeration(currentPrivileges); } } /** @@ -1795,10 +1848,17 @@ Set<String> set = new HashSet<String>(); NamingEnumeration<?> ae = attr.getAll(); try { while (ae.hasMore()) { set.add((String)ae.next()); } } finally { ae.close(); } value = set; } else @@ -1863,10 +1923,17 @@ { Set<String> set = new HashSet<String>(); NamingEnumeration<?> ae = attr.getAll(); try { while (ae.hasMore()) { set.add((String)ae.next()); } } finally { ae.close(); } value = set; } else @@ -1906,10 +1973,10 @@ nameObj = nameFromDN(rdn); String dn = nameObj + "," + getAdministratorContainerDN(); result.put(AdministratorProperty.ADMINISTRATOR_DN, dn); NamingEnumeration<? extends Attribute> ne = null; try { NamingEnumeration<? extends Attribute> ne = attrs.getAll(); ne = attrs.getAll(); while (ne.hasMore()) { Attribute attr = ne.next(); String attrID = attr.getID(); @@ -1947,6 +2014,10 @@ throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, x); } finally { handleCloseNamingEnumeration(ne); } return result; } @@ -2430,13 +2501,24 @@ searchControls.setReturningAttributes(attrIDs); NamingEnumeration<SearchResult> keyEntries = dirContext.search(baseDN, searchFilter, searchControls); try { while (keyEntries.hasMore()) { final SearchResult entry = keyEntries.next(); final Attributes attrs = entry.getAttributes(); final Attribute keyIDAttr = attrs.get(attrIDs[0]); final Attribute keyCertAttr = attrs.get(attrIDs[1]); if (null == keyIDAttr || null == keyCertAttr) continue; // schema viol. certificateMap.put((String)keyIDAttr.get(), (byte[])keyCertAttr.get()); if (null == keyIDAttr || null == keyCertAttr) { continue;// schema viol. } certificateMap.put((String)keyIDAttr.get(), (byte[])keyCertAttr.get()); } } finally { keyEntries.close(); } } catch (NamingException x) { @@ -2581,4 +2663,21 @@ } } } private void handleCloseNamingEnumeration(NamingEnumeration<?> ne) throws ADSContextException { if (ne != null) { try { ne.close(); } catch (NamingException ex) { throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, ex); } } } } opends/src/ads/org/opends/admin/ads/ADSContextHelper.java
@@ -22,7 +22,7 @@ * CDDL HEADER END * * * Copyright 2007-2009 Sun Microsystems, Inc. * Copyright 2007-2010 Sun Microsystems, Inc. */ package org.opends.admin.ads; @@ -232,10 +232,11 @@ /* search for public-key certificate entry in ADS DIT */ final String attrIDs[] = { "ds-cfg-key-id" }; NamingEnumeration<SearchResult> results = null; try { final NamingEnumeration<SearchResult> results = ctx.search( ADSContext.getInstanceKeysContainerDN(), keyAttrs, attrIDs); results = ctx.search(ADSContext.getInstanceKeysContainerDN(), keyAttrs, attrIDs); if (results.hasMore()) { final Attribute keyIdAttr = results.next().getAttributes().get(attrIDs[0]); @@ -287,6 +288,10 @@ throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, cme); } finally { handleCloseNamingEnumeration(results); } } @@ -324,9 +329,10 @@ /* search for public-key certificate entry in ADS DIT */ final String attrIDs[] = { "ds-cfg-key-id" }; NamingEnumeration<SearchResult> results = null; try { final NamingEnumeration<SearchResult> results = ctx.search( results = ctx.search( ADSContext.getInstanceKeysContainerDN(), keyAttrs, attrIDs); if (results.hasMore()) { SearchResult res = results.next(); @@ -341,6 +347,10 @@ throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, ne); } finally { handleCloseNamingEnumeration(results); } } /** @@ -364,4 +374,21 @@ { return ConfigConstants.ATTR_CRYPTO_KEY_COMPROMISED_TIME; } private void handleCloseNamingEnumeration(NamingEnumeration<?> ne) throws ADSContextException { if (ne != null) { try { ne.close(); } catch (NamingException ex) { throw new ADSContextException( ADSContextException.ErrorType.ERROR_UNEXPECTED, ex); } } } } opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
@@ -22,7 +22,7 @@ * CDDL HEADER END * * * Copyright 2007-2009 Sun Microsystems, Inc. * Copyright 2007-2010 Sun Microsystems, Inc. */ package org.opends.admin.ads; @@ -335,9 +335,9 @@ if (!serverProperties.isEmpty()) { ArrayList s = (ArrayList)serverProperties.get( ArrayList<?> s = (ArrayList<?>)serverProperties.get( ServerProperty.LDAP_ENABLED); ArrayList p = (ArrayList)serverProperties.get( ArrayList<?> p = (ArrayList<?>)serverProperties.get( ServerProperty.LDAP_PORT); if (s != null) { @@ -372,9 +372,9 @@ if (!serverProperties.isEmpty()) { ArrayList s = (ArrayList)serverProperties.get( ArrayList<?> s = (ArrayList<?>)serverProperties.get( ServerProperty.LDAPS_ENABLED); ArrayList p = (ArrayList)serverProperties.get( ArrayList<?> p = (ArrayList<?>)serverProperties.get( ServerProperty.LDAPS_PORT); if (s != null) { @@ -409,9 +409,9 @@ if (!serverProperties.isEmpty()) { ArrayList s = (ArrayList)serverProperties.get( ArrayList<?> s = (ArrayList<?>)serverProperties.get( ServerProperty.ADMIN_ENABLED); ArrayList p = (ArrayList)serverProperties.get( ArrayList<?> p = (ArrayList<?>)serverProperties.get( ServerProperty.ADMIN_PORT); if (s != null) { @@ -439,9 +439,9 @@ public List<Integer> getEnabledAdministrationPorts() { List<Integer> ports = new ArrayList<Integer>(1); ArrayList s = (ArrayList)serverProperties.get( ArrayList<?> s = (ArrayList<?>)serverProperties.get( ServerProperty.ADMIN_ENABLED); ArrayList p = (ArrayList)serverProperties.get( ArrayList<?> p = (ArrayList<?>)serverProperties.get( ServerProperty.ADMIN_PORT); if (s != null) { @@ -471,9 +471,9 @@ if (!serverProperties.isEmpty()) { ArrayList s = (ArrayList)serverProperties.get( ArrayList<?> s = (ArrayList<?>)serverProperties.get( ServerProperty.LDAP_ENABLED); ArrayList p = (ArrayList)serverProperties.get( ArrayList<?> p = (ArrayList<?>)serverProperties.get( ServerProperty.LDAP_PORT); if (s != null) { @@ -488,9 +488,9 @@ } if (securePreferred) { s = (ArrayList)serverProperties.get( s = (ArrayList<?>)serverProperties.get( ServerProperty.ADMIN_ENABLED); p = (ArrayList)serverProperties.get(ServerProperty.ADMIN_PORT); p = (ArrayList<?>)serverProperties.get(ServerProperty.ADMIN_PORT); if (s != null) { for (int i=0; i<s.size(); i++) @@ -587,7 +587,7 @@ ServerProperty.ADMIN_ENABLED }; for (ServerProperty prop : props) { ArrayList s = (ArrayList) serverProperties.get(prop); ArrayList<?> s = (ArrayList<?>) serverProperties.get(prop); for (Object o : s) { buf.append(":").append(o); } @@ -694,8 +694,8 @@ for (int i=0; i<sProps.length; i++) { ArrayList s = (ArrayList)serverProperties.get(sProps[i][0]); ArrayList p = (ArrayList)serverProperties.get(sProps[i][1]); ArrayList<?> s = (ArrayList<?>)serverProperties.get(sProps[i][0]); ArrayList<?> p = (ArrayList<?>)serverProperties.get(sProps[i][1]); if (s != null) { int port = -1; @@ -723,7 +723,7 @@ } } ArrayList array = (ArrayList)serverProperties.get( ArrayList<?> array = (ArrayList<?>)serverProperties.get( ServerProperty.STARTTLS_ENABLED); boolean startTLSEnabled = false; if ((array != null) && !array.isEmpty()) @@ -802,8 +802,11 @@ String filter = "(objectclass=ds-cfg-ldap-connection-handler)"; LdapName jndiName = new LdapName("cn=config"); NamingEnumeration listeners = ctx.search(jndiName, filter, ctls); NamingEnumeration<SearchResult> listeners = ctx.search(jndiName, filter, ctls); try { ArrayList<Integer> ldapPorts = new ArrayList<Integer>(); ArrayList<Integer> ldapsPorts = new ArrayList<Integer>(); ArrayList<Boolean> ldapEnabled = new ArrayList<Boolean>(); @@ -814,11 +817,12 @@ desc.serverProperties.put(ServerProperty.LDAPS_PORT, ldapsPorts); desc.serverProperties.put(ServerProperty.LDAP_ENABLED, ldapEnabled); desc.serverProperties.put(ServerProperty.LDAPS_ENABLED, ldapsEnabled); desc.serverProperties.put(ServerProperty.STARTTLS_ENABLED, startTLSEnabled); desc.serverProperties.put(ServerProperty.STARTTLS_ENABLED, startTLSEnabled); while(listeners.hasMore()) { SearchResult sr = (SearchResult)listeners.next(); SearchResult sr = listeners.next(); String port = getFirstValue(sr, "ds-cfg-listen-port"); @@ -842,6 +846,11 @@ } } } finally { listeners.close(); } } private static void updateAdminConnectorConfiguration(ServerDescriptor desc, InitialLdapContext ctx, TopologyCacheFilter cacheFilter) @@ -857,13 +866,16 @@ String filter = "(objectclass=ds-cfg-administration-connector)"; LdapName jndiName = new LdapName("cn=config"); NamingEnumeration listeners = ctx.search(jndiName, filter, ctls); NamingEnumeration<SearchResult> listeners = ctx.search(jndiName, filter, ctls); try { Integer adminConnectorPort = null; // we should have a single administration connector if (listeners.hasMore()) { SearchResult sr = (SearchResult) listeners.next(); SearchResult sr = listeners.next(); String port = getFirstValue(sr, "ds-cfg-listen-port"); adminConnectorPort = new Integer(port); } @@ -880,6 +892,11 @@ desc.serverProperties.put(ServerProperty.ADMIN_PORT, adminPorts); desc.serverProperties.put(ServerProperty.ADMIN_ENABLED, adminEnabled); } finally { listeners.close(); } } private static void updateJmxConfiguration(ServerDescriptor desc, InitialLdapContext ctx, TopologyCacheFilter cacheFilter) @@ -898,7 +915,8 @@ String filter = "(objectclass=ds-cfg-jmx-connection-handler)"; LdapName jndiName = new LdapName("cn=config"); NamingEnumeration listeners = ctx.search(jndiName, filter, ctls); NamingEnumeration<SearchResult> listeners = ctx.search(jndiName, filter, ctls); ArrayList<Integer> jmxPorts = new ArrayList<Integer>(); ArrayList<Integer> jmxsPorts = new ArrayList<Integer>(); @@ -910,9 +928,11 @@ desc.serverProperties.put(ServerProperty.JMX_ENABLED, jmxEnabled); desc.serverProperties.put(ServerProperty.JMXS_ENABLED, jmxsEnabled); try { while(listeners.hasMore()) { SearchResult sr = (SearchResult)listeners.next(); SearchResult sr = listeners.next(); String port = getFirstValue(sr, "ds-cfg-listen-port"); @@ -933,6 +953,11 @@ } } } finally { listeners.close(); } } private static void updateReplicas(ServerDescriptor desc, InitialLdapContext ctx, TopologyCacheFilter cacheFilter) @@ -952,11 +977,14 @@ String filter = "(objectclass=ds-cfg-backend)"; LdapName jndiName = new LdapName("cn=config"); NamingEnumeration databases = ctx.search(jndiName, filter, ctls); NamingEnumeration<SearchResult> databases = ctx.search(jndiName, filter, ctls); try { while(databases.hasMore()) { SearchResult sr = (SearchResult)databases.next(); SearchResult sr = databases.next(); String id = getFirstValue(sr, "ds-cfg-backend-id"); @@ -1029,6 +1057,11 @@ } } } finally { databases.close(); } } private static void updateReplication(ServerDescriptor desc, InitialLdapContext ctx, TopologyCacheFilter cacheFilter) @@ -1045,14 +1078,15 @@ LdapName jndiName = new LdapName( "cn=Multimaster Synchronization,cn=Synchronization Providers,cn=config"); NamingEnumeration<SearchResult> syncProviders = null; try { NamingEnumeration syncProviders = ctx.search(jndiName, filter, ctls); syncProviders = ctx.search(jndiName, filter, ctls); while(syncProviders.hasMore()) { SearchResult sr = (SearchResult)syncProviders.next(); SearchResult sr = syncProviders.next(); if ("true".equalsIgnoreCase(getFirstValue(sr, "ds-cfg-enabled"))) @@ -1065,6 +1099,13 @@ { /* ignore */ } finally { if (syncProviders != null) { syncProviders.close(); } } desc.serverProperties.put(ServerProperty.IS_REPLICATION_ENABLED, replicationEnabled ? Boolean.TRUE : Boolean.FALSE); @@ -1085,13 +1126,14 @@ jndiName = new LdapName( "cn=Multimaster Synchronization,cn=Synchronization Providers,cn=config"); syncProviders = null; try { NamingEnumeration syncProviders = ctx.search(jndiName, filter, ctls); syncProviders = ctx.search(jndiName, filter, ctls); while(syncProviders.hasMore()) { SearchResult sr = (SearchResult)syncProviders.next(); SearchResult sr = syncProviders.next(); int id = Integer.parseInt( getFirstValue(sr, "ds-cfg-server-id")); @@ -1123,6 +1165,13 @@ { /* ignore */ } finally { if (syncProviders != null) { syncProviders.close(); } } } ctls = new SearchControls(); @@ -1139,13 +1188,14 @@ desc.serverProperties.put(ServerProperty.IS_REPLICATION_SERVER, Boolean.FALSE); NamingEnumeration<SearchResult> entries = null; try { NamingEnumeration entries = ctx.search(jndiName, filter, ctls); entries = ctx.search(jndiName, filter, ctls); while(entries.hasMore()) { SearchResult sr = (SearchResult)entries.next(); SearchResult sr = entries.next(); desc.serverProperties.put(ServerProperty.IS_REPLICATION_SERVER, Boolean.TRUE); @@ -1172,6 +1222,13 @@ { /* ignore */ } finally { if (entries != null) { entries.close(); } } boolean replicationSecure = false; if (replicationEnabled) @@ -1184,16 +1241,23 @@ jndiName = new LdapName("cn=Crypto Manager,cn=config"); NamingEnumeration entries = ctx.search(jndiName, filter, ctls); entries = ctx.search(jndiName, filter, ctls); try { while(entries.hasMore()) { SearchResult sr = (SearchResult)entries.next(); SearchResult sr = entries.next(); String v = getFirstValue(sr, "ds-cfg-ssl-encryption"); replicationSecure = "true".equalsIgnoreCase(v); } } finally { entries.close(); } } desc.serverProperties.put(ServerProperty.IS_REPLICATION_SECURE, replicationSecure ? Boolean.TRUE : Boolean.FALSE); } @@ -1269,16 +1333,24 @@ String filter = "|(objectclass=*)(objectclass=ldapsubentry)"; LdapName jndiName = new LdapName("cn=schema"); NamingEnumeration listeners = ctx.search(jndiName, filter, ctls); NamingEnumeration<SearchResult> listeners = ctx.search(jndiName, filter, ctls); try { while(listeners.hasMore()) { SearchResult sr = (SearchResult)listeners.next(); SearchResult sr = listeners.next(); desc.serverProperties.put(ServerProperty.SCHEMA_GENERATION_ID, getFirstValue(sr, "ds-sync-generation-id")); } } finally { listeners.close(); } } /** Seeds the bound instance's local ads-truststore with a set of instance @@ -1346,11 +1418,18 @@ NamingEnumeration<SearchResult> ne = ctx.search(TRUSTSTORE_DN, "(objectclass=ds-cfg-instance-key)", sc); ArrayList<String> dnsToDelete = new ArrayList<String>(); try { while (ne.hasMore()) { SearchResult sr = ne.next(); dnsToDelete.add(sr.getName()+","+TRUSTSTORE_DN); } } finally { ne.close(); } for (String dn : dnsToDelete) { ctx.destroySubcontext(dn); @@ -1384,14 +1463,22 @@ String filter = "(ds-backend-id="+backendID+")"; LdapName jndiName = new LdapName("cn=monitor"); NamingEnumeration listeners = ctx.search(jndiName, filter, ctls); NamingEnumeration<SearchResult> listeners = ctx.search(jndiName, filter, ctls); try { while(listeners.hasMore()) { SearchResult sr = (SearchResult)listeners.next(); SearchResult sr = listeners.next(); v.addAll(getValues(sr, "ds-base-dn-entry-count")); } } finally { listeners.close(); } return v; } opends/src/ads/org/opends/admin/ads/TopologyCache.java
@@ -475,13 +475,13 @@ LdapName jndiName = new LdapName("cn=monitor"); InitialLdapContext ctx = null; NamingEnumeration<SearchResult> monitorEntries = null; try { ServerLoader loader = getServerLoader(replicationServer.getAdsProperties()); ctx = loader.createContext(); NamingEnumeration<SearchResult> monitorEntries = ctx.search(jndiName, filter, ctls); monitorEntries = ctx.search(jndiName, filter, ctls); while(monitorEntries.hasMore()) { @@ -537,6 +537,10 @@ } finally { if (monitorEntries != null) { monitorEntries.close(); } if (ctx != null) { ctx.close(); opends/src/guitools/org/opends/guitools/controlpanel/browser/NodeRefresher.java
@@ -349,12 +349,19 @@ NamingEnumeration<SearchResult> s = ctx.search(new LdapName(node.getDN()), controller.getFilter(), ctls); try { if (!s.hasMoreElements()) { throw new NameNotFoundException("Entry "+node.getDN()+ " does not verify filter "+controller.getFilter()); } } finally { s.close(); } } /** * Performs the search in the case the user specified a custom filter. @@ -372,12 +379,19 @@ NamingEnumeration<SearchResult> s = ctx.search(new LdapName(dn), controller.getFilter(), ctls); try { if (!s.hasMoreElements()) { throw new NameNotFoundException("Entry "+dn+ " does not verify filter "+controller.getFilter()); } } finally { s.close(); } } /** * Read the local entry associated to the current node. @@ -402,12 +416,19 @@ NamingEnumeration<SearchResult> s = ctx.search(new LdapName(node.getDN()), controller.getObjectSearchFilter(), ctls); try { if (s.hasMore()) { localEntry = s.next(); localEntry.setName(node.getDN()); } } finally { s.close(); } if (localEntry == null) { /* Not enough rights to read the entry or the entry simply does not exist */ @@ -511,6 +532,8 @@ NamingEnumeration<SearchResult> sr = ctx.search(remoteDn, filter, ctls); try { if (sr.hasMore()) { entry = sr.next(); @@ -529,6 +552,11 @@ { throw new NameNotFoundException(); } } finally { sr.close(); } throwAbandonIfNeeded(null); } catch (InterruptedNamingException x) { @@ -660,6 +688,17 @@ if (ctx != null) { controller.releaseLDAPConnection(ctx); } if (searchResults != null) { try { searchResults.close(); } catch (NamingException x) { throwAbandonIfNeeded(x); } } } } @@ -731,6 +770,8 @@ controller.getChildSearchFilter(), ctls); try { while (entries.hasMore()) { SearchResult r = entries.next(); @@ -851,6 +892,11 @@ throwAbandonIfNeeded(null); } } finally { entries.close(); } } catch (SizeLimitExceededException slee) { parentNode.setSizeLimitReached(true); @@ -886,11 +932,18 @@ controller.getObjectSearchFilter(), ctls); try { while (entries.hasMore()) { sr = entries.next(); sr.setName(dn); } } finally { entries.close(); } return sr; } opends/src/guitools/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
@@ -135,6 +135,8 @@ if (attrs != null) { NamingEnumeration<?> en = attrs.getAll(); try { while (en.hasMore()) { Attribute attr = (Attribute)en.next(); String attrName = attr.getID(); @@ -151,6 +153,11 @@ attributes.put(attrName.toLowerCase(), values); } } finally { en.close(); } } toString = calculateToString(); hashCode = calculateHashCode(); } opends/src/guitools/org/opends/guitools/controlpanel/task/AddToGroupTask.java
@@ -22,7 +22,7 @@ * CDDL HEADER END * * * Copyright 2008-2009 Sun Microsystems, Inc. * Copyright 2008-2010 Sun Microsystems, Inc. */ package org.opends.guitools.controlpanel.task; @@ -259,6 +259,8 @@ Utilities.getJNDIName(groupDn.toString()), filter, ctls); try { while (result.hasMore()) { SearchResult sr = result.next(); @@ -304,6 +306,11 @@ attribute)); } } } finally { result.close(); } return modifications; } } opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
@@ -367,6 +367,8 @@ ctx.search(Utilities.getJNDIName(dnToRemove.toString()), filter, ctls); DN entryDNFound = dnToRemove; try { while (entryDNs.hasMore()) { SearchResult sr = entryDNs.next(); @@ -378,6 +380,11 @@ deleteSubtreeRecursively(ctx, entryDNFound, null, toNotify); } } } finally { entryDNs.close(); } } catch (NameNotFoundException nnfe) { // The entry is not there: it has been removed opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java
@@ -658,7 +658,7 @@ { hasSuperior = true; isFound = true; newSuperiors.add(getNewSuperior(oc)); newSuperiors.addAll(getNewSuperiors(oc)); break; } } @@ -715,22 +715,29 @@ } private ObjectClass getNewSuperior(ObjectClass currentSup) private Set<ObjectClass> getNewSuperiors(ObjectClass currentSup) { Set<ObjectClass> newSuperiors = new LinkedHashSet<ObjectClass>(); if(currentSup.getSuperiorClasses() == null || currentSup.getSuperiorClasses().isEmpty()) { return currentSup; // Nothing to do } if(providedOcsToDelete.contains(currentSup)) else { for(ObjectClass o : currentSup.getSuperiorClasses()) { return getNewSuperior(o); if (providedOcsToDelete.contains(o)) { newSuperiors.addAll(getNewSuperiors(o)); } else { newSuperiors.add(o); } } return null; } return newSuperiors; } opends/src/guitools/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java
@@ -22,7 +22,7 @@ * CDDL HEADER END * * * Copyright 2008-2009 Sun Microsystems, Inc. * Copyright 2008-2010 Sun Microsystems, Inc. */ package org.opends.guitools.controlpanel.task; @@ -294,6 +294,8 @@ NamingEnumeration<SearchResult> entries = ctx.search(Utilities.getJNDIName(dn.toString()), filter, ctls); try { while (entries.hasMore()) { SearchResult sr = entries.next(); @@ -308,6 +310,11 @@ } } } finally { entries.close(); } } catch (Throwable t) { } opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
@@ -958,7 +958,15 @@ NamingEnumeration<SearchResult> en = ctx.search("cn=Version,cn=monitor", "objectclass=*", searchControls); SearchResult sr = en.next(); SearchResult sr = null; try { sr = en.next(); } finally { en.close(); } CustomSearchResult csr = new CustomSearchResult(sr, "cn=Version,cn=monitor"); opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
@@ -826,12 +826,19 @@ javaVersion = null; numberConnections = -1; try { while (monitorEntries.hasMore()) { SearchResult sr = monitorEntries.next(); handleMonitoringSearchResult(sr, "cn=monitor"); } } finally { monitorEntries.close(); } } catch (NamingException ne) { OnlineUpdateException oue = new OnlineUpdateException( @@ -858,12 +865,19 @@ NamingEnumeration<SearchResult> taskEntries = ctx.search(jndiName, filter, ctls); try { while (taskEntries.hasMore()) { SearchResult sr = taskEntries.next(); handleTaskSearchResult(sr, ConfigConstants.DN_TASK_ROOT, ts); } } finally { taskEntries.close(); } } catch (NamingException ne) { OnlineUpdateException oue = new OnlineUpdateException( opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
@@ -22,7 +22,7 @@ * CDDL HEADER END * * * Copyright 2008-2009 Sun Microsystems, Inc. * Copyright 2008-2010 Sun Microsystems, Inc. */ package org.opends.guitools.controlpanel.util; @@ -72,6 +72,7 @@ public CustomSearchResult processBackgroundTask() throws Throwable { isOver = false; NamingEnumeration<SearchResult> en = null; try { SearchControls controls = new SearchControls(); @@ -82,8 +83,7 @@ controls.setSearchScope(SearchControls.OBJECT_SCOPE); final String filter = "(|(objectclass=*)(objectclass=ldapsubentry))"; NamingEnumeration<SearchResult> en = ctx.search(Utilities.getJNDIName(dn), filter, controls); en = ctx.search(Utilities.getJNDIName(dn), filter, controls); SearchResult sr = en.next(); @@ -95,6 +95,10 @@ { isOver = true; } if (en != null) { en.close(); } } } opends/src/guitools/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java
@@ -93,7 +93,15 @@ ctx.search(ConfigConstants.DN_DEFAULT_SCHEMA_ROOT, filter, searchControls); SearchResult sr = srs.next(); SearchResult sr = null; try { sr = srs.next(); } finally { srs.close(); } CustomSearchResult csr = new CustomSearchResult(sr, ConfigConstants.DN_DEFAULT_SCHEMA_ROOT); opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -4595,8 +4595,15 @@ { NamingEnumeration<SearchResult> res = ctx.search(dn, filter, searchControls); SearchResult sr = res.next(); SearchResult sr = null; try { sr = res.next(); } finally { res.close(); } // Get the number of entries that have been handled and // a percentage... Message msg; @@ -4890,7 +4897,15 @@ { NamingEnumeration<SearchResult> res = ctx.search(dn, filter, searchControls); SearchResult sr = res.next(); SearchResult sr = null; try { sr = res.next(); } finally { res.close(); } String logMsg = getFirstValue(sr, "ds-task-log-message"); if (logMsg != null) { opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -1754,6 +1754,8 @@ LdapName jndiName = new LdapName("cn=monitor"); NamingEnumeration<?> listeners = ctx.search(jndiName, filter, ctls); try { while (listeners.hasMore()) { SearchResult sr = (SearchResult)listeners.next(); @@ -1769,6 +1771,11 @@ time = formatter.parse(v).getTime(); } } finally { listeners.close(); } } catch (Throwable t) { LOG.log(Level.WARNING, "Error retrieving server current time: "+t, t); opends/src/server/org/opends/server/admin/client/ldap/JNDIDirContextAdaptor.java
@@ -22,7 +22,7 @@ * CDDL HEADER END * * * Copyright 2008 Sun Microsystems, Inc. * Copyright 2008-2010 Sun Microsystems, Inc. */ package org.opends.server.admin.client.ldap; @@ -235,9 +235,16 @@ try { NamingEnumeration<SearchResult> results = dirContext.search(dn, filter, controls); try { if (results.hasMore()) { return true; } } finally { results.close(); } } catch (NameNotFoundException e) { // Fall through - entry not found. } @@ -262,12 +269,19 @@ List<LdapName> children = new LinkedList<LdapName>(); NamingEnumeration<SearchResult> results = dirContext.search(dn, filter, controls); try { while (results.hasMore()) { SearchResult sr = results.next(); LdapName child = new LdapName(dn.getRdns()); child.add(new Rdn(sr.getName())); children.add(child); } } finally { results.close(); } return children; } opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -7745,7 +7745,15 @@ { NamingEnumeration<SearchResult> res = ctx.search(dn, filter, searchControls); SearchResult sr = res.next(); SearchResult sr = null; try { sr = res.next(); } finally { res.close(); } String logMsg = getFirstValue(sr, "ds-task-log-message"); if (logMsg != null) { @@ -7898,7 +7906,15 @@ { NamingEnumeration<SearchResult> res = ctx.search(dn, filter, searchControls); SearchResult sr = res.next(); SearchResult sr = null; try { sr = res.next(); } finally { res.close(); } // Get the number of entries that have been handled and // a percentage...