activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r769838 - in /activemq/trunk: ./ activemq-jaas/ activemq-jaas/src/main/java/org/apache/activemq/jaas/ activemq-jaas/src/test/java/org/apache/activemq/jaas/ activemq-jaas/src/test/java/org/apache/activemq/jaas/ldap/ activemq-jaas/src/test/re...
Date Wed, 29 Apr 2009 17:14:15 GMT
Author: dejanb
Date: Wed Apr 29 17:14:15 2009
New Revision: 769838

URL: http://svn.apache.org/viewvc?rev=769838&view=rev
Log:
fix for https://issues.apache.org/activemq/browse/AMQ-1781 - ldap login module npe

Added:
    activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginProperty.java
    activemq/trunk/activemq-jaas/src/test/resources/log4j.properties
Removed:
    activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/ldap/
Modified:
    activemq/trunk/activemq-jaas/pom.xml
    activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginModule.java
    activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/LDAPLoginModuleTest.java
    activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/PropertiesLoginModuleTest.java
    activemq/trunk/activemq-jaas/src/test/resources/login.config
    activemq/trunk/pom.xml

Modified: activemq/trunk/activemq-jaas/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-jaas/pom.xml?rev=769838&r1=769837&r2=769838&view=diff
==============================================================================
--- activemq/trunk/activemq-jaas/pom.xml (original)
+++ activemq/trunk/activemq-jaas/pom.xml Wed Apr 29 17:14:15 2009
@@ -36,84 +36,74 @@
 
   <build>
     <plugins>
