You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by vt...@apache.org on 2004/02/27 07:07:13 UTC

svn commit: rev 6903 - in incubator/directory/janus/trunk: authentication/api/src/java/org/apache/janus authentication/api/src/java/org/apache/janus/authentication authentication/api/src/java/org/apache/janus/authentication/realm authentication/impl/src/java/org/apache/janus authentication/impl/src/java/org/apache/janus/authentication authentication/impl/src/java/org/apache/janus/authentication/realm authentication/impl/src/test/org/apache/janus authentication/impl/src/test/org/apache/janus/authentication authentication/impl/src/test/org/apache/janus/authentication/realm authentication/xml/src/java/org/apache/janus/script authentication/xml/src/java/org/apache/janus/script/xml authentication/xml/src/test/org/apache/janus/script authentication/xml/src/test/org/apache/janus/script/xml authorization/api/src/java/org/apache/janus/authorization authorization/impl/src/java/org/apache/janus/authorization authorization/impl/src/test/org/apache/janus/authorization authorization/impl/src/test/org/apache/janus/authorization/role

Author: vtence
Date: Thu Feb 26 22:07:12 2004
New Revision: 6903

Added:
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/AuthenticationException.java
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/Authenticator.java
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/Credential.java
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/CredentialSet.java
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/MutableRealm.java
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/Realm.java
   incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/DefaultAuthenticator.java
   incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/AbstractPrincipal.java
   incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/AuthenticationMethod.java
   incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/CredentialsMatcher.java
   incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/DefaultRealm.java
   incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/EqualCredentials.java
   incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/UsernamePasswordAuthentication.java
   incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/UsernamePrincipal.java
   incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/DefaultAuthenticatorTest.java
   incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/FruitPrincipal.java
   incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/AlwaysMatch.java
   incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/DefaultRealmTest.java
   incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/NeverMatch.java
   incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/UsernamePasswordAuthenticationTest.java
   incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/
   incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/RealmBuilder.java
   incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/RealmBuilderMonitor.java
   incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/xml/
   incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java
   incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/xml/NullRealmBuilderMonitor.java
   incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/xml/XMLRealm.java
   incubator/directory/janus/trunk/authentication/xml/src/test/org/apache/janus/script/
   incubator/directory/janus/trunk/authentication/xml/src/test/org/apache/janus/script/xml/
   incubator/directory/janus/trunk/authentication/xml/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java
   incubator/directory/janus/trunk/authentication/xml/src/test/org/apache/janus/script/xml/XMLRealmTest.java
Removed:
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/Subject.java
   incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/DefaultSubject.java
   incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/CatPrincipal.java
   incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/DefaultSubjectTest.java
   incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/DogPrincipal.java
Modified:
   incubator/directory/janus/trunk/authorization/api/src/java/org/apache/janus/authorization/Authorizer.java
   incubator/directory/janus/trunk/authorization/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java
   incubator/directory/janus/trunk/authorization/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java
   incubator/directory/janus/trunk/authorization/impl/src/test/org/apache/janus/authorization/role/DefaultRoleManagerTest.java
Log:
o Migrated new authentication code from sandbox to main tree

Added: incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/AuthenticationException.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/AuthenticationException.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,31 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication;
+
+/**
+ * /**
+ * Thrown if there is a problem performing authentication.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class AuthenticationException extends Exception
+{
+    public AuthenticationException( String s )
+    {
+        super( s );
+    }
+}

Added: incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/Authenticator.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/Authenticator.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,46 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication;
+
+import javax.security.auth.Subject;
+
+/**
+ * <i><strong>Warning:</strong> This is experimental. Don't know yet if authenticator
+ * may use a single realm or several realms to perform authentication. In the case of several realms,
+ * each realm will probably support a unique authentication method and the argument to <code>authenticate</code>
+ * will change to a grouping of credential collections.</i>
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public interface Authenticator
+{
+    /**
+     * Returns a populated Subject with the principals which represent the
+     * identity of the user as well as any other principal for which permissions may be associated.
+     * <p/>
+     * If the configured realm implementation has <code>GroupSupport</code> then this
+     * authenticator may choose to add a principal for each group the user is a member of.
+     *
+     * @param credentials A collection of credential objects provided as proof of identity
+     * @return a Subject populated with appropriate principals
+     * @throws AuthenticationException
+     *          thrown if there is a problem during authentication
+     */
+    Subject authenticate( CredentialSet credentials )
+            throws AuthenticationException;
+}
+

Added: incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/Credential.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/Credential.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,78 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication;
+
+import java.io.Serializable;
+
+/**
+ * Class representing a unit of proof of identity.
+ * <p/>
+ * A credential is represented by a type and a value.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public final class Credential implements Serializable
+{
+    private final String m_type;
+    private final Object m_value;
+
+    /**
+     * Constructs a new credential object with the given type
+     * and value.
+     */
+    public Credential( String type, Object value )
+    {
+        m_type = type;
+        m_value = value;
+    }
+
+    public boolean isOfType( String type )
+    {
+        return m_type.equals( type );
+    }
+
+    public Object getValue()
+    {
+        return m_value;
+    }
+
+    public boolean equals( Object o )
+    {
+        if ( this == o ) return true;
+        if ( !(o instanceof Credential) ) return false;
+
+        final Credential credential = (Credential) o;
+
+        if ( !m_type.equals( credential.m_type ) ) return false;
+        if ( !m_value.equals( credential.m_value ) ) return false;
+
+        return true;
+    }
+
+    public int hashCode()
+    {
+        int result;
+        result = m_type.hashCode();
+        result = 29 * result + m_value.hashCode();
+        return result;
+    }
+
+    public String toString()
+    {
+        return "[type = " + m_type + ", value = " + m_value + "]";
+    }
+}
\ No newline at end of file

