diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-02-19 21:44:19 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-02-19 21:44:19 +0000 |
| commit | 840b1793643b37b9fa8f8352a6851417042301ed (patch) | |
| tree | ec59ddd96d2758c5621e8b6046478dae760c6eb0 /qpid/java/broker-core | |
| parent | 29a70653f314b99c103c8149cacc4fed2a13898c (diff) | |
| download | qpid-python-840b1793643b37b9fa8f8352a6851417042301ed.tar.gz | |
QPID-5567 : Always Use AccessControllerContext to find the current context Subject
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1569934 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-core')
35 files changed, 280 insertions, 142 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java index 3104df6b00..61738c0655 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java @@ -21,6 +21,7 @@ package org.apache.qpid.server.configuration.updater; import java.security.AccessController; +import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.List; @@ -211,14 +212,12 @@ public class TaskExecutor private class CallableWrapper<T> implements Task<T> { private Task<T> _userTask; - private Subject _securityManagerSubject; private LogActor _actor; private Subject _contextSubject; public CallableWrapper(Task<T> userWork) { _userTask = userWork; - _securityManagerSubject = SecurityManager.getThreadSubject(); _actor = CurrentActor.get(); _contextSubject = Subject.getSubject(AccessController.getContext()); } @@ -226,35 +225,21 @@ public class TaskExecutor @Override public T call() { - SecurityManager.setThreadSubject(_securityManagerSubject); CurrentActor.set(_actor); try { T result = null; - try - { - result = Subject.doAs(_contextSubject, new PrivilegedExceptionAction<T>() + result = Subject.doAs(_contextSubject, new PrivilegedAction<T>() { @Override - public T run() throws Exception + public T run() { return executeTask(_userTask); } }); - } - catch (PrivilegedActionException e) - { - Exception underlying = e.getException(); - if(underlying instanceof RuntimeException) - { - throw (RuntimeException)underlying; - } - else - { - throw new ServerScopedRuntimeException(e); - } - } + + return result; } finally @@ -267,14 +252,6 @@ public class TaskExecutor { LOGGER.warn("Unexpected exception on current actor removal", e); } - try - { - SecurityManager.setThreadSubject(null); - } - catch (Exception e) - { - LOGGER.warn("Unexpected exception on nullifying of subject for a security manager", e); - } } } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/connection/ConnectionPrincipal.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/connection/ConnectionPrincipal.java new file mode 100644 index 0000000000..e459b5df80 --- /dev/null +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/connection/ConnectionPrincipal.java @@ -0,0 +1,74 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.server.connection; + +import org.apache.qpid.server.protocol.AMQConnectionModel; + +import java.security.Principal; + +public class ConnectionPrincipal implements Principal +{ + private final AMQConnectionModel _connection; + + public ConnectionPrincipal(final AMQConnectionModel connection) + { + _connection = connection; + } + + @Override + public String getName() + { + return _connection.getRemoteAddressString(); + } + + public AMQConnectionModel getConnection() + { + return _connection; + } + + @Override + public boolean equals(final Object o) + { + if (this == o) + { + return true; + } + if (o == null || getClass() != o.getClass()) + { + return false; + } + + final ConnectionPrincipal that = (ConnectionPrincipal) o; + + if (!_connection.equals(that._connection)) + { + return false; + } + + return true; + } + + @Override + public int hashCode() + { + return _connection.hashCode(); + } +} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/connection/SessionPrincipal.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/connection/SessionPrincipal.java new file mode 100644 index 0000000000..d6dff4f937 --- /dev/null +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/connection/SessionPrincipal.java @@ -0,0 +1,74 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.server.connection; + +import org.apache.qpid.server.protocol.AMQSessionModel; + +import java.security.Principal; + +public class SessionPrincipal implements Principal +{ + private final AMQSessionModel _session; + + public SessionPrincipal(final AMQSessionModel session) + { + _session = session; + } + + public AMQSessionModel getSession() + { + return _session; + } + + @Override + public String getName() + { + return "session:"+_session.getId(); + } + + @Override + public boolean equals(final Object o) + { + if (this == o) + { + return true; + } + if (o == null || getClass() != o.getClass()) + { + return false; + } + + final SessionPrincipal that = (SessionPrincipal) o; + + if (!_session.equals(that._session)) + { + return false; + } + + return true; + } + + @Override + public int hashCode() + { + return _session.hashCode(); + } +} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java index e76b9f15fc..d3a42bddc4 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java @@ -414,7 +414,7 @@ public final class VirtualHostAdapter extends AbstractAdapter implements Virtual try { - AMQQueue queue = _virtualHost.createQueue(null, attributes); + AMQQueue queue = _virtualHost.createQueue(attributes); synchronized (_queueAdapters) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java index 623cf62472..d978705841 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/AMQConnectionModel.java @@ -27,6 +27,7 @@ import org.apache.qpid.server.model.Transport; import org.apache.qpid.server.stats.StatisticsGatherer; import org.apache.qpid.server.util.Deletable; +import java.net.SocketAddress; import java.security.Principal; import java.util.List; import java.util.UUID; @@ -72,6 +73,8 @@ public interface AMQConnectionModel<T extends AMQConnectionModel<T,S>, S extends String getRemoteAddressString(); + SocketAddress getRemoteAddress(); + String getClientId(); String getClientVersion(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java index 399586fcff..11d2bccb1e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java @@ -27,7 +27,6 @@ import java.util.UUID; import org.apache.qpid.server.exchange.AMQUnknownExchangeType; import org.apache.qpid.server.model.ExclusivityPolicy; import org.apache.qpid.server.model.LifetimePolicy; -import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.configuration.BrokerProperties; import org.apache.qpid.server.configuration.QueueConfiguration; @@ -65,18 +64,17 @@ public class AMQQueueFactory implements QueueFactory @Override public AMQQueue restoreQueue(Map<String, Object> attributes) { - return createOrRestoreQueue(null, attributes, false); + return createOrRestoreQueue(attributes, false); } @Override - public AMQQueue createQueue(final AMQSessionModel creatingSession, - Map<String, Object> attributes) + public AMQQueue createQueue(Map<String, Object> attributes) { - return createOrRestoreQueue(creatingSession, attributes, true); + return createOrRestoreQueue(attributes, true); } - private AMQQueue createOrRestoreQueue(final AMQSessionModel creatingSession, Map<String, Object> attributes, + private AMQQueue createOrRestoreQueue(Map<String, Object> attributes, boolean createInStore) { @@ -129,19 +127,19 @@ public class AMQQueueFactory implements QueueFactory if(attributes.containsKey(Queue.SORT_KEY)) { - queue = new SortedQueue(_virtualHost, creatingSession, attributes); + queue = new SortedQueue(_virtualHost, attributes); } else if(attributes.containsKey(Queue.LVQ_KEY)) { - queue = new ConflationQueue(_virtualHost, creatingSession, attributes); + queue = new ConflationQueue(_virtualHost, attributes); } else if(attributes.containsKey(Queue.PRIORITIES)) { - queue = new PriorityQueue(_virtualHost, creatingSession, attributes); + queue = new PriorityQueue(_virtualHost, attributes); } else { - queue = new StandardQueue(_virtualHost, creatingSession, attributes); + queue = new StandardQueue(_virtualHost, attributes); } //Register the new queue @@ -232,7 +230,7 @@ public class AMQQueueFactory implements QueueFactory args.put(Queue.ID, UUIDGenerator.generateQueueUUID(dlQueueName, _virtualHost.getName())); args.put(Queue.NAME, dlQueueName); args.put(Queue.DURABLE, true); - dlQueue = _virtualHost.createQueue(null, args); + dlQueue = _virtualHost.createQueue(args); } catch (QueueExistsException e) { @@ -260,7 +258,7 @@ public class AMQQueueFactory implements QueueFactory Map<String, Object> arguments = createQueueAttributesFromConfig(_virtualHost, config); - AMQQueue q = createOrRestoreQueue(null, arguments, false); + AMQQueue q = createOrRestoreQueue(arguments, false); return q; } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java index f350368634..d9c130953a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/ConflationQueue.java @@ -34,9 +34,9 @@ public class ConflationQueue extends SimpleAMQQueue<ConflationQueueList.Conflati protected ConflationQueue(VirtualHost virtualHost, - final AMQSessionModel creatingSession, Map<String, Object> attributes) + Map<String, Object> attributes) { - super(virtualHost, creatingSession, attributes, entryList(attributes)); + super(virtualHost, attributes, entryList(attributes)); } private static ConflationQueueList.Factory entryList(final Map<String, Object> attributes) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java index c9ac3f3621..20e7edda92 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/OutOfOrderQueue.java @@ -29,11 +29,10 @@ public abstract class OutOfOrderQueue<E extends QueueEntryImpl<E,Q,L>, Q extends { protected OutOfOrderQueue(VirtualHost virtualHost, - final AMQSessionModel creatingSession, Map<String, Object> attributes, QueueEntryListFactory<E, Q, L> entryListFactory) { - super(virtualHost, creatingSession, attributes, entryListFactory); + super(virtualHost, attributes, entryListFactory); } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java index 1e41a0fb3e..b86d8efe87 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/PriorityQueue.java @@ -33,10 +33,9 @@ public class PriorityQueue extends OutOfOrderQueue<PriorityQueueList.PriorityQue public static final int DEFAULT_PRIORITY_LEVELS = 10; protected PriorityQueue(VirtualHost virtualHost, - final AMQSessionModel creatingSession, Map<String, Object> attributes) { - super(virtualHost, creatingSession, attributes, entryList(attributes)); + super(virtualHost, attributes, entryList(attributes)); } private static PriorityQueueList.Factory entryList(final Map<String, Object> attributes) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java index c80018799b..5b13c4c574 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueFactory.java @@ -26,8 +26,7 @@ import org.apache.qpid.server.protocol.AMQSessionModel; public interface QueueFactory { - AMQQueue createQueue(final AMQSessionModel creatingSession, - Map<String, Object> arguments); + AMQQueue createQueue(Map<String, Object> arguments); AMQQueue restoreQueue(Map<String, Object> arguments); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java index ef3eea19b3..6cbbbf0cb2 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java @@ -18,6 +18,8 @@ */ package org.apache.qpid.server.queue; +import java.security.AccessControlContext; +import java.security.AccessController; import java.security.Principal; import java.util.*; import java.util.concurrent.ConcurrentSkipListSet; @@ -29,6 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import org.apache.log4j.Logger; +import org.apache.qpid.server.connection.SessionPrincipal; import org.apache.qpid.server.model.ExclusivityPolicy; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.protocol.AMQConnectionModel; @@ -63,6 +66,8 @@ import org.apache.qpid.server.util.ServerScopedRuntimeException; import org.apache.qpid.server.util.StateChangeListener; import org.apache.qpid.server.virtualhost.VirtualHost; +import javax.security.auth.Subject; + abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleAMQQueue<E, Q,L>, L extends SimpleQueueEntryList<E,Q,L>> implements AMQQueue<E, Q, QueueConsumer<?,E,Q,L>>, StateChangeListener<QueueConsumer<?,E,Q,L>, QueueConsumer.State>, MessageGroupManager.ConsumerResetHelper<E,Q,L> @@ -184,7 +189,6 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA private final long[] _lastNotificationTimes = new long[NotificationCheck.values().length]; protected SimpleAMQQueue(VirtualHost virtualHost, - final AMQSessionModel<?,?> creatingSession, Map<String, Object> attributes, QueueEntryListFactory<E, Q, L> entryListFactory) { @@ -201,25 +205,39 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA Queue.LIFETIME_POLICY, attributes, LifetimePolicy.PERMANENT); - if(creatingSession != null) + + Subject activeSubject = Subject.getSubject(AccessController.getContext()); + Set<SessionPrincipal> sessionPrincipals = activeSubject == null ? Collections.<SessionPrincipal>emptySet() : activeSubject.getPrincipals(SessionPrincipal.class); + AMQSessionModel<?,?> sessionModel; + if(sessionPrincipals.isEmpty()) + { + sessionModel = null; + } + else + { + final SessionPrincipal sessionPrincipal = sessionPrincipals.iterator().next(); + sessionModel = sessionPrincipal.getSession(); + } + + if(sessionModel != null) { switch(_exclusivityPolicy) { case PRINCIPAL: - _exclusiveOwner = creatingSession.getConnectionModel().getAuthorizedPrincipal(); + _exclusiveOwner = sessionModel.getConnectionModel().getAuthorizedPrincipal(); break; case CONTAINER: - _exclusiveOwner = creatingSession.getConnectionModel().getRemoteContainerName(); + _exclusiveOwner = sessionModel.getConnectionModel().getRemoteContainerName(); break; case CONNECTION: - _exclusiveOwner = creatingSession.getConnectionModel(); - addExclusivityConstraint(creatingSession.getConnectionModel()); + _exclusiveOwner = sessionModel.getConnectionModel(); + addExclusivityConstraint(sessionModel.getConnectionModel()); break; case SESSION: - _exclusiveOwner = creatingSession; - addExclusivityConstraint(creatingSession); + _exclusiveOwner = sessionModel; + addExclusivityConstraint(sessionModel); break; case NONE: case LINK: @@ -251,9 +269,9 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA if(_lifetimePolicy == LifetimePolicy.DELETE_ON_CONNECTION_CLOSE) { - if(creatingSession != null) + if(sessionModel != null) { - addLifetimeConstraint(creatingSession.getConnectionModel()); + addLifetimeConstraint(sessionModel.getConnectionModel()); } else { @@ -264,9 +282,9 @@ abstract class SimpleAMQQueue<E extends QueueEntryImpl<E,Q,L>, Q extends SimpleA } else if(_lifetimePolicy == LifetimePolicy.DELETE_ON_SESSION_END) { - if(creatingSession != null) + if(sessionModel != null) { - addLifetimeConstraint(creatingSession); + addLifetimeConstraint(sessionModel); } else { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java index d1da7feddc..c35c41b4f7 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SortedQueue.java @@ -38,20 +38,19 @@ public class SortedQueue extends OutOfOrderQueue<SortedQueueEntry, SortedQueue, private final String _sortedPropertyName; protected SortedQueue(VirtualHost virtualHost, - final AMQSessionModel creatingSession, Map<String, Object> attributes, QueueEntryListFactory<SortedQueueEntry, SortedQueue, SortedQueueEntryList> factory) { - super(virtualHost, creatingSession, attributes, factory); + super(virtualHost, attributes, factory); _sortedPropertyName = MapValueConverter.getStringAttribute(Queue.SORT_KEY,attributes); } protected SortedQueue(VirtualHost virtualHost, - final AMQSessionModel creatingSession, Map<String, Object> attributes) + Map<String, Object> attributes) { this(virtualHost, - creatingSession, attributes, + attributes, new SortedQueueEntryListFactory(MapValueConverter.getStringAttribute(Queue.SORT_KEY, attributes))); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueue.java index 8a0570eb4e..e5050eca86 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueue.java @@ -28,8 +28,8 @@ import java.util.Map; public class StandardQueue extends SimpleAMQQueue<StandardQueueEntry,StandardQueue,StandardQueueEntryList> { public StandardQueue(final VirtualHost virtualHost, - final AMQSessionModel creatingSession, final Map<String, Object> arguments) + final Map<String, Object> arguments) { - super(virtualHost, creatingSession, arguments, new StandardQueueEntryList.Factory()); + super(virtualHost, arguments, new StandardQueueEntryList.Factory()); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/AccessControl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/AccessControl.java index 61e928a38c..87946590ec 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/AccessControl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/AccessControl.java @@ -23,20 +23,20 @@ import org.apache.qpid.server.security.access.ObjectType; import org.apache.qpid.server.security.access.Operation; /** - * The two methods, {@link #access(ObjectType, Object)} and {@link #authorise(Operation, ObjectType, ObjectProperties)}, + * The two methods, {@link #access(org.apache.qpid.server.security.access.ObjectType)} and {@link #authorise(Operation, ObjectType, ObjectProperties)}, * return the {@link Result} of the security decision, which may be to {@link Result#ABSTAIN} if no decision is made. */ public interface AccessControl { /** - * Default result for {@link #access(ObjectType, Object)} or {@link #authorise(Operation, ObjectType, ObjectProperties)}. + * Default result for {@link #access(org.apache.qpid.server.security.access.ObjectType)} or {@link #authorise(Operation, ObjectType, ObjectProperties)}. */ Result getDefault(); /** * Authorise access granted to an object instance. */ - Result access(ObjectType objectType, Object instance); + Result access(ObjectType objectType); /** * Authorise an operation on an object defined by a set of properties. diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java index 5af035c6b3..e5911d268b 100755 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java @@ -54,7 +54,6 @@ import static org.apache.qpid.server.security.access.Operation.PURGE; import static org.apache.qpid.server.security.access.Operation.UNBIND; import static org.apache.qpid.server.security.access.Operation.UPDATE; -import javax.security.auth.Subject; import java.net.SocketAddress; import java.security.AccessControlException; import java.util.Collection; @@ -68,9 +67,6 @@ public class SecurityManager implements ConfigurationChangeListener { private static final Logger _logger = Logger.getLogger(SecurityManager.class); - /** Container for the {@link java.security.Principal} that is using to this thread. */ - private static final ThreadLocal<Subject> _subject = new ThreadLocal<Subject>(); - public static final ThreadLocal<Boolean> _accessChecksDisabled = new ClearingThreadLocal(false); private ConcurrentHashMap<String, AccessControl> _globalPlugins = new ConcurrentHashMap<String, AccessControl>(); @@ -189,16 +185,6 @@ public class SecurityManager implements ConfigurationChangeListener return accessControl.getClass().getName(); } - public static Subject getThreadSubject() - { - return _subject.get(); - } - - public static void setThreadSubject(final Subject subject) - { - _subject.set(subject); - } - public static Logger getLogger() { return _logger; @@ -335,7 +321,7 @@ public class SecurityManager implements ConfigurationChangeListener { Result allowed(AccessControl plugin) { - return plugin.access(ObjectType.MANAGEMENT, null); + return plugin.access(ObjectType.MANAGEMENT); } })) { @@ -343,13 +329,13 @@ public class SecurityManager implements ConfigurationChangeListener } } - public void accessVirtualhost(final String vhostname, final SocketAddress remoteAddress) + public void accessVirtualhost(final String vhostname) { if(!checkAllPlugins(new AccessCheck() { Result allowed(AccessControl plugin) { - return plugin.access(VIRTUALHOST, remoteAddress); + return plugin.access(VIRTUALHOST); } })) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/jmx/JMXPasswordAuthenticator.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/jmx/JMXPasswordAuthenticator.java index 4e61e4b80b..1a23de0821 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/jmx/JMXPasswordAuthenticator.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/jmx/JMXPasswordAuthenticator.java @@ -21,6 +21,7 @@ package org.apache.qpid.server.security.auth.jmx; import java.net.SocketAddress; +import java.security.PrivilegedAction; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.security.SecurityManager; @@ -117,15 +118,16 @@ public class JMXPasswordAuthenticator implements JMXAuthenticator private void doManagementAuthorisation(Subject authenticatedSubject) { - SecurityManager.setThreadSubject(authenticatedSubject); - try + Subject.doAs(authenticatedSubject, new PrivilegedAction<Object>() { - _broker.getSecurityManager().accessManagement(); - } - finally - { - SecurityManager.setThreadSubject(null); - } + @Override + public Object run() + { + _broker.getSecurityManager().accessManagement(); + return null; + } + }); + } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java index 31481721d6..feb619f01a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java @@ -536,7 +536,7 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg } } - public AMQQueue createQueue(final AMQSessionModel creatingSession, Map<String, Object> attributes) throws QueueExistsException + public AMQQueue createQueue(Map<String, Object> attributes) throws QueueExistsException { // make a copy as we may augment (with an ID for example) attributes = new LinkedHashMap<String, Object>(attributes); @@ -585,7 +585,7 @@ public abstract class AbstractVirtualHost implements VirtualHost, IConnectionReg } - return _queueFactory.createQueue(creatingSession, attributes); + return _queueFactory.createQueue(attributes); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java index 61b2265d89..ab5a406cff 100755 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java @@ -59,7 +59,7 @@ public interface VirtualHost extends DurableConfigurationStore.Source, Closeable int removeQueue(AMQQueue queue); - AMQQueue createQueue(final AMQSessionModel creatingSession, Map<String, Object> arguments) throws QueueExistsException; + AMQQueue createQueue(Map<String, Object> arguments) throws QueueExistsException; Exchange createExchange(UUID id, diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/updater/TaskExecutorTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/updater/TaskExecutorTest.java index 9dc4fb768e..a54ba06c53 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/updater/TaskExecutorTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/updater/TaskExecutorTest.java @@ -20,6 +20,7 @@ */ package org.apache.qpid.server.configuration.updater; +import java.security.AccessControlContext; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.concurrent.BlockingQueue; @@ -216,27 +217,32 @@ public class TaskExecutorTest extends TestCase _executor.start(); LogActor actor = new TestLogActor(new NullRootMessageLogger()); Subject subject = new Subject(); - Subject currentSecurityManagerSubject = SecurityManager.getThreadSubject(); final AtomicReference<LogActor> taskLogActor = new AtomicReference<LogActor>(); final AtomicReference<Subject> taskSubject = new AtomicReference<Subject>(); try { CurrentActor.set(actor); - SecurityManager.setThreadSubject(subject); - _executor.submitAndWait(new TaskExecutor.Task<Object>() + Subject.doAs(subject, new PrivilegedAction<Object>() { @Override - public Void call() + public Object run() + { _executor.submitAndWait(new TaskExecutor.Task<Object>() { - taskLogActor.set(CurrentActor.get()); - taskSubject.set(SecurityManager.getThreadSubject()); + @Override + public Void call() + { + taskLogActor.set(CurrentActor.get()); + taskSubject.set(Subject.getSubject(AccessController.getContext())); + return null; + } + }); return null; } }); + } finally { - SecurityManager.setThreadSubject(currentSecurityManagerSubject); CurrentActor.remove(); } assertEquals("Unexpected task log actor", actor, taskLogActor.get()); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java index 1358798a38..eeb83a7148 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java @@ -38,6 +38,7 @@ import org.apache.qpid.server.stats.StatisticsCounter; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.StateChangeListener; +import java.net.SocketAddress; import java.security.Principal; import java.util.ArrayList; import java.util.List; @@ -456,6 +457,11 @@ public class MockConsumer implements ConsumerTarget return "remoteAddress:1234"; } + public SocketAddress getRemoteAddress() + { + return null; + } + @Override public String getClientId() { diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java index adb024257d..c900b72ae5 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java @@ -80,7 +80,7 @@ public class TopicExchangeTest extends QpidTestCase Map<String,Object> attributes = new HashMap<String, Object>(); attributes.put(Queue.ID, UUIDGenerator.generateRandomUUID()); attributes.put(Queue.NAME, name); - return _vhost.createQueue(null, attributes); + return _vhost.createQueue(attributes); } public void testNoRoute() throws Exception diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java index 4b6a51f84b..5f1e88dba9 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java @@ -43,7 +43,6 @@ import org.apache.qpid.server.logging.actors.CurrentActor; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.plugin.ExchangeType; -import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.virtualhost.VirtualHost; import org.apache.qpid.test.utils.QpidTestCase; @@ -97,13 +96,13 @@ public class AMQQueueFactoryTest extends QpidTestCase final ArgumentCaptor<Map> attributes = ArgumentCaptor.forClass(Map.class); - when(_virtualHost.createQueue(any(AMQSessionModel.class), attributes.capture())).then( + when(_virtualHost.createQueue(attributes.capture())).then( new Answer<AMQQueue>() { @Override public AMQQueue answer(InvocationOnMock invocation) throws Throwable { - return _queueFactory.createQueue(null, attributes.getValue()); + return _queueFactory.createQueue(attributes.getValue()); } } ); @@ -206,7 +205,7 @@ public class AMQQueueFactoryTest extends QpidTestCase attributes.put(Queue.PRIORITIES, 5); - AMQQueue queue = _queueFactory.createQueue(null, attributes); + AMQQueue queue = _queueFactory.createQueue(attributes); assertEquals("Queue not a priority queue", PriorityQueue.class, queue.getClass()); verifyQueueRegistered("testPriorityQueue"); @@ -224,7 +223,7 @@ public class AMQQueueFactoryTest extends QpidTestCase attributes.put(Queue.NAME, queueName); - AMQQueue queue = _queueFactory.createQueue(null, attributes); + AMQQueue queue = _queueFactory.createQueue(attributes); assertEquals("Queue not a simple queue", StandardQueue.class, queue.getClass()); verifyQueueRegistered(queueName); @@ -256,7 +255,7 @@ public class AMQQueueFactoryTest extends QpidTestCase attributes.put(Queue.NAME, queueName); attributes.put(Queue.CREATE_DLQ_ON_CREATION, true); - AMQQueue queue = _queueFactory.createQueue(null, attributes); + AMQQueue queue = _queueFactory.createQueue(attributes); Exchange altExchange = queue.getAlternateExchange(); assertNotNull("Queue should have an alternate exchange as DLQ is enabled", altExchange); @@ -297,7 +296,7 @@ public class AMQQueueFactoryTest extends QpidTestCase attributes.put(Queue.ID, UUID.randomUUID()); attributes.put(Queue.NAME, queueName); - AMQQueue queue = _queueFactory.createQueue(null, attributes); + AMQQueue queue = _queueFactory.createQueue(attributes); assertEquals("Unexpected maximum delivery count", 5, queue.getMaximumDeliveryCount()); Exchange altExchange = queue.getAlternateExchange(); @@ -338,7 +337,7 @@ public class AMQQueueFactoryTest extends QpidTestCase attributes.put(Queue.NAME, queueName); attributes.put(Queue.CREATE_DLQ_ON_CREATION, false); - AMQQueue queue = _queueFactory.createQueue(null, attributes); + AMQQueue queue = _queueFactory.createQueue(attributes); assertNull("Queue should not have an alternate exchange as DLQ is disabled", queue.getAlternateExchange()); assertNull("The alternate exchange should still not exist", _virtualHost.getExchange(dlExchangeName)); @@ -372,7 +371,7 @@ public class AMQQueueFactoryTest extends QpidTestCase attributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS); //create an autodelete queue - AMQQueue queue = _queueFactory.createQueue(null, attributes); + AMQQueue queue = _queueFactory.createQueue(attributes); assertEquals("Queue should be autodelete", LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS, queue.getLifetimePolicy()); @@ -398,7 +397,7 @@ public class AMQQueueFactoryTest extends QpidTestCase attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, (Object) 5); - final AMQQueue queue = _queueFactory.createQueue(null, attributes); + final AMQQueue queue = _queueFactory.createQueue(attributes); assertNotNull("The queue was not registered as expected ", queue); assertEquals("Maximum delivery count not as expected", 5, queue.getMaximumDeliveryCount()); @@ -416,7 +415,7 @@ public class AMQQueueFactoryTest extends QpidTestCase attributes.put(Queue.ID, UUID.randomUUID()); attributes.put(Queue.NAME, "testMaximumDeliveryCountDefault"); - final AMQQueue queue = _queueFactory.createQueue(null, attributes); + final AMQQueue queue = _queueFactory.createQueue(attributes); assertNotNull("The queue was not registered as expected ", queue); assertEquals("Maximum delivery count not as expected", 0, queue.getMaximumDeliveryCount()); @@ -434,7 +433,7 @@ public class AMQQueueFactoryTest extends QpidTestCase Map<String,Object> attributes = new HashMap<String, Object>(); attributes.put(Queue.ID, UUID.randomUUID()); - _queueFactory.createQueue(null, attributes); + _queueFactory.createQueue(attributes); fail("queue with null name can not be created!"); } catch (Exception e) @@ -463,7 +462,7 @@ public class AMQQueueFactoryTest extends QpidTestCase attributes.put(Queue.CREATE_DLQ_ON_CREATION, true); - _queueFactory.createQueue(null, attributes); + _queueFactory.createQueue(attributes); fail("queue with DLQ name having more than 255 characters can not be created!"); } catch (Exception e) @@ -493,7 +492,7 @@ public class AMQQueueFactoryTest extends QpidTestCase attributes.put(Queue.CREATE_DLQ_ON_CREATION, (Object) true); - _queueFactory.createQueue(null, attributes); + _queueFactory.createQueue(attributes); fail("queue with DLE name having more than 255 characters can not be created!"); } catch (Exception e) diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/ConflationQueueListTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/ConflationQueueListTest.java index 42b83d8c47..e51b575895 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/ConflationQueueListTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/ConflationQueueListTest.java @@ -52,7 +52,7 @@ public class ConflationQueueListTest extends TestCase queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getName()); queueAttributes.put(Queue.LVQ_KEY, CONFLATION_KEY); - _queue = new ConflationQueue(mock(VirtualHost.class), null, queueAttributes); + _queue = new ConflationQueue(mock(VirtualHost.class), queueAttributes); _list = _queue.getEntries(); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java index 0ac4eb8f78..8b2ee70b26 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java @@ -51,7 +51,7 @@ public class PriorityQueueListTest extends QpidTestCase queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getName()); queueAttributes.put(Queue.PRIORITIES, 10); - PriorityQueue queue = new PriorityQueue(mock(VirtualHost.class), null, queueAttributes); + PriorityQueue queue = new PriorityQueue(mock(VirtualHost.class), queueAttributes); _list = queue.getEntries(); for (int i = 0; i < PRIORITIES.length; i++) diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java index 139e32420f..dc91be9cdb 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java @@ -204,7 +204,7 @@ public abstract class QueueEntryImplTestBase extends TestCase Map<String,Object> queueAttributes = new HashMap<String, Object>(); queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getName()); - StandardQueue queue = new StandardQueue(mock(VirtualHost.class), null, queueAttributes); + StandardQueue queue = new StandardQueue(mock(VirtualHost.class), queueAttributes); OrderedQueueEntryList queueEntryList = queue.getEntries(); // create test entries diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java index c74c7bfa8b..8f4ebf1b2e 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTestBase.java @@ -78,7 +78,7 @@ abstract class SimpleAMQQueueTestBase<E extends QueueEntryImpl<E,Q,L>, Q extends attributes.put(Queue.NAME, _qname); attributes.put(Queue.OWNER, _owner); - _queue = (Q) _virtualHost.createQueue(null, attributes); + _queue = (Q) _virtualHost.createQueue(attributes); _exchange = (DirectExchange) _virtualHost.getExchange(ExchangeDefaults.DIRECT_EXCHANGE_NAME); } @@ -106,7 +106,7 @@ abstract class SimpleAMQQueueTestBase<E extends QueueEntryImpl<E,Q,L>, Q extends Map<String,Object> attributes = new HashMap<String, Object>(_arguments); attributes.put(Queue.ID, UUIDGenerator.generateRandomUUID()); - _queue = (Q) _virtualHost.createQueue(null, attributes); + _queue = (Q) _virtualHost.createQueue(attributes); assertNull("Queue was created", _queue); } catch (IllegalArgumentException e) @@ -118,7 +118,7 @@ abstract class SimpleAMQQueueTestBase<E extends QueueEntryImpl<E,Q,L>, Q extends Map<String,Object> attributes = new HashMap<String, Object>(_arguments); attributes.put(Queue.ID, UUIDGenerator.generateRandomUUID()); attributes.put(Queue.NAME, "differentName"); - _queue = (Q) _virtualHost.createQueue(null, attributes); + _queue = (Q) _virtualHost.createQueue(attributes); assertNotNull("Queue was not created", _queue); } @@ -1105,7 +1105,7 @@ abstract class SimpleAMQQueueTestBase<E extends QueueEntryImpl<E,Q,L>, Q extends { public NonAsyncDeliverQueue(final TestSimpleQueueEntryListFactory factory, VirtualHost vhost) { - super(vhost, null, attributes(), factory); + super(vhost, attributes(), factory); } private static Map<String,Object> attributes() diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java index 286c47fdf6..1d4bfa9960 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java @@ -57,7 +57,7 @@ public class SimpleAMQQueueThreadPoolTest extends QpidTestCase Map<String,Object> attributes = new HashMap<String, Object>(); attributes.put(Queue.ID, UUIDGenerator.generateRandomUUID()); attributes.put(Queue.NAME, "test"); - AMQQueue queue = test.createQueue(null, attributes); + AMQQueue queue = test.createQueue(attributes); assertFalse("Creation did not start Pool.", ReferenceCountingExecutorService.getInstance().getPool().isShutdown()); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java index 7aa546e1b3..9813ab98b5 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java @@ -44,7 +44,7 @@ public class SimpleQueueEntryImplTest extends QueueEntryImplTestBase Map<String,Object> queueAttributes = new HashMap<String, Object>(); queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, "SimpleQueueEntryImplTest"); - StandardQueue queue = new StandardQueue(mock(VirtualHost.class), null, queueAttributes); + StandardQueue queue = new StandardQueue(mock(VirtualHost.class), queueAttributes); queueEntryList = queue.getEntries(); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java index cfa58f11c4..be2948c18d 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java @@ -86,7 +86,7 @@ public class SortedQueueEntryListTest extends QueueEntryListTestBase<SortedQueue attributes.put(Queue.SORT_KEY, "KEY"); // Create test list - _testQueue = new SortedQueue(mock(VirtualHost.class), null, attributes, new QueueEntryListFactory<SortedQueueEntry,SortedQueue,SortedQueueEntryList>() + _testQueue = new SortedQueue(mock(VirtualHost.class), attributes, new QueueEntryListFactory<SortedQueueEntry,SortedQueue,SortedQueueEntryList>() { @Override diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java index e55875135a..2f1122fa9a 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java @@ -54,7 +54,7 @@ public class SortedQueueEntryTest extends QueueEntryImplTestBase attributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.PERMANENT); attributes.put(Queue.SORT_KEY, "KEY"); - SortedQueue queue = new SortedQueue(mock(VirtualHost.class), null, attributes, new QueueEntryListFactory<SortedQueueEntry,SortedQueue,SortedQueueEntryList>() + SortedQueue queue = new SortedQueue(mock(VirtualHost.class), attributes, new QueueEntryListFactory<SortedQueueEntry,SortedQueue,SortedQueueEntryList>() { @Override diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java index fe9273dbc8..5da991b8dd 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java @@ -50,7 +50,7 @@ public class StandardQueueEntryListTest extends QueueEntryListTestBase<StandardQ Map<String,Object> queueAttributes = new HashMap<String, Object>(); queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getName()); - _testQueue = new StandardQueue(mock(VirtualHost.class), null, queueAttributes); + _testQueue = new StandardQueue(mock(VirtualHost.class), queueAttributes); _sqel = _testQueue.getEntries(); for(int i = 1; i <= 100; i++) @@ -93,7 +93,7 @@ public class StandardQueueEntryListTest extends QueueEntryListTestBase<StandardQ Map<String,Object> queueAttributes = new HashMap<String, Object>(); queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getName()); - StandardQueue queue = new StandardQueue(mock(VirtualHost.class), null, queueAttributes); + StandardQueue queue = new StandardQueue(mock(VirtualHost.class), queueAttributes); return queue.getEntries(); } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java index 15e0303e61..4dd0423c27 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java @@ -52,7 +52,7 @@ public class StandardQueueTest extends SimpleAMQQueueTestBase<StandardQueueEntry queueAttributes.put(Queue.NAME, "testActiveConsumerCount"); queueAttributes.put(Queue.OWNER, "testOwner"); - setQueue(new StandardQueue(null, null, queueAttributes)); + setQueue(new StandardQueue(null, queueAttributes)); assertNull("Queue was created", getQueue()); } catch (IllegalArgumentException e) @@ -70,7 +70,7 @@ public class StandardQueueTest extends SimpleAMQQueueTestBase<StandardQueueEntry queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, getQname()); queueAttributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS); - final StandardQueue queue = new StandardQueue(getVirtualHost(), null, queueAttributes); + final StandardQueue queue = new StandardQueue(getVirtualHost(), queueAttributes); setQueue(queue); @@ -93,7 +93,7 @@ public class StandardQueueTest extends SimpleAMQQueueTestBase<StandardQueueEntry queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, "testActiveConsumerCount"); queueAttributes.put(Queue.OWNER, "testOwner"); - final StandardQueue queue = new StandardQueue(getVirtualHost(), null, queueAttributes); + final StandardQueue queue = new StandardQueue(getVirtualHost(), queueAttributes); //verify adding an active consumer increases the count final MockConsumer consumer1 = new MockConsumer(); @@ -200,7 +200,7 @@ public class StandardQueueTest extends SimpleAMQQueueTestBase<StandardQueueEntry queueAttributes.put(Queue.ID, UUID.randomUUID()); queueAttributes.put(Queue.NAME, "test"); // create queue with overridden method deliverAsync - StandardQueue testQueue = new StandardQueue(getVirtualHost(), null, queueAttributes) + StandardQueue testQueue = new StandardQueue(getVirtualHost(), queueAttributes) { @Override public void deliverAsync(QueueConsumer sub) @@ -269,7 +269,7 @@ public class StandardQueueTest extends SimpleAMQQueueTestBase<StandardQueueEntry public DequeuedQueue(VirtualHost virtualHost) { - super(virtualHost, null, attributes(), new DequeuedQueueEntryListFactory()); + super(virtualHost, attributes(), new DequeuedQueueEntryListFactory()); } private static Map<String,Object> attributes() diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/TestPrincipalUtils.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/TestPrincipalUtils.java index ea6b40e3de..f5bac17843 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/TestPrincipalUtils.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/TestPrincipalUtils.java @@ -43,7 +43,7 @@ public class TestPrincipalUtils principals.add(new GroupPrincipal(group)); } - return new Subject(true, principals, Collections.EMPTY_SET, Collections.EMPTY_SET); + return new Subject(false, principals, Collections.EMPTY_SET, Collections.EMPTY_SET); } } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java index 641fc7cb35..8f57c52299 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java @@ -186,7 +186,7 @@ public class BrokerTestHelper Map<String,Object> attributes = new HashMap<String, Object>(); attributes.put(Queue.ID, UUIDGenerator.generateRandomUUID()); attributes.put(Queue.NAME, queueName); - AMQQueue queue = virtualHost.createQueue(null, attributes); + AMQQueue queue = virtualHost.createQueue(attributes); return queue; } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java index cee7edf1b7..e68d5bb2ba 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java @@ -29,7 +29,6 @@ import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.message.MessageDestination; import org.apache.qpid.server.message.MessageSource; import org.apache.qpid.server.plugin.ExchangeType; -import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.server.protocol.LinkRegistry; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.QueueRegistry; @@ -153,7 +152,7 @@ public class MockVirtualHost implements VirtualHost } @Override - public AMQQueue createQueue(final AMQSessionModel creatingSession, Map<String, Object> arguments) + public AMQQueue createQueue(Map<String, Object> arguments) { return null; } |
