diff options
| author | Keith Wall <kwall@apache.org> | 2015-02-10 16:15:08 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2015-02-10 16:15:08 +0000 |
| commit | 085486ebe5ff21133b9caf1c31625ac6ea356568 (patch) | |
| tree | 7acbe9ca99a345dca71f9f80cd3e29ea4e3710f0 /qpid/java/broker-plugins | |
| parent | 60c62c03ca404e98e4fbd1abf4a5ebf50763d604 (diff) | |
| parent | e2e6d542b8cde9e702d1c3b63376e9d8380ba1c7 (diff) | |
| download | qpid-python-085486ebe5ff21133b9caf1c31625ac6ea356568.tar.gz | |
merge from trunk
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/QPID-6262-JavaBrokerNIO@1658748 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins')
80 files changed, 1897 insertions, 682 deletions
diff --git a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java index b8509ebd39..3e0f5b63f0 100644 --- a/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java +++ b/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java @@ -27,6 +27,6 @@ import org.apache.qpid.server.model.ManagedObject; @ManagedObject( category = false, type="AclFile" ) public interface ACLFileAccessControlProvider<X extends ACLFileAccessControlProvider<X>> extends AccessControlProvider<X> { - @ManagedAttribute( mandatory = true, description = "File location" ) + @ManagedAttribute( mandatory = true, description = "File location", oversize = true, oversizedAltText = OVER_SIZED_ATTRIBUTE_ALTERNATIVE_TEXT) String getPath(); } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java index f7f65e29c2..a149214455 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java @@ -3256,17 +3256,6 @@ public class AMQChannel + autoDelete + ")"); } - else if (queue.isDurable() != durable) - { - closeChannel(AMQConstant.ALREADY_EXISTS, - "Cannot re-declare queue '" - + queue.getName() - + "' with different durability (was: " - + queue.isDurable() - + " requested " - + durable - + ")"); - } else { setDefaultQueue(queue); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java index 1aa4ef0b3f..233f68aeb6 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java @@ -96,6 +96,16 @@ public class AMQProtocolEngine implements ServerProtocolEngine, AMQConnectionModel<AMQProtocolEngine, AMQChannel>, ServerMethodProcessor<ServerChannelMethodProcessor> { + enum ConnectionState + { + INIT, + AWAIT_START_OK, + AWAIT_SECURE_OK, + AWAIT_TUNE_OK, + AWAIT_OPEN, + OPEN + } + private static final Logger _logger = Logger.getLogger(AMQProtocolEngine.class); // to save boxing the channelId and looking up in a map... cache in an array the low numbered @@ -123,6 +133,8 @@ public class AMQProtocolEngine implements ServerProtocolEngine, private final AMQChannel[] _cachedChannels = new AMQChannel[CHANNEL_CACHE_SIZE + 1]; + private ConnectionState _state = ConnectionState.INIT; + /** * The channels that the latest call to {@link #received(ByteBuffer)} applied to. * Used so we know which channels we need to call {@link AMQChannel#receivedComplete()} @@ -486,14 +498,9 @@ public class AMQProtocolEngine implements ServerProtocolEngine, serverProperties, mechanisms.getBytes(), locales.getBytes()); - try - { - responseBody.generateFrame(0).writePayload(_sender); - } - catch (IOException e) - { - throw new ServerScopedRuntimeException(e); - } + writeFrame(responseBody.generateFrame(0)); + _state = ConnectionState.AWAIT_START_OK; + _sender.flush(); } @@ -501,14 +508,7 @@ public class AMQProtocolEngine implements ServerProtocolEngine, { _logger.info("Received unsupported protocol initiation for protocol version: " + getProtocolVersion()); - try - { - new ProtocolInitiation(ProtocolVersion.getLatestSupportedVersion()).writePayload(_sender); - } - catch (IOException ioex) - { - throw new ServerScopedRuntimeException(ioex); - } + writeFrame(new ProtocolInitiation(ProtocolVersion.getLatestSupportedVersion())); _sender.flush(); } } @@ -1498,6 +1498,7 @@ public class AMQProtocolEngine implements ServerProtocolEngine, { _logger.debug("RECV[" + channelId + "] ChannelOpen"); } + assertState(ConnectionState.OPEN); // Protect the broker against out of order frame request. if (_virtualHost == null) @@ -1534,6 +1535,15 @@ public class AMQProtocolEngine implements ServerProtocolEngine, } } + void assertState(final ConnectionState requiredState) + { + if(_state != requiredState) + { + closeConnection(AMQConstant.COMMAND_INVALID, "Command Invalid", 0); + + } + } + @Override public void receiveConnectionOpen(AMQShortString virtualHostName, AMQShortString capabilities, @@ -1586,6 +1596,7 @@ public class AMQProtocolEngine implements ServerProtocolEngine, AMQMethodBody responseBody = methodRegistry.createConnectionOpenOkBody(virtualHostName); writeFrame(responseBody.generateFrame(0)); + _state = ConnectionState.OPEN; } catch (AccessControlException e) { @@ -1656,6 +1667,8 @@ public class AMQProtocolEngine implements ServerProtocolEngine, _logger.debug("RECV ConnectionSecureOk[ response: ******** ] "); } + assertState(ConnectionState.AWAIT_SECURE_OK); + Broker<?> broker = getBroker(); SubjectCreator subjectCreator = getSubjectCreator(); @@ -1696,6 +1709,7 @@ public class AMQProtocolEngine implements ServerProtocolEngine, frameMax, broker.getConnection_heartBeatDelay()); writeFrame(tuneBody.generateFrame(0)); + _state = ConnectionState.AWAIT_TUNE_OK; setAuthorizedSubject(authResult.getSubject()); disposeSaslServer(); break; @@ -1744,6 +1758,8 @@ public class AMQProtocolEngine implements ServerProtocolEngine, + " ]"); } + assertState(ConnectionState.AWAIT_START_OK); + Broker<?> broker = getBroker(); _logger.info("SASL Mechanism selected: " + mechanism); @@ -1805,11 +1821,14 @@ public class AMQProtocolEngine implements ServerProtocolEngine, frameMax, broker.getConnection_heartBeatDelay()); writeFrame(tuneBody.generateFrame(0)); + _state = ConnectionState.AWAIT_TUNE_OK; break; case CONTINUE: ConnectionSecureBody secureBody = methodRegistry.createConnectionSecureBody(authResult.getChallenge()); writeFrame(secureBody.generateFrame(0)); + + _state = ConnectionState.AWAIT_SECURE_OK; } } } @@ -1828,6 +1847,8 @@ public class AMQProtocolEngine implements ServerProtocolEngine, _logger.debug("RECV ConnectionTuneOk[" +" channelMax: " + channelMax + " frameMax: " + frameMax + " heartbeat: " + heartbeat + " ]"); } + assertState(ConnectionState.AWAIT_TUNE_OK); + initHeartbeats(heartbeat); int brokerFrameMax = getBroker().getContextValue(Integer.class, Broker.BROKER_FRAME_SIZE); @@ -1859,7 +1880,10 @@ public class AMQProtocolEngine implements ServerProtocolEngine, setMaximumNumberOfChannels( ((channelMax == 0l) || (channelMax > 0xFFFFL)) ? 0xFFFFL : channelMax); + } + _state = ConnectionState.AWAIT_OPEN; + } public int getBinaryDataLimit() @@ -1959,6 +1983,8 @@ public class AMQProtocolEngine implements ServerProtocolEngine, @Override public ServerChannelMethodProcessor getChannelMethodProcessor(final int channelId) { + assertState(ConnectionState.OPEN); + ServerChannelMethodProcessor channelMethodProcessor = getChannel(channelId); if(channelMethodProcessor == null) { diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java index 0f198a8d46..f8098eb2ec 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java @@ -276,6 +276,12 @@ public class InternalTestProtocolSession extends AMQProtocolEngine implements Pr } } + void assertState(final ConnectionState requiredState) + { + // no-op + } + + private static final AtomicInteger portNumber = new AtomicInteger(0); private static class TestNetworkConnection implements NetworkConnection diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java index b5e1bdafbb..a44768ffdc 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java @@ -347,6 +347,11 @@ class ConsumerTarget_1_0 extends AbstractConsumerTarget return _link.getSession(); } + public void flush() + { + _consumer.flush(); + } + private class DispositionAction implements UnsettledAction { diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Message_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Message_1_0.java index 36796851e0..18f5ba9e2e 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Message_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Message_1_0.java @@ -21,23 +21,42 @@ package org.apache.qpid.server.protocol.v1_0; +import java.lang.ref.SoftReference; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; + import org.apache.qpid.server.message.AbstractServerMessageImpl; import org.apache.qpid.server.store.StoredMessage; public class Message_1_0 extends AbstractServerMessageImpl<Message_1_0, MessageMetaData_1_0> { - private List<ByteBuffer> _fragments; + private volatile SoftReference<List<ByteBuffer>> _fragmentsRef; private long _arrivalTime; + private final long _size; public Message_1_0(final StoredMessage<MessageMetaData_1_0> storedMessage) { super(storedMessage, null); - _fragments = restoreFragments(storedMessage); + final List<ByteBuffer> fragments = restoreFragments(getStoredMessage()); + _fragmentsRef = new SoftReference<>(fragments); + _size = calculateSize(fragments); + } + + private long calculateSize(final List<ByteBuffer> fragments) + { + + long size = 0l; + if(fragments != null) + { + for(ByteBuffer buf : fragments) + { + size += buf.remaining(); + } + } + return size; } private static List<ByteBuffer> restoreFragments(StoredMessage<MessageMetaData_1_0> storedMessage) @@ -65,7 +84,8 @@ public class Message_1_0 extends AbstractServerMessageImpl<Message_1_0, MessageM final Object connectionReference) { super(storedMessage, connectionReference); - _fragments = fragments; + _fragmentsRef = new SoftReference<>(fragments); + _size = calculateSize(fragments); _arrivalTime = System.currentTimeMillis(); } @@ -94,16 +114,7 @@ public class Message_1_0 extends AbstractServerMessageImpl<Message_1_0, MessageM public long getSize() { - long size = 0l; - if(_fragments != null) - { - for(ByteBuffer buf : _fragments) - { - size += buf.remaining(); - } - } - - return size; + return _size; } public long getExpiration() @@ -118,7 +129,14 @@ public class Message_1_0 extends AbstractServerMessageImpl<Message_1_0, MessageM public List<ByteBuffer> getFragments() { - return _fragments; + + List<ByteBuffer> fragments = _fragmentsRef.get(); + if(fragments == null) + { + fragments = restoreFragments(getStoredMessage()); + _fragmentsRef = new SoftReference<>(fragments); + } + return fragments; } } diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java index f8e4853099..48ff420965 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java @@ -496,6 +496,7 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS && hasCredit()) { _draining = true; + _target.flush(); } while(!_resumeAcceptedTransfers.isEmpty() && getEndpoint().hasCreditToSend()) diff --git a/qpid/java/broker-plugins/management-http/pom.xml b/qpid/java/broker-plugins/management-http/pom.xml index 47066874ed..50ff3e20f3 100644 --- a/qpid/java/broker-plugins/management-http/pom.xml +++ b/qpid/java/broker-plugins/management-http/pom.xml @@ -29,6 +29,10 @@ <name>Qpid HTTP Management Broker Plug-in</name> <description>HTTP Management broker plug-in</description> + <properties> + <dojo-version>1.10.3</dojo-version> + </properties> + <dependencies> <dependency> <groupId>org.apache.qpid</groupId> @@ -84,6 +88,7 @@ <groupId>org.dojotoolkit</groupId> <artifactId>dojo</artifactId> <version>${dojo-version}</version> + <classifier>distribution</classifier> <type>zip</type> </dependency> @@ -124,7 +129,7 @@ it gets picked up when using classpath wildcard expansion, which only collects .jar files --> <manifestEntries> - <Class-Path>dojo-${dojo-version}.zip</Class-Path> + <Class-Path>dojo-${dojo-version}-distribution.zip</Class-Path> </manifestEntries> </archive> </configuration> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java index 7b3e06f7fe..4e340c7b72 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java @@ -46,7 +46,6 @@ import org.eclipse.jetty.server.SessionManager; import org.eclipse.jetty.server.handler.ErrorHandler; import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; -import org.eclipse.jetty.server.ssl.SslSocketConnector; import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; @@ -139,7 +138,7 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem try { _server.start(); - logOperationalListenMessages(_server); + logOperationalListenMessages(httpPorts); } catch (Exception e) { @@ -352,6 +351,17 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem } SslContextFactory factory = new SslContextFactory(); factory.addExcludeProtocols(SSLUtil.SSLV3_PROTOCOL); + + if(port.getDisabledCipherSuites() != null) + { + factory.addExcludeCipherSuites(port.getDisabledCipherSuites().toArray(new String[port.getDisabledCipherSuites().size()])); + } + + if(port.getEnabledCipherSuites() != null && !port.getEnabledCipherSuites().isEmpty()) + { + factory.setIncludeCipherSuites(port.getEnabledCipherSuites().toArray(new String[port.getEnabledCipherSuites().size()])); + } + boolean needClientCert = port.getNeedClientAuth() || port.getWantClientAuth(); if (needClientCert && trustStores.isEmpty()) @@ -437,20 +447,14 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem root.addServlet(servletHolder, "/api/v" + BrokerModel.MODEL_MAJOR_VERSION + "/" + name + "/*"); } - private void logOperationalListenMessages(Server server) + private void logOperationalListenMessages(Collection<Port<?>> ports) { - Connector[] connectors = server.getConnectors(); - for (Connector connector : connectors) + for (Port port : ports) { - getBroker().getEventLogger().message(ManagementConsoleMessages.LISTENING(stringifyConnectorScheme(connector), - connector.getPort())); - if (connector instanceof SslSocketConnector) + Set<Transport> transports = port.getTransports(); + for (Transport transport: transports) { - SslContextFactory sslContextFactory = ((SslSocketConnector)connector).getSslContextFactory(); - if (sslContextFactory != null && sslContextFactory.getKeyStorePath() != null) - { - getBroker().getEventLogger().message(ManagementConsoleMessages.SSL_KEYSTORE(sslContextFactory.getKeyStorePath())); - } + getBroker().getEventLogger().message(ManagementConsoleMessages.LISTENING(Protocol.HTTP.name(), transport.name(), port.getPort())); } } } @@ -460,15 +464,10 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem Connector[] connectors = server.getConnectors(); for (Connector connector : connectors) { - getBroker().getEventLogger().message(ManagementConsoleMessages.SHUTTING_DOWN(stringifyConnectorScheme(connector), - connector.getPort())); + getBroker().getEventLogger().message(ManagementConsoleMessages.SHUTTING_DOWN(Protocol.HTTP.name(), connector.getPort())); } } - private String stringifyConnectorScheme(Connector connector) - { - return connector instanceof SslSocketConnector ? "HTTPS" : "HTTP"; - } private Collection<Port<?>> getHttpPorts(Collection<Port<?>> ports) { diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java index 445ce996ef..018b23daaf 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java @@ -45,6 +45,10 @@ public interface HttpManagementConfiguration<X extends HttpManagementConfigurati @ManagedAttribute( defaultValue = "600" ) public int getSessionTimeout(); + String QPID_HELP_URL = "qpid.helpURL"; + @ManagedContextDefault(name = QPID_HELP_URL) + String DEFAULT_HELP_URL = "http://qpid.apache.org/releases/qpid-${qpid.version}/java-broker/book"; + String HTTP_MANAGEMENT_COMPRESS_RESPONSES = "httpManagement.compressResponses"; @ManagedContextDefault(name = HTTP_MANAGEMENT_COMPRESS_RESPONSES) boolean DEFAULT_COMPRESS_RESPONSES = false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java index 7d86bd3c8c..331b50ea7c 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java @@ -54,23 +54,17 @@ public class ConfiguredObjectToMapConverter Class<? extends ConfiguredObject> clazz, int depth, final boolean useActualValues, - final boolean includeSystemContext, - final boolean extractAsConfig) - { - return convertObjectToMap(confObject, clazz, depth, useActualValues, false, includeSystemContext, extractAsConfig); - } - - public Map<String, Object> convertObjectToMap(final ConfiguredObject<?> confObject, - Class<? extends ConfiguredObject> clazz, - int depth, - final boolean useActualValues, final boolean inheritedActuals, final boolean includeSystemContext, - final boolean extractAsConfig) + final boolean extractAsConfig, + final int oversizeThreshold, + final boolean isSecureTransport + ) { Map<String, Object> object = new LinkedHashMap<>(); - incorporateAttributesIntoMap(confObject, object, useActualValues, inheritedActuals, includeSystemContext, extractAsConfig); + incorporateAttributesIntoMap(confObject, object, useActualValues, inheritedActuals, includeSystemContext, + extractAsConfig, oversizeThreshold, isSecureTransport); if(!extractAsConfig) { incorporateStatisticsIntoMap(confObject, object); @@ -78,7 +72,8 @@ public class ConfiguredObjectToMapConverter if(depth > 0) { - incorporateChildrenIntoMap(confObject, clazz, depth, object, useActualValues, inheritedActuals, includeSystemContext, extractAsConfig); + incorporateChildrenIntoMap(confObject, clazz, depth, object, useActualValues, inheritedActuals, + includeSystemContext, extractAsConfig, oversizeThreshold, isSecureTransport); } return object; } @@ -90,7 +85,9 @@ public class ConfiguredObjectToMapConverter final boolean useActualValues, final boolean inheritedActuals, final boolean includeSystemContext, - final boolean extractAsConfig) + final boolean extractAsConfig, + final int oversizeThreshold, + final boolean isSecureTransport) { // if extracting as config add a fake attribute for each secondary parent if(extractAsConfig && confObject.getModel().getParentTypes(confObject.getCategoryClass()).size()>1) @@ -160,7 +157,39 @@ public class ConfiguredObjectToMapConverter } else if (value != null) { - object.put(name, value); + ConfiguredObjectAttribute<?, ?> attribute = confObject.getModel() + .getTypeRegistry() + .getAttributeTypes(confObject.getClass()) + .get(name); + + if (attribute.isSecure() && !(isSecureTransport && extractAsConfig)) + { + // do not expose actual secure attribute value + // getAttribute() returns encoded value + value = confObject.getAttribute(name); + } + + if(attribute.isOversized() && !extractAsConfig) + { + String valueString = String.valueOf(value); + if(valueString.length() > oversizeThreshold) + { + + String replacementValue = "".equals(attribute.getOversizedAltText()) + ? String.valueOf(value).substring(0, oversizeThreshold - 4) + "..." + : attribute.getOversizedAltText(); + + object.put(name, replacementValue); + } + else + { + object.put(name, value); + } + } + else + { + object.put(name, value); + } } else if (extractAsConfig) { @@ -220,7 +249,9 @@ public class ConfiguredObjectToMapConverter final boolean useActualValues, final boolean inheritedActuals, final boolean includeSystemContext, - final boolean extractAsConfig) + final boolean extractAsConfig, + final int oversizeThreshold, + final boolean isSecure) { List<Class<? extends ConfiguredObject>> childTypes = new ArrayList<>(confObject.getModel().getChildTypes(clazz)); @@ -262,7 +293,9 @@ public class ConfiguredObjectToMapConverter useActualValues, inheritedActuals, includeSystemContext, - extractAsConfig)); + extractAsConfig, + oversizeThreshold, + isSecure)); } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java index 01dd873aa5..b995bb442c 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MetaDataServlet.java @@ -43,6 +43,7 @@ import org.apache.qpid.server.model.ConfiguredAutomatedAttribute; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.ConfiguredObjectAttribute; import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; +import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.Model; public class MetaDataServlet extends AbstractServlet @@ -103,6 +104,18 @@ public class MetaDataServlet extends AbstractServlet typeDetails.put("attributes", processAttributes(type)); typeDetails.put("managedInterfaces", getManagedInterfaces(type)); typeDetails.put("validChildTypes", getValidChildTypes(type)); + ManagedObject annotation = type.getAnnotation(ManagedObject.class); + if(annotation != null) + { + if(annotation.deprecated()) + { + typeDetails.put("deprecated",true); + } + if(!"".equals(annotation.description() ) ) + { + typeDetails.put("description", annotation.description()); + } + } return typeDetails; } @@ -175,7 +188,10 @@ public class MetaDataServlet extends AbstractServlet { attrDetails.put("secure",attribute.isSecure()); } - + if(attribute.isOversized()) + { + attrDetails.put("oversize", attribute.isOversized()); + } attributeDetails.put(attribute.getName(), attrDetails); } return attributeDetails; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java index 71ec6e786f..19d498e240 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java @@ -56,6 +56,7 @@ public class RestServlet extends AbstractServlet private static final String HIERARCHY_INIT_PARAMETER = "hierarchy"; public static final String DEPTH_PARAM = "depth"; + public static final String OVERSIZE_PARAM = "oversize"; public static final String ACTUALS_PARAM = "actuals"; public static final String SORT_PARAM = "sort"; public static final String INCLUDE_SYS_CONTEXT_PARAM = "includeSysContext"; @@ -71,6 +72,7 @@ public class RestServlet extends AbstractServlet public static final Set<String> RESERVED_PARAMS = new HashSet<>(Arrays.asList(DEPTH_PARAM, SORT_PARAM, + OVERSIZE_PARAM, ACTUALS_PARAM, INCLUDE_SYS_CONTEXT_PARAM, EXTRACT_INITIAL_CONFIG_PARAM, @@ -345,17 +347,20 @@ public class RestServlet extends AbstractServlet boolean actuals; boolean includeSystemContext; boolean inheritedActuals; + int oversizeThreshold; if(extractInitialConfig) { depth = Integer.MAX_VALUE; + oversizeThreshold = Integer.MAX_VALUE; actuals = true; includeSystemContext = false; inheritedActuals = false; } else { - depth = getDepthParameterFromRequest(request); + depth = getIntParameterFromRequest(request, DEPTH_PARAM, 1); + oversizeThreshold = getIntParameterFromRequest(request, OVERSIZE_PARAM, 120); actuals = getBooleanParameterFromRequest(request, ACTUALS_PARAM); includeSystemContext = getBooleanParameterFromRequest(request, INCLUDE_SYS_CONTEXT_PARAM); inheritedActuals = getBooleanParameterFromRequest(request, INHERITED_ACTUALS_PARAM); @@ -364,8 +369,9 @@ public class RestServlet extends AbstractServlet List<Map<String, Object>> output = new ArrayList<>(); for(ConfiguredObject configuredObject : allObjects) { + output.add(_objectConverter.convertObjectToMap(configuredObject, getConfiguredClass(), - depth, actuals, inheritedActuals, includeSystemContext, extractInitialConfig)); + depth, actuals, inheritedActuals, includeSystemContext, extractInitialConfig, oversizeThreshold, request.isSecure())); } @@ -679,22 +685,24 @@ public class RestServlet extends AbstractServlet response.setDateHeader ("Expires", 0); } - private int getDepthParameterFromRequest(HttpServletRequest request) + private int getIntParameterFromRequest(final HttpServletRequest request, + final String paramName, + final int defaultValue) { - int depth = 1; - final String depthString = request.getParameter(DEPTH_PARAM); - if(depthString!=null) + int intValue = defaultValue; + final String stringValue = request.getParameter(paramName); + if(stringValue!=null) { try { - depth = Integer.parseInt(depthString); + intValue = Integer.parseInt(stringValue); } catch (NumberFormatException e) { - LOGGER.warn("Could not parse " + depthString + " as integer"); + LOGGER.warn("Could not parse " + stringValue + " as integer for parameter " + paramName); } } - return depth; + return intValue; } private boolean getBooleanParameterFromRequest(HttpServletRequest request, final String paramName) diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addAccessControlProvider.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addAccessControlProvider.html index 07a0c4cf83..64f8078314 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addAccessControlProvider.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addAccessControlProvider.html @@ -58,7 +58,7 @@ </div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" id="addAccessControlProvider.addButton" data-dojo-props="label: 'Save'" type="submit"></button> <button data-dojo-type="dijit/form/Button" id="addAccessControlProvider.cancelButton" data-dojo-props="label: 'Cancel'" ></button> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addAuthenticationProvider.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addAuthenticationProvider.html index cf38cd425c..5a565e72e3 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addAuthenticationProvider.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addAuthenticationProvider.html @@ -56,7 +56,7 @@ <div id="addPreferencesProvider.form"></div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" id="addAuthenticationProvider.addButton" data-dojo-props="label: 'Save'" type="submit"></button> <button data-dojo-type="dijit/form/Button" id="addAuthenticationProvider.cancelButton" data-dojo-props="label: 'Cancel'" ></button> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addBinding.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addBinding.html index 1b30c6ddcc..d4ac5877cb 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addBinding.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addBinding.html @@ -56,7 +56,7 @@ </fieldset> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <input type="submit" value="Create Binding" label="Create Binding" data-dojo-type="dijit/form/Button" /> </div> </form> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addExchange.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addExchange.html index 77d5ed0bc1..25e9752392 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addExchange.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addExchange.html @@ -66,7 +66,7 @@ <div class="clear"></div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <input type="submit" value="Create Exchange" label="Create Exchange" dojoType="dijit.form.Button" /> </div> </form> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addGroupProvider.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addGroupProvider.html new file mode 100644 index 0000000000..b622fe94d2 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addGroupProvider.html @@ -0,0 +1,66 @@ +<!-- + ~ 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. + --> + +<div class="dijitHidden"> + <div data-dojo-type="dijit/Dialog" data-dojo-props="title:'Add Store'" id="addGroupProvider"> + <div id="addGroupProvider.contentPane"> + <form id="addGroupProvider.form" method="post" data-dojo-type="dijit/form/Form"> + <div class="formBox"> + <div class="clear"> + <div class="formLabel-labelCell tableContainer-labelCell">Name*:</div> + <div class="formLabel-controlCell tableContainer-valueCell"> + <input type="text" id="addGroupProvider.name" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props=" + name: 'name', + placeHolder: 'group provider name', + required: true, + promptMessage: 'Name of group provider, must be unique', + title: 'Enter a unique group provider name per broker'" /> + </div> + </div> + <div class="clear"> + <div class="formLabel-labelCell tableContainer-labelCell">Type*:</div> + <div class="tableContainer-valueCell formLabel-controlCell"> + <select id="addGroupProvider.type" data-dojo-type="dijit/form/FilteringSelect" + data-dojo-props=" + name: 'type', + required: true, + placeHolder: 'group provider type', + promptMessage: 'Type of group provider', + title: 'Select type', + searchAttr: 'name'"> + </select> + </div> + </div> + <div class="clear"> + <div id="addGroupProvider.typeFields"></div> + </div> + </div> + </form> + <div class="clear"> + </div> + </div> + + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> + <button data-dojo-type="dijit/form/Button" id="addGroupProvider.addButton" data-dojo-props="label: 'Save'" type="submit"></button> + <button data-dojo-type="dijit/form/Button" id="addGroupProvider.cancelButton" data-dojo-props="label: 'Cancel'" ></button> + </div> + </div> +</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html index c76a230382..b787e701ec 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html @@ -234,7 +234,7 @@ <input type="hidden" id="formAddPort.id" name="id"/> <div class="clear"></div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <!-- submit buttons --> <input type="submit" value="Save Port" label="Save Port" dojoType="dijit.form.Button" /> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addPreferencesProvider.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addPreferencesProvider.html index e850f5ac7f..e3984e1ae2 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addPreferencesProvider.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addPreferencesProvider.html @@ -19,7 +19,7 @@ <div id="addPreferencesProvider.preferencesProvider" data-dojo-type="qpid/management/preferencesprovider/PreferencesProviderForm"></div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <!-- submit buttons --> <input type="button" value="Save" data-dojo-props="label: 'Save'" data-dojo-type="dijit/form/Button" id="addPreferencesProvider.saveButton"/> <input type="button" value="Cancel" data-dojo-props="label: 'Cancel'" data-dojo-type="dijit/form/Button" id="addPreferencesProvider.cancelButton"/> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addQueue.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addQueue.html index 042d6d7ad7..61f0de22d8 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addQueue.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addQueue.html @@ -334,7 +334,7 @@ <div id="formAddQueue.context" ></div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <!-- submit buttons --> <input type="submit" value="Create Queue" label="Create Queue" dojoType="dijit.form.Button" /> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addStore.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addStore.html index dd6e7a3d38..a1903d456e 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addStore.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addStore.html @@ -58,7 +58,7 @@ </div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" id="addStore.addButton" data-dojo-props="label: 'Save'" type="submit"></button> <button data-dojo-type="dijit/form/Button" id="addStore.cancelButton" data-dojo-props="label: 'Cancel'" ></button> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHostNodeAndVirtualHost.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHostNodeAndVirtualHost.html index 383c782d60..a2ee2c1b4b 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHostNodeAndVirtualHost.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHostNodeAndVirtualHost.html @@ -128,7 +128,7 @@ </div> </form> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" id="addVirtualHostNodeAndVirtualHost.addButton" data-dojo-props="label: 'Add'" type="submit"></button> <button data-dojo-type="dijit/form/Button" id="addVirtualHostNodeAndVirtualHost.cancelButton" data-dojo-props="label: 'Cancel'" ></button> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/common/ResourceWidget.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/common/ResourceWidget.html new file mode 100644 index 0000000000..e47fa6ca6d --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/common/ResourceWidget.html @@ -0,0 +1,48 @@ +<!-- + - + - 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. + - + --> + +<div class="dijit dijitReset dijitInline dijitLeft" id="widget_${id}" role="presentation"> + <input type="text" name="${name}_resourceLocation" + data-dojo-attach-point="resourceLocation,textbox,focusNode" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props="required:true,disabled:false"/> + + <div data-dojo-attach-point="uploadFields"> + <div data-dojo-attach-point="uploadData" style="width:auto;overflow:hidden;text-align:right"> + <span data-dojo-attach-point="selectedFile" class="infoMessage"></span> + <span data-dojo-attach-point="selectedFileStatus"></span> + </div> + <div style="text-align:right"> + <span data-dojo-attach-point="blah"></span> + <input name="${name}_uploadedFile" multiple="false" type="file" id="uploader_${id}" + data-dojo-attach-point="uploader" + data-dojo-type="dojox/form/Uploader" + data-dojo-props="label: 'Upload'"/> + <button data-dojo-attach-point="clearButton" data-dojo-type="dijit/form/Button" + data-dojo-props="label: 'Clear', disabled: true"/>Clear</button> + + </div> + <div class="clear"></div> + </div> + <div data-dojo-attach-point="unsupportedWarning" class="infoMessage hidden clear" style="overflow:scroll;"> + File upload requires a more recent browser with HTML5 support + </div> +</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css b/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css index a18562fa1a..ec31709987 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css @@ -329,3 +329,11 @@ div .messages { max-height: 140px; overflow: auto; } + +.qpidDialogPaneActionBar +{ + margin-left:-10px; + margin-right:-10px; + margin-bottom:-10px; + margin-top:5px; +}
\ No newline at end of file diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/editBroker.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/editBroker.html index 85ca617c10..993a2c7505 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/editBroker.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/editBroker.html @@ -109,7 +109,7 @@ <div class="clear"></div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" id="editBroker.saveButton" data-dojo-props="label: 'Save'">Save</button> <button data-dojo-type="dijit/form/Button" id="editBroker.cancelButton" data-dojo-props="label: 'Cancel'" ></button> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/editQueue.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/editQueue.html index aff2b5dfa5..e7b33ed6f9 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/editQueue.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/editQueue.html @@ -289,7 +289,7 @@ <div id="formEditQueue.context" ></div> </div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" id="formEditQueue.saveButton" data-dojo-props="label: 'Save'">Save</button> <button data-dojo-type="dijit/form/Button" id="formEditQueue.cancelButton" data-dojo-props="label: 'Cancel'" ></button> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHost.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHost.html index f4826016ec..8e03dfdd17 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHost.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHost.html @@ -127,7 +127,7 @@ <div id="editVirtualHost.context" ></div> </div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" id="editVirtualHost.saveButton" data-dojo-props="label: 'Save'">Save</button> <button data-dojo-type="dijit/form/Button" id="editVirtualHost.cancelButton" data-dojo-props="label: 'Cancel'" ></button> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHostNode.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHostNode.html index 46e76c31f0..cee18f7185 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHostNode.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHostNode.html @@ -44,7 +44,7 @@ <div id="editVirtualHostNode.context" ></div> </div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" id="editVirtualHostNode.saveButton" data-dojo-props="label: 'Save'">Save</button> <button data-dojo-type="dijit/form/Button" id="editVirtualHostNode.cancelButton" data-dojo-props="label: 'Cancel'" ></button> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/footer.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/footer.html index 76d1d26695..44fa4fda36 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/footer.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/footer.html @@ -19,7 +19,7 @@ - --> -<div class="footer"><p>© 2004-<span class="currentYear">2014</span> The Apache Software Foundation. +<div class="footer"><p>© 2004-<span class="currentYear">2015</span> The Apache Software Foundation. <br/> Apache Qpid, Qpid, Apache, the Apache feather logo, and the Apache Qpid project logo are trademarks of The Apache Software Foundation. diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/grid/showColumnDefDialog.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/grid/showColumnDefDialog.html index 5b6b8ad774..535b9a1fe5 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/grid/showColumnDefDialog.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/grid/showColumnDefDialog.html @@ -23,7 +23,7 @@ <div>Select columns to display:</div> <div class="columnList"></div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button value="Display" data-dojo-type="dijit.form.Button" class="displayButton" data-dojo-props="label: 'Display' "></button> <button value="Cancel" data-dojo-type="dijit.form.Button" data-dojo-props="label: 'Cancel'" diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/grid/showRowNumberLimitDialog.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/grid/showRowNumberLimitDialog.html index 087d54c0f9..cacdf49e66 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/grid/showRowNumberLimitDialog.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/grid/showRowNumberLimitDialog.html @@ -24,7 +24,7 @@ <input class="rowNumberLimit" data-dojo-type="dijit.form.NumberSpinner" data-dojo-props="invalidMessage: 'Invalid value', required: true, smallDelta: 1,mconstraints: {min:1,max:65535,places:0, pattern: '#####'}, label: 'Maximum number of rows:', name: 'rowNumberLimit'"></input> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button value="Submit" data-dojo-type="dijit.form.Button" class="submitButton" data-dojo-props="label: 'Submit' "></button> <button value="Cancel" data-dojo-type="dijit.form.Button" data-dojo-props="label: 'Cancel'" diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/group/addGroupMember.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/group/addGroupMember.html index 0372468f91..e479e8cb74 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/group/addGroupMember.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/group/addGroupMember.html @@ -30,8 +30,9 @@ </table> <br/> - <!-- submit buttons --> - <input type="submit" value="Add Group Member" label="Add Group Member" dojoType="dijit.form.Button" /> + <div class="dijitDialogPaneActionBar"> + <input type="submit" value="Add Group Member" label="Add Group Member" dojoType="dijit.form.Button" /> + </div> </form> </div> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/group/showGroup.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/group/showGroup.html index 4fddf727d0..c84e794ac1 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/group/showGroup.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/group/showGroup.html @@ -23,8 +23,10 @@ <br/> <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Group Members'"> <div class="groupMembers"></div> - <button data-dojo-type="dijit.form.Button" class="addGroupMemberButton" type="button">Add Group Member</button> - <button data-dojo-type="dijit.form.Button" class="removeGroupMemberButton" type="button">Remove Group Members</button> + <div class="dijitDialogPaneActionBar"> + <button data-dojo-type="dijit.form.Button" class="addGroupMemberButton" type="button">Add Group Member</button> + <button data-dojo-type="dijit.form.Button" class="removeGroupMemberButton" type="button">Remove Group Members</button> + </div> </div> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/addGroup.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/addGroup.html index 8d3431808a..29ce2ebe6c 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/addGroup.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/addGroup.html @@ -30,8 +30,9 @@ </table> <br/> - <!-- submit buttons --> - <input type="submit" value="Create Group" label="Create Group" dojoType="dijit.form.Button" /> + <div class="dijitDialogPaneActionBar"> + <input type="submit" value="Create Group" label="Create Group" dojoType="dijit.form.Button" /> + </div> </form> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/groupfile/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/groupfile/add.html new file mode 100644 index 0000000000..7fc458cd4f --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/groupfile/add.html @@ -0,0 +1,37 @@ +<!-- + - + - 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. + - + --> +<div> + <div class="clear"> + <div class="formLabel-labelCell tableContainer-labelCell">Path*:</div> + <div class="formLabel-controlCell tableContainer-valueCell"> + <input type="text" class="addGroupProviderPath" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props=" + name: 'path', + required: true, + placeHolder: 'path/to/group/file', + title: 'Enter path to file with groups', + promptMessage: 'Enter path to file with groups'"/> + </div> + </div> + + <div class="clear"></div> +</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/groupfile/show.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/groupfile/show.html new file mode 100644 index 0000000000..740c65fd38 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/groupfile/show.html @@ -0,0 +1,25 @@ +<!-- + ~ 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. + --> +<div> + <div class="clear"> + <div class="formLabel-labelCell">Path to file:</div> + <div ><span class="path" ></span></div> + </div> + <div class="clear"></div> +</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/showFileGroupManager.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/showGroupManagingGroupProvider.html index d266971ee2..62a6c7537c 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/showFileGroupManager.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/groupprovider/showGroupManagingGroupProvider.html @@ -19,16 +19,12 @@ - --> <div class="FileGroupManager"> - <div class="clear"> - <div class="formLabel-labelCell">Path:</div> - <div class="path"></div> - </div> - <div class="clear"></div> - <br/> <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Groups'"> <div class="groups"></div> - <button data-dojo-type="dijit.form.Button" class="addGroupButton">Add Group</button> - <button data-dojo-type="dijit.form.Button" class="deleteGroupButton">Delete Groups</button> + <div class="dijitDialogPaneActionBar"> + <button data-dojo-type="dijit.form.Button" class="addGroupButton">Add Group</button> + <button data-dojo-type="dijit.form.Button" class="deleteGroupButton">Delete Groups</button> + </div> </div> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html index 379a25bbcd..896640fd67 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html @@ -125,7 +125,7 @@ </div> </div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <input type="button" id="errorDialog.button.cancel" value="Cancel" label="Cancel" dojoType="dijit.form.Button" onClick="dijit.byId('errorDialog').hide();"/> <input type="button" id="errorDialog.button.relogin" value="Login" label="Login" dojoType="dijit.form.Button" onClick="dijit.byId('errorDialog').hide(); window.location='logout';"/> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/FormWidgetMixin.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/FormWidgetMixin.js new file mode 100644 index 0000000000..11160e9608 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/FormWidgetMixin.js @@ -0,0 +1,102 @@ +/* + * + * 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. + * + */ +define(["dojo/_base/declare"], function(declare) +{ + return declare("qpid.common.FormWidgetMixin", null, + { + name: "", + value: "", + _onChangeActive: false, + + compare: function(val1, val2) + { + if(typeof val1 == "number" && typeof val2 == "number") + { + return (isNaN(val1) && isNaN(val2)) ? 0 : val1 - val2; + } + else if(val1 > val2) + { + return 1; + } + else if(val1 < val2) + { + return -1; + } + else + { + return 0; + } + }, + onChange: function() + { + }, + _setValueAttr: function(newValue, priorityChange) + { + this._handleOnChange(newValue, priorityChange); + }, + _handleOnChange: function(newValue, priorityChange) + { + this._set("value", newValue); + if(this._lastValueReported == undefined && (priorityChange === null || !this._onChangeActive)) + { + this._resetValue = this._lastValueReported = newValue; + } + this._pendingOnChange = this._pendingOnChange || (typeof newValue != typeof this._lastValueReported) + || (this.compare(newValue, this._lastValueReported) != 0); + if(( priorityChange || priorityChange === undefined) && this._pendingOnChange) + { + this._lastValueReported = newValue; + this._pendingOnChange = false; + if(this._onChangeActive) + { + if(this._onChangeHandle) + { + this._onChangeHandle.remove(); + } + this._onChangeHandle = this.defer(function() { this._onChangeHandle = null; this.onChange(newValue); }); + } + } + }, + create: function() + { + this.inherited(arguments); + this._onChangeActive = true; + }, + destroy: function() + { + if(this._onChangeHandle) + { + this._onChangeHandle.remove(); + this.onChange(this._lastValueReported); + } + this.inherited(arguments); + }, + undo: function() + { + this._setValueAttr(this._lastValueReported, false); + }, + reset: function() + { + this._hasBeenBlurred = false; + this._setValueAttr(this._resetValue, true); + } + }); +});
\ No newline at end of file diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js new file mode 100644 index 0000000000..f603c96ff3 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js @@ -0,0 +1,178 @@ +/* + * + * 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. + * + */ +define([ + "dojo/_base/declare", + "dojo/_base/array", + "dojo/_base/lang", + "qpid/common/util", + "dijit/_Widget", + "dijit/_TemplatedMixin", + "dijit/_WidgetsInTemplateMixin", + "qpid/common/FormWidgetMixin", + "dojo/text!common/ResourceWidget.html", + "dojox/html/entities", + "dojox/form/Uploader", + "dijit/form/Button", + "dijit/form/ValidationTextBox", + "dojox/validate/us", + "dojox/validate/web", + "dojo/domReady!"], +function (declare, array, lang, util, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, FormWidgetMixin, template, entities) +{ + + return declare("qpid.common.ResourceWidget", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, FormWidgetMixin], + { + templateString: template, + fileReaderSupported: window.FileReader ? true : false, + displayWarningWhenFileReaderUnsupported: false, + isDebug: false, + + buildRendering: function() + { + //Strip out the apache comment header from the template html as comments unsupported. + this.templateString = this.templateString.replace(/<!--[\s\S]*?-->/g, ""); + this.inherited(arguments); + }, + postCreate: function() + { + this.inherited(arguments); + + if(this._resetValue === undefined) + { + this._lastValueReported = this._resetValue = this.value; + } + + var that = this; + + if (this.fileReaderSupported) + { + this.fileReader= new FileReader(); + this.fileReader.onload = function(evt) {that._uploadFileComplete(evt);}; + this.fileReader.onerror = function(ex) {console.error("Failed to load file for " + this.name, ex);}; + this.uploader.on("change", function(selected){that._fileChanged(selected)}); + this.clearButton.on("click", function(event){that._fileClearButtonClicked(event)}); + } + else + { + // Fall back for IE8/9 which do not support FileReader + this.uploadFields.style.display = "none"; + if (displayWarningWhenFileReaderUnsupported) + { + this.unsupportedWarning.className = this.unsupportedWarning.className.replace("hidden", ""); + } + } + this.resourceLocation.on("blur", function(){that._pathChanged()}); + this._originalValue = arguments.value; + if (this.placeHolder) + { + this.resourceLocation.set("placeHolder", this.placeHolder); + } + if (this.promptMessage) + { + this.resourceLocation.set("promptMessage", this.promptMessage); + } + if (this.title) + { + this.resourceLocation.set("title", this.title); + } + this.resourceLocation.set("required", this.required ? true : false); + this.uploadData.style.display = "none"; + }, + startup: function() + { + if (this.fileReaderSupported) + { + this.uploader.startup(); + } + }, + _fileChanged: function (evt) + { + var file = this.uploader.domNode.children[0].files[0]; + this.selectedFileName = file.name; + this.selectedFile.innerHTML = file.name; + this.selectedFileStatus.className = "loadingIcon"; + if (this.isDebug) + { + this._log("Beginning to read file " + file.name + " for " + this.name); + } + this.fileReader.readAsDataURL(file); + }, + _uploadFileComplete: function(evt) + { + var reader = evt.target; + var result = reader.result; + if (this.isDebug) + { + this._log(this.name + " file read complete, contents " + result); + } + this.set("value", result); + }, + _fileClearButtonClicked: function(event) + { + this.uploader.reset(); + this.set("value", this._resetValue); + }, + _pathChanged: function() + { + var serverPathValue = this.resourceLocation.get("value") || this._resetValue; + this.set("value", serverPathValue); + }, + _setValueAttr: function(newValue, priorityChange) + { + var isDataUrl = newValue && newValue.indexOf("data:") == 0; + if (isDataUrl) + { + this.uploadData.style.display = "block"; + this.selectedFileStatus.className = "loadedIcon"; + this.selectedFile.innerHTML = this.selectedFileName || "uploaded data"; + this.resourceLocation.set("value", ""); + this.resourceLocation.setDisabled(true); + this.resourceLocation.set("required", false); + this.clearButton.setDisabled(false); + this.selectedFileStatus.className = "loadedIcon"; + } + else + { + this.resourceLocation.set("value", newValue); + this.selectedFileName = null; + this.selectedFileStatus.className = ""; + this.selectedFile.innerHTML = ""; + this.resourceLocation.set("required", this.required ? true : false); + this.resourceLocation.setDisabled(false); + this.clearButton.setDisabled(true); + this.uploadData.style.display = "none"; + } + this.inherited(arguments); + }, + _log: function(message) + { + if (this.isDebug) + { + console.log(message); + } + }, + _setPlaceHolderAttr: function(newValue) + { + this.resourceLocation.set("placeHolder", newValue); + } + } + ); +}); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js index c62ba5d5d4..1520cb8f7a 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js @@ -29,7 +29,7 @@ define(["dojo/_base/xhr", _init: function () { var that = this; - xhr.get({sync: true, handleAs: "json", url: "service/metadata", load: function(metadata){that._onMetadata(metadata)}}); + xhr.get({sync: true, handleAs: "json", url: "service/metadata", load: function(data){that._onMetadata(data)}}); }, _onMetadata: function (metadata) { @@ -68,7 +68,8 @@ define(["dojo/_base/xhr", }, implementsManagedInterface: function (category, type, managedInterfaceName) { - return this.getMetaData(category, type).managedInterfaces.indexOf(managedInterfaceName) >= 0; + var managedInterfaces = this.getMetaData(category, type).managedInterfaces; + return array.indexOf(managedInterfaces, managedInterfaceName) >= 0 ; }, validChildTypes: function (category, type, childCategory) { diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js index 161ce4f83c..8545d2da75 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js @@ -33,12 +33,11 @@ define(["dojo/_base/xhr", "dojo/dom-style", "dojox/html/entities", "dojo/dom", - "qpid/management/addPreferencesProvider", "qpid/management/PreferencesProvider", "qpid/management/authenticationprovider/PrincipalDatabaseAuthenticationManager", "dojo/domReady!"], function (xhr, parser, query, connect, properties, updater, util, UpdatableStore, EnhancedGrid, - addAuthenticationProvider, event, registry, domStyle, entities, dom, addPreferencesProvider, PreferencesProvider, PrincipalDatabaseAuthenticationManager) { + addAuthenticationProvider, event, registry, domStyle, entities, dom, PreferencesProvider, PrincipalDatabaseAuthenticationManager) { function AuthenticationProvider(name, parent, controller) { this.name = name; @@ -79,14 +78,6 @@ define(["dojo/_base/xhr", that.deleteAuthenticationProvider(); }); - var addPreferencesProviderButton = query(".addPreferencesProviderButton", contentPane.containerNode)[0]; - var addPreferencesProviderWidget = registry.byNode(addPreferencesProviderButton); - connect.connect(addPreferencesProviderWidget, "onClick", - function(evt){ - event.stop(evt); - that.addPreferencesProvider(); - }); - authProviderUpdater.update(); if (util.isProviderManagingUsers(authProviderUpdater.authProviderData.type)) { @@ -136,14 +127,6 @@ define(["dojo/_base/xhr", } }; - AuthenticationProvider.prototype.addPreferencesProvider = function() { - if (this.authProviderUpdater && this.authProviderUpdater.authProviderData - && (!this.authProviderUpdater.authProviderData.preferencesproviders - || !this.authProviderUpdater.authProviderData.preferencesproviders[0])){ - addPreferencesProvider.show(this.name); - } - }; - function AuthProviderUpdater(node, authProviderObj, controller, authenticationProvider) { this.controller = controller; @@ -154,7 +137,6 @@ define(["dojo/_base/xhr", this.preferencesProviderType=dom.byId("preferencesProviderType"); this.preferencesProviderName=dom.byId("preferencesProviderName"); this.preferencesProviderState=dom.byId("preferencesProviderState"); - this.addPreferencesProviderButton = query(".addPreferencesProviderButton", node)[0]; this.editPreferencesProviderButton = query(".editPreferencesProviderButton", node)[0]; this.deletePreferencesProviderButton = query(".deletePreferencesProviderButton", node)[0]; this.preferencesProviderAttributes = dom.byId("preferencesProviderAttributes") @@ -169,7 +151,6 @@ this.authenticationProviderDetailsContainer = query(".authenticationProviderDeta { if (preferencesProviderData) { - this.addPreferencesProviderButton.style.display = 'none'; if (!this.preferencesProvider) { var preferencesProvider =new PreferencesProvider(preferencesProviderData.name, this.authProviderData); @@ -184,7 +165,6 @@ this.authenticationProviderDetailsContainer = query(".authenticationProviderDeta { this.preferencesProvider.update(null); } - this.addPreferencesProviderButton.style.display = 'inline'; } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js index 09473524b5..f739e52665 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js @@ -22,18 +22,24 @@ define(["dojo/_base/xhr", "dojo/parser", "dojo/query", "dojo/_base/connect", + "dojo/_base/array", + "dojo/_base/event", "qpid/common/properties", "qpid/common/updater", "qpid/common/util", + "qpid/common/metadata", "qpid/common/UpdatableStore", "dojox/grid/EnhancedGrid", "dijit/registry", - "dojo/_base/event", "dojox/html/entities", + "dojo/text!showGroupProvider.html", + "qpid/management/addGroupProvider", "dojox/grid/enhanced/plugins/Pagination", "dojox/grid/enhanced/plugins/IndirectSelection", "dojo/domReady!"], - function (xhr, parser, query, connect, properties, updater, util, UpdatableStore, EnhancedGrid, registry, event, entities) { + function (xhr, parser, query, connect, array, event, properties, updater, util, metadata, UpdatableStore, + EnhancedGrid, registry, entities, template, addGroupProvider) + { function GroupProvider(name, parent, controller) { this.name = name; @@ -45,38 +51,63 @@ define(["dojo/_base/xhr", return "GroupProvider: " + this.name ; }; - GroupProvider.prototype.open = function(contentPane) { + GroupProvider.prototype.open = function(contentPane) + { var that = this; this.contentPane = contentPane; - xhr.get({url: "showGroupProvider.html", - sync: true, - load: function(data) { - contentPane.containerNode.innerHTML = data; - parser.parse(contentPane.containerNode); - - that.groupProviderAdapter = new GroupProviderUpdater(contentPane.containerNode, that.modelObj, that.controller); - - updater.add( that.groupProviderAdapter ); - - that.groupProviderAdapter.update(); - - var deleteButton = query(".deleteGroupProviderButton", contentPane.containerNode)[0]; - var deleteWidget = registry.byNode(deleteButton); - connect.connect(deleteWidget, "onClick", - function(evt){ - event.stop(evt); - that.deleteGroupProvider(); - }); - }}); + contentPane.containerNode.innerHTML = template; + parser.parse(contentPane.containerNode); + + this.groupProviderUpdater = new GroupProviderUpdater(contentPane.containerNode, this.modelObj, this.controller); + + // load data + this.groupProviderUpdater.update(); + + this.deleteButton = registry.byNode(query(".deleteGroupProviderButton", contentPane.containerNode)[0]); + this.deleteButton.on("click", function(evt){ event.stop(evt); that.deleteGroupProvider(); }); + + this.editButton = registry.byNode(query(".editGroupProviderButton", contentPane.containerNode)[0]); + this.editButton.on("click", function(evt){ event.stop(evt); that.editGroupProvider(); }); + + var type = this.groupProviderUpdater.groupProviderData.type; + var providerDetailsNode = query(".providerDetails", contentPane.containerNode)[0]; + + require(["qpid/management/groupprovider/"+ encodeURIComponent(type.toLowerCase()) + "/show"], + function(DetailsUI) + { + that.groupProviderUpdater.details = new DetailsUI({containerNode: providerDetailsNode, parent: that}); + that.groupProviderUpdater.details.update(that.groupProviderUpdater.groupProviderData); + }); + + var managedInterfaces = metadata.getMetaData("GroupProvider", type).managedInterfaces; + if (managedInterfaces) + { + + var managedInterfaceUI = this.groupProviderUpdater.managedInterfaces; + + array.forEach(managedInterfaces, + function(managedInterface) + { + require(["qpid/management/groupprovider/" + encodeURIComponent(managedInterface)], + function(ManagedInterface) + { + managedInterfaceUI[ManagedInterface] = new ManagedInterface(providerDetailsNode, that.modelObj, that.controller); + managedInterfaceUI[ManagedInterface].update(that.groupProviderUpdater.groupProviderData); + }); + }); + } + + updater.add( this.groupProviderUpdater ); }; + GroupProvider.prototype.close = function() { - updater.remove( this.groupProviderAdapter ); + updater.remove( this.groupProviderUpdater ); }; GroupProvider.prototype.deleteGroupProvider = function() { var warnMessage = ""; - if (this.groupProviderAdapter.groupProviderData && this.groupProviderAdapter.groupProviderData.type.indexOf("File") != -1) + if (this.groupProviderUpdater.groupProviderData && this.groupProviderUpdater.groupProviderData.type.indexOf("File") != -1) { warnMessage = "NOTE: provider deletion will also remove the group file on disk.\n\n"; } @@ -96,7 +127,23 @@ define(["dojo/_base/xhr", util.xhrErrorHandler(this.failureReason); } } - }; + }; + + GroupProvider.prototype.editGroupProvider = function() + { + xhr.get( + { + url: this.groupProviderUpdater.query, + sync: true, + content: { actuals: true }, + handleAs: "json", + load: function(actualData) + { + addGroupProvider.show(actualData[0]); + } + } + ); + } function GroupProviderUpdater(node, groupProviderObj, controller) { @@ -105,27 +152,8 @@ define(["dojo/_base/xhr", this.type = query(".type", node)[0]; this.state = query(".state", node)[0]; this.query = "api/latest/groupprovider/"+encodeURIComponent(groupProviderObj.name); - this.typeUI ={"GroupFile": "FileGroupManager"}; - var that = this; - - xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}) - .then(function(data) - { - that.groupProviderData = data[0]; - - util.flattenStatistics( that.groupProviderData ); - - that.updateHeader(); - - var ui = that.typeUI[that.groupProviderData.type]; - require(["qpid/management/groupprovider/"+ ui], - function(SpecificProvider) { - that.details = new SpecificProvider(query(".providerDetails", node)[0], groupProviderObj, controller); - that.details.update(); - }); - - }); - + this.managedInterfaces = {}; + this.details = null; } GroupProviderUpdater.prototype.updateHeader = function() @@ -138,6 +166,28 @@ define(["dojo/_base/xhr", GroupProviderUpdater.prototype.update = function() { var that = this; + xhr.get({url: this.query, sync: true, handleAs: "json"}).then(function(data) {that._update(data[0]);}); + }; + + GroupProviderUpdater.prototype._update = function(data) + { + this.groupProviderData = data; + util.flattenStatistics( this.groupProviderData ); + this.updateHeader(); + + if (this.details) + { + this.details.update(this.groupProviderData); + } + + for(var managedInterface in this.managedInterfaces) + { + var managedInterfaceUI = this.managedInterfaces[managedInterface]; + if (managedInterfaceUI) + { + managedInterfaceUI.update(this.groupProviderData); + } + } }; return GroupProvider; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js index 6cb9ad727d..0f23053c2d 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js @@ -54,10 +54,8 @@ define(["dojo/dom", parser.parse(contentPane.containerNode); that.keyStoreUpdater = new KeyStoreUpdater(contentPane.containerNode, that.modelObj, that.controller, that.url); - - updater.add( that.keyStoreUpdater ); - that.keyStoreUpdater.update(); + updater.add( that.keyStoreUpdater ); var deleteKeyStoreButton = query(".deleteStoreButton", contentPane.containerNode)[0]; var node = registry.byNode(deleteKeyStoreButton); @@ -132,13 +130,20 @@ define(["dojo/dom", that.keyStoreData = data[0]; that.updateHeader(); - require(["qpid/management/store/" + encodeURIComponent(that.keyStoreData.type.toLowerCase()) + "/show"], + if (that.details) + { + that.details.update(that.keyStoreData); + } + else + { + require(["qpid/management/store/" + encodeURIComponent(that.keyStoreData.type.toLowerCase()) + "/show"], function(DetailsUI) { that.details = new DetailsUI({containerNode:that.keyStoreDetailsContainer, parent: that}); that.details.update(that.keyStoreData); } ); + } }); }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js index 35ccbf9cae..0d40669823 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js @@ -56,7 +56,6 @@ define(["dojo/_base/xhr", that.containerNode = node; that.parentObject = parentObject; that.preferencesProviderType=query(".preferencesProviderType", node)[0]; - that.preferencesProviderName=query(".preferencesProviderName", node)[0]; that.preferencesProviderState=query(".preferencesProviderState", node)[0]; that.editPreferencesProviderButton = query(".editPreferencesProviderButton", node)[0]; that.deletePreferencesProviderButton = query(".deletePreferencesProviderButton", node)[0]; @@ -137,7 +136,6 @@ define(["dojo/_base/xhr", this.editPreferencesProviderButton.style.display = 'inline'; this.deletePreferencesProviderButton.style.display = 'inline'; this.preferencesProviderType.innerHTML = entities.encode(String(data.type)); - this.preferencesProviderName.innerHTML = entities.encode(String(data.name)); this.preferencesProviderState.innerHTML = entities.encode(String(data.state)); if (!this.details) { diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js index f3fa06ccba..82e2b204f9 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js @@ -54,10 +54,8 @@ define(["dojo/dom", parser.parse(contentPane.containerNode); that.keyStoreUpdater = new KeyStoreUpdater(contentPane.containerNode, that.modelObj, that.controller, that.url); - - updater.add( that.keyStoreUpdater ); - that.keyStoreUpdater.update(); + updater.add( that.keyStoreUpdater ); var deleteTrustStoreButton = query(".deleteStoreButton", contentPane.containerNode)[0]; var node = registry.byNode(deleteTrustStoreButton); @@ -129,14 +127,20 @@ define(["dojo/dom", { that.trustStoreData = data[0]; that.updateHeader(); - - require(["qpid/management/store/" + encodeURIComponent(that.trustStoreData.type.toLowerCase()) + "/show"], - function(DetailsUI) - { - that.details = new DetailsUI({containerNode:that.keyStoreDetailsContainer, parent: that}); - that.details.update(that.trustStoreData); - } - ); + if (that.details) + { + that.details.update(that.trustStoreData); + } + else + { + require(["qpid/management/store/" + encodeURIComponent(that.trustStoreData.type.toLowerCase()) + "/show"], + function(DetailsUI) + { + that.details = new DetailsUI({containerNode:that.keyStoreDetailsContainer, parent: that}); + that.details.update(that.trustStoreData); + } + ); + } }); }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js index e05fc7582d..17b7edcec9 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js @@ -60,6 +60,7 @@ define(["dojo/_base/xhr", this.authenticationProviderName = registry.byId("addAuthenticationProvider.name"); this.authenticationProviderName.set("regExpGen", util.nameOrContextVarRegexp); + this.authenticationProviderName.on("change", function(newValue){that.preferencesProviderForm.preferencesProviderNameWidget.set("value",newValue);}); this.dialog = registry.byId("addAuthenticationProvider"); this.addButton = registry.byId("addAuthenticationProvider.addButton"); @@ -102,7 +103,7 @@ define(["dojo/_base/xhr", this.initialData = actualData; this.effectiveData = effectiveData; this.authenticationProviderType.set("value", actualData.type); - this.authenticationProviderName.set("value", actualData.name); + this.authenticationProviderType.set("disabled", true); this.authenticationProviderName.set("disabled", true); if (actualData.preferencesproviders && actualData.preferencesproviders[0]) @@ -112,7 +113,9 @@ define(["dojo/_base/xhr", else { this.preferencesProviderForm.reset(); + this.preferencesProviderForm.preferencesProviderNameWidget.set("value", actualData.name); } + this.authenticationProviderName.set("value", actualData.name); } else { diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addGroupProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addGroupProvider.js index 82281ad3d3..f158b8ceb6 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addGroupProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addGroupProvider.js @@ -18,7 +18,7 @@ * under the License. * */ -define(["dojo/_base/lang", +define([ "dojo/_base/xhr", "dojo/dom", "dojo/dom-construct", @@ -26,8 +26,10 @@ define(["dojo/_base/lang", "dojo/parser", "dojo/_base/array", "dojo/_base/event", - 'dojo/_base/json', + 'dojo/json', "qpid/common/util", + "qpid/common/metadata", + "dojo/text!addGroupProvider.html", "dojo/store/Memory", "dojox/validate/us", "dojox/validate/web", @@ -42,140 +44,152 @@ define(["dojo/_base/lang", "dijit/layout/ContentPane", "dojox/layout/TableContainer", "dojo/domReady!"], - function (lang, xhr, dom, construct, registry, parser, array, event, json, util) { - - var addGroupProvider = {}; - - addGroupProvider.show = function(groupProvider) { - var fields = [{ - name: "name", - createWidget: function(groupProvider) { - return new dijit.form.ValidationTextBox({ - required: true, - value: groupProvider.name, - disabled: groupProvider.name ? true : false, - label: "Name*:", - regexp: "^[\x20-\x2e\x30-\x7F]{1,255}$", - promptMessage: "Name of group provider.", - placeHolder: "name", - name: "name"}); - } - }, { - name: "type", - createWidget: function(groupProvider) { - - var typeContainer = construct.create("div"); - - var typeListContainer = new dojox.layout.TableContainer({ - cols: 1, - "labelWidth": "300", - customClass: "formLabel", - showLabels: true, - orientation: "horiz" - }); - - typeContainer.appendChild(typeListContainer.domNode); - - var providers = []; - var fieldSetContainers = {}; - xhr.get({ - url: "service/helper?action=ListGroupProviderAttributes", - handleAs: "json", - sync: true - }).then( - function(data) { - var providerIndex = 0; - - for (var providerType in data) { - if (data.hasOwnProperty(providerType)) { - providers[providerIndex++] = {id: providerType, name: providerType}; - - var attributes = data[providerType].attributes; - var descriptions = data[providerType].descriptions; - - var layout = new dojox.layout.TableContainer( { - cols: 1, - "labelWidth": "300", - customClass: "formLabel", - showLabels: true, - orientation: "horiz" - }); - - for(var i=0; i < attributes.length; i++) { - if ("type" == attributes[i]) - { - continue; - } - var labelValue = attributes[i]; - if (descriptions && descriptions[attributes[i]]) - { - labelValue = descriptions[attributes[i]]; - } - var text = new dijit.form.TextBox({ - label: labelValue + ":", - name: attributes[i] - }); - layout.addChild(text); - } - - typeContainer.appendChild(layout.domNode); - fieldSetContainers[providerType] = layout; - } - } - }); - - var providersStore = new dojo.store.Memory({ data: providers }); - - var typeList = new dijit.form.FilteringSelect({ - required: true, - value: groupProvider.type, - store: providersStore, - label: "Type*:", - name: "type"}); - - typeListContainer.addChild(typeList); - - var onChangeHandler = function onChangeHandler(newValue){ - for (var i in fieldSetContainers) { - var container = fieldSetContainers[i]; - var descendants = container.getChildren(); - for(var i in descendants){ - var descendant = descendants[i]; - var propName = descendant.name; - if (propName) { - descendant.set("disabled", true); - } + function (xhr, dom, construct, registry, parser, array, event, json, util, metadata, template) + { + + var addGroupProvider = + { + init: function() + { + var that=this; + this.containerNode = construct.create("div", {innerHTML: template}); + parser.parse(this.containerNode); + + this.groupProviderName = registry.byId("addGroupProvider.name"); + this.groupProviderName.set("regExpGen", util.nameOrContextVarRegexp); + + this.dialog = registry.byId("addGroupProvider"); + this.addButton = registry.byId("addGroupProvider.addButton"); + this.cancelButton = registry.byId("addGroupProvider.cancelButton"); + this.cancelButton.on("click", function(e){that._cancel(e);}); + this.addButton.on("click", function(e){that._add(e);}); + + this.groupProviderTypeFieldsContainer = dom.byId("addGroupProvider.typeFields"); + this.groupProviderForm = registry.byId("addGroupProvider.form"); + + this.groupProviderType = registry.byId("addGroupProvider.type"); + this.groupProviderType.on("change", function(type){that._groupProviderTypeChanged(type);}); + + var supportedTypes = metadata.getTypesForCategory("GroupProvider"); + supportedTypes.sort(); + var supportedTypesStore = util.makeTypeStore(supportedTypes); + this.groupProviderType.set("store", supportedTypesStore); + }, + show: function(actualData) + { + this.initialData = actualData; + this.groupProviderForm.reset(); + + if (actualData) + { + this._destroyTypeFields(this.containerNode); + this._initFields(actualData); + } + this.groupProviderName.set("disabled", actualData == null ? false : true); + this.groupProviderType.set("disabled", actualData == null ? false : true); + this.dialog.set("title", actualData == null ? "Add Group Provider" : "Edit Group Provider - " + actualData.name) + this.dialog.show(); + }, + _initFields:function(data) + { + var type = data["type"]; + var attributes = metadata.getMetaData("GroupProvider", type).attributes; + for(var name in attributes) + { + var widget = registry.byId("addGroupProvider."+name); + if (widget) + { + widget.set("value", data[name]); } - container.domNode.style.display = "none"; - } - var container = fieldSetContainers[newValue]; - if (container) - { - container.domNode.style.display = "block"; - var descendants = container.getChildren(); - for(var i in descendants){ - var descendant = descendants[i]; - var propName = descendant.name; - if (propName) { - descendant.set("disabled", false); - } + } + }, + _cancel: function(e) + { + event.stop(e); + this.dialog.hide(); + }, + _add: function(e) + { + event.stop(e); + this._submit(); + }, + _submit: function() + { + if (this.groupProviderForm.validate()) + { + var success = false,failureReason=null; + + var groupProviderData = util.getFormWidgetValues(this.groupProviderForm, this.initialData); + var encodedName = encodeURIComponent(this.groupProviderName.value); + var jsonString = json.stringify(groupProviderData); + + try { + xhr.put( + { + url: "api/latest/groupprovider/" + encodedName, + sync: true, + handleAs: "json", + headers: { "Content-Type": "application/json"}, + putData: jsonString, + load: function(x) {success = true; }, + error: function(error) {success = false; failureReason = error;} + }); + } + catch (e) + { + console.warn(e); } - } - }; - typeList.on("change", onChangeHandler); - onChangeHandler(typeList.value); - return new dijit.layout.ContentPane({content: typeContainer, style:{padding: 0}}); - } - }]; - util.showSetAttributesDialog( - fields, - groupProvider ? groupProvider : {}, - "api/latest/groupprovider" + (name ? "/" + encodeURIComponent(name.name) : ""), - groupProvider ? "Edit group provider - " + groupProvider.name : "Add group provider", - "Group", - groupProvider && groupProvider.type ? groupProvider.type : "Group", - groupProvider ? false : true); + if (success == true) + { + this.dialog.hide(); + } + else + { + util.xhrErrorHandler(failureReason); + } + } + else + { + alert('Form contains invalid data. Please correct first'); + } + }, + _groupProviderTypeChanged: function(type) + { + this._destroyTypeFields(this.groupProviderTypeFieldsContainer); + if (type) + { + var that = this; + require([ "qpid/management/groupprovider/" + type.toLowerCase() + "/add"], function(typeUI) + { + try + { + typeUI.show({containerNode: that.groupProviderTypeFieldsContainer, parent: that, data: that.initialData}); + util.applyMetadataToWidgets(that.groupProviderTypeFieldsContainer, "GroupProvider", type); + } + catch(e) + { + console.warn(e); + } + }); + } + }, + _destroyTypeFields: function(typeFieldsContainer) + { + var widgets = registry.findWidgets(typeFieldsContainer); + array.forEach(widgets, function(item) { item.destroyRecursive();}); + construct.empty(typeFieldsContainer); + } }; + + try + { + addGroupProvider.init(); + } + catch(e) + { + console.warn(e); + } return addGroupProvider; + });
\ No newline at end of file diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js index 98068f2376..5a42f12870 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js @@ -80,16 +80,17 @@ define(["dojo/_base/lang", }, show: function(effectiveData) { + this.effectiveData = effectiveData; this.storeForm.reset(); if (effectiveData) { - this.effectiveData = effectiveData; this._destroyTypeFields(this.containerNode); this._initFields(effectiveData); } this.storeName.set("disabled", effectiveData == null ? false : true); this.storeType.set("disabled", effectiveData == null ? false : true); + this.dialog.set("title", effectiveData == null ? "Add Key Store" : "Edit Key Store - " + effectiveData.name) this.dialog.show(); }, _initFields:function(data) diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js index 8f63a8c935..8ac6be04cc 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js @@ -34,11 +34,12 @@ define(["dojo/_base/xhr", "dojox/grid/EnhancedGrid", "dojo/data/ObjectStore", "qpid/management/group/addGroupMember", + "dojox/html/entities", "dojox/grid/enhanced/plugins/Pagination", "dojox/grid/enhanced/plugins/IndirectSelection", "dojo/domReady!"], function (xhr, parser, query, registry, connect, event, json, properties, updater, util, formatter, - UpdatableStore, JsonRest, EnhancedGrid, ObjectStore, addGroupMember) { + UpdatableStore, JsonRest, EnhancedGrid, ObjectStore, addGroupMember, entities) { function Group(name, parent, controller) { this.name = name; @@ -78,10 +79,8 @@ define(["dojo/_base/xhr", parser.parse(contentPane.containerNode); that.groupUpdater = new GroupUpdater(contentPane.containerNode, that, that.controller); - - updater.add( that.groupUpdater ); - that.groupUpdater.update(); + updater.add( that.groupUpdater ); var addGroupMemberButton = query(".addGroupMemberButton", contentPane.containerNode)[0]; connect.connect(registry.byNode(addGroupMemberButton), "onClick", @@ -128,7 +127,7 @@ define(["dojo/_base/xhr", "durable", "lifetimePolicy", "type"]); - + this.name.innerHTML = entities.encode(String(groupObj.getGroupName())); this.query = "api/latest/groupmember/"+ encodeURIComponent(groupObj.getGroupProviderName()) + "/" + encodeURIComponent(groupObj.getGroupName()); xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then(function(data) diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/FileGroupManager.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/GroupManagingGroupProvider.js index 4ee411633f..ea12280d0d 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/FileGroupManager.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/GroupManagingGroupProvider.js @@ -34,6 +34,7 @@ define(["dojo/_base/xhr", "qpid/common/updater", "qpid/common/UpdatableStore", "dojox/grid/EnhancedGrid", + "dojo/text!groupprovider/showGroupManagingGroupProvider.html", "dojox/grid/enhanced/plugins/Pagination", "dojox/grid/enhanced/plugins/IndirectSelection", "dojox/validate/us", "dojox/validate/web", @@ -44,49 +45,17 @@ define(["dojo/_base/xhr", "dijit/form/Form", "dijit/form/DateTextBox", "dojo/domReady!"], - function (xhr, dom, parser, query, construct, connect, win, event, json, registry, entities, util, properties, updater, UpdatableStore, EnhancedGrid) { - function DatabaseGroupManager(containerNode, groupProviderObj, controller) { + function (xhr, dom, parser, query, construct, connect, win, event, json, registry, entities, util, properties, + updater, UpdatableStore, EnhancedGrid, template) + { + function GroupManagingGroupProvider(containerNode, groupProviderObj, controller) + { var node = construct.create("div", null, containerNode, "last"); var that = this; this.name = groupProviderObj.name; - xhr.get({url: "groupprovider/showFileGroupManager.html", - sync: true, - load: function(data) { - node.innerHTML = data; - parser.parse(node); - - - that.groupDatabaseUpdater= new GroupProviderUpdater(node, groupProviderObj, controller); - - updater.add( that.groupDatabaseUpdater); - - that.groupDatabaseUpdater.update(); - - - }}); - } - - DatabaseGroupManager.prototype.update = function() { - this.groupDatabaseUpdater.update(); - }; - - DatabaseGroupManager.prototype.close = function() { - updater.remove( this.groupDatabaseUpdater ); - }; - - function GroupProviderUpdater(node, groupProviderObj, controller) - { + node.innerHTML = template; + parser.parse(node); this.controller = controller; - this.query = "api/latest/groupprovider/"+encodeURIComponent(groupProviderObj.name); - this.name = groupProviderObj.name; - var that = this; - - xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}) - .then(function(data) { - that.path = query(".path", node)[0]; - that.groupProviderData = data[0]; - - util.flattenStatistics( that.groupProviderData ); var groupDiv = query(".groups", node)[0]; @@ -95,7 +64,7 @@ define(["dojo/_base/xhr", keepSelection: true, plugins: { pagination: { - pageSizes: ["10", "25", "50", "100"], + pageSizes: [10, 25, 50, 100], description: true, sizeSwitch: true, pageStepper: true, @@ -106,10 +75,7 @@ define(["dojo/_base/xhr", indirectSelection: true }}; - - - that.groupsGrid = - new UpdatableStore(that.groupProviderData.groups, groupDiv, + this.groupsGrid = new UpdatableStore([], groupDiv, [ { name: "Group Name", field: "name", width: "100%" } ], function(obj) { connect.connect(obj.grid, "onRowDblClick", obj.grid, @@ -120,22 +86,13 @@ define(["dojo/_base/xhr", that.controller.show("group", name, groupProviderObj, theItem.id); }); }, gridProperties, EnhancedGrid); - - - var addGroupButton = query(".addGroupButton", node)[0]; - connect.connect(registry.byNode(addGroupButton), "onClick", function(evt){ addGroup.show(groupProviderObj.name) }); - - var deleteGroupButton = query(".deleteGroupButton", node)[0]; - var deleteWidget = registry.byNode(deleteGroupButton); - connect.connect(deleteWidget, "onClick", - function(evt){ - event.stop(evt); - that.deleteGroups(); - }); - }); + var addGroupButton = query(".addGroupButton", node)[0]; + registry.byNode(addGroupButton).on("click", function(evt){ addGroup.show(groupProviderObj.name) }); + var deleteWidget = registry.byNode(query(".deleteGroupButton", node)[0]); + deleteWidget.on("click", function(evt){ event.stop(evt); that.deleteGroups(); }); } - GroupProviderUpdater.prototype.deleteGroups = function() + GroupManagingGroupProvider.prototype.deleteGroups = function() { var grid = this.groupsGrid.grid; var data = grid.selection.getSelected(); @@ -169,22 +126,12 @@ define(["dojo/_base/xhr", } }; - GroupProviderUpdater.prototype.update = function() + GroupManagingGroupProvider.prototype.update = function(data) { - - var that = this; - - xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}) - .then(function(data) { - that.groupProviderData = data[0]; - that.path.innerHTML = entities.encode(String(that.groupProviderData.path)); - util.flattenStatistics( that.groupProviderData ); - - that.groupsGrid.update(that.groupProviderData.groups); - - }); - - + if (data) + { + this.groupsGrid.update(data.groups); + } }; var addGroup = {}; @@ -258,5 +205,5 @@ define(["dojo/_base/xhr", registry.byId("addGroup").show(); }; - return DatabaseGroupManager; + return GroupManagingGroupProvider; }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/groupfile/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/groupfile/add.js new file mode 100644 index 0000000000..f28f250134 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/groupfile/add.js @@ -0,0 +1,37 @@ +/* + * + * 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. + * + */ +define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/common/util", "qpid/common/metadata"], + function (dom, query, array, registry, util, metadata) + { + + return { show: function(data) + { + var that=this; + util.parseHtmlIntoDiv(data.containerNode, "groupprovider/groupfile/add.html"); + if (data.data) + { + var pathWidget = registry.byNode(query(".addGroupProviderPath", data.containerNode)[0]); + pathWidget.set("value", data.data.path); + } + } + }; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/groupfile/show.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/groupfile/show.js new file mode 100644 index 0000000000..a559140898 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/groupfile/show.js @@ -0,0 +1,37 @@ +/* + * + * 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. + * + */ +define(["qpid/common/util", "dojo/domReady!"], + function (util, metadata) + { + + function GroupFile(data) + { + util.buildUI(data.containerNode, data.parent, "groupprovider/groupfile/show.html", ["path"], this); + } + + GroupFile.prototype.update = function(data) + { + util.updateUI(data, ["path"], this); + } + + return GroupFile; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/managedgroupprovider/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/managedgroupprovider/add.js new file mode 100644 index 0000000000..fd8e09dcda --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/managedgroupprovider/add.js @@ -0,0 +1,26 @@ +/* + * + * 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. + * + */ +define([], + function (dom, query, array, registry, util, metadata) + { + return { show: function(data) { /* nothing to do */ } }; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/managedgroupprovider/show.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/managedgroupprovider/show.js new file mode 100644 index 0000000000..ed6a0e155b --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/managedgroupprovider/show.js @@ -0,0 +1,35 @@ +/* + * + * 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. + * + */ +define([], + function () + { + + function ManagedGroupProvider(data) + { + } + + ManagedGroupProvider.prototype.update = function(data) + { + } + + return ManagedGroupProvider; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js index 5eaaa89242..ef8273328b 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js @@ -125,7 +125,8 @@ function (util, metadata, xhr, declare, array, domConstruct, win, query, json, _ this.preferencesProviderNameWidget.set("value", data.name); if (data.type == this.preferencesProviderTypeWidget.get("value")) { - this._toggleWidgets(data.type); + // re-create UI anyway + this._preferencesProviderTypeChanged(data.type); } else { @@ -193,6 +194,10 @@ function (util, metadata, xhr, declare, array, domConstruct, win, query, json, _ { this.reset(); } + else + { + this._toggleWidgets(this.preferencesProviderTypeWidget.value); + } }, }); }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filekeystore/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filekeystore/add.js index b158b9e051..b4c45d8f99 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filekeystore/add.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filekeystore/add.js @@ -25,8 +25,6 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm { init: function() { - // Readers are HTML5 - this.reader = window.FileReader ? new FileReader() : undefined; }, show: function(data) { @@ -34,79 +32,16 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm util.parseHtmlIntoDiv(data.containerNode, "store/filekeystore/add.html"); this.containerNode = data.containerNode; - this.keyStoreServerPath = registry.byId("addStore.serverPath"); - this.keyStoreUploadFields = dom.byId("addStore.uploadFields"); - this.keyStoreSelectedFileContainer = dom.byId("addStore.selectedFile"); - this.keyStoreSelectedFileStatusContainer = dom.byId("addStore.selectedFileStatus"); - this.keyStoreFile = registry.byId("addStore.file"); - this.keyStoreFileClearButton = registry.byId("addStore.fileClearButton"); - this.keyStoreOldBrowserWarning = dom.byId("addStore.oldBrowserWarning"); - //Only submitted field - this.keyStorePath = registry.byId("addStore.path"); + this.keyStoreOldBrowserWarning = dom.byId("addStore.oldBrowserWarning"); this.addButton = data.parent.addButton; - if (this.reader) - { - this.reader.onload = function(evt) {that._keyStoreUploadFileComplete(evt);}; - this.reader.onerror = function(ex) {console.error("Failed to load key store file", ex);}; - this.keyStoreFile.on("change", function(selected){that._keyStoreFileChanged(selected)}); - this.keyStoreFileClearButton.on("click", function(event){that._keyStoreFileClearButtonClicked(event)}); - } - else + if (!window.FileReader) { - // Fall back for IE8/9 which do not support FileReader - this.keyStoreUploadFields.style.display = "none"; this.keyStoreOldBrowserWarning.innerHTML = "File upload requires a more recent browser with HTML5 support"; this.keyStoreOldBrowserWarning.className = this.keyStoreOldBrowserWarning.className.replace("hidden", ""); } - - this.keyStoreServerPath.on("blur", function(){that._keyStoreServerPathChanged()}); - }, - _keyStoreFileChanged: function (evt) - { - // We only ever expect a single file - var file = this.keyStoreFile.domNode.children[0].files[0]; - - this.addButton.setDisabled(true); - this.keyStoreSelectedFileContainer.innerHTML = file.name; - this.keyStoreSelectedFileStatusContainer.className = "loadingIcon"; - - console.log("Beginning to read key store file " + file.name); - this.reader.readAsDataURL(file); - }, - _keyStoreUploadFileComplete: function(evt) - { - var reader = evt.target; - var result = reader.result; - console.log("Key store file read complete, contents " + result); - this.addButton.setDisabled(false); - this.keyStoreSelectedFileStatusContainer.className = "loadedIcon"; - - this.keyStoreServerPath.set("value", ""); - this.keyStoreServerPath.setDisabled(true); - this.keyStoreServerPath.set("required", false); - - this.keyStoreFileClearButton.setDisabled(false); - - this.keyStorePath.set("value", result); - }, - _keyStoreFileClearButtonClicked: function(event) - { - this.keyStoreFile.reset(); - this.keyStoreSelectedFileStatusContainer.className = ""; - this.keyStoreSelectedFileContainer.innerHTML = ""; - this.keyStoreServerPath.set("required", true); - this.keyStoreServerPath.setDisabled(false); - this.keyStoreFileClearButton.setDisabled(true); - - this.keyStorePath.set("value", ""); - }, - _keyStoreServerPathChanged: function() - { - var serverPathValue = this.keyStoreServerPath.get("value"); - this.keyStorePath.set("value", serverPathValue); }, update: function(effectiveData) { @@ -115,27 +50,20 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm array.forEach(widgets, function(item) { var name = item.id.replace("addStore.",""); - if (name in attributes && item.type != "password") + if (name in attributes ) { - item.set("value", effectiveData[name]); + var attribute = attributes[name]; + if (attribute.secure || attribute.oversize) + { + item.set("required", false); + item.set("placeHolder", effectiveData[name]); + } + else + { + item.set("value", effectiveData[name]); + } } }); - - var keyStorePathValue = effectiveData["path"]; - var isDataUrl = keyStorePathValue.indexOf("data:") == 0; - - if (isDataUrl) - { - this.keyStoreSelectedFileStatusContainer.className = "loadedIcon"; - this.keyStoreSelectedFileContainer.innerHTML = "uploaded.jks"; - this.keyStoreServerPath.setDisabled(true); - this.keyStoreServerPath.set("required", false); - this.keyStoreFileClearButton.setDisabled(false); - } - else - { - this.keyStoreServerPath.set("value", keyStorePathValue); - } } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filetruststore/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filetruststore/add.js index 9d113a9d9e..e04ee1a835 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filetruststore/add.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/filetruststore/add.js @@ -25,8 +25,6 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm { init: function() { - // Readers are HTML5 - this.reader = window.FileReader ? new FileReader() : undefined; }, show: function(data) { @@ -34,79 +32,17 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm util.parseHtmlIntoDiv(data.containerNode, "store/filetruststore/add.html"); this.containerNode = data.containerNode; - this.keyStoreServerPath = registry.byId("addStore.serverPath"); - this.keyStoreUploadFields = dom.byId("addStore.uploadFields"); - this.keyStoreSelectedFileContainer = dom.byId("addStore.selectedFile"); - this.keyStoreSelectedFileStatusContainer = dom.byId("addStore.selectedFileStatus"); - this.keyStoreFile = registry.byId("addStore.file"); - this.keyStoreFileClearButton = registry.byId("addStore.fileClearButton"); - this.keyStoreOldBrowserWarning = dom.byId("addStore.oldBrowserWarning"); - //Only submitted field - this.keyStorePath = registry.byId("addStore.path"); + this.keyStoreOldBrowserWarning = dom.byId("addStore.oldBrowserWarning"); this.addButton = data.parent.addButton; - if (this.reader) - { - this.reader.onload = function(evt) {that._keyStoreUploadFileComplete(evt);}; - this.reader.onerror = function(ex) {console.error("Failed to load trust store file", ex);}; - this.keyStoreFile.on("change", function(selected){that._keyStoreFileChanged(selected)}); - this.keyStoreFileClearButton.on("click", function(event){that._keyStoreFileClearButtonClicked(event)}); - } - else + if (!window.FileReader) { // Fall back for IE8/9 which do not support FileReader - this.keyStoreUploadFields.style.display = "none"; this.keyStoreOldBrowserWarning.innerHTML = "File upload requires a more recent browser with HTML5 support"; this.keyStoreOldBrowserWarning.className = this.keyStoreOldBrowserWarning.className.replace("hidden", ""); } - - this.keyStoreServerPath.on("blur", function(){that._keyStoreServerPathChanged()}); - }, - _keyStoreFileChanged: function (evt) - { - // We only ever expect a single file - var file = this.keyStoreFile.domNode.children[0].files[0]; - - this.addButton.setDisabled(true); - this.keyStoreSelectedFileContainer.innerHTML = file.name; - this.keyStoreSelectedFileStatusContainer.className = "loadingIcon"; - - console.log("Beginning to read trust store file " + file.name); - this.reader.readAsDataURL(file); - }, - _keyStoreUploadFileComplete: function(evt) - { - var reader = evt.target; - var result = reader.result; - console.log("Trust store file read complete, contents " + result); - this.addButton.setDisabled(false); - this.keyStoreSelectedFileStatusContainer.className = "loadedIcon"; - - this.keyStoreServerPath.set("value", ""); - this.keyStoreServerPath.setDisabled(true); - this.keyStoreServerPath.set("required", false); - - this.keyStoreFileClearButton.setDisabled(false); - - this.keyStorePath.set("value", result); - }, - _keyStoreFileClearButtonClicked: function(event) - { - this.keyStoreFile.reset(); - this.keyStoreSelectedFileStatusContainer.className = ""; - this.keyStoreSelectedFileContainer.innerHTML = ""; - this.keyStoreServerPath.set("required", true); - this.keyStoreServerPath.setDisabled(false); - this.keyStoreFileClearButton.setDisabled(true); - - this.keyStorePath.set("value", ""); - }, - _keyStoreServerPathChanged: function() - { - var serverPathValue = this.keyStoreServerPath.get("value"); - this.keyStorePath.set("value", serverPathValue); }, update: function(effectiveData) { @@ -115,27 +51,21 @@ define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/comm array.forEach(widgets, function(item) { var name = item.id.replace("addStore.",""); - if (name in attributes && item.type != "password") + if (name in attributes ) { - item.set("value", effectiveData[name]); + var attribute = attributes[name]; + if (attribute.secure || attribute.oversize) + { + item.set("required", false); + item.set("placeHolder", effectiveData[name]); + } + else + { + item.set("value", effectiveData[name]); + } } }); - var keyStorePathValue = effectiveData["path"]; - var isDataUrl = keyStorePathValue.indexOf("data:") == 0; - - if (isDataUrl) - { - this.keyStoreSelectedFileStatusContainer.className = "loadedIcon"; - this.keyStoreSelectedFileContainer.innerHTML = "uploaded.jks"; - this.keyStoreServerPath.setDisabled(true); - this.keyStoreServerPath.set("required", false); - this.keyStoreFileClearButton.setDisabled(false); - } - else - { - this.keyStoreServerPath.set("value", keyStorePathValue); - } } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavakeystore/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavakeystore/add.js new file mode 100644 index 0000000000..0d74699d79 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavakeystore/add.js @@ -0,0 +1,81 @@ +/* + * + * 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. + * + */ +define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/common/util", "qpid/common/metadata", "qpid/common/ResourceWidget"], + function (dom, query, array, registry, util, metadata) + { + var addKeyStore = + { + init: function() + { + }, + show: function(data) + { + var that=this; + util.parseHtmlIntoDiv(data.containerNode, "store/nonjavakeystore/add.html"); + + this.keyStoreOldBrowserWarning = dom.byId("addStore.oldBrowserWarning"); + this.addButton = data.parent.addButton; + this.containerNode = data.containerNode; + + if (!window.FileReader) + { + this.keyStoreOldBrowserWarning.innerHTML = "File upload requires a more recent browser with HTML5 support"; + this.keyStoreOldBrowserWarning.className = this.keyStoreOldBrowserWarning.className.replace("hidden", ""); + } + }, + update: function(effectiveData) + { + if (effectiveData) + { + var attributes = metadata.getMetaData("KeyStore", "NonJavaKeyStore").attributes; + var widgets = registry.findWidgets(this.containerNode); + array.forEach(widgets, function(item) + { + var name = item.id.replace("addStore.",""); + if (name in attributes ) + { + var attribute = attributes[name]; + if (attribute.oversize || attribute.secure) + { + item.set("required", false); + item.set("placeHolder", effectiveData[name]); + } + else + { + item.set("value", effectiveData[name]); + } + } + }); + } + } + }; + + try + { + addKeyStore.init(); + } + catch(e) + { + console.warn(e); + } + return addKeyStore; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavakeystore/show.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavakeystore/show.js new file mode 100644 index 0000000000..c31b020e3e --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavakeystore/show.js @@ -0,0 +1,61 @@ +/* + * 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. + */ + +define(["qpid/common/util", "qpid/common/metadata", "qpid/management/UserPreferences", "dojox/html/entities", "dojo/domReady!"], + function (util, metadata, UserPreferences, entities) + { + + function toDate(value) + { + return value ? entities.encode(String(UserPreferences.formatDateTime(value, {addOffset: true, appendTimeZone: true}))) : ""; + } + + var dateFields = ["certificateValidEnd","certificateValidStart"]; + + function NonJavaKeyStore(data) + { + this.fields = []; + var attributes = metadata.getMetaData("KeyStore", "NonJavaKeyStore").attributes; + for(var name in attributes) + { + if (dateFields.indexOf(name) == -1) + { + this.fields.push(name); + } + } + var allFields = this.fields.concat(dateFields); + util.buildUI(data.containerNode, data.parent, "store/nonjavakeystore/show.html",allFields, this); + } + + NonJavaKeyStore.prototype.update = function(data) + { + util.updateUI(data, this.fields, this); + if (data) + { + for(var idx in dateFields) + { + var name = dateFields[idx]; + this[name].innerHTML = toDate(data[name]); + } + } + } + + return NonJavaKeyStore; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavatruststore/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavatruststore/add.js new file mode 100644 index 0000000000..53e3b43082 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavatruststore/add.js @@ -0,0 +1,81 @@ +/* + * + * 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. + * + */ +define(["dojo/dom","dojo/query", "dojo/_base/array", "dijit/registry","qpid/common/util", "qpid/common/metadata"], + function (dom, query, array, registry, util, metadata) + { + var addKeyStore = + { + init: function() + { + }, + show: function(data) + { + var that=this; + util.parseHtmlIntoDiv(data.containerNode, "store/nonjavatruststore/add.html"); + + this.keyStoreOldBrowserWarning = dom.byId("addStore.oldBrowserWarning"); + this.addButton = data.parent.addButton; + this.containerNode = data.containerNode; + + if (!window.FileReader) + { + this.keyStoreOldBrowserWarning.innerHTML = "File upload requires a more recent browser with HTML5 support"; + this.keyStoreOldBrowserWarning.className = this.keyStoreOldBrowserWarning.className.replace("hidden", ""); + } + }, + update: function(effectiveData) + { + if (effectiveData) + { + var attributes = metadata.getMetaData("TrustStore", "NonJavaTrustStore").attributes; + var widgets = registry.findWidgets(this.containerNode); + array.forEach(widgets, function(item) + { + var name = item.id.replace("addStore.",""); + if (name in attributes ) + { + var attribute = attributes[name]; + if (attribute.oversize || attribute.secure) + { + item.set("required", false); + item.set("placeHolder", effectiveData[name]); + } + else + { + item.set("value", effectiveData[name]); + } + } + }); + } + } + }; + + try + { + addKeyStore.init(); + } + catch(e) + { + console.warn(e); + } + return addKeyStore; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavatruststore/show.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavatruststore/show.js new file mode 100644 index 0000000000..89b0b5d88f --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/nonjavatruststore/show.js @@ -0,0 +1,67 @@ +/* + * 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. + */ + +define(["dojo/query", + "qpid/common/util", + "qpid/common/metadata", + "dojox/grid/DataGrid", + "qpid/common/UpdatableStore", + "qpid/management/UserPreferences", + "dojo/domReady!"], + function (query, util, metadata, DataGrid, UpdatableStore, UserPreferences) + { + + + function NonJavaTrustStore(data) + { + this.fields = []; + var attributes = metadata.getMetaData("TrustStore", "NonJavaTrustStore").attributes; + for(var name in attributes) + { + this.fields.push(name); + } + util.buildUI(data.containerNode, data.parent, "store/nonjavatruststore/show.html", this.fields, this); + var gridNode = query(".details", data.containerNode)[0]; + var dateTimeFormatter = function(value){ return value ? UserPreferences.formatDateTime(value, {addOffset: true, appendTimeZone: true}) : "";}; + this.detailsGrid = new UpdatableStore([], + gridNode, + [ + { name: 'Subject', field: 'SUBJECT_NAME', width: '25%' }, + { name: 'Issuer', field: 'ISSUER_NAME', width: '25%' }, + { name: 'Valid from', field: 'VALID_START', width: '25%', formatter: dateTimeFormatter }, + { name: 'Valid to', field: 'VALID_END', width: '25%', formatter: dateTimeFormatter} + ]); + } + + NonJavaTrustStore.prototype.update = function(data) + { + util.updateUI(data, this.fields, this); + var details = data.certificateDetails; + for(var i=0; i < details.length; i++) + { + details[i].id = details[i].SUBJECT_NAME + "_" + details[i].ISSUER_NAME + "_" + details[i].VALID_START + "_" + details[i].VALID_END; + } + this.detailsGrid.grid.beginUpdate(); + this.detailsGrid.update(details); + this.detailsGrid.grid.endUpdate(); + } + + return NonJavaTrustStore; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/login.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/login.html index aaa2855bd2..6e7f05e41b 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/login.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/login.html @@ -104,7 +104,7 @@ <div data-dojo-type="dijit.form.ValidationTextBox" type="password" id="password" name="password" data-dojo-props="label:'Password:',required:true, intermediateChanges:true"></div> </div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button data-dojo-type="dijit.form.Button" type="submit" id="loginButton">Login</button> </div> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/logs/showLogFileDownloadDialog.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/logs/showLogFileDownloadDialog.html index bc633d059a..d48682a566 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/logs/showLogFileDownloadDialog.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/logs/showLogFileDownloadDialog.html @@ -23,7 +23,7 @@ <div><b>Select log files to download</b></div> <div class="logFilesGrid" style='height:300px;width: 580px'></div> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button value="Download" data-dojo-type="dijit.form.Button" class="downloadLogsButton" data-dojo-props="iconClass: 'downloadLogsIcon', label: 'Download' "></button> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/preferencesProviderForm.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/preferencesProviderForm.html index 979b3abe8d..b995d4e8dd 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/preferencesProviderForm.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/preferencesProviderForm.html @@ -23,7 +23,7 @@ <div class="formBox"> <fieldset> <legend>Preferences Provider</legend> - <div class="clear"> + <div class="clear hidden"> <div class="formLabel-labelCell tableContainer-labelCell">Name*:</div> <div class="formLabel-controlCell tableContainer-valueCell"> <input type="text" diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/showAuthProvider.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/showAuthProvider.html index a669d7800d..992da02027 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/showAuthProvider.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/showAuthProvider.html @@ -37,7 +37,6 @@ <div class="clear dijitDialogPaneActionBar"> <button data-dojo-type="dijit.form.Button" class="editAuthenticationProviderButton" type="button" data-dojo-props="disabled: true">Edit</button> <button data-dojo-type="dijit.form.Button" class="deleteAuthenticationProviderButton" type="button">Delete</button> - <button data-dojo-type="dijit.form.Button" class="addPreferencesProviderButton">Add Preferences Provider</button> </div> </div> <br/> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/showGroupProvider.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/showGroupProvider.html index e095a0a427..3793a4407a 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/showGroupProvider.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/showGroupProvider.html @@ -35,9 +35,10 @@ <div class="clear"></div> <div class="providerDetails"></div> - + <br/> <div class="dijitDialogPaneActionBar"> - <input class="deleteGroupProviderButton" type="button" value="Delete Group provider" label="Delete Group Provider" dojoType="dijit.form.Button" /> + <input class="deleteGroupProviderButton" type="button" value="Delete" label="Delete" data-dojo-type="dijit.form.Button" /> + <input class="editGroupProviderButton" type="button" value="Edit" label="Edit" data-dojo-type="dijit.form.Button" data-dojo-props="disabled:true"/> </div> </div> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html index 2695d8f099..8dff5132bd 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferences.html @@ -40,7 +40,7 @@ </tr> </table> </div> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" data-dojo-props="label: 'Set'" id="preferences.setButton">Set</button> <button data-dojo-type="dijit/form/Button" data-dojo-props="label: 'Set and Close'" id="preferences.setAndCloseButton">Set and Close</button> </div> @@ -70,7 +70,7 @@ </tr> </thead> </table> - <div class="dijitDialogPaneActionBar"> + <div class="dijitDialogPaneActionBar qpidDialogPaneActionBar"> <button id="preferences.deleteButton" data-dojo-type="dijit/form/Button" data-dojo-props="label:'Delete', title:'Delete preferences for selected users'">Delete</button> <button id="preferences.deleteAndCloseButton" data-dojo-type="dijit/form/Button" data-dojo-props="label: 'Delete and Close', title:'Delete preferences for selected users and close the dialog'">Delete and Close</button> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferencesProvider.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferencesProvider.html index 5d14aace76..49eb355ff3 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferencesProvider.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferencesProvider.html @@ -25,10 +25,6 @@ <div class="preferencesProviderType"></div> </div> <div class="clear"> - <div class="formLabel-labelCell">Name:</div> - <div class="preferencesProviderName"></div> - </div> - <div class="clear"> <div class="formLabel-labelCell">State:</div> <div class="preferencesProviderState"></div> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filekeystore/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filekeystore/add.html index 1732688ba7..676ae4007b 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filekeystore/add.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filekeystore/add.html @@ -22,42 +22,14 @@ <div class="clear"> <div id="addStore.serverPathLabel" class="formLabel-labelCell tableContainer-labelCell">Server path or upload*:</div> <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addStore.serverPath" - data-dojo-type="dijit/form/ValidationTextBox" + <input type="text" id="addStore.storeUrl" + data-dojo-type="qpid/common/ResourceWidget" data-dojo-props=" - name: 'serverPath', + name: 'storeUrl', placeHolder: 'key store file server path', required: true, - excluded: true, promptMessage: 'Location of the key store file on the server', title: 'Enter the key store file path'" /> - - <!-- Hidden and used purely for form submission --> - <input type="hidden" id="addStore.path" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'path', - required: true" /> - </div> - - <div id="addStore.uploadFields"> - <div id="addStore.fileLabel" class="formLabel-labelCell tableContainer-labelCell"></div> - <div class="fileUpload clear"> - <span id="addStore.selectedFile" class="infoMessage"></span> - <span id="addStore.selectedFileStatus"></span> - </div> - - <div class="fileUpload clear"> - <input type="file" id="addStore.file" - multiple="false" - data-dojo-type="dojox/form/Uploader" - data-dojo-props="label: 'Upload'"/> - <button id="addStore.fileClearButton" - data-dojo-type="dijit/form/Button" - data-dojo-props="label: 'Clear', - disabled: true"> - </button> - </div> </div> <div class="clear"> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html index 36180d8a39..15b1692300 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/add.html @@ -22,39 +22,14 @@ <div class="clear"> <div id="addStore.serverPathLabel" class="formLabel-labelCell tableContainer-labelCell">Server path or upload*:</div> <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addStore.serverPath" - data-dojo-type="dijit/form/ValidationTextBox" + <input type="text" id="addStore.storeUrl" + data-dojo-type="qpid/common/ResourceWidget" data-dojo-props=" - name: 'serverPath', + name: 'storeUrl', placeHolder: 'trust store file server path', required: true, - excluded: true, promptMessage: 'Location of the trust store file on the server', title: 'Enter the store file path'" /> - <!-- Hidden and used purely for form submission --> - <input type="hidden" id="addStore.path" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'path', - required: true" /> - </div> - <div id="addStore.uploadFields"> - <div id="addStore.fileLabel" class="formLabel-labelCell tableContainer-labelCell"></div> - <div class="fileUpload clear"> - <span id="addStore.selectedFile" class="infoMessage"></span> - <span id="addStore.selectedFileStatus"></span> - </div> - <div class="fileUpload clear"> - <input type="file" id="addStore.file" - multiple="false" - data-dojo-type="dojox/form/Uploader" - data-dojo-props="label: 'Upload'"/> - <button id="addStore.fileClearButton" - data-dojo-type="dijit/form/Button" - data-dojo-props="label: 'Clear', - disabled: true"> - </button> - </div> </div> <div class="clear"> <div class="formLabel-labelCell tableContainer-labelCell">Password*:</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/show.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/show.html index 1c3744b83c..99190d1f90 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/show.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/filetruststore/show.html @@ -19,8 +19,8 @@ <div> <div class="clear"> - <div class="formLabel-labelCell">Path:</div> - <div ><span class="path" ></span></div> + <div class="formLabel-labelCell">Store Url:</div> + <div ><span class="storeUrl" ></span></div> </div> <div class="clear"> <div class="formLabel-labelCell">Peers only:</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavakeystore/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavakeystore/add.html new file mode 100644 index 0000000000..b7af1c6b47 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavakeystore/add.html @@ -0,0 +1,66 @@ +<!-- + ~ 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. + --> + + +<div> + <div id="addStore.oldBrowserWarning" class="infoMessage hidden clear"></div> + + <div class="clear"> + <div id="addStore.privateKeyLabel" class="formLabel-labelCell tableContainer-labelCell">Private Key (Server path or upload)*:</div> + <div class="formLabel-controlCell tableContainer-valueCell"> + <input type="text" id="addStore.privateKeyUrl" + data-dojo-type="qpid/common/ResourceWidget" + data-dojo-props=" + name: 'privateKeyUrl', + placeHolder: 'path to file with private key in PEM/DER format', + required: true, + promptMessage: 'Enter broker server path to file containing unencrypted private key in DER or PEM format', + title: 'Enter broker server path to file containing unencrypted private key in DER or PEM format'" /> + + </div> + </div> + + <div class="clear"> + <div id="addStore.serverPathLabel" class="formLabel-labelCell tableContainer-labelCell">Certificate (Server path or upload)*:</div> + <div class="formLabel-controlCell tableContainer-valueCell"> + <input type="text" id="addStore.certificateUrl" + data-dojo-type="qpid/common/ResourceWidget" + data-dojo-props=" + name: 'certificateUrl', + placeHolder: 'path to file with certificate in PEM/DER format', + required: true, + promptMessage: 'Enter broker server path to file containing certificate in DER or PEM format', + title: 'Enter broker server path to file containing certificate in DER or PEM format'" /> + </div> + </div> + + <div class="clear"> + <div id="addStore.intermediateCertificateLabel" class="formLabel-labelCell tableContainer-labelCell">Intermediate Certificates (Server path or upload):</div> + <div class="formLabel-controlCell tableContainer-valueCell"> + <input type="text" id="addStore.intermediateCertificateUrl" + data-dojo-type="qpid/common/ResourceWidget" + data-dojo-props=" + name: 'intermediateCertificateUrl', + placeHolder: 'path to file with certificates in PEM/DER format', + required: false, + promptMessage: 'Enter broker server path to file containing intermediate certificates in DER or PEM format', + title: 'Enter path to file containing intermediate certificates in format DER or PEM'" /> + </div> + </div> +</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavakeystore/show.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavakeystore/show.html new file mode 100644 index 0000000000..51ebd06012 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavakeystore/show.html @@ -0,0 +1,47 @@ +<!-- + ~ 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. + --> + +<div> + <div class="clear privateKeyUrlContainer"> + <div class="formLabel-labelCell">Private Key:</div> + <div ><span class="privateKeyUrl" ></span></div> + </div> + <div class="clear certificateUrlContainer"> + <div class="formLabel-labelCell">Certificate:</div> + <div><span class="certificateUrl" ></span></div> + </div> + <div class="clear intermediateCertificateUrlContainer"> + <div class="formLabel-labelCell">Intermediate Certificate:</div> + <div><span class="intermediateCertificateUrl" ></span></div> + </div> + <div class="clear"> + <div class="formLabel-labelCell">Subject:</div> + <div><span class="subjectName" ></span></div> + </div> + <div class="clear"> + <div class="formLabel-labelCell">Certificate valid to:</div> + <div><span class="certificateValidEnd" ></span></div> + </div> + <div class="clear"> + <div class="formLabel-labelCell">Certificate valid from:</div> + <div><span class="certificateValidStart" ></span></div> + </div> + <div class="clear"></div> +</div> + diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavatruststore/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavatruststore/add.html new file mode 100644 index 0000000000..4ec2678575 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavatruststore/add.html @@ -0,0 +1,38 @@ +<!-- + ~ 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. + --> + + +<div> + <div id="addStore.oldBrowserWarning" class="infoMessage hidden clear"></div> + + <div class="clear"> + <div id="addStore.certificatesLabel" class="formLabel-labelCell tableContainer-labelCell">Certificates (Server path or upload)*:</div> + <div class="formLabel-controlCell tableContainer-valueCell"> + <input type="text" id="addStore.certificatesUrl" + data-dojo-type="qpid/common/ResourceWidget" + data-dojo-props=" + name: 'certificatesUrl', + placeHolder: 'path to file with certificate(s) in PEM/DER format', + required: true, + promptMessage: 'Enter broker server path to file containing certificate(s) in DER or PEM format', + title: 'Enter broker server path to file containing certificate(s) in DER or PEM format'" /> + </div> + </div> + +</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavatruststore/show.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavatruststore/show.html new file mode 100644 index 0000000000..b45f457e41 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/store/nonjavatruststore/show.html @@ -0,0 +1,31 @@ +<!-- + ~ 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. + --> + +<div> + <div class="clear certificatesUrlContainer"> + <div class="formLabel-labelCell">Certificate:</div> + <div><span class="certificatesUrl" ></span></div> + </div> + <div class="clear"></div> + <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Certificate details'" class="detailsGridPanel"> + <div class="details"></div> + </div> + <div></div> +</div> + diff --git a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java index ac595154bb..b3c9bd911f 100644 --- a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java +++ b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java @@ -20,6 +20,7 @@ package org.apache.qpid.server.management.plugin.servlet.rest; import static org.apache.qpid.server.management.plugin.servlet.rest.ConfiguredObjectToMapConverter.STATISTICS_MAP_KEY; +import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; @@ -27,6 +28,7 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -37,6 +39,8 @@ import java.util.Set; import junit.framework.TestCase; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectAttribute; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; import org.apache.qpid.server.model.Model; public class ConfiguredObjectToMapConverterTest extends TestCase @@ -57,8 +61,15 @@ public class ConfiguredObjectToMapConverterTest extends TestCase when(_configuredObject.getStatistics()).thenReturn(Collections.singletonMap(statisticName, (Number) statisticValue)); - Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class, 0, - false, false, false); + Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 0, + false, + false, + false, + false, + 120, + false); Map<String, Object> statsAsMap = (Map<String, Object>) resultMap.get(STATISTICS_MAP_KEY); assertNotNull("Statistics should be part of map", statsAsMap); assertEquals("Unexpected number of statistics", 1, statsAsMap.size()); @@ -69,10 +80,19 @@ public class ConfiguredObjectToMapConverterTest extends TestCase { final String attributeName = "attribute"; final String attributeValue = "value"; + Model model = createTestModel(); + when(_configuredObject.getModel()).thenReturn(model); configureMockToReturnOneAttribute(_configuredObject, attributeName, attributeValue); - Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class, 0, - false, false, false); + Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 0, + false, + false, + false, + false, + 120, + false); assertEquals("Unexpected number of attributes", 1, resultMap.size()); assertEquals("Unexpected attribute value", attributeValue, resultMap.get(attributeName)); } @@ -89,8 +109,15 @@ public class ConfiguredObjectToMapConverterTest extends TestCase configureMockToReturnOneAttribute(_configuredObject, attributeName, attributeValue); - Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class, 0, - false, false, false); + Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 0, + false, + false, + false, + false, + 120, + false); assertEquals("Unexpected number of attributes", 1, resultMap.size()); assertEquals("Unexpected attribute value", "attributeConfiguredObjectName", resultMap.get(attributeName)); } @@ -108,8 +135,15 @@ public class ConfiguredObjectToMapConverterTest extends TestCase configureMockToReturnOneAttribute(mockChild, childAttributeName, childAttributeValue); when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild)); - Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class, 1, - false, false, false); + Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 1, + false, + false, + false, + false, + 120, + false); assertEquals("Unexpected parent map size", 1, resultMap.size()); final List<Map<String, Object>> childList = (List<Map<String, Object>>) resultMap.get("testchilds"); @@ -146,8 +180,15 @@ public class ConfiguredObjectToMapConverterTest extends TestCase when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild)); - Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class, 1, true, - false, false); + Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 1, + true, + false, + false, + false, + 120, + false); assertEquals("Unexpected parent map size", 2, resultMap.size()); assertEquals("Incorrect context", resultMap.get(ConfiguredObject.CONTEXT), actualContext); List<Map<String, Object>> childList = (List<Map<String, Object>>) resultMap.get("testchilds"); @@ -158,7 +199,15 @@ public class ConfiguredObjectToMapConverterTest extends TestCase assertEquals("Unexpected child attribute value", childActualAttributeValue, childMap.get(childAttributeName)); - resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class, 1, false, false, false); + resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 1, + false, + false, + false, + false, + 120, + false); assertEquals("Unexpected parent map size", 2, resultMap.size()); Map<String, Object> inheritedContext = new HashMap<>(); inheritedContext.put("key","value"); @@ -174,12 +223,177 @@ public class ConfiguredObjectToMapConverterTest extends TestCase } + public void testOversizedAttributes() + { + + Model model = createTestModel(); + ConfiguredObjectTypeRegistry typeRegistry = model.getTypeRegistry(); + final Map<String, ConfiguredObjectAttribute<?, ?>> attributeTypes = + typeRegistry.getAttributeTypes(TestChild.class); + final ConfiguredObjectAttribute longAttr = mock(ConfiguredObjectAttribute.class); + when(longAttr.isOversized()).thenReturn(true); + when(longAttr.getOversizedAltText()).thenReturn(""); + when(attributeTypes.get(eq("longAttr"))).thenReturn(longAttr); + + TestChild mockChild = mock(TestChild.class); + when(mockChild.getModel()).thenReturn(model); + when(_configuredObject.getModel()).thenReturn(model); + configureMockToReturnOneAttribute(mockChild, "longAttr", "this is not long"); + when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild)); + + + Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 1, + false, + false, + false, + false, + 20, + false); + Object children = resultMap.get("testchilds"); + assertNotNull(children); + assertTrue(children instanceof Collection); + assertTrue(((Collection)children).size()==1); + Object attrs = ((Collection)children).iterator().next(); + assertTrue(attrs instanceof Map); + assertEquals("this is not long", ((Map) attrs).get("longAttr")); + + + + resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 1, + false, + false, + false, + false, + 8, + false); + + children = resultMap.get("testchilds"); + assertNotNull(children); + assertTrue(children instanceof Collection); + assertTrue(((Collection)children).size()==1); + attrs = ((Collection)children).iterator().next(); + assertTrue(attrs instanceof Map); + assertEquals("this...", ((Map) attrs).get("longAttr")); + + + + + when(longAttr.getOversizedAltText()).thenReturn("test alt text"); + + resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 1, + false, + false, + false, + false, + 8, + false); + + children = resultMap.get("testchilds"); + assertNotNull(children); + assertTrue(children instanceof Collection); + assertTrue(((Collection)children).size()==1); + attrs = ((Collection)children).iterator().next(); + assertTrue(attrs instanceof Map); + assertEquals("test alt text", ((Map) attrs).get("longAttr")); + + + } + + public void testSecureAttributes() + { + + Model model = createTestModel(); + ConfiguredObjectTypeRegistry typeRegistry = model.getTypeRegistry(); + Map<String, ConfiguredObjectAttribute<?, ?>> attributeTypes = typeRegistry.getAttributeTypes(TestChild.class); + ConfiguredObjectAttribute secureAttribute = mock(ConfiguredObjectAttribute.class); + when(secureAttribute.isSecure()).thenReturn(true); + when(attributeTypes.get(eq("secureAttribute"))).thenReturn(secureAttribute); + + TestChild mockChild = mock(TestChild.class); + when(mockChild.getModel()).thenReturn(model); + when(_configuredObject.getModel()).thenReturn(model); + + // set encoded value + configureMockToReturnOneAttribute(mockChild, "secureAttribute", "*****"); + + // set actual values + when(mockChild.getActualAttributes()).thenReturn(Collections.singletonMap("secureAttribute", "secret")); + when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild)); + when(model.getParentTypes(TestChild.class)).thenReturn(Collections.<Class<? extends ConfiguredObject>>singleton(TestChild.class)); + when(_configuredObject.getCategoryClass()).thenReturn(TestChild.class); + when(mockChild.isDurable()).thenReturn(true); + + Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 1, + false, + false, + false, + false, + 20, + false); + Object children = resultMap.get("testchilds"); + assertNotNull(children); + assertTrue(children instanceof Collection); + assertTrue(((Collection)children).size()==1); + Object attrs = ((Collection)children).iterator().next(); + assertTrue(attrs instanceof Map); + assertEquals("*****", ((Map) attrs).get("secureAttribute")); + + resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 1, + true, + true, + false, + true, + 20, + true); + + children = resultMap.get("testchilds"); + assertNotNull(children); + assertTrue(children instanceof Collection); + assertTrue(((Collection)children).size()==1); + attrs = ((Collection)children).iterator().next(); + assertTrue(attrs instanceof Map); + assertEquals("secret", ((Map) attrs).get("secureAttribute")); + + resultMap = _converter.convertObjectToMap(_configuredObject, + ConfiguredObject.class, + 1, + true, + true, + false, + false, + 20, + true); + + children = resultMap.get("testchilds"); + assertNotNull(children); + assertTrue(children instanceof Collection); + assertTrue(((Collection)children).size()==1); + attrs = ((Collection)children).iterator().next(); + assertTrue(attrs instanceof Map); + assertEquals("*****", ((Map) attrs).get("secureAttribute")); + } + private Model createTestModel() { Model model = mock(Model.class); final List<Class<? extends ConfiguredObject>> list = new ArrayList<Class<? extends ConfiguredObject>>(); list.add(TestChild.class); when(model.getChildTypes(ConfiguredObject.class)).thenReturn(list); + final ConfiguredObjectTypeRegistry typeRegistry = mock(ConfiguredObjectTypeRegistry.class); + final Map<String, ConfiguredObjectAttribute<?, ?>> attrTypes = mock(Map.class); + when(attrTypes.get(any(String.class))).thenReturn(mock(ConfiguredObjectAttribute.class)); + when(typeRegistry.getAttributeTypes(any(Class.class))).thenReturn(attrTypes); + when(model.getTypeRegistry()).thenReturn(typeRegistry); return model; } diff --git a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java index 78eba66158..040973ff6e 100644 --- a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java +++ b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java @@ -36,6 +36,7 @@ import java.rmi.server.RMIServerSocketFactory; import java.rmi.server.UnicastRemoteObject; import java.security.GeneralSecurityException; import java.util.HashMap; +import java.util.Set; import javax.management.JMException; import javax.management.MBeanServer; @@ -142,11 +143,9 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry throw new ServerScopedRuntimeException("Unable to create SSLContext for key store", e); } - getEventLogger().message(ManagementConsoleMessages.SSL_KEYSTORE(keyStore.getName())); - //create the SSL RMI socket factories csf = new SslRMIClientSocketFactory(); - ssf = new QpidSslRMIServerSocketFactory(sslContext); + ssf = new QpidSslRMIServerSocketFactory(sslContext,_connectorPort.getEnabledCipherSuites(), _connectorPort.getDisabledCipherSuites()); } else { @@ -252,8 +251,12 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry _cs.start(); - String connectorServer = (connectorSslEnabled ? "SSL " : "") + "JMX RMIConnectorServer"; - getEventLogger().message(ManagementConsoleMessages.LISTENING(connectorServer, jmxPortConnectorServer)); + Set<Transport> connectorTransports = _connectorPort.getTransports(); + for (Transport transport: connectorTransports) + { + getEventLogger().message(ManagementConsoleMessages.LISTENING("JMX RMIConnectorServer", transport.name(), jmxPortConnectorServer)); + } + getEventLogger().message(ManagementConsoleMessages.READY(OPERATIONAL_LOGGING_NAME)); } @@ -263,7 +266,7 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry final RMIServerSocketFactory ssf = getRmiServerSocketFactory(useCustomRmiRegistry); Registry rmiRegistry = LocateRegistry.createRegistry(jmxPortRegistryServer, null, ssf); - getEventLogger().message(ManagementConsoleMessages.LISTENING("RMI Registry", jmxPortRegistryServer)); + getEventLogger().message(ManagementConsoleMessages.LISTENING("RMI Registry", Transport.TCP.name(), jmxPortRegistryServer)); return rmiRegistry; } diff --git a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java index 5c15a40427..8af9d87672 100644 --- a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java +++ b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; +import java.util.Collection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; @@ -35,6 +36,8 @@ import org.apache.qpid.transport.network.security.ssl.SSLUtil; public class QpidSslRMIServerSocketFactory extends SslRMIServerSocketFactory { private final SSLContext _sslContext; + private final Collection<String> _enabledCipherSuites; + private final Collection<String> _disabledCipherSuites; /** * SslRMIServerSocketFactory which creates the ServerSocket using the @@ -43,9 +46,12 @@ public class QpidSslRMIServerSocketFactory extends SslRMIServerSocketFactory * key store. * * @param sslContext previously created sslContext using the desired key store. - * @throws NullPointerException if the provided {@link SSLContext} is null. + * @param enabledCipherSuites + *@param disabledCipherSuites @throws NullPointerException if the provided {@link SSLContext} is null. */ - public QpidSslRMIServerSocketFactory(SSLContext sslContext) throws NullPointerException + public QpidSslRMIServerSocketFactory(SSLContext sslContext, + final Collection<String> enabledCipherSuites, + final Collection<String> disabledCipherSuites) throws NullPointerException { super(); @@ -55,6 +61,8 @@ public class QpidSslRMIServerSocketFactory extends SslRMIServerSocketFactory } _sslContext = sslContext; + _enabledCipherSuites = enabledCipherSuites; + _disabledCipherSuites = disabledCipherSuites; //TODO: settings + implementation for SSL client auth, updating equals and hashCode appropriately. } @@ -77,6 +85,7 @@ public class QpidSslRMIServerSocketFactory extends SslRMIServerSocketFactory true); sslSocket.setUseClientMode(false); SSLUtil.removeSSLv3Support(sslSocket); + SSLUtil.updateEnabledCipherSuites(sslSocket, _enabledCipherSuites, _disabledCipherSuites); return sslSocket; } }; |
