Search in sources :

Example 1 with VirtualHostAccessControlProvider

use of org.apache.qpid.server.model.VirtualHostAccessControlProvider in project qpid-broker-j by apache.

the class AbstractVirtualHost method updateAccessControl.

private void updateAccessControl() {
    if (!((SystemConfig) _broker.getParent()).isManagementMode()) {
        List<VirtualHostAccessControlProvider> children = new ArrayList<>(getChildren(VirtualHostAccessControlProvider.class));
        LOGGER.debug("Updating access control list with {} provider children", children.size());
        Collections.sort(children, VirtualHostAccessControlProvider.ACCESS_CONTROL_PROVIDER_COMPARATOR);
        List<AccessControl<?>> accessControls = new ArrayList<>(children.size() + 2);
        accessControls.add(_systemUserAllowed);
        for (VirtualHostAccessControlProvider prov : children) {
            if (prov.getState() == State.ERRORED) {
                accessControls.clear();
                accessControls.add(AccessControl.ALWAYS_DENIED);
                break;
            } else if (prov.getState() == State.ACTIVE) {
                accessControls.add(prov.getController());
            }
        }
        accessControls.add(getParentAccessControl());
        ((CompoundAccessControl) _accessControl).setAccessControls(accessControls);
    }
}
Also used : ArrayList(java.util.ArrayList) CompoundAccessControl(org.apache.qpid.server.security.CompoundAccessControl) VirtualHostAccessControlProvider(org.apache.qpid.server.model.VirtualHostAccessControlProvider) CompoundAccessControl(org.apache.qpid.server.security.CompoundAccessControl) SubjectFixedResultAccessControl(org.apache.qpid.server.security.SubjectFixedResultAccessControl) AccessControl(org.apache.qpid.server.security.AccessControl)

Example 2 with VirtualHostAccessControlProvider

use of org.apache.qpid.server.model.VirtualHostAccessControlProvider in project qpid-broker-j by apache.

the class AbstractVirtualHost method doRestart.

