summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins/management-http/src
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-04-30 01:22:13 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-04-30 01:22:13 +0000
commitae71aa7102a41735e49ec5c98409bc69fffd9a8f (patch)
treef0709ee8c5993d6995e5de59c0cdc855a540614e /qpid/java/broker-plugins/management-http/src
parent0d49f2fa419a414e1c9548001fcbde03d442f5c1 (diff)
downloadqpid-python-ae71aa7102a41735e49ec5c98409bc69fffd9a8f.tar.gz
QPID-5578 : [Java Broker] Use annotation to allow registration of all ConfiguredObject types at startup. Use this meta data for REST servlets. Remove unnecessary pluggable factory interfaces
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1591170 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/management-http/src')
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java5
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/AbstractSpecialisedAttributeLister.java77
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java47
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java46
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListGroupProviderAttributes.java46
5 files changed, 92 insertions, 129 deletions
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java
index 0ed97ac3a0..1937ee8744 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java
@@ -34,6 +34,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.codec.binary.Base64;
+
import org.apache.qpid.server.management.plugin.servlet.ServletConnectionPrincipal;
import org.apache.qpid.server.management.plugin.session.LoginLogoutReporter;
import org.apache.qpid.server.model.AuthenticationProvider;
@@ -44,7 +45,7 @@ import org.apache.qpid.server.security.auth.AuthenticatedPrincipal;
import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus;
import org.apache.qpid.server.security.auth.SubjectAuthenticationResult;
import org.apache.qpid.server.security.auth.UsernamePrincipal;
-import org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManagerFactory;
+import org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManager;
import org.apache.qpid.transport.network.security.ssl.SSLUtil;
public class HttpManagementUtil
@@ -162,7 +163,7 @@ public class HttpManagementUtil
{
principal = certificates[0].getSubjectX500Principal();
- if(!Boolean.valueOf(String.valueOf(authenticationProvider.getAttribute(ExternalAuthenticationManagerFactory.ATTRIBUTE_USE_FULL_DN))))
+ if(!Boolean.valueOf(String.valueOf(authenticationProvider.getAttribute(ExternalAuthenticationManager.ATTRIBUTE_USE_FULL_DN))))
{
String username;
String dn = ((X500Principal) principal).getName(X500Principal.RFC2253);
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/AbstractSpecialisedAttributeLister.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/AbstractSpecialisedAttributeLister.java
new file mode 100644
index 0000000000..173e4fce66
--- /dev/null
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/AbstractSpecialisedAttributeLister.java
@@ -0,0 +1,77 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.management.plugin.servlet.rest.action;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.apache.qpid.server.management.plugin.servlet.rest.Action;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ConfiguredObjectAttribute;
+import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry;
+
+abstract class AbstractSpecialisedAttributeLister<T extends ConfiguredObject> implements Action
+{
+
+
+ private static final String ATTRIBUTES = "attributes";
+ private static final String DESCRIPTIONS = "descriptions";
+
+ @Override
+ final public Object perform(Map<String, Object> request, Broker broker)
+ {
+ Collection<Class<? extends ConfiguredObject>> groupProviderTypes =
+ ConfiguredObjectTypeRegistry.getTypeSpecialisations(getCategoryClass());
+
+ Map<String, Object> attributes = new TreeMap<String, Object>();
+
+ for (Class<? extends ConfiguredObject> groupProviderType : groupProviderTypes)
+ {
+ Collection<ConfiguredObjectAttribute<?, ?>> typeSpecificAttributes =
+ ConfiguredObjectTypeRegistry.getTypeSpecificAttributes(groupProviderType);
+
+ Map<String, Object> data = new HashMap<String, Object>();
+
+ Collection<String> attributeNames = new TreeSet<>();
+ Map<String,String> descriptions = new HashMap<>();
+ for(ConfiguredObjectAttribute<?, ?> attr : typeSpecificAttributes)
+ {
+ attributeNames.add(attr.getName());
+ if(!"".equals(attr.getAnnotation().description()))
+ {
+ descriptions.put(attr.getName(), attr.getAnnotation().description());
+ }
+ }
+ data.put(ATTRIBUTES, attributeNames);
+ data.put(DESCRIPTIONS, descriptions);
+
+ attributes.put(ConfiguredObjectTypeRegistry.getType(groupProviderType), data);
+ }
+ return attributes;
+ }
+
+ abstract Class<T> getCategoryClass();
+
+}
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java
index 84d05997b5..1eb3f9a9ac 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java
@@ -20,32 +20,10 @@
*/
package org.apache.qpid.server.management.plugin.servlet.rest.action;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TreeMap;
+import org.apache.qpid.server.model.AccessControlProvider;
-import org.apache.qpid.server.management.plugin.servlet.rest.Action;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.plugin.AccessControlProviderFactory;
-import org.apache.qpid.server.plugin.QpidServiceLoader;
-
-public class ListAccessControlProviderAttributes implements Action
+public class ListAccessControlProviderAttributes extends AbstractSpecialisedAttributeLister<AccessControlProvider>
{
- private static final String ATTRIBUTES = "attributes";
- private static final String DESCRIPTIONS = "descriptions";
- private Map<String, AccessControlProviderFactory> _factories;
-
- public ListAccessControlProviderAttributes()
- {
- _factories = new TreeMap<String, AccessControlProviderFactory>();
- Iterable<AccessControlProviderFactory> factories = new QpidServiceLoader<AccessControlProviderFactory>()
- .instancesOf(AccessControlProviderFactory.class);
- for (AccessControlProviderFactory factory : factories)
- {
- _factories.put(factory.getType(), factory);
- }
- }
-
@Override
public String getName()
{
@@ -53,25 +31,8 @@ public class ListAccessControlProviderAttributes implements Action
}
@Override
- public Object perform(Map<String, Object> request, Broker broker)
+ Class<AccessControlProvider> getCategoryClass()
{
- Map<String, Object> attributes = new TreeMap<String, Object>();
- for (String providerType : _factories.keySet())
- {
- AccessControlProviderFactory<?> factory = _factories.get(providerType);
-
- Map<String, Object> data = new HashMap<String, Object>();
- // TODO RG - fix
- // data.put(ATTRIBUTES, factory.getAttributeNames());
- Map<String, String> resources = factory.getAttributeDescriptions();
- if (resources != null)
- {
- data.put(DESCRIPTIONS, resources);
- }
-
- attributes.put(factory.getType(), data);
- }
- return attributes;
+ return AccessControlProvider.class;
}
-
}
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java
index 5c629587e0..3e006a705a 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java
@@ -20,32 +20,10 @@
*/
package org.apache.qpid.server.management.plugin.servlet.rest.action;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TreeMap;
+import org.apache.qpid.server.model.AuthenticationProvider;
-import org.apache.qpid.server.management.plugin.servlet.rest.Action;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.plugin.AuthenticationManagerFactory;
-import org.apache.qpid.server.plugin.QpidServiceLoader;
-
-public class ListAuthenticationProviderAttributes implements Action
+public class ListAuthenticationProviderAttributes extends AbstractSpecialisedAttributeLister<AuthenticationProvider>
{
- private static final String ATTRIBUTES = "attributes";
- private static final String DESCRIPTIONS = "descriptions";
- private Map<String, AuthenticationManagerFactory> _factories;
-
- public ListAuthenticationProviderAttributes()
- {
- _factories = new TreeMap<String, AuthenticationManagerFactory>();
- Iterable<AuthenticationManagerFactory> factories = new QpidServiceLoader<AuthenticationManagerFactory>()
- .instancesOf(AuthenticationManagerFactory.class);
- for (AuthenticationManagerFactory factory : factories)
- {
- _factories.put(factory.getType(), factory);
- }
- }
-
@Override
public String getName()
{
@@ -53,24 +31,8 @@ public class ListAuthenticationProviderAttributes implements Action
}
@Override
- public Object perform(Map<String, Object> request, Broker broker)
+ Class<AuthenticationProvider> getCategoryClass()
{
- Map<String, Object> attributes = new TreeMap<String, Object>();
- for (String providerType : _factories.keySet())
- {
- AuthenticationManagerFactory factory = _factories.get(providerType);
-
- Map<String, Object> data = new HashMap<String, Object>();
- data.put(ATTRIBUTES, factory.getAttributeNames());
- Map<String, String> resources = factory.getAttributeDescriptions();
- if (resources != null)
- {
- data.put(DESCRIPTIONS, resources);
- }
-
- attributes.put(factory.getType(), data);
- }
- return attributes;
+ return AuthenticationProvider.class;
}
-
}
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListGroupProviderAttributes.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListGroupProviderAttributes.java
index d1414faa71..ecb4320f1f 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListGroupProviderAttributes.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListGroupProviderAttributes.java
@@ -20,32 +20,10 @@
*/
package org.apache.qpid.server.management.plugin.servlet.rest.action;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TreeMap;
+import org.apache.qpid.server.model.GroupProvider;
-import org.apache.qpid.server.management.plugin.servlet.rest.Action;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.plugin.GroupManagerFactory;
-import org.apache.qpid.server.plugin.QpidServiceLoader;
-
-public class ListGroupProviderAttributes implements Action
+public class ListGroupProviderAttributes extends AbstractSpecialisedAttributeLister<GroupProvider>
{
- private static final String ATTRIBUTES = "attributes";
- private static final String DESCRIPTIONS = "descriptions";
- private Map<String, GroupManagerFactory> _factories;
-
- public ListGroupProviderAttributes()
- {
- _factories = new TreeMap<String, GroupManagerFactory>();
- Iterable<GroupManagerFactory> factories = new QpidServiceLoader<GroupManagerFactory>()
- .instancesOf(GroupManagerFactory.class);
- for (GroupManagerFactory factory : factories)
- {
- _factories.put(factory.getType(), factory);
- }
- }
-
@Override
public String getName()
{
@@ -53,24 +31,8 @@ public class ListGroupProviderAttributes implements Action
}
@Override
- public Object perform(Map<String, Object> request, Broker broker)
+ Class<GroupProvider> getCategoryClass()
{
- Map<String, Object> attributes = new TreeMap<String, Object>();
- for (String providerType : _factories.keySet())
- {
- GroupManagerFactory factory = _factories.get(providerType);
-
- Map<String, Object> data = new HashMap<String, Object>();
- data.put(ATTRIBUTES, factory.getAttributeNames());
- Map<String, String> resources = factory.getAttributeDescriptions();
- if (resources != null)
- {
- data.put(DESCRIPTIONS, resources);
- }
-
- attributes.put(factory.getType(), data);
- }
- return attributes;
+ return GroupProvider.class;
}
-
}