| | |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.io.PrintStream; |
| | | import java.net.URI; |
| | | import java.security.KeyStoreException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import javax.naming.NamingException; |
| | | import javax.naming.NamingSecurityException; |
| | | import javax.naming.ldap.Rdn; |
| | | import javax.swing.JPanel; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg0; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.ldap.AuthenticationException; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.EntryNotFoundException; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | |
| | | backendTypes.get(backendId).getBackend()); |
| | | } |
| | | } |
| | | catch (NamingException e) |
| | | catch (LdapException e) |
| | | { |
| | | LocalizableMessage failedMsg = getThrowableMsg(INFO_ERROR_CONNECTING_TO_LOCAL.get(), e); |
| | | throw new ApplicationException(ReturnCode.CONFIGURATION_ERROR, failedMsg, e); |
| | |
| | | localTime = Utils.getServerClock(conn); |
| | | localServerDisplay = conn.getHostPort(); |
| | | } |
| | | catch (NamingException ne) |
| | | catch (LdapException ne) |
| | | { |
| | | LocalizableMessage failedMsg = getThrowableMsg(INFO_ERROR_CONNECTING_TO_LOCAL.get(), ne); |
| | | throw new ApplicationException(ReturnCode.CONFIGURATION_ERROR, failedMsg, ne); |
| | |
| | | ADSContext adsContext = null; // Bound to ADS host (via one of above). |
| | | |
| | | /* |
| | | * Outer try-catch-finally to convert occurrences of NamingException and |
| | | * ADSContextException to ApplicationException and clean up JNDI contexts. |
| | | * Outer try-catch-finally to convert occurrences of LdapException and ADSContextException to |
| | | * ApplicationException and clean up connections. |
| | | */ |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | catch (LdapException ne) |
| | | { |
| | | LocalizableMessage msg; |
| | | if (isRemoteServer) |
| | | { |
| | | msg = getMessageForException(ne, auth.getHostPort().toString()); |
| | | } |
| | | else |
| | | { |
| | | msg = Utils.getMessageForException(ne); |
| | | } |
| | | throw new ApplicationException(ReturnCode.CONFIGURATION_ERROR, msg, ne); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | LocalizableMessage msg; |
| | |
| | | } |
| | | throw new ApplicationException(ReturnCode.CONFIGURATION_ERROR, msg, e); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | | LocalizableMessage msg; |
| | | if (isRemoteServer) |
| | | { |
| | | msg = getMessageForException(ne, auth.getHostPort().toString()); |
| | | } |
| | | else |
| | | { |
| | | msg = Utils.getMessageForException(ne); |
| | | } |
| | | throw new ApplicationException(ReturnCode.CONFIGURATION_ERROR, msg, ne); |
| | | } |
| | | catch (ADSContextException ace) |
| | | { |
| | | throw new ApplicationException(ReturnCode.CONFIGURATION_ERROR, (isRemoteServer ? INFO_REMOTE_ADS_EXCEPTION.get( |
| | |
| | | } |
| | | } |
| | | |
| | | private ConnectionWrapper createConnection(AuthenticationData auth) throws NamingException |
| | | private ConnectionWrapper createConnection(AuthenticationData auth) throws LdapException |
| | | { |
| | | String ldapUrl = auth.getLdapUrl(); |
| | | HostPort hostPort = auth.getHostPort(); |
| | | DN dn = auth.getDn(); |
| | | String pwd = auth.getPwd(); |
| | | |
| | | if (auth.useSecureConnection()) |
| | | { |
| | | ApplicationTrustManager trustManager = getTrustManager(); |
| | | trustManager.setHost(auth.getHostPort().getHost()); |
| | | return new ConnectionWrapper(ldapUrl, LDAPS, dn, pwd, getConnectTimeout(), getTrustManager()); |
| | | trustManager.setHost(hostPort.getHost()); |
| | | return new ConnectionWrapper(hostPort, LDAPS, dn, pwd, getConnectTimeout(), getTrustManager()); |
| | | } |
| | | else |
| | | { |
| | | return new ConnectionWrapper(ldapUrl, LDAP, dn, pwd, getConnectTimeout(), getTrustManager()); |
| | | return new ConnectionWrapper(hostPort, LDAP, dn, pwd, getConnectTimeout(), getTrustManager()); |
| | | } |
| | | } |
| | | |
| | |
| | | AuthenticationData auth = repl.getAuthenticationData(); |
| | | if (auth != null) |
| | | { |
| | | PreferredConnection.Type type; |
| | | if (auth.useSecureConnection()) |
| | | { |
| | | type = PreferredConnection.Type.LDAPS; |
| | | } |
| | | else |
| | | { |
| | | type = PreferredConnection.Type.LDAP; |
| | | } |
| | | cnx.add(new PreferredConnection(auth.getLdapUrl(), type)); |
| | | cnx.add(new PreferredConnection(auth.getHostPort(), auth.getConnectionType())); |
| | | } |
| | | } |
| | | return cnx; |
| | |
| | | excType = toUserDataCertificateExceptionType(cause); |
| | | if (excType != null) |
| | | { |
| | | String h; |
| | | int p; |
| | | try |
| | | { |
| | | URI uri = new URI(e.getLdapUrl()); |
| | | h = uri.getHost(); |
| | | p = uri.getPort(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error parsing ldap url of TopologyCacheException.", t)); |
| | | h = INFO_NOT_AVAILABLE_LABEL.get().toString(); |
| | | p = -1; |
| | | } |
| | | HostPort hostPort2 = e.getHostPort(); |
| | | String h = hostPort2.getHost(); |
| | | int p = hostPort2.getPort(); |
| | | throw new UserDataCertificateException(Step.REPLICATION_OPTIONS, INFO_CERTIFICATE_EXCEPTION.get(h, p), |
| | | e.getCause(), h, p, e.getTrustManager().getLastRefusedChain(), e.getTrustManager() |
| | | .getLastRefusedAuthType(), excType); |
| | |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PWD, true); |
| | | errorMsgs.add(INFO_CANNOT_CONNECT_TO_REMOTE_GENERIC.get(host + ":" + port, t)); |
| | | } |
| | | else if (t instanceof NamingException) |
| | | else if (t instanceof LdapException) |
| | | { |
| | | errorMsgs.add(getMessageForException((NamingException) t, host + ":" + port)); |
| | | errorMsgs.add(getMessageForException((LdapException) t, host + ":" + port)); |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_DN, true); |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PWD, true); |
| | | if (!(t instanceof NamingSecurityException)) |
| | | if (!(t instanceof AuthorizationException) && !(t instanceof AuthenticationException)) |
| | | { |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_HOST, true); |
| | | qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PORT, true); |
| | |
| | | return servers; |
| | | } |
| | | |
| | | private ConnectionWrapper createLocalConnection() throws NamingException |
| | | private ConnectionWrapper createLocalConnection() throws LdapException |
| | | { |
| | | UserData uData = getUserData(); |
| | | HostPort hostPort = new HostPort(uData.getHostName(), uData.getAdminConnectorPort()); |