in broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java [276:349]
protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes)
{
super.validateChange(proxyForValidation, changedAttributes);
Port<?> updated = (Port<?>)proxyForValidation;
if (!getName().equals(updated.getName()))
{
throw new IllegalConfigurationException("Changing the port name is not allowed");
}
if (changedAttributes.contains(PORT))
{
int newPort = updated.getPort();
if (getPort() != newPort && newPort != 0)
{
for (Port<?> p : _container.getChildren(Port.class))
{
if (p.getBoundPort() == newPort || p.getPort() == newPort)
{
throw new IllegalConfigurationException("Port number " + newPort +
" is already in use by port " + p.getName());
}
}
}
}
Collection<Transport> transports = updated.getTransports();
Collection<Protocol> protocols = updated.getProtocols();
boolean usesSsl = isUsingTLSTransport(transports);
if (usesSsl && changedAttributes.contains(KEY_STORE) && updated.getKeyStore() == null)
{
throw new IllegalConfigurationException("Can't create port which requires SSL but has no key store configured.");
}
if (changedAttributes.contains(Port.AUTHENTICATION_PROVIDER) || changedAttributes.contains(Port.TRANSPORTS))
{
validateAuthenticationMechanisms(updated.getAuthenticationProvider(), updated.getTransports());
}
boolean requiresCertificate = updated.getNeedClientAuth() || updated.getWantClientAuth();
if (changedAttributes.contains(TRANSPORTS) || changedAttributes.contains(TRUST_STORES) ||
changedAttributes.contains(NEED_CLIENT_AUTH) || changedAttributes.contains(WANT_CLIENT_AUTH))
{
if (usesSsl)
{
if ((updated.getTrustStores() == null || updated.getTrustStores().isEmpty()) && requiresCertificate)
{
throw new IllegalConfigurationException(
"Can't create port which requests SSL client certificates but has no trust store configured.");
}
}
else
{
if (requiresCertificate)
{
throw new IllegalConfigurationException(
"Can't create port which requests SSL client certificates but doesn't use SSL transport.");
}
}
}
if (requiresCertificate && updated.getClientCertRecorder() != null)
{
if (!(updated.getClientCertRecorder() instanceof ManagedPeerCertificateTrustStore))
{
throw new IllegalConfigurationException("Only trust stores of type " + ManagedPeerCertificateTrustStore.TYPE_NAME + " may be used as the client certificate recorder");
}
}
}