qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1574258 - in /qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server: model/ model/adapter/ queue/ security/auth/manager/
Date Tue, 04 Mar 2014 23:53:17 GMT
Author: rgodfrey
Date: Tue Mar  4 23:53:16 2014
New Revision: 1574258

URL: http://svn.apache.org/r1574258
Log:
QPID-5591 : Address review comments from Robbie Gemmell

Added:
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttributeField.java
Modified:
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractKeyStoreAdapter.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java

Added: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttributeField.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttributeField.java?rev=1574258&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttributeField.java
(added)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttributeField.java
Tue Mar  4 23:53:16 2014
@@ -0,0 +1,28 @@
+package org.apache.qpid.server.model;/*
+ *
+ * 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.
+ *
+ */
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ManagedAttributeField
+{
+}

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java?rev=1574258&r1=1574257&r2=1574258&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
Tue Mar  4 23:53:16 2014
@@ -23,6 +23,7 @@ package org.apache.qpid.server.model.ada
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.security.AccessControlException;
 import java.security.AccessController;
 import java.util.*;
@@ -78,12 +79,15 @@ public abstract class AbstractConfigured
     private final Collection<ConfigurationChangeListener> _changeListeners =
             new ArrayList<ConfigurationChangeListener>();
 
+    @ManagedAttributeField
     private final UUID _id;
+
     private final Map<String, Object> _defaultAttributes = new HashMap<String, Object>();
     private final TaskExecutor _taskExecutor;
     private final long _createdTime;
     private final String _createdBy;
 
+    @ManagedAttributeField
     private String _name;
 
     private final Map<String, Attribute<?,?>> _attributeTypes;
@@ -348,10 +352,10 @@ public abstract class AbstractConfigured
     @Override
     public Object getAttribute(String name)
     {
-        Attribute<?,?> attr = _attributeTypes.get(name);
+        Attribute<X,?> attr = (Attribute<X, ?>) _attributeTypes.get(name);
         if(attr != null && attr.getAnnotation().automate())
         {
-            Object value = attr.get(this);
+            Object value = attr.getValue((X)this);
             if(value != null && attr.getAnnotation().secure() &&
                !SecurityManager.SYSTEM.equals(Subject.getSubject(AccessController.getContext())))
             {
@@ -759,21 +763,6 @@ public abstract class AbstractConfigured
 
         }
 
-        public T get(final AbstractConfiguredObject<?> object)
-        {
-            try
-            {
-                return (T) _getter.invoke(object);
-            }
-            catch (IllegalAccessException e)
-            {
-                throw new ServerScopedRuntimeException("Unable to access attribute " + getName()
+ " on configuredObject type " + object.getClass().getName(), e);
-            }
-            catch (InvocationTargetException e)
-            {
-                throw new ServerScopedRuntimeException("Unable to access attribute " + getName()
+ " on configuredObject type " + object.getClass().getName(), e);
-            }
-        }
     }
 
     private static final class Statistic<C extends ConfiguredObject, T extends Number>
extends AttributeOrStatistic<C,T>
@@ -1347,13 +1336,14 @@ public abstract class AbstractConfigured
         }
     }
 
-    private static Field findField(final Attribute<?, ?> attr, Class<?> clazz)
+    private static Field findField(final Attribute<?, ?> attr, Class<?> objClass)
     {
+        Class<?> clazz = objClass;
         while(clazz != null)
         {
             for(Field field : clazz.getDeclaredFields())
             {
-                if(field.getName().equals("_" + attr.getName()))
+                if(field.getAnnotation(ManagedAttributeField.class) != null && field.getName().equals("_"
+ attr.getName().replace('.','_')))
                 {
                     field.setAccessible(true);
                     return field;
@@ -1361,7 +1351,11 @@ public abstract class AbstractConfigured
             }
             clazz = clazz.getSuperclass();
         }
-        return null;
+        if(objClass.isInterface() || Modifier.isAbstract(objClass.getModifiers()))
+        {
+            return null;
+        }
+        throw new ServerScopedRuntimeException("Unable to find field definition for automated
field " + attr.getName() + " in class " + objClass.getName());
     }
 
     private static String getName(final Method m, final Class<?> type)

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractKeyStoreAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractKeyStoreAdapter.java?rev=1574258&r1=1574257&r2=1574258&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractKeyStoreAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractKeyStoreAdapter.java
Tue Mar  4 23:53:16 2014
@@ -32,6 +32,7 @@ import org.apache.qpid.server.model.Brok
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.KeyStore;
 import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.TrustStore;
 import org.apache.qpid.server.security.SecurityManager;
@@ -44,6 +45,7 @@ public abstract class AbstractKeyStoreAd
     public static final String DUMMY_PASSWORD_MASK = "********";
     public static final String DEFAULT_KEYSTORE_TYPE = java.security.KeyStore.getDefaultType();
 
+    @ManagedAttributeField
     private String _password;
 
 

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java?rev=1574258&r1=1574257&r2=1574258&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
Tue Mar  4 23:53:16 2014
@@ -38,14 +38,23 @@ final class ConnectionAdapter extends Ab
     private final Map<AMQSessionModel, SessionAdapter> _sessionAdapters =
             new HashMap<AMQSessionModel, SessionAdapter>();
 
+    @ManagedAttributeField
     private String _remoteAddress;
+    @ManagedAttributeField
     private String _localAddress;
+    @ManagedAttributeField
     private String _clientId;
+    @ManagedAttributeField
     private String _clientVersion;
+    @ManagedAttributeField
     private boolean _incoming;
+    @ManagedAttributeField
     private Transport _transport;
+    @ManagedAttributeField
     private Port _port;
+    @ManagedAttributeField
     private String _remoteProcessName;
+    @ManagedAttributeField
     private String _remoteProcessPid;
 
     public ConnectionAdapter(final AMQConnectionModel conn, TaskExecutor taskExecutor)

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java?rev=1574258&r1=1574257&r2=1574258&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
Tue Mar  4 23:53:16 2014
@@ -43,6 +43,7 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.IntegrityViolationException;
 import org.apache.qpid.server.model.KeyStore;
+import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.security.SecurityManager;
@@ -64,9 +65,13 @@ public class KeyStoreAdapter extends Abs
         put(KEY_MANAGER_FACTORY_ALGORITHM, String.class);
     }});
 
