Author: vtence
Date: Wed Nov 10 13:47:37 2004
New Revision: 57383

Added:
   
incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authentication/
   
incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authentication/InformationProvider.java
   
incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authentication/group/
   
incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authentication/group/GroupProvider.java
Log:
Started refactoring of group management - work in progress

Added: 
incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authentication/InformationProvider.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authentication/InformationProvider.java
   Wed Nov 10 13:47:37 2004
@@ -0,0 +1,24 @@
+/*
+ *   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;
+
+public interface InformationProvider
+{
+    void populate( Subject s );
+}

Added: 
incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authentication/group/GroupProvider.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authentication/group/GroupProvider.java
   Wed Nov 10 13:47:37 2004
@@ -0,0 +1,51 @@
+/*
+ *   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.group;
+
+import org.apache.janus.authentication.InformationProvider;
+
+import javax.security.auth.Subject;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+public class GroupProvider implements InformationProvider
+{
+    private final Map m_groupMapping;
+
+    public GroupProvider()
+    {
+        this( Collections.EMPTY_MAP );
+    }
+
+    public GroupProvider( Map groupMapping )
+    {
+        m_groupMapping = groupMapping;
+    }
+
+    public void populate( Subject s )
+    {
+        Principal[] principals = ( Principal[] ) s.getPrincipals().toArray( 
new Principal[s.getPrincipals().size()] );
+        for ( int i = 0; i < principals.length; i++ )
+        {
+            Principal p = principals[i];
+            Collection attributes = (Collection) m_groupMapping.get( p );
+            if (attributes != null) s.getPrincipals().addAll( attributes );
+        }
+    }
+}

Reply via email to