Search in sources :

Example 6 with IllegalConfigurationException

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;
}
Also used : OAuth2UserPrincipal(org.apache.qpid.server.security.auth.manager.oauth2.OAuth2UserPrincipal) GroupPrincipal(org.apache.qpid.server.security.group.GroupPrincipal) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) Map(java.util.Map) GroupPrincipal(org.apache.qpid.server.security.group.GroupPrincipal) OAuth2UserPrincipal(org.apache.qpid.server.security.auth.manager.oauth2.OAuth2UserPrincipal) Principal(java.security.Principal) HashSet(java.util.HashSet)

Example 7 with IllegalConfigurationException

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();
}
Also used : QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) HashMap(java.util.HashMap) ContainerType(org.apache.qpid.server.model.ContainerType) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DynamicModel(org.apache.qpid.server.model.DynamicModel)

Example 8 with IllegalConfigurationException

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. ");
    }
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) MessageStoreProvider(org.apache.qpid.server.store.MessageStoreProvider) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode)

Example 9 with IllegalConfigurationException

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);
    }
}
Also used : VirtualHostStoreUpgraderAndRecoverer(org.apache.qpid.server.store.VirtualHostStoreUpgraderAndRecoverer) PrivilegedAction(java.security.PrivilegedAction) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) IOException(java.io.IOException)

Example 10 with IllegalConfigurationException

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);
            }
        }
    }
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) IOException(java.io.IOException)

Aggregations

IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)87 HashMap (java.util.HashMap)31 IOException (java.io.IOException)25 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)20 File (java.io.File)15 UUID (java.util.UUID)12 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)12 GeneralSecurityException (java.security.GeneralSecurityException)10 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)9 LinkedHashMap (java.util.LinkedHashMap)7 Map (java.util.Map)7 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)7 AccessControlException (java.security.AccessControlException)6 ArrayList (java.util.ArrayList)6 Protocol (org.apache.qpid.server.model.Protocol)5 UnknownAlternateBindingException (org.apache.qpid.server.virtualhost.UnknownAlternateBindingException)5 MalformedURLException (java.net.MalformedURLException)4 URL (java.net.URL)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 HashSet (java.util.HashSet)4