Added: incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/CredentialSet.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/CredentialSet.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,151 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Declared final so we make sure no imposter implementation is possible.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public final class CredentialSet
+{
+    private final Set m_credentials;
+
+    public CredentialSet()
+    {
+        this( Collections.EMPTY_SET );
+    }
+
+    public CredentialSet( CredentialSet credentials )
+    {
+        this( credentials.elements() );
+    }
+
+    public CredentialSet( Collection credentials )
+    {
+        m_credentials = new HashSet( credentials );
+    }
+
+    public boolean add( Credential c )
+    {
+        return m_credentials.add( c );
+    }
+
+    /**
+     * Checks if this credential set contains credentials.
+     *
+     * @return true is this set is empty, false if it contains
+     *         at least one credential.
+     */
+    public boolean isEmpty()
+    {
+        return m_credentials.isEmpty();
+    }
+
+    /**
+     * Returns a collection containing all the credential objects
+     * in the current collection.
+     *
+     * @return an unmodifiable collection of all the credentials in this set.
+     */
+    public Set elements()
+    {
+        return Collections.unmodifiableSet( m_credentials );
+    }
+
+    /**
+     * Returns a subset of the current set
+     * of credentials composed of all credentials
+     * of the given type.
+     *
+     * @param type of credential to be returned.
+     * @return a new CredentialSet containing all
+     *         of the Credential objects of the given type.
+     */
+    public CredentialSet getCredentials( String type )
+    {
+        final CredentialSet subSet = new CredentialSet();
+        for ( Iterator it = m_credentials.iterator(); it.hasNext(); )
+        {
+            final Credential c = (Credential) it.next();
+            if ( c.isOfType( type ) ) subSet.add( c );
+        }
+
+        return subSet;
+    }
+
+    public Credential getCredential( String type )
+    {
+        for ( Iterator it = m_credentials.iterator(); it.hasNext(); )
+        {
+            final Credential c = (Credential) it.next();
+            if ( c.isOfType( type ) ) return c;
+        }
+
+        return null;
+    }
+
+    public int size()
+    {
+        return m_credentials.size();
+    }
+
+    public boolean equals( Object o )
+    {
+        if ( this == o ) return true;
+        if ( !(o instanceof CredentialSet) ) return false;
+
+        final CredentialSet credentialSet = (CredentialSet) o;
+
+        if ( !m_credentials.equals( credentialSet.m_credentials ) ) return false;
+
+        return true;
+    }
+
+    public int hashCode()
+    {
+        return m_credentials.hashCode();
+    }
+
+    public String toString()
+    {
+        if ( isEmpty() ) return "{}";
+
+        StringBuffer sb = new StringBuffer( "{" );
+        for ( Iterator it = m_credentials.iterator(); it.hasNext(); )
+        {
+            Credential c = (Credential) it.next();
+            sb.append( c ).append( ", " );
+        }
+
+        removeTrailingSeparator( sb );
+        sb.append( "}" );
+
+        return sb.toString();
+    }
+
+    private void removeTrailingSeparator( StringBuffer sb )
+    {
+        sb.setLength( sb.length() - 2 );
+    }
+}

Added: incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/MutableRealm.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/MutableRealm.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,27 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import org.apache.janus.authentication.CredentialSet;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public interface MutableRealm extends Realm
+{
+    boolean addIdentity( CredentialSet credentials );
+}