private ListenableFuture<Void> doRestart() {
    createHousekeepingExecutor();
    final VirtualHostStoreUpgraderAndRecoverer virtualHostStoreUpgraderAndRecoverer = new VirtualHostStoreUpgraderAndRecoverer((VirtualHostNode<?>) getParent());
    virtualHostStoreUpgraderAndRecoverer.reloadAndRecoverVirtualHost(getDurableConfigurationStore());
    final Collection<VirtualHostAccessControlProvider> accessControlProviders = getChildren(VirtualHostAccessControlProvider.class);
    if (!accessControlProviders.isEmpty()) {
        accessControlProviders.forEach(child -> child.addChangeListener(_accessControlProviderListener));
    }
    final List<ListenableFuture<Void>> childOpenFutures = new ArrayList<>();
    Subject.doAs(getSubjectWithAddedSystemRights(), (PrivilegedAction<Object>) () -> {
        applyToChildren(child -> {
            final ListenableFuture<Void> childOpenFuture = child.openAsync();
            childOpenFutures.add(childOpenFuture);
            addFutureCallback(childOpenFuture, new FutureCallback<Void>() {

                @Override
                public void onSuccess(final Void result) {
                }

                @Override
                public void onFailure(final Throwable t) {
                    LOGGER.error("Exception occurred while opening {} : {}", child.getClass().getSimpleName(), child.getName(), t);
                    onRestartFailure();
                }
            }, getTaskExecutor());
        });
        return null;
    });
    ListenableFuture<List<Void>> combinedFuture = Futures.allAsList(childOpenFutures);
    return Futures.transformAsync(combinedFuture, input -> onActivate(), MoreExecutors.directExecutor());
}
Also used : AccessControlContext(java.security.AccessControlContext) Arrays(java.util.Arrays) BufferedInputStream(java.io.BufferedInputStream) ManagedAttributeField(org.apache.qpid.server.model.ManagedAttributeField) BrokerModel(org.apache.qpid.server.model.BrokerModel) MessageStoreSerializer(org.apache.qpid.server.store.serializer.MessageStoreSerializer) Future(java.util.concurrent.Future) NetworkConnectionScheduler(org.apache.qpid.server.transport.NetworkConnectionScheduler) Map(java.util.Map) QueueEntryIterator(org.apache.qpid.server.queue.QueueEntryIterator) NotFoundException(org.apache.qpid.server.model.NotFoundException) UserPreferences(org.apache.qpid.server.model.preferences.UserPreferences) EnumSet(java.util.EnumSet) AutoCommitTransaction(org.apache.qpid.server.txn.AutoCommitTransaction) Binding(org.apache.qpid.server.model.Binding) Set(java.util.Set) AMQPConnection(org.apache.qpid.server.transport.AMQPConnection) InstanceProperties(org.apache.qpid.server.message.InstanceProperties) Iterators.cycle(com.google.common.collect.Iterators.cycle) StandardCharsets(java.nio.charset.StandardCharsets) HousekeepingExecutor(org.apache.qpid.server.util.HousekeepingExecutor) Serializable(java.io.Serializable) MessageStoreMessages(org.apache.qpid.server.logging.messages.MessageStoreMessages) Operation(org.apache.qpid.server.security.access.Operation) PreferenceRecord(org.apache.qpid.server.store.preferences.PreferenceRecord) StateTransition(org.apache.qpid.server.model.StateTransition) QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) SystemConfig(org.apache.qpid.server.model.SystemConfig) CompoundAccessControl(org.apache.qpid.server.security.CompoundAccessControl) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) UUIDGenerator(org.apache.qpid.server.model.UUIDGenerator) CustomRestHeaders(org.apache.qpid.server.model.CustomRestHeaders) Queue(org.apache.qpid.server.model.Queue) PreferencesRoot(org.apache.qpid.server.store.preferences.PreferencesRoot) Callable(java.util.concurrent.Callable) ServerMessage(org.apache.qpid.server.message.ServerMessage) ArrayList(java.util.ArrayList) ResultCalculator(org.apache.qpid.server.security.SubjectFixedResultAccessControl.ResultCalculator) PreferenceStoreUpdaterImpl(org.apache.qpid.server.store.preferences.PreferenceStoreUpdaterImpl) ManageableMessage(org.apache.qpid.server.model.ManageableMessage) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) UserPreferencesImpl(org.apache.qpid.server.model.preferences.UserPreferencesImpl) QueueEntry(org.apache.qpid.server.queue.QueueEntry) MessageHandler(org.apache.qpid.server.store.handler.MessageHandler) SubjectFixedResultAccessControl(org.apache.qpid.server.security.SubjectFixedResultAccessControl) PreferenceStore(org.apache.qpid.server.store.preferences.PreferenceStore) StoredMessage(org.apache.qpid.server.store.StoredMessage) NoFactoryForTypeException(org.apache.qpid.server.model.NoFactoryForTypeException) MessageDeletedException(org.apache.qpid.server.message.MessageDeletedException) DtxRegistry(org.apache.qpid.server.txn.DtxRegistry) MessageInstanceHandler(org.apache.qpid.server.store.handler.MessageInstanceHandler) IOException(java.io.IOException) PreferencesRecoverer(org.apache.qpid.server.store.preferences.PreferencesRecoverer) Connection(org.apache.qpid.server.model.Connection) File(java.io.File) FutureCallback(com.google.common.util.concurrent.FutureCallback) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) Strings(org.apache.qpid.server.util.Strings) AtomicLong(java.util.concurrent.atomic.AtomicLong) Futures(com.google.common.util.concurrent.Futures) Result(org.apache.qpid.server.security.Result) SuppressingInheritedAccessControlContextThreadFactory(org.apache.qpid.server.pool.SuppressingInheritedAccessControlContextThreadFactory) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) ScheduledFuture(java.util.concurrent.ScheduledFuture) MessageReference(org.apache.qpid.server.message.MessageReference) URL(java.net.URL) Date(java.util.Date) Outcome(org.apache.qpid.server.logging.Outcome) DistributedTransactionHandler(org.apache.qpid.server.store.handler.DistributedTransactionHandler) LoggerFactory(org.slf4j.LoggerFactory) DefaultDestination(org.apache.qpid.server.exchange.DefaultDestination) TaskExecutorImpl(org.apache.qpid.server.configuration.updater.TaskExecutorImpl) SettableFuture(com.google.common.util.concurrent.SettableFuture) MessageStore(org.apache.qpid.server.store.MessageStore) ExchangeDefaults(org.apache.qpid.server.exchange.ExchangeDefaults) VirtualHostAccessControlProvider(org.apache.qpid.server.model.VirtualHostAccessControlProvider) AmqpPort(org.apache.qpid.server.model.port.AmqpPort) StoreException(org.apache.qpid.server.store.StoreException) MessageEnqueueRecord(org.apache.qpid.server.store.MessageEnqueueRecord) PatternSyntaxException(java.util.regex.PatternSyntaxException) LocalTransaction(org.apache.qpid.server.txn.LocalTransaction) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LinkModel(org.apache.qpid.server.protocol.LinkModel) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) UUID(java.util.UUID) PrivilegedAction(java.security.PrivilegedAction) RoutingResult(org.apache.qpid.server.message.RoutingResult) ConfigurationExtractor(org.apache.qpid.server.model.ConfigurationExtractor) VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) ConnectionValidator(org.apache.qpid.server.plugin.ConnectionValidator) MessageStoreLogSubject(org.apache.qpid.server.logging.subjects.MessageStoreLogSubject) List(java.util.List) Principal(java.security.Principal) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) VirtualHost(org.apache.qpid.server.model.VirtualHost) MessageDestination(org.apache.qpid.server.message.MessageDestination) MessageSource(org.apache.qpid.server.message.MessageSource) Pattern(java.util.regex.Pattern) CacheBuilder(com.google.common.cache.CacheBuilder) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DataInputStream(java.io.DataInputStream) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AccessControl(org.apache.qpid.server.security.AccessControl) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) JdkFutureAdapters(com.google.common.util.concurrent.JdkFutureAdapters) EventLogger(org.apache.qpid.server.logging.EventLogger) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) ConfigurationChangeListener(org.apache.qpid.server.model.ConfigurationChangeListener) Collections.newSetFromMap(java.util.Collections.newSetFromMap) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExclusivityPolicy(org.apache.qpid.server.model.ExclusivityPolicy) Preference(org.apache.qpid.server.model.preferences.Preference) AuthenticatedPrincipal(org.apache.qpid.server.security.auth.AuthenticatedPrincipal) SystemNodeCreator(org.apache.qpid.server.plugin.SystemNodeCreator) AbstractConfigurationChangeListener(org.apache.qpid.server.model.AbstractConfigurationChangeListener) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) Task(org.apache.qpid.server.configuration.updater.Task) Param(org.apache.qpid.server.model.Param) OutputStream(java.io.OutputStream) PreferenceStoreUpdater(org.apache.qpid.server.store.preferences.PreferenceStoreUpdater) ServerTransaction(org.apache.qpid.server.txn.ServerTransaction) Logger(org.slf4j.Logger) VirtualHostMessages(org.apache.qpid.server.logging.messages.VirtualHostMessages) Iterator(java.util.Iterator) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) SocketConnectionMetaData(org.apache.qpid.server.security.auth.SocketConnectionMetaData) MalformedURLException(java.net.MalformedURLException) Exchange(org.apache.qpid.server.model.Exchange) Content(org.apache.qpid.server.model.Content) Broker(org.apache.qpid.server.model.Broker) State(org.apache.qpid.server.model.State) Subject(javax.security.auth.Subject) TimeUnit(java.util.concurrent.TimeUnit) ConfiguredObjectRecordHandler(org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler) VirtualHostStoreUpgraderAndRecoverer(org.apache.qpid.server.store.VirtualHostStoreUpgraderAndRecoverer) URLEncoder(java.net.URLEncoder) AMQInvalidArgumentException(org.apache.qpid.server.filter.AMQInvalidArgumentException) Event(org.apache.qpid.server.store.Event) MessageStoreProvider(org.apache.qpid.server.store.MessageStoreProvider) MessageNode(org.apache.qpid.server.message.MessageNode) DoOnConfigThread(org.apache.qpid.server.model.DoOnConfigThread) Cache(com.google.common.cache.Cache) RestContentHeader(org.apache.qpid.server.model.RestContentHeader) Collections(java.util.Collections) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) StatisticsReportingTask(org.apache.qpid.server.stats.StatisticsReportingTask) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) VirtualHostAccessControlProvider(org.apache.qpid.server.model.VirtualHostAccessControlProvider) VirtualHostStoreUpgraderAndRecoverer(org.apache.qpid.server.store.VirtualHostStoreUpgraderAndRecoverer) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ArrayList(java.util.ArrayList) List(java.util.List) FutureCallback(com.google.common.util.concurrent.FutureCallback)

Aggregations

ArrayList (java.util.ArrayList)2 Cache (com.google.common.cache.Cache)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 Iterators.cycle (com.google.common.collect.Iterators.cycle)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 SettableFuture (com.google.common.util.concurrent.SettableFuture)1 BufferedInputStream (java.io.BufferedInputStream)1 DataInputStream (java.io.DataInputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Serializable (java.io.Serializable)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1