directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: rev 6666 - incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm
Date Sun, 15 Feb 2004 22:41:28 GMT
Author: vtence
Date: Sun Feb 15 14:41:28 2004
New Revision: 6666

Added:
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/GroupAlreadyExistsException.java
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/GroupSupport.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/PrincipalAlreadyExistsException.java
   incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/Realm.java
Log:
Initial import

Added: incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/GroupAlreadyExistsException.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/GroupAlreadyExistsException.java
Sun Feb 15 14:41:28 2004
@@ -0,0 +1,34 @@
+/*
+ *   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;
+
+/**
+ * An exception thrown when attempting to add a duplicate group
+ * to a realm.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class GroupAlreadyExistsException
+        extends PrincipalAlreadyExistsException
+{
+    public GroupAlreadyExistsException( String s, Principal group )
+    {
+        super( s, group );
+    }
+}

Added: incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/GroupSupport.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/GroupSupport.java
Sun Feb 15 14:41:28 2004
@@ -0,0 +1,38 @@
+/*
+ *   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;
+import java.util.Set;
+
+/**
+ * Realms that want to provide support for groups of principals
+ * implement the GroupSupport interface.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public interface GroupSupport
+{
+    /**
+     * This method is used to acquire the set of group names associated with the
+     * given principal name.
+     *
+     * @param principal Principal for which the groups should be returned
+     * @return The set of groups associated with the given principal.
+     */
+    Set getGroupsForPrincipal( Principal principal );
+}

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
Sun Feb 15 14:41:28 2004
@@ -0,0 +1,89 @@
+/*
+ *   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 java.security.Principal;
+import java.util.Set;
+
+/**
+ * This interface defines operation to make changes on realms.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public interface MutableRealm extends Realm
+{
+    /**
+     * Gets the subset of principals of this realm that matches the
+     * specified type.
+     *
+     * @param c The class of principals to filter
+     * @return The principals of this realm instance of the specified class
+     *         as a Set.
+     */
+    Set getPrincipals( Class c );
+
+    /**
+     * This method is used to acquire the set of principals associated with a
+     * given group.
+     *
+     * @param group The principal of the group
+     * @return the set of principals members of the given group.
+     * @throws UnsupportedOperationException if this realm does not implement GroupSupport
+     */
+    Set getPrincipalsForGroup( Principal group );
+
+    /**
+     * Adds a new principal to the realm.
+     *
+     * @throws PrincipalAlreadyExistsException
+     *          if the specified principal is already in this realm
+     */
+    Principal addPrincipal( String principalName )
+            throws PrincipalAlreadyExistsException;
+
+    /**
+     * Adds a new group to the realm.
+     *
+     * @throws GroupAlreadyExistsException
+     *                                       if the specified group already exists
+     *                                       in this realm
+     * @throws UnsupportedOperationException if this realm does not implement GroupSupport
+     */
+    Principal addGroup( String groupName ) throws GroupAlreadyExistsException;
+
+    /**
+     * Adds a credential object to a Principal set of credentials.
+     * <p/>
+     * If an equivalent credential object exists in the set of
+     * credentials associated to the specified Principal,
+     * this method has no effect.
+     *
+     * @return true If the credential object was added to the set
+     *         of credentials of the principal, false otherwise
+     * @throws IllegalArgumentException if the specified principal does not
+     *                                  belong to this realm
+     */
+    boolean addCredentialToPrincipal( Principal principal,
+                                      Credential credential );
+
+    /**
+     * @throws UnsupportedOperationException if this realm does not implement GroupSupport
+     */
+    boolean addPrincipalToGroup( Principal group, Principal principal );
+}
\ No newline at end of file

Added: incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/PrincipalAlreadyExistsException.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/authentication/api/src/java/org/apache/janus/authentication/realm/PrincipalAlreadyExistsException.java
Sun Feb 15 14:41:28 2004
@@ -0,0 +1,41 @@
+/*
+ *   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;
+
+/**
+ * An exception thrown when attempting to add a duplicate principal
+ * to a realm.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public class PrincipalAlreadyExistsException extends Exception
+{
+    private final Principal m_principal;
+
+    public PrincipalAlreadyExistsException( String s, Principal principal )
+    {
+        super( s );
+        m_principal = principal;
+    }
+
+    public Principal getPrincipal()
+    {
+        return m_principal;
+    }
+}

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
Sun Feb 15 14:41:28 2004
@@ -0,0 +1,53 @@
+/*
+ *   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.CredentialCollection;
+
+import java.security.Principal;
+
+/**
+ * The Realm interface allows for the abstraction of disparate
+ * user registries.
+ * <p/>
+ * A realm must adhere to the following rules:
+ * <ul>
+ * <li> Single authentication method
+ * <li> Single type of principals (excepting groups)
+ * <li> A credential collection uniquely identifies a single principal
+ * </ul>
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ */
+public interface Realm
+{
+    /**
+     * Validates the login information provided via
+     * the <code>CredentialCollection</code>.
+     *
+     * @param credentials a CredentialCollection containing a set
+     *                    of Credential objects representing the users
+     *                    set of proof of identity.
+     * @return the Principal identified by the credential collections
+     *         provided or null if no match could be found.
+     * @throws UnsupportedOperationException if the authentication type of the credentials
+     *                                       is not supported by the implementing realm
+     * @throws IllegalArgumentException      if the credential collection provided does not
+     *                                       adhere to the rules of the realm.
+     */
+    Principal validateCredentials( CredentialCollection credentials );
+}

Mime
View raw message