Added: incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/Realm.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/Realm.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,29 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import org.apache.janus.authentication.CredentialSet;
+
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public interface Realm
+{
+    Principal validateCredentials( CredentialSet credentials );
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/DefaultAuthenticator.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/DefaultAuthenticator.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,52 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication;
+
+import org.apache.janus.authentication.realm.Realm;
+
+import javax.security.auth.Subject;
+import java.security.Principal;
+
+/**
+ * An implementation of an authenticator that uses a single realm to perform authentication.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class DefaultAuthenticator implements Authenticator
+{
+    private final Realm m_realm;
+
+    public DefaultAuthenticator( Realm realm )
+    {
+        m_realm = realm;
+    }
+
+    public Subject authenticate( CredentialSet credentials )
+            throws AuthenticationException
+    {
+        Principal p = m_realm.validateCredentials( credentials );
+        if ( p == null )
+        {
+            throw new AuthenticationException( "Credentials rejected" );
+        }
+
+        Subject subject = new Subject();
+        subject.getPrincipals().add( p );
+
+        return subject;
+    }
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/AbstractPrincipal.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/AbstractPrincipal.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,68 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import java.security.Principal;
+
+/**
+ * A principal name is unique within the set
+ * of principals of the same type.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public abstract class AbstractPrincipal implements Principal
+{
+    private final String m_name;
+
+    public AbstractPrincipal( String name )
+    {
+        if ( name == null ) throw new NullPointerException( "name" );
+        if ( name.equals( "" ) )
+        {
+            throw new IllegalArgumentException( "Empty name" );
+        }
+        m_name = name;
+    }
+
+    public String getName()
+    {
+        return m_name;
+    }
+
+    public boolean equals( Object o )
+    {
+        if ( this == o ) return true;
+        if ( !( o instanceof AbstractPrincipal ) ) return false;
+
+        final AbstractPrincipal abstractPrincipal = (AbstractPrincipal) o;
+
+        if ( !m_name.equals( abstractPrincipal.m_name ) ) return false;
+
+        return true;
+    }
+
+    public int hashCode()
+    {
+        return m_name.hashCode();
+    }
+
+    public String toString()
+    {
+        return "name=" + m_name;
+    }
+}
+

Added: incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/AuthenticationMethod.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/AuthenticationMethod.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,33 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import org.apache.janus.authentication.CredentialSet;
+
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public interface AuthenticationMethod
+{
+    Principal getPrincipal( CredentialSet credentialSet );
+
+    boolean supports( CredentialSet credentialSet );
+
+    CredentialsMatcher matcher( CredentialSet credentials );
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/CredentialsMatcher.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/CredentialsMatcher.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,27 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import org.apache.janus.authentication.CredentialSet;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public interface CredentialsMatcher
+{
+    boolean matches( CredentialSet creds );
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/DefaultRealm.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/DefaultRealm.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,77 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import org.apache.janus.authentication.CredentialSet;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class DefaultRealm implements MutableRealm
+{
+    private final AuthenticationMethod m_authenticationMethod;
+    private final Collection m_identities;
+
+    public DefaultRealm( AuthenticationMethod authenticationMethod )
+    {
+        m_authenticationMethod = authenticationMethod;
+        m_identities = new ArrayList();
+    }
+
+    public Principal validateCredentials( CredentialSet credentials )
+    {
+        if ( !m_authenticationMethod.supports( credentials ) ) return null;
+        if ( !contains( credentials ) ) return null;
+
+        return m_authenticationMethod.getPrincipal( credentials );
+    }
+
+    public boolean addIdentity( CredentialSet credentials )
+    {
+        if ( !m_authenticationMethod.supports( credentials ) )
+        {
+            throw new IllegalArgumentException(
+                    "Credentials not supported by authentication method" );
+        }
+        if ( contains( credentials ) ) return false;
+        m_identities.add( new CredentialSet( credentials ) );
+
+        return true;
+    }
+
+    private boolean contains( CredentialSet credentials )
+    {
+        CredentialsMatcher criterion = m_authenticationMethod.matcher( credentials );
+        return search( criterion );
+    }
+
+    public boolean search( CredentialsMatcher criterion )
+    {
+        for ( Iterator it = m_identities.iterator(); it.hasNext(); )
+        {
+            CredentialSet creds = (CredentialSet) it.next();
+            if ( criterion.matches( creds ) ) return true;
+        }
+
+        return false;
+    }
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/EqualCredentials.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/EqualCredentials.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,37 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import org.apache.janus.authentication.CredentialSet;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class EqualCredentials implements CredentialsMatcher
+{
+    private final CredentialSet m_toMatch;
+
+    public EqualCredentials( CredentialSet credentials )
+    {
+        m_toMatch = credentials;
+    }
+
+    public boolean matches( CredentialSet creds )
+    {
+        return m_toMatch.equals( creds );
+    }
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/UsernamePasswordAuthentication.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/UsernamePasswordAuthentication.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,55 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import org.apache.janus.authentication.Credential;
+import org.apache.janus.authentication.CredentialSet;
+
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class UsernamePasswordAuthentication implements AuthenticationMethod
+{
+    public UsernamePasswordAuthentication()
+    {
+    }
+
+    public Principal getPrincipal( CredentialSet credentialSet )
+    {
+        Credential username = credentialSet.getCredential( "username" );
+        return new UsernamePrincipal( username.getValue().toString() );
+    }
+
+    public boolean supports( CredentialSet credentialSet )
+    {
+        if ( credentialSet.size() != 2 ) return false;
+        CredentialSet usernames = credentialSet.getCredentials( "username" );
+        if ( usernames.size() != 1 ) return false;
+        CredentialSet passwords = credentialSet.getCredentials( "password" );
+        if ( passwords.size() != 1 ) return false;
+
+        return true;
+    }
+
+    public CredentialsMatcher matcher( CredentialSet credentials )
+    {
+        return new EqualCredentials( credentials );
+    }
+
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/UsernamePrincipal.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/java/org/apache/janus/authentication/realm/UsernamePrincipal.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,47 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class UsernamePrincipal extends AbstractPrincipal
+{
+    public UsernamePrincipal( String name )
+    {
+        super( name );
+    }
+
+    public boolean equals( Object o )
+    {
+        if ( this == o ) return true;
+        if ( !( o instanceof UsernamePrincipal ) ) return false;
+        if ( !super.equals( o ) ) return false;
+
+        return true;
+    }
+
+    public int hashCode()
+    {
+        return super.hashCode();
+    }
+
+    public String toString()
+    {
+        return "UsernamePrincipal: " + super.toString() + "";
+    }
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/DefaultAuthenticatorTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/DefaultAuthenticatorTest.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,86 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication;
+
+import com.mockobjects.dynamic.C;
+import com.mockobjects.dynamic.Mock;
+import junit.framework.TestCase;
+import org.apache.janus.authentication.realm.Realm;
+
+import javax.security.auth.Subject;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class DefaultAuthenticatorTest extends TestCase
+{
+    private DefaultAuthenticator m_authenticator;
+    private Mock m_mockRealm;
+
+    public static void main( String[] args )
+    {
+        junit.textui.TestRunner.run( DefaultAuthenticatorTest.class );
+    }
+
+    protected void setUp() throws Exception
+    {
+        m_mockRealm
+                = new Mock( Realm.class );
+        m_authenticator
+                = new DefaultAuthenticator( (Realm) m_mockRealm.proxy() );
+    }
+
+    private CredentialSet banana()
+    {
+        CredentialSet credentials = new CredentialSet();
+        credentials.add( new Credential( "fruit", "banana" ) );
+        return credentials;
+    }
+
+    public void testAuthentication()
+    {
+        m_mockRealm.matchAndReturn( "validateCredentials", C.eq( banana() ),
+                new FruitPrincipal( "banana" ) );
+
+        Subject subject = null;
+        try
+        {
+            subject = m_authenticator.authenticate( banana() );
+        }
+        catch ( AuthenticationException e )
+        {
+            fail( "Login failed" );
+        }
+        assertTrue( "Principal was not added to subject",
+                subject.getPrincipals().contains( new FruitPrincipal( "banana" ) ) );
+    }
+
+    public void testAuthenticationFailure()
+    {
+        m_mockRealm.matchAndReturn( "validateCredentials", C.ANY_ARGS, null );
+
+        try
+        {
+            m_authenticator.authenticate( new CredentialSet() );
+            fail( "Login has not failed" );
+        }
+        catch ( AuthenticationException expected )
+        {
+            assertTrue( true );
+        }
+    }
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/FruitPrincipal.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/FruitPrincipal.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,30 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication;
+
+import org.apache.janus.authentication.realm.AbstractPrincipal;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class FruitPrincipal extends AbstractPrincipal
+{
+    public FruitPrincipal( String name )
+    {
+        super( name );
+    }
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/AlwaysMatch.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/AlwaysMatch.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,30 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import org.apache.janus.authentication.CredentialSet;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class AlwaysMatch implements CredentialsMatcher
+{
+    public boolean matches( CredentialSet credentials )
+    {
+        return true;
+    }
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/DefaultRealmTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/DefaultRealmTest.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,159 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import com.mockobjects.dynamic.C;
+import com.mockobjects.dynamic.Mock;
+import junit.framework.TestCase;
+import org.apache.janus.authentication.Credential;
+import org.apache.janus.authentication.CredentialSet;
+
+import java.security.Principal;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class DefaultRealmTest extends TestCase
+{
+    public static void main( String[] args )
+    {
+        junit.textui.TestRunner.run( DefaultRealmTest.class );
+    }
+
+    private DefaultRealm realm;
+
+    public void testValidationFailsIfCredentialSetNotSupported()
+    {
+        Mock mockAuthenticationMethod = new Mock( AuthenticationMethod.class );
+        realm = new DefaultRealm( (AuthenticationMethod) mockAuthenticationMethod.proxy() );
+        mockAuthenticationMethod.matchAndReturn( "supports", joeCredentials(), false );
+        assertNull( "Empty credential set was validated", realm.validateCredentials( joeCredentials() ) );
+    }
+
+    public void testEmptyRealmNeverValidates()
+    {
+        Mock mockAuthenticationMethod = createMockAuthenticationMethod();
+        mockAuthenticationMethod.matchAndReturn( "matcher", C.ANY_ARGS, new AlwaysMatch() );
+        realm = new DefaultRealm( (AuthenticationMethod) mockAuthenticationMethod.proxy() );
+
+        assertNull( "Principal was returned but realm contains no entry",
+                realm.validateCredentials( johnCredentials() ) );
+
+    }
+
+    public void testValidationFailsIfCredentialsAreNotMatched()
+    {
+        Mock mockAuthenticationMethod = createMockAuthenticationMethod();
+        mockAuthenticationMethod.matchAndReturn( "matcher", C.ANY_ARGS, new NeverMatch() );
+
+        realm = new DefaultRealm( (AuthenticationMethod) mockAuthenticationMethod.proxy() );
+
+        assertNull( "Principal was returned but credentials are invalid",
+                realm.validateCredentials( johnCredentials() ) );
+
+    }
+
+    public void testValidationSucceedsIfOneEntryIsMatched()
+    {
+        Mock mockAuthenticationMethod = createMockAuthenticationMethod();
+        mockAuthenticationMethod.matchAndReturn( "matcher", C.ANY_ARGS, new EqualCredentials( janeCredentials() ) );
+        mockAuthenticationMethod.matchAndReturn( "getPrincipal", janeCredentials(), jane() );
+
+        realm = new DefaultRealm( (AuthenticationMethod) mockAuthenticationMethod.proxy() );
+
+        try
+        {
+            realm.addIdentity( janeCredentials() );
+            realm.addIdentity( johnCredentials() );
+        }
+        catch ( IllegalArgumentException unexpected )
+        {
+            fail( "Invalid credential set was reported when it was valid" );
+        }
+
+        assertEquals( "Principal identified does not match credentials",
+                jane(),
+                realm.validateCredentials( janeCredentials() ) );
+    }
+
+
+    public void testRejectsNewEntryIfCredentialSetIsNotSupported()
+    {
+        Mock mockAuthenticationMethod = new Mock( AuthenticationMethod.class );
+        realm = new DefaultRealm( (AuthenticationMethod) mockAuthenticationMethod.proxy() );
+
+        mockAuthenticationMethod.matchAndReturn( "supports", joeCredentials(), false );
+
+        try
+        {
+            realm.addIdentity( joeCredentials() );
+            fail( "Malformed credential set was accepted in realm" );
+        }
+        catch ( IllegalArgumentException expected )
+        {
+            assertTrue( true );
+        }
+    }
+
+    public void testIdentityIsNotAddedIfAlreadyInRealm()
+    {
+        Mock mockAuthenticationMethod = createMockAuthenticationMethod();
+        realm = new DefaultRealm( (AuthenticationMethod) mockAuthenticationMethod.proxy() );
+        mockAuthenticationMethod.matchAndReturn( "matcher", C.ANY_ARGS, new EqualCredentials( joeCredentials() ) );
+
+        realm.addIdentity( joeCredentials() );
+        assertFalse( "Identity reported as added twice", realm.addIdentity( joeCredentials() ) );
+    }
+
+    private CredentialSet johnCredentials()
+    {
+        Set creds = new HashSet();
+        creds.add( new Credential( "username", "john" ) );
+        creds.add( new Credential( "password", "doe" ) );
+        return new CredentialSet( creds );
+    }
+
+    private CredentialSet janeCredentials()
+    {
+        Set creds = new HashSet();
+        creds.add( new Credential( "username", "jane" ) );
+        creds.add( new Credential( "password", "doe" ) );
+        return new CredentialSet( creds );
+    }
+
+    private CredentialSet joeCredentials()
+    {
+        Set creds = new HashSet();
+        creds.add( new Credential( "username", "joe" ) );
+        creds.add( new Credential( "password", "blow" ) );
+        return new CredentialSet( creds );
+    }
+
+    private Principal jane()
+    {
+        return new UsernamePrincipal( "jane" );
+    }
+
+    public Mock createMockAuthenticationMethod()
+    {
+        Mock mockAuthenticationMethod = new Mock( AuthenticationMethod.class );
+        mockAuthenticationMethod.matchAndReturn( "supports", C.ANY_ARGS, true );
+        return mockAuthenticationMethod;
+    }
+}
\ No newline at end of file

Added: incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/NeverMatch.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/NeverMatch.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,30 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import org.apache.janus.authentication.CredentialSet;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class NeverMatch implements CredentialsMatcher
+{
+    public boolean matches( CredentialSet credentials )
+    {
+        return false;
+    }
+}

Added: incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/UsernamePasswordAuthenticationTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/impl/src/test/org/apache/janus/authentication/realm/UsernamePasswordAuthenticationTest.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,87 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authentication.realm;
+
+import junit.framework.TestCase;
+import org.apache.janus.authentication.Credential;
+import org.apache.janus.authentication.CredentialSet;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class UsernamePasswordAuthenticationTest extends TestCase
+{
+    private UsernamePasswordAuthentication m_auth;
+
+    protected void setUp() throws Exception
+    {
+        m_auth = new UsernamePasswordAuthentication();
+    }
+
+    private CredentialSet validCredentials()
+    {
+        Set credentials = new HashSet();
+        credentials.add( new Credential( "username", "john" ) );
+        credentials.add( new Credential( "password", "doe" ) );
+        return new CredentialSet( credentials );
+    }
+
+    private CredentialSet extraCredentials()
+    {
+        Set credentials = new HashSet();
+        credentials.add( new Credential( "username", "john" ) );
+        credentials.add( new Credential( "password", "doe" ) );
+        credentials.add( new Credential( "password", "baz" ) );
+        credentials.add( new Credential( "foo", "bar" ) );
+        return new CredentialSet( credentials );
+    }
+
+    public void testCredentialsWithNoUsernameAreNotSupported()
+    {
+        assertFalse( "Reports it supports credentials with no username", m_auth.supports( new CredentialSet( Collections.singleton( new Credential( "password", "bar" ) ) ) ) );
+    }
+
+    public void testCredentialsWithNoPasswordAreNotSupported()
+    {
+        assertFalse( "Reports it supports credentials with no password", m_auth.supports( new CredentialSet( Collections.singleton( new Credential( "username", "foo" ) ) ) ) );
+    }
+
+    public void testSetsWithAllValidCredentialsPlusExtraOnesAreNotSupported()
+    {
+        assertFalse( "Reports it supports extra credentials", m_auth.supports( extraCredentials() ) );
+    }
+
+    public void testAUsernameAndAPaswordIsAValidCredentialSet()
+    {
+        assertTrue( "Reports it does not support credentials with a username and a password", m_auth.supports( validCredentials() ) );
+    }
+
+    public void testCredentialsMatchIfEqual()
+    {
+        assertTrue( "Equal sets of credentials do not match", m_auth.matcher( validCredentials() ).matches( validCredentials() ) );
+        assertFalse( "Different sets of credentials were matched", m_auth.matcher( extraCredentials() ).matches( validCredentials() ) );
+    }
+
+    public void testPrincipalsCreatedAreUsernamePrincipals()
+    {
+        assertEquals( "Created wrong principal", new UsernamePrincipal( "john" ), m_auth.getPrincipal( validCredentials() ) );
+    }
+}

Added: incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/RealmBuilder.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/RealmBuilder.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,27 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script;
+
+import org.apache.janus.authentication.realm.MutableRealm;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public interface RealmBuilder
+{
+    void buildRealm( MutableRealm realm ) throws Exception;
+}

Added: incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/RealmBuilderMonitor.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/RealmBuilderMonitor.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,27 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script;
+
+import org.apache.janus.authentication.CredentialSet;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public interface RealmBuilderMonitor
+{
+    void duplicateIdentity( CredentialSet identity );
+}

Added: incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,73 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script.xml;
+
+import org.apache.janus.authentication.Credential;
+import org.apache.janus.authentication.CredentialSet;
+import org.apache.janus.authentication.realm.MutableRealm;
+import org.apache.janus.script.RealmBuilder;
+import org.apache.janus.script.RealmBuilderMonitor;
+import org.dom4j.Document;
+import org.dom4j.Element;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Builds a realm with username password identities.
+ * <p/>
+ * <strong>Warning:</strong> Document is assumed to be valid.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class Dom4JRealmBuilder implements RealmBuilder
+{
+    private final Document m_doc;
+    private final RealmBuilderMonitor m_monitor;
+
+    public Dom4JRealmBuilder( Document doc, RealmBuilderMonitor monitor )
+    {
+        m_doc = doc;
+        m_monitor = monitor;
+    }
+
+    public void buildRealm( MutableRealm realm ) throws IOException
+    {
+        Element root = m_doc.getRootElement();
+        Element users = root.element( "users" );
+        addUsers( realm, users );
+    }
+
+    private void addUsers( MutableRealm realm, Element users )
+    {
+        List userList = users.elements( "user" );
+
+        for ( Iterator it = userList.iterator(); it.hasNext(); )
+        {
+            final Element user = (Element) it.next();
+            CredentialSet creds = new CredentialSet();
+            String username = user.attributeValue( "username" );
+            creds.add( new Credential( "username", username ) );
+            String password = user.attributeValue( "password" );
+            creds.add( new Credential( "password", password ) );
+
+            boolean added = realm.addIdentity( creds );
+            if ( !added ) m_monitor.duplicateIdentity( creds );
+        }
+    }
+}

Added: incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/xml/NullRealmBuilderMonitor.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/xml/NullRealmBuilderMonitor.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,30 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script.xml;
+
+import org.apache.janus.authentication.CredentialSet;
+import org.apache.janus.script.RealmBuilderMonitor;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class NullRealmBuilderMonitor implements RealmBuilderMonitor
+{
+    public void duplicateIdentity( CredentialSet identity )
+    {
+    }
+}

Added: incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/xml/XMLRealm.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/xml/src/java/org/apache/janus/script/xml/XMLRealm.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,57 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script.xml;
+
+import org.apache.janus.authentication.CredentialSet;
+import org.apache.janus.authentication.realm.DefaultRealm;
+import org.apache.janus.authentication.realm.MutableRealm;
+import org.apache.janus.authentication.realm.Realm;
+import org.apache.janus.authentication.realm.UsernamePasswordAuthentication;
+import org.apache.janus.script.RealmBuilder;
+import org.apache.janus.script.RealmBuilderMonitor;
+import org.dom4j.Document;
+import org.dom4j.io.SAXReader;
+
+import java.io.Reader;
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class XMLRealm implements Realm
+{
+    private final MutableRealm m_delegate;
+
+    public XMLRealm( Reader reader ) throws Exception
+    {
+        this( reader, new NullRealmBuilderMonitor() );
+    }
+
+    public XMLRealm( Reader reader, RealmBuilderMonitor monitor ) throws Exception
+    {
+        SAXReader xmlReader = new SAXReader();
+        Document root = xmlReader.read( reader );
+        RealmBuilder builder = new Dom4JRealmBuilder( root, monitor );
+        m_delegate = new DefaultRealm( new UsernamePasswordAuthentication() );
+        builder.buildRealm( m_delegate );
+    }
+
+    public Principal validateCredentials( CredentialSet credentials )
+    {
+        return m_delegate.validateCredentials( credentials );
+    }
+}

Added: incubator/directory/janus/trunk/authentication/xml/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/xml/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,115 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script.xml;
+
+import com.mockobjects.dynamic.Mock;
+import junit.framework.TestCase;
+import org.apache.janus.authentication.Credential;
+import org.apache.janus.authentication.CredentialSet;
+import org.apache.janus.authentication.realm.DefaultRealm;
+import org.apache.janus.authentication.realm.MutableRealm;
+import org.apache.janus.authentication.realm.UsernamePasswordAuthentication;
+import org.apache.janus.script.RealmBuilderMonitor;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.tree.DefaultDocument;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class Dom4JRealmBuilderTest extends TestCase
+{
+    public static void main( String[] args )
+    {
+        junit.textui.TestRunner.run( Dom4JRealmBuilderTest.class );
+    }
+
+    protected void setUp() throws Exception
+    {
+    }
+
+    public void testSimpleBuild() throws Exception
+    {
+        Dom4JRealmBuilder builder = new Dom4JRealmBuilder( simpleRealm(), new NullRealmBuilderMonitor() );
+
+        Mock mockRealm = new Mock( MutableRealm.class );
+        mockRealm.expectAndReturn( "addIdentity", johnCredentials(), true );
+        mockRealm.expectAndReturn( "addIdentity", janeCredentials(), true );
+
+        builder.buildRealm( (MutableRealm) mockRealm.proxy() );
+
+        mockRealm.verify();
+    }
+
+    private Document simpleRealm()
+    {
+        Document doc = new DefaultDocument();
+        Element root = doc.addElement( "realm" );
+        Element users = root.addElement( "users" );
+        Element john = users.addElement( "user" );
+        john.addAttribute( "username", "john" );
+        john.addAttribute( "password", "doe" );
+        Element jane = users.addElement( "user" );
+        jane.addAttribute( "username", "jane" );
+        jane.addAttribute( "password", "doe" );
+
+        return doc;
+    }
+
+    private CredentialSet johnCredentials()
+    {
+        CredentialSet johnCredentials = new CredentialSet();
+        johnCredentials.add( new Credential( "username", "john" ) );
+        johnCredentials.add( new Credential( "password", "doe" ) );
+        return johnCredentials;
+    }
+
+    private CredentialSet janeCredentials()
+    {
+        CredentialSet johnCredentials = new CredentialSet();
+        johnCredentials.add( new Credential( "username", "jane" ) );
+        johnCredentials.add( new Credential( "password", "doe" ) );
+        return johnCredentials;
+    }
+
+    public void testNotifiesOfDuplicateIdentities() throws Exception
+    {
+        Mock mockMonitor = new Mock( RealmBuilderMonitor.class );
+        Dom4JRealmBuilder builder = new Dom4JRealmBuilder( realmWithDuplicateIdentity(),
+                (RealmBuilderMonitor) mockMonitor.proxy() );
+
+        mockMonitor.expect( "duplicateIdentity", johnCredentials() );
+        builder.buildRealm( new DefaultRealm( new UsernamePasswordAuthentication() ) );
+
+        mockMonitor.verify();
+    }
+
+    private Document realmWithDuplicateIdentity()
+    {
+        Document doc = new DefaultDocument();
+        Element root = doc.addElement( "realm" );
+        Element users = root.addElement( "users" );
+        Element john = users.addElement( "user" );
+        john.addAttribute( "username", "john" );
+        john.addAttribute( "password", "doe" );
+        Element jane = users.addElement( "user" );
+        jane.addAttribute( "username", "john" );
+        jane.addAttribute( "password", "doe" );
+
+        return doc;
+    }
+}

Added: incubator/directory/janus/trunk/authentication/xml/src/test/org/apache/janus/script/xml/XMLRealmTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/xml/src/test/org/apache/janus/script/xml/XMLRealmTest.java	Thu Feb 26 22:07:12 2004
@@ -0,0 +1,98 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script.xml;
+
+import junit.framework.TestCase;
+import org.apache.janus.authentication.Credential;
+import org.apache.janus.authentication.CredentialSet;
+import org.apache.janus.authentication.realm.UsernamePrincipal;
+
+import java.io.StringReader;
+
+/**
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class XMLRealmTest extends TestCase
+{
+    private XMLRealm m_realm;
+
+    public static void main( String[] args )
+    {
+        junit.textui.TestRunner.run( XMLRealmTest.class );
+    }
+
+    public void testBuildsRealmFromXMLDocument() throws Exception
+    {
+        m_realm = new XMLRealm( new StringReader( simpleRealm() ) );
+
+        assertEquals( "Could not validateCredentials identity; must be missing in realm", new UsernamePrincipal(
+                "john" ),
+                m_realm.validateCredentials( johnCredentials() ) );
+        assertEquals( "Could not validateCredentials identity; must be missing in realm", new UsernamePrincipal(
+                "jane" ),
+                m_realm.validateCredentials( janeCredentials() ) );
+    }
+
+    private String simpleRealm()
+    {
+        String content = "<?xml version=\"1.0\"?>\n"
+                         + "<realm>\n"
+                         + "    <users>\n"
+                         + "        <user username=\"john\" password=\"doe\"/>\n"
+                         + "        <user username=\"jane\" password=\"doe\"/>\n"
+                         + "    </users>\n"
+                         + "</realm>";
+        return content;
+    }
+
+    private CredentialSet johnCredentials()
+    {
+        CredentialSet johnCredentials = new CredentialSet();
+        johnCredentials.add( new Credential( "username", "john" ) );
+        johnCredentials.add( new Credential( "password", "doe" ) );
+        return johnCredentials;
+    }
+
+    private CredentialSet janeCredentials()
+    {
+        CredentialSet janeCredentials = new CredentialSet();
+        janeCredentials.add( new Credential( "username", "jane" ) );
+        janeCredentials.add( new Credential( "password", "doe" ) );
+        return janeCredentials;
+    }
+
+    public void testIgnoresDuplicateIdentities() throws Exception
+    {
+        m_realm = new XMLRealm( new StringReader( realmWithDuplicateIdentities() ) );
+
+        assertEquals( "Could not validateCredentials identity; must be missing in realm", new UsernamePrincipal(
+                "john" ),
+                m_realm.validateCredentials( johnCredentials() ) );
+    }
+
+    private String realmWithDuplicateIdentities()
+    {
+        String content = "<?xml version=\"1.0\"?>\n"
+                         + "<realm>\n"
+                         + "    <users>\n"
+                         + "        <user username=\"john\" password=\"doe\"/>\n"
+                         + "        <user username=\"john\" password=\"doe\"/>\n"
+                         + "    </users>\n"
+                         + "</realm>";
+        return content;
+    }
+}

Modified: incubator/directory/janus/trunk/authorization/api/src/java/org/apache/janus/authorization/Authorizer.java
==============================================================================
--- incubator/directory/janus/trunk/authorization/api/src/java/org/apache/janus/authorization/Authorizer.java	(original)
+++ incubator/directory/janus/trunk/authorization/api/src/java/org/apache/janus/authorization/Authorizer.java	Thu Feb 26 22:07:12 2004
@@ -16,7 +16,7 @@
  */
 package org.apache.janus.authorization;
 
-import org.apache.janus.Subject;
+import javax.security.auth.Subject;
 
 /**
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>

Modified: incubator/directory/janus/trunk/authorization/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java
==============================================================================
--- incubator/directory/janus/trunk/authorization/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java	(original)
+++ incubator/directory/janus/trunk/authorization/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java	Thu Feb 26 22:07:12 2004
@@ -16,10 +16,10 @@
  */
 package org.apache.janus.authorization;
 
-import org.apache.janus.Subject;
 import org.apache.janus.authorization.policy.PolicyContext;
 import org.apache.janus.authorization.role.RoleManager;
 
+import javax.security.auth.Subject;
 import java.util.Set;
 import java.util.Iterator;
 import java.security.Principal;

Modified: incubator/directory/janus/trunk/authorization/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java
==============================================================================
--- incubator/directory/janus/trunk/authorization/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java	(original)
+++ incubator/directory/janus/trunk/authorization/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java	Thu Feb 26 22:07:12 2004
@@ -19,12 +19,11 @@
 import com.mockobjects.dynamic.C;
 import com.mockobjects.dynamic.Mock;
 import junit.framework.TestCase;
-import org.apache.janus.DefaultSubject;
-import org.apache.janus.Subject;
-import org.apache.janus.authentication.realm.UsernamePrincipal;
-import org.apache.janus.authentication.realm.GroupPrincipal;
 import org.apache.janus.authorization.policy.PolicyContext;
 import org.apache.janus.authorization.role.RoleManager;
+import org.apache.janus.authentication.realm.UsernamePrincipal;
+
+import javax.security.auth.Subject;
 
 /**
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
@@ -64,7 +63,7 @@
                 new CheckedPermission(), true );
 
         assertFalse( "Authorization given to subject with no role",
-                m_authorizer.checkAuthorization( new DefaultSubject(),
+                m_authorizer.checkAuthorization( new Subject(),
                         new CheckedPermission() ) );
     }
 
@@ -92,29 +91,29 @@
         m_mockPolicyContext.matchAndReturn( "requiresPriviledges",
                 new CheckedPermission(), true );
         m_mockRoleManager.matchAndReturn( "isPrincipalInRole",
-                C.args( C.eq( new GroupPrincipal( "women" ) ), C.isA( PermissionGrant.class ) ),
+                C.args( C.eq( new SSNPrincipal( "123-456-789" ) ), C.isA( PermissionGrant.class ) ),
                 false );
         m_mockRoleManager.matchAndReturn( "isPrincipalInRole",
                 C.args( C.eq( new UsernamePrincipal( "janeDoe" ) ), C.isA( PermissionGrant.class ) ),
                 true );
 
         assertTrue( "Subject with principal in role did not get authorization",
-                m_authorizer.checkAuthorization( member( "janeDoe", "women" ),
+                m_authorizer.checkAuthorization( member( "janeDoe", "123-456-789" ),
                         new CheckedPermission() ) );
     }
 
     private Subject user( String username )
     {
-        DefaultSubject subject = new DefaultSubject();
-        subject.addPrincipal( new UsernamePrincipal( username ) );
+        Subject subject = new Subject();
+        subject.getPrincipals().add( new UsernamePrincipal( username ) );
         return subject;
     }
 
-    private Subject member( String username, String groupName )
+    private Subject member( String username, String ssn )
     {
-        DefaultSubject subject = new DefaultSubject();
-        subject.addPrincipal( new UsernamePrincipal( username ) );
-        subject.addPrincipal( new GroupPrincipal( groupName ) );
+        Subject subject = new Subject();
+        subject.getPrincipals().add( new UsernamePrincipal( username ) );
+        subject.getPrincipals().add( new SSNPrincipal( ssn ) );
         return subject;
     }
 }

Modified: incubator/directory/janus/trunk/authorization/impl/src/test/org/apache/janus/authorization/role/DefaultRoleManagerTest.java
==============================================================================
--- incubator/directory/janus/trunk/authorization/impl/src/test/org/apache/janus/authorization/role/DefaultRoleManagerTest.java	(original)
+++ incubator/directory/janus/trunk/authorization/impl/src/test/org/apache/janus/authorization/role/DefaultRoleManagerTest.java	Thu Feb 26 22:07:12 2004
@@ -17,11 +17,12 @@
 package org.apache.janus.authorization.role;
 
 import junit.framework.TestCase;
-import org.apache.janus.authentication.realm.UsernamePrincipal;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+
+import org.apache.janus.authentication.realm.UsernamePrincipal;
 
 /**
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>