-
       <!-- Configure which tests are included/excuded -->
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
-          <childDelegation>true</childDelegation>
-          <forkMode>once</forkMode>
-          <excludes>
-            <exclude implementation="java.lang.String">**/LDAPLoginModuleTest.*</exclude>
-          </excludes>
-          <includes>
-            <include implementation="java.lang.String">**/*Test.*</include>
-          </includes>
+          <forkMode>pertest</forkMode>
+          <childDelegation>false</childDelegation>
+          <useFile>true</useFile>
+          <argLine>-Xmx512M</argLine>
+
+           <systemProperties>
+            <property>
+              <name>org.apache.activemq.default.directory.prefix</name>
+              <value>target/</value>
+            </property>
+            <property>
+              <name>log4j.configuration</name>
+              <value>file:target/test-classes/log4j.properties</value>
+            </property>
+          </systemProperties>
         </configuration>
       </plugin>
-
     </plugins>
   </build>
 
 
   <dependencies>
     <dependency>
-      <groupId>commons-logging</groupId>
-      <artifactId>commons-logging</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>directory</groupId>
-      <artifactId>apacheds-core</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>directory</groupId>
-      <artifactId>apacheds-shared</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>directory-shared</groupId>
-      <artifactId>apache-ldapber-provider</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>directory-shared</groupId>
-      <artifactId>ldap-common</artifactId>
-      <scope>test</scope>
-    </dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+      </dependency>
     <dependency>
-      <groupId>directory-asn1</groupId>
-      <artifactId>asn1-codec</artifactId>
-      <scope>test</scope>
+        <groupId>commons-collections</groupId>
+        <artifactId>commons-collections</artifactId>
+        <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>directory-asn1</groupId>
-      <artifactId>asn1-der</artifactId>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-integ</artifactId>
+      <version>${directory-version}</version>
       <scope>test</scope>
-    </dependency>
+    </dependency>  
+
     <dependency>
-      <groupId>directory-shared</groupId>
-      <artifactId>kerberos-common</artifactId>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-server-integ</artifactId>
+      <version>${directory-version}</version>
       <scope>test</scope>
-    </dependency>
+    </dependency> 
+    
     <dependency>
-      <groupId>directory-network</groupId>
-      <artifactId>mina</artifactId>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>directory-protocols</groupId>
-      <artifactId>kerberos-protocol</artifactId>
+      <groupId>org.apache.xbean</groupId>
+      <artifactId>xbean-spring</artifactId>
+      <optional>true</optional>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>directory-protocols</groupId>
-      <artifactId>ldap-protocol</artifactId>
-      <scope>test</scope>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
     </dependency>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <groupId>org.slf4j</groupId>
+      <artifactId>nlog4j</artifactId>
+      <version>${nlog4j-version}</version>
       <scope>test</scope>
     </dependency>
   </dependencies>

Modified: activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginModule.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginModule.java?rev=769838&r1=769837&r2=769838&view=diff
==============================================================================
--- activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginModule.java
(original)
+++ activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginModule.java
Wed Apr 29 17:14:15 2009
@@ -77,48 +77,35 @@
     protected DirContext context;
 
     private Subject subject;
-    private CallbackHandler handler;
-    private String initialContextFactory;
-    private String connectionURL;
-    private String connectionUsername;
-    private String connectionPassword;
-    private String connectionProtocol;
-    private String authentication;
-    private String userBase;
-    private String roleBase;
-    private String roleName;
-    private String userRoleName;
+    private CallbackHandler handler;  
+    private LDAPLoginProperty [] config;
     private String username;
-    private MessageFormat userSearchMatchingFormat;
-    private MessageFormat roleSearchMatchingFormat;
-    private boolean userSearchSubtreeBool;
-    private boolean roleSearchSubtreeBool;
     private Set<GroupPrincipal> groups = new HashSet<GroupPrincipal>();
 
     public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState,
Map options) {
         this.subject = subject;
         this.handler = callbackHandler;
-        initialContextFactory = (String)options.get(INITIAL_CONTEXT_FACTORY);
-        connectionURL = (String)options.get(CONNECTION_URL);
-        connectionUsername = (String)options.get(CONNECTION_USERNAME);
-        connectionPassword = (String)options.get(CONNECTION_PASSWORD);
-        connectionProtocol = (String)options.get(CONNECTION_PROTOCOL);
-        authentication = (String)options.get(AUTHENTICATION);
-        userBase = (String)options.get(USER_BASE);
-        String userSearchMatching = (String)options.get(USER_SEARCH_MATCHING);
-        String userSearchSubtree = (String)options.get(USER_SEARCH_SUBTREE);
-        roleBase = (String)options.get(ROLE_BASE);
-        roleName = (String)options.get(ROLE_NAME);
-        String roleSearchMatching = (String)options.get(ROLE_SEARCH_MATCHING);
-        String roleSearchSubtree = (String)options.get(ROLE_SEARCH_SUBTREE);
-        userRoleName = (String)options.get(USER_ROLE_NAME);
-        userSearchMatchingFormat = new MessageFormat(userSearchMatching);
-        roleSearchMatchingFormat = new MessageFormat(roleSearchMatching);
-        userSearchSubtreeBool = Boolean.valueOf(userSearchSubtree).booleanValue();
-        roleSearchSubtreeBool = Boolean.valueOf(roleSearchSubtree).booleanValue();
+        
+        config = new LDAPLoginProperty [] {
+        		new LDAPLoginProperty (INITIAL_CONTEXT_FACTORY, (String)options.get(INITIAL_CONTEXT_FACTORY)),
+        		new LDAPLoginProperty (CONNECTION_URL, (String)options.get(CONNECTION_URL)),
+        		new LDAPLoginProperty (CONNECTION_USERNAME, (String)options.get(CONNECTION_USERNAME)),
+        		new LDAPLoginProperty (CONNECTION_PASSWORD, (String)options.get(CONNECTION_PASSWORD)),
+        		new LDAPLoginProperty (CONNECTION_PROTOCOL, (String)options.get(CONNECTION_PROTOCOL)),
+        		new LDAPLoginProperty (AUTHENTICATION, (String)options.get(AUTHENTICATION)),
+        		new LDAPLoginProperty (USER_BASE, (String)options.get(USER_BASE)),
+        		new LDAPLoginProperty (USER_SEARCH_MATCHING, (String)options.get(USER_SEARCH_MATCHING)),
+        		new LDAPLoginProperty (USER_SEARCH_SUBTREE, (String)options.get(USER_SEARCH_SUBTREE)),
+        		new LDAPLoginProperty (ROLE_BASE, (String)options.get(ROLE_BASE)),
+        		new LDAPLoginProperty (ROLE_NAME, (String)options.get(ROLE_NAME)),
+        		new LDAPLoginProperty (ROLE_SEARCH_MATCHING, (String)options.get(ROLE_SEARCH_MATCHING)),
+        		new LDAPLoginProperty (ROLE_SEARCH_SUBTREE, (String)options.get(ROLE_SEARCH_SUBTREE)),
+        		new LDAPLoginProperty (USER_ROLE_NAME, (String)options.get(USER_ROLE_NAME)),
+        		};
     }
 
     public boolean login() throws LoginException {
+
         Callback[] callbacks = new Callback[2];
 
         callbacks[0] = new NameCallback("User name");
@@ -130,12 +117,17 @@
         } catch (UnsupportedCallbackException uce) {
             throw (LoginException)new LoginException().initCause(uce);
         }
+        
+        String password;
+        
         username = ((NameCallback)callbacks[0]).getName();
-        String password = new String(((PasswordCallback)callbacks[1]).getPassword());
-
-        if (username == null || "".equals(username) || password == null || "".equals(password))
{
-            return false;
-        }
+        if (username == null)
+        	return false;
+        	
+        if (((PasswordCallback)callbacks[1]).getPassword() != null)
+        	password = new String(((PasswordCallback)callbacks[1]).getPassword());
+        else
+        	password="";
 
         try {
             boolean result = authenticate(username, password);
@@ -179,8 +171,17 @@
 
     protected boolean authenticate(String username, String password) throws Exception {
 
+        MessageFormat userSearchMatchingFormat;
+        boolean userSearchSubtreeBool;
+        
         DirContext context = null;
         context = open();
+        
+        if (!isLoginPropertySet(USER_SEARCH_MATCHING))
+        	return false;
+
+        userSearchMatchingFormat = new MessageFormat(getLDAPPropertyValue(USER_SEARCH_MATCHING));
+        userSearchSubtreeBool = Boolean.valueOf(getLDAPPropertyValue(USER_SEARCH_SUBTREE)).booleanValue();
 
         try {
 
@@ -196,14 +197,14 @@
 
             // setup attributes
             ArrayList<String> list = new ArrayList<String>();
-            if (userRoleName != null) {
-                list.add(userRoleName);
+            if (isLoginPropertySet(USER_ROLE_NAME)) {
+                list.add(getLDAPPropertyValue(USER_ROLE_NAME));
             }
             String[] attribs = new String[list.size()];
             list.toArray(attribs);
             constraints.setReturningAttributes(attribs);
 
-            NamingEnumeration results = context.search(userBase, filter, constraints);
+            NamingEnumeration results = context.search(getLDAPPropertyValue(USER_BASE), filter,
constraints);
 
             if (results == null || !results.hasMore()) {
                 return false;
@@ -216,7 +217,7 @@
             }
             NameParser parser = context.getNameParser("");
             Name contextName = parser.parse(context.getNameInNamespace());
-            Name baseName = parser.parse(userBase);
+            Name baseName = parser.parse(getLDAPPropertyValue(USER_BASE));
             Name entryName = parser.parse(result.getName());
             Name name = contextName.addAll(baseName);
             name = name.addAll(entryName);
@@ -227,8 +228,8 @@
                 return false;
             }
             ArrayList<String> roles = null;
-            if (userRoleName != null) {
-                roles = addAttributeValues(userRoleName, attrs, roles);
+            if (isLoginPropertySet(USER_ROLE_NAME)) {
+                roles = addAttributeValues(getLDAPPropertyValue(USER_ROLE_NAME), attrs, roles);
             }
 
             // check the credentials by binding to server
@@ -255,10 +256,15 @@
 
     protected ArrayList<String> getRoles(DirContext context, String dn, String username,
ArrayList<String> currentRoles) throws NamingException {
         ArrayList<String> list = currentRoles;
+        MessageFormat roleSearchMatchingFormat;
+        boolean roleSearchSubtreeBool;
+        roleSearchMatchingFormat = new MessageFormat(getLDAPPropertyValue(ROLE_SEARCH_MATCHING));
+        roleSearchSubtreeBool = Boolean.valueOf(getLDAPPropertyValue(ROLE_SEARCH_SUBTREE)).booleanValue();
+        
         if (list == null) {
             list = new ArrayList<String>();
         }
-        if (roleName == null || "".equals(roleName)) {
+        if (!isLoginPropertySet(ROLE_NAME)) {
             return list;
         }
         String filter = roleSearchMatchingFormat.format(new String[] {
@@ -271,14 +277,14 @@
         } else {
             constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
         }
-        NamingEnumeration results = context.search(roleBase, filter, constraints);
+        NamingEnumeration results = context.search(getLDAPPropertyValue(ROLE_BASE), filter,
constraints);
         while (results.hasMore()) {
             SearchResult result = (SearchResult)results.next();
             Attributes attrs = result.getAttributes();
             if (attrs == null) {
                 continue;
             }
-            list = addAttributeValues(roleName, attrs, list);
+            list = addAttributeValues(getLDAPPropertyValue(ROLE_NAME), attrs, list);
         }
         return list;
 
@@ -325,14 +331,14 @@
             log.debug("Authentication failed for dn=" + dn);
         }
 
-        if (connectionUsername != null) {
-            context.addToEnvironment(Context.SECURITY_PRINCIPAL, connectionUsername);
+        if (isLoginPropertySet(CONNECTION_USERNAME)) {
+            context.addToEnvironment(Context.SECURITY_PRINCIPAL, getLDAPPropertyValue(CONNECTION_USERNAME));
         } else {
             context.removeFromEnvironment(Context.SECURITY_PRINCIPAL);
         }
 
-        if (connectionPassword != null) {
-            context.addToEnvironment(Context.SECURITY_CREDENTIALS, connectionPassword);
+        if (isLoginPropertySet(CONNECTION_PASSWORD)) {
+            context.addToEnvironment(Context.SECURITY_CREDENTIALS, getLDAPPropertyValue(CONNECTION_PASSWORD));
         } else {
             context.removeFromEnvironment(Context.SECURITY_CREDENTIALS);
         }
@@ -361,22 +367,18 @@
     }
 
     protected DirContext open() throws NamingException {
-        if (context != null) {
-            return context;
-        }
-
         try {
             Hashtable<String, String> env = new Hashtable<String, String>();
-            env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
-            if (connectionUsername != null || !"".equals(connectionUsername)) {
-                env.put(Context.SECURITY_PRINCIPAL, connectionUsername);
-            }
-            if (connectionPassword != null || !"".equals(connectionPassword)) {
-                env.put(Context.SECURITY_CREDENTIALS, connectionPassword);
-            }
-            env.put(Context.SECURITY_PROTOCOL, connectionProtocol);
-            env.put(Context.PROVIDER_URL, connectionURL);
-            env.put(Context.SECURITY_AUTHENTICATION, authentication);
+            env.put(Context.INITIAL_CONTEXT_FACTORY, getLDAPPropertyValue(INITIAL_CONTEXT_FACTORY));
+            if (isLoginPropertySet(CONNECTION_USERNAME)) {
+                env.put(Context.SECURITY_PRINCIPAL, getLDAPPropertyValue(CONNECTION_USERNAME));
+            }
+            if (isLoginPropertySet(CONNECTION_PASSWORD)) {
+                env.put(Context.SECURITY_CREDENTIALS, getLDAPPropertyValue(CONNECTION_PASSWORD));
+            }
+            env.put(Context.SECURITY_PROTOCOL, getLDAPPropertyValue(CONNECTION_PROTOCOL));
+            env.put(Context.PROVIDER_URL, getLDAPPropertyValue(CONNECTION_URL));
+            env.put(Context.SECURITY_AUTHENTICATION, getLDAPPropertyValue(AUTHENTICATION));
             context = new InitialDirContext(env);
 
         } catch (NamingException e) {
@@ -385,5 +387,20 @@
         }
         return context;
     }
+    
+    private String getLDAPPropertyValue (String propertyName){
+    	for (int i=0; i < config.length; i++ )
+    		if (config[i].getPropertyName() == propertyName)
+    			return config[i].getPropertyValue();
+    	return null;
+    }
+    
+    private boolean isLoginPropertySet(String propertyName) {
+    	for (int i=0; i < config.length; i++ ) {
+    		if (config[i].getPropertyName() == propertyName && config[i].getPropertyValue()
!= null)
+    				return true;
+    	}
+    	return false;
+    }
 
 }

Added: activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginProperty.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginProperty.java?rev=769838&view=auto
==============================================================================
--- activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginProperty.java
(added)
+++ activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginProperty.java
Wed Apr 29 17:14:15 2009
@@ -0,0 +1,40 @@
+/**
+ * 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.activemq.jaas;
+
+public class LDAPLoginProperty {
+	private String name;
+	private String value;
+
+	public LDAPLoginProperty(String name) {
+		this.name = name;
+	}
+
+	public LDAPLoginProperty(String name, String value) {
+		this.name = name;
+		this.value = value;
+	}
+	
+	public String getPropertyName() {
+		return this.name;
+	}
+	public String getPropertyValue() {
+		return this.value;
+	}
+
+}

Modified: activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/LDAPLoginModuleTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/LDAPLoginModuleTest.java?rev=769838&r1=769837&r2=769838&view=diff
==============================================================================
--- activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/LDAPLoginModuleTest.java
(original)
+++ activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/LDAPLoginModuleTest.java
Wed Apr 29 17:14:15 2009
@@ -16,12 +16,13 @@
  */
 package org.apache.activemq.jaas;
 
