From 25602a9f8431d99aaa9a726c0046941de24c520e Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Mon, 14 Apr 2014 17:56:51 +0000 Subject: QPID-5698 : [Java Broker] make the durable attribute automated, remove unused setters git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1587262 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/server/binding/BindingImpl.java | 46 +++------ .../qpid/server/exchange/AbstractExchange.java | 42 ++------ .../server/exchange/DefaultExchangeFactory.java | 20 +++- .../server/model/AbstractConfiguredObject.java | 11 ++ .../java/org/apache/qpid/server/model/Binding.java | 4 - .../apache/qpid/server/model/ConfiguredObject.java | 47 +-------- .../qpid/server/model/SystemContextImpl.java | 28 ------ .../model/adapter/AbstractPluginAdapter.java | 43 +++----- .../qpid/server/model/adapter/BrokerAdapter.java | 38 +++---- .../server/model/adapter/ConnectionAdapter.java | 35 +------ .../model/adapter/FileBasedGroupProviderImpl.java | 112 ++++++++------------- .../adapter/FileSystemPreferencesProviderImpl.java | 41 +++----- .../qpid/server/model/adapter/SessionAdapter.java | 24 +---- .../model/adapter/VirtualHostAliasAdapter.java | 27 ----- .../qpid/server/model/port/AbstractPort.java | 51 +++------- .../apache/qpid/server/queue/AbstractQueue.java | 40 +------- .../qpid/server/queue/QueueConsumerImpl.java | 30 ------ .../qpid/server/security/FileKeyStoreImpl.java | 33 +----- .../qpid/server/security/FileTrustStoreImpl.java | 93 ++++------------- .../manager/AbstractAuthenticationManager.java | 42 +++----- .../PrincipalDatabaseAuthenticationManager.java | 47 ++++----- .../manager/ScramSHA1AuthenticationManager.java | 52 ++++------ .../server/virtualhost/AbstractVirtualHost.java | 37 +++---- .../AbstractDurableConfigurationStoreTestCase.java | 3 + .../qpid/server/virtualhost/MockVirtualHost.java | 21 ---- .../plugins/ACLFileAccessControlProviderImpl.java | 43 ++++---- .../java/org/apache/qpid/systest/rest/Asserts.java | 2 +- 27 files changed, 273 insertions(+), 739 deletions(-) (limited to 'qpid/java') diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java index 1355770f53..e0fc64b6e2 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java @@ -82,7 +82,7 @@ public class BindingImpl public BindingImpl(UUID id, Map attributes, AMQQueue queue, ExchangeImpl exchange) { - super(parentsMap(queue,exchange),combineIdWithAttributes(id,attributes),queue.getVirtualHost().getTaskExecutor()); + super(parentsMap(queue,exchange),enhanceWithDurable(combineIdWithAttributes(id, attributes), queue, exchange),queue.getVirtualHost().getTaskExecutor()); _id = id; _bindingKey = (String)attributes.get(org.apache.qpid.server.model.Binding.NAME); _queue = queue; @@ -101,6 +101,18 @@ public class BindingImpl } + private static Map enhanceWithDurable(Map attributes, + final AMQQueue queue, + final ExchangeImpl exchange) + { + if(!attributes.containsKey(DURABLE)) + { + attributes = new HashMap(attributes); + attributes.put(DURABLE, queue.isDurable() && exchange.isDurable()); + } + return attributes; + } + public String getBindingKey() { return _bindingKey; @@ -138,35 +150,11 @@ public class BindingImpl return _matches.get(); } - public boolean isDurable() - { - return _queue.isDurable() && _exchange.isDurable(); - } - - @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - if(durable != isDurable()) - { - throw new IllegalArgumentException("Cannot change the durability of a binding"); - } - } - - public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - // TODO - return null; - } - @Override public Collection getChildren(final Class clazz) { @@ -232,14 +220,6 @@ public class BindingImpl } } - @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - // TODO - return null; - } - public State getState() { return _deleted.get() ? State.DELETED : State.ACTIVE; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java index 933f2700bf..e8f8c20eb5 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java @@ -77,8 +77,6 @@ public abstract class AbstractExchange> private ExchangeImpl _alternateExchange; - private boolean _durable; - private VirtualHostImpl _virtualHost; private final List> _closeTaskList = new CopyOnWriteArrayList>(); @@ -112,7 +110,6 @@ public abstract class AbstractExchange> super(parentsMap(vhost), attributes, vhost.getTaskExecutor()); _virtualHost = vhost; - _durable = MapValueConverter.getBooleanAttribute(org.apache.qpid.server.model.Exchange.DURABLE, attributes); _lifetimePolicy = MapValueConverter.getEnumAttribute(LifetimePolicy.class, org.apache.qpid.server.model.Exchange.LIFETIME_POLICY, attributes, @@ -168,8 +165,14 @@ public abstract class AbstractExchange> } } }; + } + + @Override + protected void onOpen() + { + super.onOpen(); // Log Exchange creation - getEventLogger().message(ExchangeMessages.CREATED(getExchangeType().getType(), getName(), _durable)); + getEventLogger().message(ExchangeMessages.CREATED(getExchangeType().getType(), getName(), isDurable())); } @Override @@ -186,11 +189,6 @@ public abstract class AbstractExchange> return getExchangeType().getType(); } - public boolean isDurable() - { - return _durable; - } - public boolean isAutoDelete() { return _autoDelete; @@ -725,44 +723,18 @@ public abstract class AbstractExchange> return false; } - @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - @Override public State getState() { return _closed.get() ? State.DELETED : State.ACTIVE; } - @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - if(durable == isDurable()) - { - return; - } - throw new IllegalArgumentException(); - } - @Override public LifetimePolicy getLifetimePolicy() { return _lifetimePolicy; } - @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - // TODO - return _lifetimePolicy; - } - @Override public Collection getChildren(final Class clazz) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java index ac139a2c66..4dc9811934 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java @@ -20,6 +20,10 @@ */ package org.apache.qpid.server.exchange; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + import org.apache.log4j.Logger; import org.apache.qpid.exchange.ExchangeDefaults; @@ -29,10 +33,6 @@ import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.server.virtualhost.UnknownExchangeException; import org.apache.qpid.server.virtualhost.VirtualHostImpl; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - public class DefaultExchangeFactory implements ExchangeFactory { public static final String DEFAULT_DLE_NAME_SUFFIX = "_DLE"; @@ -98,6 +98,13 @@ public class DefaultExchangeFactory implements ExchangeFactory @Override public ExchangeImpl createExchange(final Map attributes) throws AMQUnknownExchangeType, UnknownExchangeException + { + ExchangeImpl exchange = createExchangeInstance(attributes); + ((AbstractExchange)exchange).create(); + return exchange; + } + + private ExchangeImpl createExchangeInstance(final Map attributes) { String type = MapValueConverter.getStringAttribute(org.apache.qpid.server.model.Exchange.TYPE, attributes); ExchangeType exchType = _exchangeClassMap.get(type); @@ -106,13 +113,16 @@ public class DefaultExchangeFactory implements ExchangeFactory throw new AMQUnknownExchangeType("Unknown exchange type: " + type,null); } return exchType.newInstance(_host, attributes); + } @Override public ExchangeImpl restoreExchange(Map attributes) throws AMQUnknownExchangeType, UnknownExchangeException { - return createExchange(attributes); + ExchangeImpl exchange = createExchangeInstance(attributes); + exchange.open(); + return exchange; } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java index 9359429501..7b2790b56d 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java @@ -132,6 +132,9 @@ public abstract class AbstractConfiguredObject> im @ManagedAttributeField private Map _context; + @ManagedAttributeField + private boolean _durable; + private final Map> _attributeTypes; private final Map _automatedFields; @@ -212,6 +215,8 @@ public abstract class AbstractConfiguredObject> im } _name = AttributeValueConverter.STRING_CONVERTER.convert(attributes.get(NAME),this); + Object durableObj = attributes.get(DURABLE); + _durable = AttributeValueConverter.BOOLEAN_CONVERTER.convert(durableObj == null ? _attributeTypes.get(DURABLE).getAnnotation().defaultValue() : durableObj, this); Collection names = getAttributeNames(); if(names!=null) @@ -483,6 +488,12 @@ public abstract class AbstractConfiguredObject> im return _name; } + public final boolean isDurable() + { + return _durable; + } + + public Class getCategoryClass() { return _category; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java index d1e78def75..c3a2febfd3 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Binding.java @@ -20,9 +20,6 @@ */ package org.apache.qpid.server.model; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; import java.util.Map; @ManagedObject @@ -30,7 +27,6 @@ public interface Binding> extends ConfiguredObject { public String ARGUMENTS = "arguments"; - public String DURABLE = "durable"; public String LIFETIME_POLICY = "lifetimePolicy"; public String STATE = "state"; public String TIME_TO_LIVE = "timeToLive"; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java index ed7e9ac60e..6a7eabd5d6 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java @@ -37,6 +37,7 @@ public interface ConfiguredObject> public static final String NAME = "name"; public static final String TYPE = "type"; public static final String DESCRIPTION = "description"; + public static final String DURABLE = "durable"; public static final String CONTEXT = "context"; public static final String LAST_UPDATED_BY = "lastUpdatedBy"; public static final String LAST_UPDATED_TIME = "lastUpdatedTime"; @@ -83,23 +84,6 @@ public interface ConfiguredObject> @ManagedAttribute long getCreatedTime(); - /** - * Attempt to change the name of the object - * - * Request a change to the name of the object. The caller must pass in the name it believes the object currently - * has. If the current name differs from this expected value, then no name change will occur - * - * @param currentName the name the caller believes the object to have - * @param desiredName the name the caller would like the object to have - * @return the new name for the object - * @throws IllegalStateException if the name of the object may not be changed in in the current state - * @throws AccessControlException if the current context does not have permission to change the name - * @throws IllegalArgumentException if the provided name is not legal - * @throws NullPointerException if the desired name is null - */ - String setName(String currentName, String desiredName) throws IllegalStateException, - AccessControlException; - /** * Get the desired state of the object. @@ -170,22 +154,9 @@ public interface ConfiguredObject> * * @return the durability */ - @ManagedAttribute + @ManagedAttribute( automate = true, defaultValue = "true" ) boolean isDurable(); - /** - * Sets the durability of the object - * - * @param durable true iff the caller wishes the object to store its configuration durably - * - * @throws IllegalStateException if the durability cannot be changed in the current state - * @throws AccessControlException if the current context does not have sufficient permission to change the durability - * @throws IllegalArgumentException if the object does not support the requested durability - */ - void setDurable(boolean durable) throws IllegalStateException, - AccessControlException, - IllegalArgumentException; - /** * Return the lifetime policy for the object * @@ -194,20 +165,6 @@ public interface ConfiguredObject> @ManagedAttribute LifetimePolicy getLifetimePolicy(); - /** - * Set the lifetime policy of the object - * - * @param expected The lifetime policy the caller believes the object currently has - * @param desired The lifetime policy the caller desires the object to have - * @return the new lifetime policy - * @throws IllegalStateException if the lifetime policy cannot be changed in the current state - * @throws AccessControlException if the caller does not have permission to change the lifetime policy - * @throws IllegalArgumentException if the object does not support the requested lifetime policy - */ - LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException, - AccessControlException, - IllegalArgumentException; - /** * Get the names of attributes that are set on this object * diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java index b4af364634..7575ad203a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContextImpl.java @@ -20,7 +20,6 @@ */ package org.apache.qpid.server.model; -import java.security.AccessControlException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -207,45 +206,18 @@ public class SystemContextImpl extends AbstractConfiguredObject> extends Abstrac @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException + public void validate() { - throw new UnsupportedOperationException(); - } - - @Override - public State getState() - { - return null; + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public boolean isDurable() + protected void validateChange(final ConfiguredObject proxyForValidation, final Set changedAttributes) { - return true; + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public void setDurable(boolean durable) throws IllegalStateException, AccessControlException, IllegalArgumentException + public State getState() { - throw new UnsupportedOperationException(); + return null; } @Override @@ -77,13 +79,6 @@ public abstract class AbstractPluginAdapter> extends Abstrac return LifetimePolicy.PERMANENT; } - @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException, - AccessControlException, IllegalArgumentException - { - throw new UnsupportedOperationException(); - } - @Override public Collection getChildren(Class clazz) { @@ -99,18 +94,10 @@ public abstract class AbstractPluginAdapter> extends Abstrac @Override public Object getAttribute(String name) { - if (ID.equals(name)) - { - return getId(); - } - else if (STATE.equals(name)) + if (STATE.equals(name)) { return getState(); } - else if (DURABLE.equals(name)) - { - return isDurable(); - } else if (LIFETIME_POLICY.equals(name)) { return getLifetimePolicy(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java index fb00ee7fb3..357d367f28 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java @@ -185,6 +185,20 @@ public class BrokerAdapter extends AbstractConfiguredObject imple + "' in configuration is incompatible with the broker model version '" + Model.MODEL_VERSION + "'"); } + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject proxyForValidation, final Set changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } protected void onOpen() @@ -436,41 +450,17 @@ public class BrokerAdapter extends AbstractConfiguredObject imple return true; } - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; //TODO - } - public State getState() { return null; //TODO } - - public boolean isDurable() - { - return true; - } - - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - public long getTimeToLive() { return 0; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java index 25c0a97b14..00834c5866 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java @@ -77,6 +77,7 @@ public final class ConnectionAdapter extends AbstractConfiguredObject proxyForValidation, final Set changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } protected void onOpen() { super.onOpen(); @@ -107,45 +120,18 @@ public class FileBasedGroupProviderImpl return _path; } - @Override - public String setName(String currentName, String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - @Override public State getState() { return _state.get(); } - @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(boolean durable) throws IllegalStateException, - AccessControlException, IllegalArgumentException - { - } - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, - LifetimePolicy desired) throws IllegalStateException, - AccessControlException, IllegalArgumentException - { - return null; - } - @Override public Collection getAttributeNames() { @@ -352,30 +338,31 @@ public class FileBasedGroupProviderImpl } - @Override - public String setName(String currentName, String desiredName) - throws IllegalStateException, AccessControlException - { - throw new IllegalStateException("Names cannot be updated"); - } - @Override public State getState() { return State.ACTIVE; } + @Override - public boolean isDurable() + public void validate() { - return true; + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public void setDurable(boolean durable) throws IllegalStateException, - AccessControlException, IllegalArgumentException + protected void validateChange(final ConfiguredObject proxyForValidation, final Set changedAttributes) { - throw new IllegalStateException("Durability cannot be updated"); + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override @@ -384,14 +371,6 @@ public class FileBasedGroupProviderImpl return LifetimePolicy.PERMANENT; } - @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, - LifetimePolicy desired) throws IllegalStateException, - AccessControlException, IllegalArgumentException - { - throw new IllegalStateException("LifetimePolicy cannot be updated"); - } - @Override public Collection getChildren( Class clazz) @@ -502,49 +481,42 @@ public class FileBasedGroupProviderImpl super(parentsMap(GroupAdapter.this),attrMap, taskExecutor); } - @Override - public Collection getAttributeNames() - { - return getAttributeNames(GroupMember.class); - } - @Override - public String setName(String currentName, String desiredName) - throws IllegalStateException, AccessControlException + public void validate() { - return null; + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public State getState() + protected void validateChange(final ConfiguredObject proxyForValidation, final Set changedAttributes) { - return null; + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public boolean isDurable() + public Collection getAttributeNames() { - return false; + return getAttributeNames(GroupMember.class); } - @Override - public void setDurable(boolean durable) - throws IllegalStateException, AccessControlException, - IllegalArgumentException - { - } @Override - public LifetimePolicy getLifetimePolicy() + public State getState() { return null; } @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, - LifetimePolicy desired) throws IllegalStateException, - AccessControlException, IllegalArgumentException + public LifetimePolicy getLifetimePolicy() { return null; } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java index c3a2cfde61..db01938af6 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderImpl.java @@ -91,21 +91,25 @@ public class FileSystemPreferencesProviderImpl } @Override - public Collection getAttributeNames() + public void validate() { - return getAttributeNames(FileSystemPreferencesProviderImpl.class); + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public String getPath() + public Collection getAttributeNames() { - return (String) getAttribute(PATH); + return getAttributeNames(FileSystemPreferencesProviderImpl.class); } @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException + public String getPath() { - throw new UnsupportedOperationException(); + return (String) getAttribute(PATH); } @Override @@ -114,31 +118,12 @@ public class FileSystemPreferencesProviderImpl return _state.get(); } - @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(boolean durable) throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new UnsupportedOperationException(); - } - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException, - AccessControlException, IllegalArgumentException - { - throw new UnsupportedOperationException(); - } - @Override public Collection getChildren(Class clazz) { @@ -338,6 +323,12 @@ public class FileSystemPreferencesProviderImpl { throw new IllegalConfigurationException("Path to preferences file is not specified"); } + + if(changedAttributes.contains(DURABLE) && !updated.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } public void createStoreIfNotExist() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java index 3194709743..47bf9293f9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java @@ -72,6 +72,7 @@ final class SessionAdapter extends AbstractConfiguredObject impl attributes.put(ID, UUID.randomUUID()); attributes.put(NAME, String.valueOf(session.getChannelId())); attributes.put(CHANNEL_ID, session.getChannelId()); + attributes.put(DURABLE, false); return attributes; } @@ -97,39 +98,16 @@ final class SessionAdapter extends AbstractConfiguredObject impl return Collections.emptySet(); //TODO } - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; //TODO - } - public State getState() { return null; //TODO } - public boolean isDurable() - { - return false; //TODO - } - - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - //TODO - } - public LifetimePolicy getLifetimePolicy() { return null; //TODO } - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; //TODO - } - @Override public Collection getAttributeNames() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java index d9d8877d01..7c654c566e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java @@ -21,7 +21,6 @@ package org.apache.qpid.server.model.adapter; -import java.security.AccessControlException; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -77,44 +76,18 @@ public class VirtualHostAliasAdapter extends AbstractConfiguredObject Collection getChildren(Class clazz) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java index 518abb692f..5464156a05 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java @@ -108,6 +108,21 @@ abstract public class AbstractPort> extends AbstractCo { throw new IllegalConfigurationException("Can't create a port which uses a secure transport but has no KeyStore"); } + + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject proxyForValidation, final Set changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override @@ -198,44 +213,18 @@ abstract public class AbstractPort> extends AbstractCo protected abstract Set getDefaultProtocols(); - @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException - { - throw new IllegalStateException(); - } - @Override public State getState() { return _state.get(); } - @Override - public boolean isDurable() - { - return false; - } - - @Override - public void setDurable(boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - @Override public Collection getChildren(Class clazz) { @@ -252,18 +241,10 @@ abstract public class AbstractPort> extends AbstractCo @Override public Object getAttribute(String name) { - if(ID.equals(name)) - { - return getId(); - } - else if(STATE.equals(name)) + if(STATE.equals(name)) { return getState(); } - else if(DURABLE.equals(name)) - { - return isDurable(); - } else if(LIFETIME_POLICY.equals(name)) { return getLifetimePolicy(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java index 78fea5a39c..0568e1eb3b 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java @@ -120,8 +120,6 @@ public abstract class AbstractQueue private String _description; - private boolean _durable; - private ExchangeImpl _alternateExchange; @@ -301,9 +299,6 @@ public abstract class AbstractQueue Map attributes = getActualAttributes(); - boolean durable = MapValueConverter.getBooleanAttribute(Queue.DURABLE, attributes, false); - - _exclusive = MapValueConverter.getEnumAttribute(ExclusivityPolicy.class, Queue.EXCLUSIVE, attributes, @@ -313,7 +308,6 @@ public abstract class AbstractQueue attributes, LifetimePolicy.PERMANENT); - _durable = durable; final LinkedHashMap arguments = new LinkedHashMap(attributes); arguments.put(Queue.EXCLUSIVE, _exclusive); @@ -432,8 +426,8 @@ public abstract class AbstractQueue _entries.getPriorities(), ownerString != null, _lifetimePolicy != LifetimePolicy.PERMANENT, - durable, - !durable, + isDurable(), + !isDurable(), _entries.getPriorities() > 0)); if(attributes != null && attributes.containsKey(Queue.MESSAGE_GROUP_KEY)) @@ -511,11 +505,6 @@ public abstract class AbstractQueue _noLocal = nolocal; } - public boolean isDurable() - { - return _durable; - } - public boolean isExclusive() { return _exclusive != ExclusivityPolicy.NONE; @@ -596,10 +585,6 @@ public abstract class AbstractQueue } return "standard"; } - else if(DURABLE.equals(name)) - { - return isDurable(); - } else if(LIFETIME_POLICY.equals(name)) { return getLifetimePolicy(); @@ -2778,33 +2763,12 @@ public abstract class AbstractQueue } - @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - @Override public State getState() { return isDeleted() ? State.DELETED : State.ACTIVE; } - @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - - } - - @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; - } - @Override public Collection getChildren(final Class clazz) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java index fd6528d4ad..4426ee36b7 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java @@ -22,7 +22,6 @@ package org.apache.qpid.server.queue; import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SUBSCRIPTION_FORMAT; -import java.security.AccessControlException; import java.text.MessageFormat; import java.util.Collection; import java.util.Collections; @@ -103,8 +102,6 @@ class QueueConsumerImpl } }; @ManagedAttributeField - private boolean _durable; - @ManagedAttributeField private boolean _exclusive; @ManagedAttributeField private boolean _noLocal; @@ -517,39 +514,12 @@ class QueueConsumerImpl return _selector; } - @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - return null; - } - - @Override - public boolean isDurable() - { - return _durable; - } - - @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - - } - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.DELETE_ON_SESSION_END; } - @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; - } - @Override public Collection getChildren(final Class clazz) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java index cfc3987677..8316e027d1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileKeyStoreImpl.java @@ -105,11 +105,6 @@ public class FileKeyStoreImpl extends AbstractConfiguredObject { return getAttributeNames(getClass()); } - @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException - { - throw new IllegalStateException(); - } @Override public State getState() @@ -117,31 +112,12 @@ public class FileKeyStoreImpl extends AbstractConfiguredObject return State.ACTIVE; } - @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(boolean durable) throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException, AccessControlException, - IllegalArgumentException - { - throw new IllegalStateException(); - } - @Override public Object getAttribute(String name) { @@ -149,10 +125,6 @@ public class FileKeyStoreImpl extends AbstractConfiguredObject { return getState(); } - else if(KeyStore.DURABLE.equals(name)) - { - return isDurable(); - } else if(KeyStore.LIFETIME_POLICY.equals(name)) { return getLifetimePolicy(); @@ -260,6 +232,11 @@ public class FileKeyStoreImpl extends AbstractConfiguredObject throw new IllegalConfigurationException("Unknown keyManagerFactoryAlgorithm: " + fileKeyStore.getKeyManagerFactoryAlgorithm()); } + + if(!fileKeyStore.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java index efaf565364..84b8b38ff1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java @@ -21,15 +21,12 @@ package org.apache.qpid.server.security; import java.io.IOException; -import java.lang.reflect.Type; import java.security.AccessControlException; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -51,7 +48,6 @@ import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.TrustStore; import org.apache.qpid.server.security.access.Operation; import org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManagerFactory; -import org.apache.qpid.server.util.MapValueConverter; import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager; import org.apache.qpid.transport.network.security.ssl.QpidPeersOnlyTrustManager; import org.apache.qpid.transport.network.security.ssl.SSLUtil; @@ -59,17 +55,6 @@ import org.apache.qpid.transport.network.security.ssl.SSLUtil; public class FileTrustStoreImpl extends AbstractConfiguredObject implements FileTrustStore { - - @SuppressWarnings("serial") - public static final Map ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap(){{ - put(NAME, String.class); - put(PATH, String.class); - put(PASSWORD, String.class); - put(TRUST_STORE_TYPE, String.class); - put(PEERS_ONLY, Boolean.class); - put(TRUST_MANAGER_FACTORY_ALGORITHM, String.class); - }}); - @ManagedAttributeField private String _trustStoreType; @ManagedAttributeField @@ -95,7 +80,11 @@ public class FileTrustStoreImpl extends AbstractConfiguredObject attributes) + protected void validateChange(final ConfiguredObject proxyForValidation, final Set changedAttributes) { - Map changedValues = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES); - if(changedValues.containsKey(TrustStore.NAME)) + super.validateChange(proxyForValidation, changedAttributes); + FileTrustStore updated = (FileTrustStore) proxyForValidation; + if(changedAttributes.contains(TrustStore.NAME) && !getName().equals(updated.getName())) { - String newName = (String) changedValues.get(TrustStore.NAME); - if(!getName().equals(newName)) - { - throw new IllegalConfigurationException("Changing the trust store name is not allowed"); - } + throw new IllegalConfigurationException("Changing the trust store name is not allowed"); } - - Map merged = generateEffectiveAttributes(changedValues); - - String trustStorePath = changedValues.containsKey(PATH) ? (String) changedValues.get(PATH) : getPath(); - String trustStorePassword = - changedValues.containsKey(PASSWORD) ? (String) changedValues.get(PASSWORD) : getPassword(); - String trustStoreType = changedValues.containsKey(TRUST_STORE_TYPE) - ? (String) changedValues.get(TRUST_STORE_TYPE) - : getTrustStoreType(); - String trustManagerFactoryAlgorithm = - changedValues.containsKey(TRUST_MANAGER_FACTORY_ALGORITHM) - ? (String) changedValues.get(TRUST_MANAGER_FACTORY_ALGORITHM) - : getTrustManagerFactoryAlgorithm(); - - validateTrustStoreAttributes(trustStoreType, trustStorePath, - trustStorePassword, trustManagerFactoryAlgorithm); - - super.changeAttributes(changedValues); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + validateTrustStore(updated); } - private void validateTrustStoreAttributes(String type, String trustStorePath, - String password, String trustManagerFactoryAlgorithm) + + private static void validateTrustStore(FileTrustStore trustStore) { try { - SSLUtil.getInitializedKeyStore(trustStorePath, password, type); + SSLUtil.getInitializedKeyStore(trustStore.getPath(), trustStore.getPassword(), trustStore.getTrustStoreType()); } catch (Exception e) { - throw new IllegalConfigurationException("Cannot instantiate trust store at " + trustStorePath, e); + throw new IllegalConfigurationException("Cannot instantiate trust store at " + trustStore.getPath(), e); } try { - TrustManagerFactory.getInstance(trustManagerFactoryAlgorithm); + TrustManagerFactory.getInstance(trustStore.getTrustManagerFactoryAlgorithm()); } catch (NoSuchAlgorithmException e) { - throw new IllegalConfigurationException("Unknown trustManagerFactoryAlgorithm: " + trustManagerFactoryAlgorithm); + throw new IllegalConfigurationException("Unknown trustManagerFactoryAlgorithm: " + trustStore.getTrustManagerFactoryAlgorithm()); } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java index cacb08ab5c..a7a6ff42f1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java @@ -78,6 +78,21 @@ public abstract class AbstractAuthenticationManager proxyForValidation, final Set changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } protected final Broker getBroker() @@ -131,45 +146,18 @@ public abstract class AbstractAuthenticationManager C addChild(Class childClass, Map attributes, ConfiguredObject... otherParents) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java index e454b1b50a..26421437a7 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java @@ -356,6 +356,26 @@ public abstract class PrincipalDatabaseAuthenticationManager proxyForValidation, final Set changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + @Override public String getPassword() { @@ -376,45 +396,18 @@ public abstract class PrincipalDatabaseAuthenticationManager Collection getChildren(Class clazz) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java index 82c045fe2d..c755015c33 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -448,6 +449,25 @@ public class ScramSHA1AuthenticationManager _authenticationManager._users.put(getName(), this); } + @Override + public void validate() + { + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject proxyForValidation, final Set changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } @Override protected boolean setState(final State currentState, final State desiredState) { @@ -525,50 +545,18 @@ public class ScramSHA1AuthenticationManager } } - @Override - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - throw new IllegalStateException("Names cannot be updated"); - } - @Override public State getState() { return State.ACTIVE; } - @Override - public boolean isDurable() - { - return true; - } - - @Override - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - - } - @Override public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - @Override - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - if(expected == desired && expected == LifetimePolicy.PERMANENT) - { - return LifetimePolicy.PERMANENT; - } - throw new IllegalArgumentException("Cannot change lifetime policy of a user"); - - } - @Override public Collection getChildren(final Class clazz) { 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 007baf3422..3207e13e96 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 @@ -212,6 +212,20 @@ public abstract class AbstractVirtualHost> exte { throw new IllegalConfigurationException("Virtual host type must be specified"); } + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } + } + + @Override + protected void validateChange(final ConfiguredObject proxyForValidation, final Set changedAttributes) + { + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } protected void onOpen() @@ -333,12 +347,6 @@ public abstract class AbstractVirtualHost> exte } } - public String setName(final String currentName, final String desiredName) - throws IllegalStateException, AccessControlException - { - throw new IllegalStateException(); - } - public String setType(final String currentType, final String desiredType) throws IllegalStateException, AccessControlException { @@ -373,28 +381,11 @@ public abstract class AbstractVirtualHost> exte } - public boolean isDurable() - { - return true; - } - - public void setDurable(final boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - public LifetimePolicy getLifetimePolicy() { return LifetimePolicy.PERMANENT; } - public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - throw new IllegalStateException(); - } - @Override public Collection getChildren(Class clazz) diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java index 0182237a99..ea5e02e4d9 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java @@ -178,6 +178,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest Map map = new HashMap(); map.put(Binding.NAME, ROUTING_KEY); map.put(Binding.ARGUMENTS,_bindingArgs); + map.put(Binding.DURABLE,true); Map parents = new HashMap(); @@ -417,6 +418,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest when(queue.getId()).thenReturn(_queueId); when(queue.getAlternateExchange()).thenReturn(alternateExchange); when(queue.getCategoryClass()).thenReturn((Class)Queue.class); + when(queue.isDurable()).thenReturn(true); final VirtualHostImpl vh = mock(VirtualHostImpl.class); when(vh.getSecurityManager()).thenReturn(mock(SecurityManager.class)); when(queue.getVirtualHost()).thenReturn(vh); @@ -469,6 +471,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest when(exchange.isAutoDelete()).thenReturn(true); when(exchange.getId()).thenReturn(_exchangeId); when(exchange.getCategoryClass()).thenReturn(Exchange.class); + when(exchange.isDurable()).thenReturn(true); ConfiguredObjectRecord exchangeRecord = mock(ConfiguredObjectRecord.class); when(exchangeRecord.getId()).thenReturn(_exchangeId); 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 b4d3148dfa..37b464be40 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 @@ -148,13 +148,6 @@ public class MockVirtualHost implements VirtualHostImpl getAttributeNames() { diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java index db2b44c5e6..ae23a308f5 100644 --- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java +++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java @@ -72,40 +72,42 @@ public class ACLFileAccessControlProviderImpl } @Override - protected void onOpen() + public void validate() { - super.onOpen(); - _accessControl = new DefaultAccessControl(getPath(), _broker); - } - - @Override - public String getPath() - { - return _path; + super.validate(); + if(!isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException + protected void validateChange(final ConfiguredObject proxyForValidation, final Set changedAttributes) { - return null; + super.validateChange(proxyForValidation, changedAttributes); + if(changedAttributes.contains(DURABLE) && !proxyForValidation.isDurable()) + { + throw new IllegalArgumentException(getClass().getSimpleName() + " must be durable"); + } } @Override - public State getState() + protected void onOpen() { - return _state.get(); + super.onOpen(); + _accessControl = new DefaultAccessControl(getPath(), _broker); } @Override - public boolean isDurable() + public String getPath() { - return true; + return _path; } @Override - public void setDurable(boolean durable) - throws IllegalStateException, AccessControlException, IllegalArgumentException + public State getState() { + return _state.get(); } @Override @@ -114,13 +116,6 @@ public class ACLFileAccessControlProviderImpl return LifetimePolicy.PERMANENT; } - @Override - public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) - throws IllegalStateException, AccessControlException, IllegalArgumentException - { - return null; - } - @Override public Collection getAttributeNames() { diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java index 1584dc6e46..a2bb05dd00 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java @@ -258,7 +258,7 @@ public class Asserts public static void assertPortAttributes(Map port, State state) { assertNotNull("Unexpected value of attribute " + Port.ID, port.get(Port.ID)); - assertEquals("Unexpected value of attribute " + Port.DURABLE, Boolean.FALSE, port.get(Port.DURABLE)); + assertEquals("Unexpected value of attribute " + Port.DURABLE, Boolean.TRUE, port.get(Port.DURABLE)); assertEquals("Unexpected value of attribute " + Port.LIFETIME_POLICY, LifetimePolicy.PERMANENT.name(), port.get(Broker.LIFETIME_POLICY)); assertEquals("Unexpected value of attribute " + Port.STATE, state.name(), port.get(Port.STATE)); -- cgit v1.2.1