{
switch (e.getType())
{
case NOT_GLOBAL_ADMINISTRATOR:
Message errorMsg = INFO_NOT_GLOBAL_ADMINISTRATOR_PROVIDED.get();
throw new UserDataException(Step.REPLICATION_OPTIONS, errorMsg);
case GENERIC_CREATING_CONNECTION:
if ((e.getCause() != null) &&
isCertificateException(e.getCause()))
{
UserDataCertificateException.Type excType;
ApplicationTrustManager.Cause cause = null;
if (e.getTrustManager() != null)
{
cause = e.getTrustManager().getLastRefusedCause();
}
LOG.log(Level.INFO, "Certificate exception cause: "+cause);
if (cause == ApplicationTrustManager.Cause.NOT_TRUSTED)
{
excType = UserDataCertificateException.Type.NOT_TRUSTED;
}
else if (cause ==
ApplicationTrustManager.Cause.HOST_NAME_MISMATCH)
{
excType = UserDataCertificateException.Type.HOST_NAME_MISMATCH;
}
else
{
excType = null;
}
if (excType != null)
{
String h;
int p;
try
{
URI uri = new URI(e.getLdapUrl());
h = uri.getHost();
p = uri.getPort();
}
catch (Throwable t)
{
LOG.log(Level.WARNING,
"Error parsing ldap url of TopologyCacheException.", t);
h = INFO_NOT_AVAILABLE_LABEL.get().toString();
p = -1;
}
throw new UserDataCertificateException(
Step.REPLICATION_OPTIONS,
INFO_CERTIFICATE_EXCEPTION.get(
h, String.valueOf(p)),
e.getCause(), h, p,
e.getTrustManager().getLastRefusedChain(),
e.getTrustManager().getLastRefusedAuthType(), excType);
}
}
}
exceptionMsgs.add(getMessage(e));
}
if (exceptionMsgs.size() > 0)
{
Message confirmationMsg =
INFO_ERROR_READING_REGISTERED_SERVERS_CONFIRM.get(
getMessageFromCollection(exceptionMsgs, "\n"));
throw new UserDataConfirmationException(Step.REPLICATION_OPTIONS,
confirmationMsg);
}
}
else
{
updateUserDataWithSuffixesInServer(ctx);
}
}
catch (UserDataException ude)
{
throw ude;
}
catch (Throwable t)
{
LOG.log(Level.INFO, "Error connecting to remote server.", t);
if (isCertificateException(t))
{
UserDataCertificateException.Type excType;
ApplicationTrustManager.Cause cause =
trustManager.getLastRefusedCause();
LOG.log(Level.INFO, "Certificate exception cause: "+cause);
if (cause == ApplicationTrustManager.Cause.NOT_TRUSTED)
{
excType = UserDataCertificateException.Type.NOT_TRUSTED;
}
else if (cause == ApplicationTrustManager.Cause.HOST_NAME_MISMATCH)
{
excType = UserDataCertificateException.Type.HOST_NAME_MISMATCH;
}
else
{
excType = null;
}
if (excType != null)
{
throw new UserDataCertificateException(Step.REPLICATION_OPTIONS,
INFO_CERTIFICATE_EXCEPTION.get(host, String.valueOf(port)), t,
host, port, trustManager.getLastRefusedChain(),
trustManager.getLastRefusedAuthType(), excType);
}
else
{
qs.displayFieldInvalid(FieldName.REMOTE_SERVER_HOST, true);
qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PORT, true);
qs.displayFieldInvalid(FieldName.REMOTE_SERVER_DN, true);
qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PWD, true);
errorMsgs.add(INFO_CANNOT_CONNECT_TO_REMOTE_GENERIC.get(
host+":"+port, t.toString()));
}
}
else if (t instanceof NamingException)
{
errorMsgs.add(Utils.getMessageForException((NamingException)t,
host+":"+port));
qs.displayFieldInvalid(FieldName.REMOTE_SERVER_DN, true);
qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PWD, true);
if (!(t instanceof NamingSecurityException))
{
qs.displayFieldInvalid(FieldName.REMOTE_SERVER_HOST, true);
qs.displayFieldInvalid(FieldName.REMOTE_SERVER_PORT, true);
}
}
else if (t instanceof ADSContextException)
{
errorMsgs.add(INFO_REMOTE_ADS_EXCEPTION.get(
host+":"+port, t.toString()));
}
else
{
throw new UserDataException(Step.REPLICATION_OPTIONS,
getThrowableMsg(INFO_BUG_MSG.get(), t));
}
}
finally
{