-import java.io.File;
+import static org.junit.Assert.assertTrue;
+
 import java.io.IOException;
-import java.net.InetAddress;
+import java.net.URL;
 import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.Properties;
+
 import javax.naming.Context;
 import javax.naming.NameClassPair;
 import javax.naming.NamingEnumeration;
@@ -35,40 +36,60 @@
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 
-import junit.framework.TestCase;
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.integ.SiRunner;
+import org.apache.directory.server.ldap.LdapService;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
-import org.apache.activemq.jaas.ldap.MutableServerStartupConfiguration;
-import org.apache.activemq.jaas.ldap.ServerContextFactory;
-import org.apache.ldap.server.configuration.ShutdownConfiguration;
-import org.apache.ldap.server.jndi.CoreContextFactory;
 
 
 
-/**
- * @version $Rev: $ $Date: $
- */
-public class LDAPLoginModuleTest extends TestCase {
-
+@RunWith ( SiRunner.class ) 
+@CleanupLevel ( Level.CLASS )
+@ApplyLdifs( {
+	"dn: uid=first,ou=system\n" +
+	"uid: first\n" +
+	"userPassword: secret\n" +
+	"objectClass: account\n" +
+	"objectClass: simpleSecurityObject\n" +
+	"objectClass: top\n" 
+}
+)
+public class LDAPLoginModuleTest {
+	
+    static {
+        String path = System.getProperty("java.security.auth.login.config");
+        if (path == null) {
+            URL resource = PropertiesLoginModuleTest.class.getClassLoader().getResource("login.config");
+            if (resource != null) {
+                path = resource.getFile();
+                System.setProperty("java.security.auth.login.config", path);
+            }
+        }
+    }
+    
+    private static final String BASE = "ou=system";
+    public static LdapService ldapService;
+    private static final String FILTER = "(objectclass=*)";
+    
     private static final String PRINCIPAL = "uid=admin,ou=system";
     private static final String CREDENTIALS = "secret";
-
-    public void testNothing() {
-    }
-
+    
     @SuppressWarnings("unchecked")
+    @Test
     public void testRunning() throws Exception {
 
         Hashtable env = new Hashtable();
-        env.put(Context.PROVIDER_URL, "ldap://localhost:9389");
+        env.put(Context.PROVIDER_URL, "ldap://localhost:1024");
         env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
         env.put(Context.SECURITY_AUTHENTICATION, "simple");
         env.put(Context.SECURITY_PRINCIPAL, PRINCIPAL);
         env.put(Context.SECURITY_CREDENTIALS, CREDENTIALS);
         DirContext ctx = new InitialDirContext(env);
 
-        // Perform search using URL
-        // NamingEnumeration answer = ctx.search(
-        // "ldap://localhost:389/ou=system", "(uid=admin)", null);
         HashSet set = new HashSet();
 
         NamingEnumeration list = ctx.list("ou=system");
@@ -85,8 +106,9 @@
         assertTrue(set.contains("prefNodeName=sysPrefRoot"));
 
     }
-
-    public void xtestLogin() throws LoginException {
+    
+    @Test
+    public void testLogin() throws LoginException {
         LoginContext context = new LoginContext("LDAPLogin", new CallbackHandler() {
             public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
                 for (int i = 0; i < callbacks.length; i++) {
@@ -104,39 +126,4 @@
         context.logout();
     }
 
-    @SuppressWarnings("unchecked")
-    public void setUp() throws Exception {
-        MutableServerStartupConfiguration startup = new MutableServerStartupConfiguration();
-        // put some mandatory JNDI properties here
-        startup.setWorkingDirectory(new File("target/ldap"));
-        startup.setAllowAnonymousAccess(true);
-        startup.setLdapPort(9389);
-        startup.setEnableNetworking(true);
-        startup.setHost(InetAddress.getByName("localhost"));
-
-        Properties env = new Properties();
-        env.putAll(startup.toJndiEnvironment());
-        env.put(Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName());
-        env.put(Context.PROVIDER_URL, "ou=system");
-        env.put(Context.SECURITY_AUTHENTICATION, "simple");
-        env.put(Context.SECURITY_PRINCIPAL, PRINCIPAL);
-        env.put(Context.SECURITY_CREDENTIALS, CREDENTIALS);
-
-        //Fire it up
-        new InitialDirContext(env);
-    }
-
-    @SuppressWarnings("unchecked")
-    public void tearDown() throws Exception {
-        Properties env = new Properties();
-        env.putAll(new ShutdownConfiguration().toJndiEnvironment());
-        env.put(Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName());
-        env.put(Context.PROVIDER_URL, "ou=system");
-        env.put(Context.SECURITY_AUTHENTICATION, "simple");
-        env.put(Context.SECURITY_PRINCIPAL, PRINCIPAL);
-        env.put(Context.SECURITY_CREDENTIALS, CREDENTIALS);
-
-        //Shut it down
-        new InitialDirContext(env);
-    }
 }

Modified: activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/PropertiesLoginModuleTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/PropertiesLoginModuleTest.java?rev=769838&r1=769837&r2=769838&view=diff
==============================================================================
--- activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/PropertiesLoginModuleTest.java
(original)
+++ activemq/trunk/activemq-jaas/src/test/java/org/apache/activemq/jaas/PropertiesLoginModuleTest.java
Wed Apr 29 17:14:15 2009
@@ -46,7 +46,6 @@
                 System.setProperty("java.security.auth.login.config", path);
             }
         }
-        System.out.println("Path to login config: " + path);
     }
 
     public void testLogin() throws LoginException {

Added: activemq/trunk/activemq-jaas/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-jaas/src/test/resources/log4j.properties?rev=769838&view=auto
==============================================================================
--- activemq/trunk/activemq-jaas/src/test/resources/log4j.properties (added)
+++ activemq/trunk/activemq-jaas/src/test/resources/log4j.properties Wed Apr 29 17:14:15 2009
@@ -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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, out, stdout
+
+log4j.logger.org.apache.activemq=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/activemq-test.log
+log4j.appender.out.append=true

Modified: activemq/trunk/activemq-jaas/src/test/resources/login.config
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-jaas/src/test/resources/login.config?rev=769838&r1=769837&r2=769838&view=diff
==============================================================================
--- activemq/trunk/activemq-jaas/src/test/resources/login.config (original)
+++ activemq/trunk/activemq-jaas/src/test/resources/login.config Wed Apr 29 17:14:15 2009
@@ -12,7 +12,7 @@
  * 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.
+ * limitations under the License.         
  */
 PropertiesLogin {
     org.apache.activemq.jaas.PropertiesLoginModule required
@@ -25,11 +25,18 @@
     org.apache.activemq.jaas.LDAPLoginModule required
         debug=true
         initialContextFactory=com.sun.jndi.ldap.LdapCtxFactory
-        connectionURL="ldap://localhost:9389"
+        connectionURL="ldap://localhost:1024"
         connectionUsername="uid=admin,ou=system"
         connectionPassword=secret
         connectionProtocol=s
         authentication=simple
+        userBase="ou=system"
+        userSearchMatching="(uid={0})"
+        userSearchSubtree=false
+        roleBase="ou=system"
+        roleName=dummyRoleName
+        roleSearchMatching="(uid={1})"
+        roleSearchSubtree=false
         ;
 };
 

Modified: activemq/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/pom.xml?rev=769838&r1=769837&r2=769838&view=diff
==============================================================================
--- activemq/trunk/pom.xml (original)
+++ activemq/trunk/pom.xml Wed Apr 29 17:14:15 2009
@@ -45,7 +45,7 @@
     <camel-version>2.0-SNAPSHOT</camel-version>
     <cglib-version>2.0</cglib-version>
     <commons-beanutils-version>1.6.1</commons-beanutils-version>
-    <commons-collections-version>3.1</commons-collections-version>
+    <commons-collections-version>3.2.1</commons-collections-version>
     <openjpa-version>1.2.0</openjpa-version>
     <commons-dbcp-version>1.2.2</commons-dbcp-version>
     <commons-httpclient-version>2.0.1</commons-httpclient-version>
@@ -55,18 +55,19 @@
     <directory-asn1-version>0.3.2</directory-asn1-version>
     <directory-kerboros-version>0.5</directory-kerboros-version>
     <directory-mina-version>0.7.3</directory-mina-version>
-    <directory-version>0.9.2</directory-version>
+    <directory-version>1.5.4</directory-version>
     <geronimo-version>1.0</geronimo-version>
     <howl-version>0.1.8</howl-version>
     <hsqldb-version>1.7.2.2</hsqldb-version>
     <jdom-version>1.0</jdom-version>
     <jetty-version>6.1.9</jetty-version>
     <jmock-version>1.0.1</jmock-version>
-    <junit-version>3.8.1</junit-version>
+    <junit-version>4.4</junit-version>
     <jxta-version>2.0</jxta-version>
     <log4j-version>1.2.14</log4j-version>
+    <nlog4j-version>1.2.25</nlog4j-version>
     <org-apache-derby-version>10.1.3.1</org-apache-derby-version>
-    <org-apache-maven-surefire-plugin-version>2.2</org-apache-maven-surefire-plugin-version>
+    <org-apache-maven-surefire-plugin-version>2.3</org-apache-maven-surefire-plugin-version>
     <p2psockets-version>1.1.2</p2psockets-version>
     <regexp-version>1.3</regexp-version>
     <rome-version>0.8</rome-version>
@@ -853,70 +854,6 @@
         <version>${jdom-version}</version>
       </dependency>
 
-      <!-- ACTIVEMQ-JAAS Dependencies -->
-      <dependency>
-        <groupId>directory</groupId>
-        <artifactId>apacheds-core</artifactId>
-        <version>${directory-version}</version>
-      </dependency>
-      <dependency>
-        <groupId>directory</groupId>
-        <artifactId>apacheds-shared</artifactId>
-        <version>${directory-version}</version>
-      </dependency>
-      <dependency>
-        <groupId>directory-shared</groupId>
-        <artifactId>apache-ldapber-provider</artifactId>
-        <version>${directory-version}</version>
-        <exclusions>
-          <exclusion>
-            <groupId>commons-test</groupId>
-            <artifactId>commons-test</artifactId>
-          </exclusion>
-        </exclusions>
-      </dependency>
-      <dependency>
-        <groupId>directory-shared</groupId>
-        <artifactId>ldap-common</artifactId>
-        <version>${directory-version}</version>
-      </dependency>
-      <dependency>
-        <groupId>directory-asn1</groupId>
-        <artifactId>asn1-codec</artifactId>
-        <version>${directory-asn1-version}</version>
-      </dependency>
-      <dependency>
-        <groupId>directory-asn1</groupId>
-        <artifactId>asn1-der</artifactId>
-        <version>${directory-asn1-version}</version>
-        <exclusions>
-          <exclusion>
-            <groupId>commons-test</groupId>
-            <artifactId>commons-test</artifactId>
-          </exclusion>
-        </exclusions>
-      </dependency>
-      <dependency>
-        <groupId>directory-shared</groupId>
-        <artifactId>kerberos-common</artifactId>
-        <version>${directory-kerboros-version}</version>
-      </dependency>
-      <dependency>
-        <groupId>directory-network</groupId>
-        <artifactId>mina</artifactId>
-        <version>${directory-mina-version}</version>
-      </dependency>
-      <dependency>
-        <groupId>directory-protocols</groupId>
-        <artifactId>kerberos-protocol</artifactId>
-        <version>${directory-kerboros-version}</version>
-      </dependency>
-      <dependency>
-        <groupId>directory-protocols</groupId>
-        <artifactId>ldap-protocol</artifactId>
-        <version>${directory-version}</version>
-      </dependency>
-
       <dependency>
         <groupId>p2psockets</groupId>
         <artifactId>p2psockets-core</artifactId>



Mime
View raw message