use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class CloudFoundryDashboardManagementGroupProviderImpl method getGroupPrincipalsForUser.
@Override
public Set<Principal> getGroupPrincipalsForUser(Principal userPrincipal) {
if (!(userPrincipal instanceof OAuth2UserPrincipal)) {
return Collections.emptySet();
}
if (_serviceToManagementGroupMapping == null) {
throw new IllegalConfigurationException("CloudFoundryDashboardManagementGroupProvider serviceToManagementGroupMapping may not be null");
}
OAuth2UserPrincipal oauth2UserPrincipal = (OAuth2UserPrincipal) userPrincipal;
String accessToken = oauth2UserPrincipal.getAccessToken();
Set<Principal> groupPrincipals = new HashSet<>();
for (Map.Entry<String, String> entry : _serviceToManagementGroupMapping.entrySet()) {
String serviceInstanceId = entry.getKey();
String managementGroupName = entry.getValue();
if (mayManageServiceInstance(serviceInstanceId, accessToken)) {
LOGGER.debug("Adding group '{}' to the set of Principals", managementGroupName);
groupPrincipals.add(new GroupPrincipal(managementGroupName, this));
} else {
LOGGER.debug("CloudFoundryDashboardManagementEndpoint denied management permission for service instance '{}'", serviceInstanceId);
}
}
return groupPrincipals;
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class ConfiguredObjectRecordConverter method readFromJson.
public Collection<ConfiguredObjectRecord> readFromJson(Class<? extends ConfiguredObject> rootClass, ConfiguredObject<?> parent, Reader reader) throws IOException {
Map<UUID, ConfiguredObjectRecord> objectsById = new HashMap<>();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
Map data = objectMapper.readValue(reader, Map.class);
if (!data.isEmpty()) {
if (rootClass == null && parent instanceof DynamicModel) {
String defaultContainerType = ((DynamicModel) parent).getDefaultContainerType();
String containerTypeName = defaultContainerType;
if (data.get(ConfiguredObject.TYPE) instanceof String) {
containerTypeName = data.get(ConfiguredObject.TYPE).toString();
}
QpidServiceLoader loader = new QpidServiceLoader();
Map<String, ContainerType> instancesByType = loader.getInstancesByType(ContainerType.class);
final ContainerType<?> containerType = instancesByType.get(containerTypeName);
if (containerType != null) {
_model = containerType.getModel();
rootClass = containerType.getCategoryClass();
} else {
// fall back to default container type
final ContainerType<?> defaultContainerTypeInstance = instancesByType.get(defaultContainerType);
if (defaultContainerTypeInstance != null) {
_model = defaultContainerTypeInstance.getModel();
rootClass = defaultContainerTypeInstance.getCategoryClass();
} else {
throw new IllegalConfigurationException(String.format("Cannot identify container type for '%s'", containerType));
}
}
}
Collection<NameToIdResolver> unresolved = loadChild(rootClass, data, parent.getCategoryClass(), parent.getId(), objectsById);
_rootClass = rootClass;
Iterator<NameToIdResolver> iterator = unresolved.iterator();
while (iterator.hasNext()) {
if (iterator.next().resolve(objectsById)) {
iterator.remove();
}
}
if (!unresolved.isEmpty()) {
throw new IllegalArgumentException("Initial configuration has unresolved references");
}
}
return objectsById.values();
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class ProvidedStoreVirtualHostImpl method onValidate.
@Override
public void onValidate() {
super.onValidate();
VirtualHostNode<?> virtualHostNode = (VirtualHostNode) getParent();
DurableConfigurationStore configurationStore = virtualHostNode.getConfigurationStore();
if (!(configurationStore instanceof MessageStoreProvider)) {
throw new IllegalConfigurationException(VIRTUAL_HOST_TYPE + " virtual host can only be used where the node's store (" + configurationStore.getClass().getName() + ") is a message store provider. ");
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNode method activate.
@Override
protected ListenableFuture<Void> activate() {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Activating virtualhost node " + this);
}
getConfigurationStore().init(this);
getConfigurationStore().upgradeStoreStructure();
getEventLogger().message(getConfigurationStoreLogSubject(), ConfigStoreMessages.CREATED());
writeLocationEventLog();
getEventLogger().message(getConfigurationStoreLogSubject(), ConfigStoreMessages.RECOVERY_START());
VirtualHostStoreUpgraderAndRecoverer upgrader = new VirtualHostStoreUpgraderAndRecoverer(this);
ConfiguredObjectRecord[] initialRecords = null;
try {
initialRecords = getInitialRecords();
} catch (IOException e) {
throw new IllegalConfigurationException("Could not process initial configuration", e);
}
final boolean isNew = upgrader.upgradeAndRecover(getConfigurationStore(), initialRecords);
if (initialRecords.length > 0) {
setAttributes(Collections.<String, Object>singletonMap(VIRTUALHOST_INITIAL_CONFIGURATION, "{}"));
}
getEventLogger().message(getConfigurationStoreLogSubject(), ConfigStoreMessages.RECOVERY_COMPLETE());
QueueManagingVirtualHost<?> host = getVirtualHost();
if (host != null) {
final QueueManagingVirtualHost<?> recoveredHost = host;
final ListenableFuture<Void> openFuture;
recoveredHost.setFirstOpening(isNew && initialRecords.length == 0);
openFuture = Subject.doAs(getSubjectWithAddedSystemRights(), new PrivilegedAction<ListenableFuture<Void>>() {
@Override
public ListenableFuture<Void> run() {
return recoveredHost.openAsync();
}
});
return openFuture;
} else {
return Futures.immediateFuture(null);
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNode method validateOnCreate.
@Override
protected void validateOnCreate() {
super.validateOnCreate();
DurableConfigurationStore store = createConfigurationStore();
if (store != null) {
try {
store.init(this);
} catch (Exception e) {
throw new IllegalConfigurationException("Cannot open node configuration store:" + e.getMessage(), e);
} finally {
try {
store.closeConfigurationStore();
} catch (Exception e) {
LOGGER.warn("Failed to close database", e);
}
}
}
}
Aggregations