use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AbstractSystemConfig method initiateStoreAndRecovery.
private Container<?> initiateStoreAndRecovery() throws IOException {
ConfiguredObjectRecord[] initialRecords = convertToConfigurationRecords(getInitialConfigurationLocation());
final DurableConfigurationStore store = getConfigurationStore();
store.init(AbstractSystemConfig.this);
store.upgradeStoreStructure();
final List<ConfiguredObjectRecord> records = new ArrayList<>();
boolean isNew = store.openConfigurationStore(new ConfiguredObjectRecordHandler() {
@Override
public void handle(final ConfiguredObjectRecord record) {
records.add(record);
}
}, initialRecords);
String containerTypeName = getDefaultContainerType();
for (ConfiguredObjectRecord record : records) {
if (record.getParents() != null && record.getParents().size() == 1 && getId().equals(record.getParents().get(SystemConfig.class.getSimpleName()))) {
containerTypeName = record.getType();
break;
}
}
QpidServiceLoader loader = new QpidServiceLoader();
final ContainerType<?> containerType = loader.getInstancesByType(ContainerType.class).get(containerTypeName);
if (containerType != null) {
if (containerType.getModel() != getModel()) {
updateModel(containerType.getModel());
}
containerType.getRecoverer(this).upgradeAndRecover(records);
} else {
throw new IllegalConfigurationException("Unknown container type '" + containerTypeName + "'");
}
final Class categoryClass = containerType.getCategoryClass();
return (Container<?>) getContainer(categoryClass);
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class BrokerImpl method validateChange.
@Override
protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) {
super.validateChange(proxyForValidation, changedAttributes);
Broker updated = (Broker) proxyForValidation;
if (changedAttributes.contains(MODEL_VERSION) && !BrokerModel.MODEL_VERSION.equals(updated.getModelVersion())) {
throw new IllegalConfigurationException("Cannot change the model version");
}
if (changedAttributes.contains(CONTEXT)) {
@SuppressWarnings("unchecked") Map<String, String> context = (Map<String, String>) proxyForValidation.getAttribute(CONTEXT);
if (context.containsKey(BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE)) {
String value = context.get(BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE);
try {
DescendantScope.valueOf(value);
} catch (Exception e) {
throw new IllegalConfigurationException(String.format("Unsupported value '%s' is specified for context variable '%s'. Please, change it to any of supported : %s", value, BROKER_FAIL_STARTUP_WITH_ERRORED_CHILD_SCOPE, EnumSet.allOf(DescendantScope.class)));
}
}
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class FileBasedGroupProviderImpl method validateOnCreate.
@Override
protected void validateOnCreate() {
super.validateOnCreate();
File groupsFile = new File(_path);
if (groupsFile.exists()) {
if (!groupsFile.canRead()) {
throw new IllegalConfigurationException(String.format("Cannot read groups file '%s'. Please check permissions.", _path));
}
FileGroupDatabase groupDatabase = new FileGroupDatabase();
try {
groupDatabase.setGroupFile(_path);
} catch (Exception e) {
throw new IllegalConfigurationException(String.format("Cannot load groups from '%s'", _path), e);
}
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AmqpPortImpl method createSslContext.
private SSLContext createSslContext() {
KeyStore keyStore = getKeyStore();
Collection<TrustStore> trustStores = getTrustStores();
boolean needClientCert = (Boolean) getAttribute(NEED_CLIENT_AUTH) || (Boolean) getAttribute(WANT_CLIENT_AUTH);
if (needClientCert && trustStores.isEmpty()) {
throw new IllegalConfigurationException("Client certificate authentication is enabled on AMQP port '" + this.getName() + "' but no trust store defined");
}
SSLContext sslContext = SSLUtil.createSslContext(keyStore, trustStores, getName());
SSLSessionContext serverSessionContext = sslContext.getServerSessionContext();
if (getTLSSessionCacheSize() > 0) {
serverSessionContext.setSessionCacheSize(getTLSSessionCacheSize());
}
if (getTLSSessionTimeout() > 0) {
serverSessionContext.setSessionTimeout(getTLSSessionTimeout());
}
return sslContext;
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AmqpPortImpl method onActivate.
@Override
protected State onActivate() {
if (getAncestor(SystemConfig.class).isManagementMode()) {
return State.QUIESCED;
} else {
Collection<Transport> transports = getTransports();
TransportProvider transportProvider = null;
final HashSet<Transport> transportSet = new HashSet<>(transports);
for (TransportProviderFactory tpf : (new QpidServiceLoader()).instancesOf(TransportProviderFactory.class)) {
if (tpf.getSupportedTransports().contains(transports)) {
transportProvider = tpf.getTransportProvider(transportSet);
}
}
if (transportProvider == null) {
throw new IllegalConfigurationException("No transport providers found which can satisfy the requirement to support the transports: " + transports);
}
if (transports.contains(Transport.SSL) || transports.contains(Transport.WSS)) {
_sslContext = createSslContext();
}
Protocol defaultSupportedProtocolReply = getDefaultAmqpSupportedReply();
try {
_transport = transportProvider.createTransport(transportSet, _sslContext, this, getProtocols(), defaultSupportedProtocolReply);
_transport.start();
_boundPort = _transport.getAcceptingPort();
for (Transport transport : getTransports()) {
_container.getEventLogger().message(BrokerMessages.LISTENING(String.valueOf(transport), _transport.getAcceptingPort()));
}
return State.ACTIVE;
} catch (PortBindFailureException e) {
_container.getEventLogger().message(PortMessages.BIND_FAILED(getType().toUpperCase(), getPort()));
throw e;
}
}
}
Aggregations