+    @ManagedAttributeField
     private String _keyStoreType;
+    @ManagedAttributeField
     private String _certificateAlias;
+    @ManagedAttributeField
     private String _keyManagerFactoryAlgorithm;
+    @ManagedAttributeField
     private String _path;
 
     @SuppressWarnings("serial")

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java?rev=1574258&r1=1574257&r2=1574258&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
Tue Mar  4 23:53:16 2014
@@ -43,6 +43,7 @@ final class SessionAdapter extends Abstr
     private AMQSessionModel _session;
     private Map<Consumer, QueueConsumer> _consumerAdapters = new HashMap<Consumer,
QueueConsumer>();
 
+    @ManagedAttributeField
     private int _channelId;
 
     public SessionAdapter(final AMQSessionModel session, TaskExecutor taskExecutor)

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java?rev=1574258&r1=1574257&r2=1574258&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java
Tue Mar  4 23:53:16 2014
@@ -44,6 +44,7 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.IntegrityViolationException;
+import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.TrustStore;
@@ -74,10 +75,13 @@ public class TrustStoreAdapter extends A
         put(TrustStore.TRUST_MANAGER_FACTORY_ALGORITHM, TrustManagerFactory.getDefaultAlgorithm());
     }});
 
-
+    @ManagedAttributeField
     private String _trustStoreType;
+    @ManagedAttributeField
     private String _trustManagerFactoryAlgorithm;
+    @ManagedAttributeField
     private String _path;
+    @ManagedAttributeField
     private boolean _peersOnly;
 
 

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java?rev=1574258&r1=1574257&r2=1574258&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
Tue Mar  4 23:53:16 2014
@@ -36,6 +36,7 @@ import org.apache.qpid.server.message.Se
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Consumer;
 import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.adapter.AbstractConfiguredObject;
 import org.apache.qpid.server.protocol.AMQSessionModel;
@@ -99,11 +100,17 @@ class QueueConsumerImpl
             CurrentActor.get().message(SubscriptionMessages.STATE(newState.toString()));
         }
     };
+    @ManagedAttributeField
     private boolean _durable;
+    @ManagedAttributeField
     private boolean _exclusive;
+    @ManagedAttributeField
     private boolean _noLocal;
+    @ManagedAttributeField
     private String _distributionMode;
+    @ManagedAttributeField
     private String _settlementMode;
+    @ManagedAttributeField
     private String _selector;
 
     QueueConsumerImpl(final AbstractQueue queue,

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java?rev=1574258&r1=1574257&r2=1574258&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java
Tue Mar  4 23:53:16 2014
@@ -27,6 +27,7 @@ import javax.security.sasl.SaslServer;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ManagedAttribute;
+import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.security.auth.AuthenticationResult;
 import org.apache.qpid.server.security.auth.UsernamePrincipal;
 import org.apache.qpid.server.security.auth.sasl.external.ExternalSaslServer;
@@ -35,6 +36,7 @@ public class ExternalAuthenticationManag
 {
     private static final String EXTERNAL = "EXTERNAL";
 
+    @ManagedAttributeField
     private boolean _useFullDN;
 
     protected ExternalAuthenticationManager(final Broker broker,

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java?rev=1574258&r1=1574257&r2=1574258&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java
Tue Mar  4 23:53:16 2014
@@ -56,6 +56,7 @@ public abstract class PrincipalDatabaseA
 
 
     private final PrincipalDatabase _principalDatabase;
+    @ManagedAttributeField
     private String _path;
 
     protected PrincipalDatabaseAuthenticationManager(final Broker broker,

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java?rev=1574258&r1=1574257&r2=1574258&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java
Tue Mar  4 23:53:16 2014
@@ -49,6 +49,7 @@ import org.apache.log4j.Logger;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ManagedAttribute;
+import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.TrustStore;
 import org.apache.qpid.server.security.auth.AuthenticationResult;
 import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus;
@@ -70,10 +71,15 @@ public class SimpleLDAPAuthenticationMan
      */
     private static final String JAVA_NAMING_LDAP_FACTORY_SOCKET = "java.naming.ldap.factory.socket";
 
+    @ManagedAttributeField
     private String _providerUrl;
+    @ManagedAttributeField
     private String _providerAuthUrl;
+    @ManagedAttributeField
     private String _searchContext;
+    @ManagedAttributeField
     private String _searchFilter;
+    @ManagedAttributeField
     private String _ldapContextFactory;
 
 
@@ -81,6 +87,7 @@ public class SimpleLDAPAuthenticationMan
      * Trust store - typically used when the Directory has been secured with a certificate
signed by a
      * private CA (or self-signed certificate).
      */
+    @ManagedAttributeField
     private TrustStore _trustStore;
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message