| | |
| | | import javax.naming.ldap.LdapName; |
| | | |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.guitools.i18n.ResourceProvider; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import org.opends.messages.Message; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | /** |
| | | * This class is used to retrieve configuration and monitoring information using |
| | | * LDAP protocol. |
| | |
| | | private HashSet<DatabaseDescriptor> databases = |
| | | new HashSet<DatabaseDescriptor>(); |
| | | private HashSet<String> administrativeUsers = new HashSet<String>(); |
| | | private String errorMessage; |
| | | private Message errorMessage; |
| | | private boolean replicationConfigured = false; |
| | | private HashSet<String> replicatedSuffixes = new HashSet<String>(); |
| | | private HashMap<String, Integer> hmMissingChanges = |
| | |
| | | { |
| | | detail = ne.toString(); |
| | | } |
| | | String[] arg = {detail}; |
| | | errorMessage = getMsg("error-reading-config-ldap", arg); |
| | | errorMessage = INFO_ERROR_READING_CONFIG_LDAP.get(detail); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | // Bug |
| | | t.printStackTrace(); |
| | | String[] arg = {t.toString()}; |
| | | errorMessage = getMsg("error-reading-config-ldap", arg); |
| | | errorMessage = INFO_ERROR_READING_CONFIG_LDAP.get(t.toString()); |
| | | } |
| | | } |
| | | |
| | |
| | | * @return the error message that we got when retrieving the information |
| | | * using LDAP. |
| | | */ |
| | | public String getErrorMessage() |
| | | public Message getErrorMessage() |
| | | { |
| | | return errorMessage; |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ConfigException(getMsg("could-not-find-valid-ldapurl")); |
| | | throw new ConfigException(INFO_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | break; |
| | | case USE_LDAPS: |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ConfigException(getMsg("could-not-find-valid-ldapurl")); |
| | | throw new ConfigException(INFO_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | break; |
| | | case USE_LDAP: |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ConfigException(getMsg("could-not-find-valid-ldapurl")); |
| | | throw new ConfigException(INFO_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | break; |
| | | case USE_MOST_SECURE_AVAILABLE: |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ConfigException(getMsg("could-not-find-valid-ldapurl")); |
| | | throw new ConfigException(INFO_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | break; |
| | | case USE_LESS_SECURE_AVAILABLE: |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ConfigException(getMsg("could-not-find-valid-ldapurl")); |
| | | throw new ConfigException(INFO_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | break; |
| | | default: |
| | |
| | | * Returns the number of entries in a given backend using the provided |
| | | * InitialLdapContext. |
| | | * @param ctx the InitialLdapContext to use to update the configuration. |
| | | * @param backenID the id of the backend. |
| | | * @param backendID the id of the backend. |
| | | * @return the number of entries in the backend. |
| | | * @throws NamingException if there was an error. |
| | | */ |
| | |
| | | getFirstValue(entry, "ds-cfg-use-ssl")); |
| | | |
| | | ListenerDescriptor.Protocol protocol; |
| | | String protocolDescription; |
| | | Message protocolDescription; |
| | | |
| | | ListenerDescriptor.State state; |
| | | if (hasObjectClass(entry, "ds-cfg-ldap-connection-handler")) |
| | |
| | | addressPort = address+":"+port; |
| | | if (isSecure) |
| | | { |
| | | protocolDescription = getMsg("ldaps-protocol-label"); |
| | | protocolDescription = INFO_LDAPS_PROTOCOL_LABEL.get(); |
| | | protocol = ListenerDescriptor.Protocol.LDAPS; |
| | | } |
| | | else |
| | | { |
| | | protocolDescription = getMsg("ldap-protocol-label"); |
| | | protocolDescription = INFO_LDAP_PROTOCOL_LABEL.get(); |
| | | protocol = ListenerDescriptor.Protocol.LDAP; |
| | | } |
| | | boolean enabled = "true".equalsIgnoreCase( |
| | |
| | | addressPort = "0.0.0.0:"+port; |
| | | if (isSecure) |
| | | { |
| | | protocolDescription = getMsg("jmx-secure-protocol-label"); |
| | | protocolDescription = INFO_JMX_SECURE_PROTOCOL_LABEL.get(); |
| | | protocol = ListenerDescriptor.Protocol.JMXS; |
| | | } |
| | | else |
| | | { |
| | | protocolDescription = getMsg("jmx-protocol-label"); |
| | | protocolDescription = INFO_JMX_PROTOCOL_LABEL.get(); |
| | | protocol = ListenerDescriptor.Protocol.JMX; |
| | | } |
| | | boolean enabled = "true".equalsIgnoreCase( |
| | |
| | | } |
| | | else |
| | | { |
| | | addressPort = getMsg("unknown-label"); |
| | | addressPort = INFO_UNKNOWN_LABEL.get().toString(); |
| | | protocolDescription = null; |
| | | protocol = ListenerDescriptor.Protocol.OTHER; |
| | | /* Try to figure a name from the cn */ |
| | |
| | | int index = cn.toLowerCase().indexOf("connection handler"); |
| | | if (index > 0) |
| | | { |
| | | protocolDescription = cn.substring(0, index).trim(); |
| | | protocolDescription = Message.raw(cn.substring(0, index).trim()); |
| | | } |
| | | else |
| | | { |
| | | protocolDescription = cn; |
| | | protocolDescription = Message.raw(cn); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | protocolDescription = getMsg("undefined-protocol-label"); |
| | | protocolDescription = INFO_UNDEFINED_PROTOCOL_LABEL.get(); |
| | | } |
| | | state = ListenerDescriptor.State.UNKNOWN; |
| | | } |
| | |
| | | return ConfigFromFile.isConfigBackend(id); |
| | | } |
| | | |
| | | /** |
| | | * The following three methods are just commodity methods to get localized |
| | | * messages. |
| | | */ |
| | | private String getMsg(String key) |
| | | { |
| | | return getI18n().getMsg(key); |
| | | } |
| | | |
| | | private String getMsg(String key, String[] args) |
| | | { |
| | | return getI18n().getMsg(key, args); |
| | | } |
| | | |
| | | private ResourceProvider getI18n() |
| | | { |
| | | return ResourceProvider.getInstance(); |
| | | } |
| | | |
| | | private String getURL(ConfigFromFile offlineConf, |
| | | ConnectionProtocolPolicy policy) throws ConfigException |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ConfigException(getMsg("could-not-find-valid-ldapurl")); |
| | | throw new ConfigException(INFO_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | break; |
| | | case USE_LDAPS: |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ConfigException(getMsg("could-not-find-valid-ldapurl")); |
| | | throw new ConfigException(INFO_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | break; |
| | | case USE_LDAP: |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ConfigException(getMsg("could-not-find-valid-ldapurl")); |
| | | throw new ConfigException(INFO_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | break; |
| | | case USE_MOST_SECURE_AVAILABLE: |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ConfigException(getMsg("could-not-find-valid-ldapurl")); |
| | | throw new ConfigException(INFO_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | break; |
| | | case USE_LESS_SECURE_AVAILABLE: |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new ConfigException(getMsg("could-not-find-valid-ldapurl")); |
| | | throw new ConfigException(INFO_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | break; |
| | | default: |