You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by dd...@apache.org on 2008/09/16 11:29:46 UTC

svn commit: r695786 - in /portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security: mapping/stubs/ spi/ stubs/

Author: ddam
Date: Tue Sep 16 02:29:45 2008
New Revision: 695786

URL: http://svn.apache.org/viewvc?rev=695786&view=rev
Log:
make a start with stubs for both mapping/synchronization framework and the Jetspeed security framework

Added:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java   (with props)
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityFactory.java   (with props)
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java   (with props)
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java   (with props)
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubGroupManager.java   (with props)
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java   (with props)
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java   (with props)
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubUserManager.java   (with props)

Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java?rev=695786&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java Tue Sep 16 02:29:45 2008
@@ -0,0 +1,77 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.mapping.stubs;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO;
+import org.apache.jetspeed.security.mapping.model.Entity;
+import org.springframework.ldap.filter.Filter;
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ */
+public class StubEntityDAO implements EntityDAO
+{
+
+    private Map<String,Entity> entities = new HashMap<String,Entity>();
+    
+    public void addEntity(Entity entity)
+    {
+        entities.put(entity.getId(),entity);
+    }
+
+    public Collection<Entity> getAllEntities()
+    {
+        return entities.values();
+    }
+
+    public Collection<Entity> getEntities(Filter filter)
+    {
+        return entities.values();
+    }
+
+    public Collection<Entity> getEntitiesById(Collection<String> entityIds)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Collection<Entity> getEntitiesByInternalId(Collection<String> entityIds)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Entity getEntity(String entityId)
+    {
+        return entities.get(entityId);
+    }
+
+    public void removeEntity(Entity entity)
+    {
+        entities.remove(entity.getId());
+    }
+
+    public void update(Entity entity)
+    {
+        entities.put(entity.getId(),entity);
+    }
+
+}

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityFactory.java?rev=695786&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityFactory.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityFactory.java Tue Sep 16 02:29:45 2008
@@ -0,0 +1,56 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.mapping.stubs;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.apache.jetspeed.security.mapping.model.AttributeDef;
+import org.apache.jetspeed.security.mapping.model.Entity;
+import org.apache.jetspeed.security.mapping.model.impl.EntityImpl;
+
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ */
+public class StubEntityFactory
+{
+    private Map<String,AttributeDef> attributeDefs;
+
+    public void setAttributeDefs(Collection<AttributeDef> attributeDefs){
+        for (AttributeDef attributeDef : attributeDefs)
+        {
+            this.attributeDefs.put(attributeDef.getName(), attributeDef);
+        }
+    }
+    
+    public Entity createEntity(String id, String entityType, String[]... attrKeyValuePairs){
+        
+        EntityImpl stubEntity = new EntityImpl("user", id, new HashSet<AttributeDef>(attributeDefs.values()));
+        for (int i = 0; i < attrKeyValuePairs.length; i++)
+        {
+            AttributeDef def = attributeDefs.get(attrKeyValuePairs[i][0]);
+            if (def!=null){
+                stubEntity.setAttribute(def.getName(), attrKeyValuePairs[i][1]);
+            }
+        }
+        stubEntity.setInternalId(id); // simply use the id
+        return stubEntity;
+    }
+    
+}

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java?rev=695786&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java Tue Sep 16 02:29:45 2008
@@ -0,0 +1,87 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.mapping.stubs;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.jetspeed.security.mapping.SecurityEntityRelationType;
+import org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO;
+import org.apache.jetspeed.security.mapping.ldap.dao.EntityRelationDAO;
+import org.apache.jetspeed.security.mapping.model.Entity;
+
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ */
+public class StubEntityRelationDAO implements EntityRelationDAO
+{
+
+    private Map<Entity,Collection<Entity>> fromTo = new HashMap<Entity,Collection<Entity>>();
+    private Map<Entity,Collection<Entity>> toFrom = new HashMap<Entity,Collection<Entity>>();
+    private SecurityEntityRelationType relationType;
+    
+    
+    public StubEntityRelationDAO(SecurityEntityRelationType relationType)
+    {
+        super();
+        this.relationType = relationType;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.mapping.ldap.dao.EntityRelationDAO#getRelatedEntitiesFrom(org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO, org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO, org.apache.jetspeed.security.mapping.model.Entity)
+     */
+    public Collection<Entity> getRelatedEntitiesFrom(EntityDAO fromDao, EntityDAO toDao, Entity fromEntity)
+    {
+        return fromTo.get(fromEntity);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.mapping.ldap.dao.EntityRelationDAO#getRelatedEntitiesTo(org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO, org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO, org.apache.jetspeed.security.mapping.model.Entity)
+     */
+    public Collection<Entity> getRelatedEntitiesTo(EntityDAO fromDao, EntityDAO toDao, Entity toEntity)
+    {
+        return toFrom.get(toEntity);
+    }
+    
+    public SecurityEntityRelationType getRelationType()
+    {
+        return relationType;
+    }
+
+    private void internalRelate(Map<Entity,Collection<Entity>> mapping, Entity startEntity, Entity endEntity){
+        Collection<Entity> mappedEntities = mapping.get(startEntity);
+        if (mappedEntities == null){
+            mappedEntities=new ArrayList<Entity>();
+            mapping.put(startEntity,mappedEntities);
+        }
+        if (!mappedEntities.contains(endEntity)){
+            mappedEntities.add(endEntity);
+        }
+    }
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.mapping.ldap.dao.EntityRelationDAO#relate(org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO, org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO, org.apache.jetspeed.security.mapping.model.Entity, org.apache.jetspeed.security.mapping.model.Entity)
+     */
+    public void relate(EntityDAO sourceDao, EntityDAO targetDao, Entity sourceEntity, Entity targetEntity)
+    {
+        internalRelate(fromTo,sourceEntity,targetEntity);
+        internalRelate(toFrom,targetEntity,sourceEntity);
+    }
+
+}

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java?rev=695786&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java Tue Sep 16 02:29:45 2008
@@ -0,0 +1,125 @@
+package org.apache.jetspeed.security.spi;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+import org.apache.jetspeed.security.mapping.SecurityEntityManager;
+import org.apache.jetspeed.security.mapping.impl.SecurityEntityRelationTypeImpl;
+import org.apache.jetspeed.security.mapping.ldap.dao.DefaultLDAPEntityManager;
+import org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO;
+import org.apache.jetspeed.security.mapping.ldap.dao.EntityRelationDAO;
+import org.apache.jetspeed.security.mapping.model.AttributeDef;
+import org.apache.jetspeed.security.mapping.model.Entity;
+import org.apache.jetspeed.security.mapping.model.impl.AttributeDefImpl;
+import org.apache.jetspeed.security.mapping.stubs.StubEntityDAO;
+import org.apache.jetspeed.security.mapping.stubs.StubEntityFactory;
+import org.apache.jetspeed.security.mapping.stubs.StubEntityRelationDAO;
+
+
+public class TestDefaultJetspeedSynchronizer extends TestCase
+{
+
+    private SecurityEntityManager entityManager;
+    
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        Collection<AttributeDef> attrDefs = new ArrayList<AttributeDef>();  
+        attrDefs.add(new AttributeDefImpl("fullname"));
+        attrDefs.add(new AttributeDefImpl("company"));        
+        
+        StubEntityFactory stubFactory = new StubEntityFactory();
+        stubFactory.setAttributeDefs(attrDefs);
+        
+        Entity user_jsmith=stubFactory.createEntity("jsmith", "user", new String[]{"John Smith","IBM"});
+        Entity user_jdoe=stubFactory.createEntity("jdoe", "user", new String[]{"Jane Doe","Apple"});
+
+        StubEntityDAO userDao = new StubEntityDAO();
+        userDao.addEntity(user_jsmith);
+        userDao.addEntity(user_jdoe);
+        
+        Entity role_manager=stubFactory.createEntity("manager", "role", new String[]{"Manager Role",""});
+        Entity role_admin=stubFactory.createEntity("admin", "role", new String[]{"Admin Role",""});
+        Entity role_random=stubFactory.createEntity("random", "role", new String[]{"Random Role",""});
+        Entity role_yetAnother=stubFactory.createEntity("yetAnotherRole", "role", new String[]{"Yet Another Role",""});
+        
+        StubEntityDAO roleDao = new StubEntityDAO();
+        userDao.addEntity(role_manager);
+        userDao.addEntity(role_admin);
+        userDao.addEntity(role_random);
+        userDao.addEntity(role_yetAnother);
+
+        
+        Entity group_programmers=stubFactory.createEntity("programmers", "group", new String[]{"Group for Programmers",""});
+        Entity group_board=stubFactory.createEntity("boardOfDirectors", "group", new String[]{"Group for the board of directors",""});
+        Entity group_random=stubFactory.createEntity("randomGroup", "group", new String[]{"Random Group",""});
+        Entity group_yetAnother=stubFactory.createEntity("yetAnotherGroup", "group", new String[]{"Yet Another Group",""});
+
+        StubEntityDAO groupDao = new StubEntityDAO();
+        userDao.addEntity(group_programmers);
+        userDao.addEntity(group_board);
+        userDao.addEntity(group_random);
+        userDao.addEntity(group_yetAnother);
+
+        StubEntityRelationDAO userToRole = new StubEntityRelationDAO(new SecurityEntityRelationTypeImpl(
+                JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME,
+                JetspeedPrincipalType.USER_TYPE_NAME,
+                JetspeedPrincipalType.ROLE_TYPE_NAME));
+        userToRole.relate(null, null, user_jsmith, role_manager);
+        userToRole.relate(null, null, user_jsmith, role_random);
+        userToRole.relate(null, null, user_jdoe, role_manager);
+        userToRole.relate(null, null, user_jdoe, role_random);
+        userToRole.relate(null, null, user_jdoe, role_admin);
+
+        StubEntityRelationDAO userToGroup = new StubEntityRelationDAO(new SecurityEntityRelationTypeImpl(
+                JetspeedPrincipalAssociationType.IS_CHILD_OF_ASSOCIATION_TYPE_NAME,
+                JetspeedPrincipalType.USER_TYPE_NAME,
+                JetspeedPrincipalType.GROUP_TYPE_NAME));
+        userToGroup.relate(null, null, user_jsmith, group_programmers);
+        userToGroup.relate(null, null, user_jsmith, group_random);
+        userToGroup.relate(null, null, user_jdoe, group_board);
+        userToGroup.relate(null, null, user_jdoe, group_yetAnother);
+        userToGroup.relate(null, null, user_jdoe, group_random);
+        
+        StubEntityRelationDAO groupToRole = new StubEntityRelationDAO(new SecurityEntityRelationTypeImpl(
+                JetspeedPrincipalAssociationType.IS_CHILD_OF_ASSOCIATION_TYPE_NAME,
+                JetspeedPrincipalType.GROUP_TYPE_NAME,
+                JetspeedPrincipalType.ROLE_TYPE_NAME));
+        
+        groupToRole.relate(null, null, group_board, role_manager);
+        groupToRole.relate(null, null, group_programmers, role_yetAnother);
+        
+        Map<String,EntityDAO> entityDAOs = new HashMap<String,EntityDAO>();
+        entityDAOs.put(JetspeedPrincipalType.USER_TYPE_NAME,userDao);
+        entityDAOs.put(JetspeedPrincipalType.ROLE_TYPE_NAME,roleDao);
+        entityDAOs.put(JetspeedPrincipalType.USER_TYPE_NAME,groupDao);
+
+        Collection<EntityRelationDAO> entityRelationDAOs = new ArrayList<EntityRelationDAO>();
+        entityRelationDAOs.add(userToRole);
+        entityRelationDAOs.add(userToGroup);
+        entityRelationDAOs.add(groupToRole);
+
+        DefaultLDAPEntityManager entityMan = new DefaultLDAPEntityManager();
+        entityMan.setEntityDAOs(entityDAOs);
+        entityMan.setEntityRelationDAOs(entityRelationDAOs);
+        
+        
+        
+    }
+
+    @Override
+    protected void tearDown() throws Exception
+    {
+        // TODO Auto-generated method stub
+        super.tearDown();
+    }
+
+    
+}

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubGroupManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubGroupManager.java?rev=695786&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubGroupManager.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubGroupManager.java Tue Sep 16 02:29:45 2008
@@ -0,0 +1,37 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.stubs;
+
+import org.apache.jetspeed.security.JetspeedPrincipal;
+
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ */
+
+public class StubGroupManager extends StubJetspeedPrincipalManager
+{
+
+    
+    public JetspeedPrincipal newPrincipal(String name, boolean mapped)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    
+}

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubGroupManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubGroupManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java?rev=695786&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java Tue Sep 16 02:29:45 2008
@@ -0,0 +1,153 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.stubs;
+
+import java.sql.Timestamp;
+import java.util.Map;
+
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+import org.apache.jetspeed.security.PrincipalReadOnlyException;
+import org.apache.jetspeed.security.SecurityAttributes;
+
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ */
+
+public class StubJetspeedPrincipal implements JetspeedPrincipal
+{
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#getCreationDate()
+     */
+    public Timestamp getCreationDate()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#getId()
+     */
+    public Long getId()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#getInfoMap()
+     */
+    public Map<String, String> getInfoMap()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#getModifiedDate()
+     */
+    public Timestamp getModifiedDate()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#getName()
+     */
+    public String getName()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#getSecurityAttributes()
+     */
+    public SecurityAttributes getSecurityAttributes()
+    {
+        
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#getType()
+     */
+    public JetspeedPrincipalType getType()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean isEnabled()
+    {
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#isExtendable()
+     */
+    public boolean isExtendable()
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean isMapped()
+    {
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#isReadOnly()
+     */
+    public boolean isReadOnly()
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#isRemovable()
+     */
+    public boolean isRemovable()
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#isTransient()
+     */
+    public boolean isTransient()
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipal#setEnabled(boolean)
+     */
+    public void setEnabled(boolean enabled) throws PrincipalReadOnlyException
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java?rev=695786&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java Tue Sep 16 02:29:45 2008
@@ -0,0 +1,202 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.stubs;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.jetspeed.security.DependentPrincipalException;
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.JetspeedPrincipalAssociationReference;
+import org.apache.jetspeed.security.JetspeedPrincipalManager;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+import org.apache.jetspeed.security.PrincipalAlreadyExistsException;
+import org.apache.jetspeed.security.PrincipalAssociationNotAllowedException;
+import org.apache.jetspeed.security.PrincipalAssociationRequiredException;
+import org.apache.jetspeed.security.PrincipalAssociationUnsupportedException;
+import org.apache.jetspeed.security.PrincipalNotFoundException;
+import org.apache.jetspeed.security.PrincipalNotRemovableException;
+import org.apache.jetspeed.security.PrincipalReadOnlyException;
+import org.apache.jetspeed.security.PrincipalUpdateException;
+
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ */
+
+public abstract class StubJetspeedPrincipalManager implements JetspeedPrincipalManager
+{
+
+    private Map<String,JetspeedPrincipal> principals=new HashMap<String,JetspeedPrincipal>();
+    private Map<String,Map<String,List<JetspeedPrincipal>>> principalAssociationsFrom=new HashMap<String,Map<String,List<JetspeedPrincipal>>>();
+    private Map<String,Map<String,List<JetspeedPrincipal>>> principalAssociationsTo=new HashMap<String,Map<String,List<JetspeedPrincipal>>>();
+    
+    private void internalAddAssocation(Map<String,Map<String,List<JetspeedPrincipal>>> associationsMap, JetspeedPrincipal from, JetspeedPrincipal to, String associationName){
+        Map<String,List<JetspeedPrincipal>> fromToMap = associationsMap.get(associationName);
+        if (fromToMap == null){
+            fromToMap = new HashMap<String,List<JetspeedPrincipal>>();
+            associationsMap.put(associationName, fromToMap);
+        }
+        List<JetspeedPrincipal> toPrincipals = fromToMap.get(from.getName());
+        if (toPrincipals==null){
+            toPrincipals=new ArrayList<JetspeedPrincipal>();
+            fromToMap.put(from.getName(), toPrincipals);
+        }
+        if (!toPrincipals.contains(to)){
+            toPrincipals.add(to);
+        }
+    }
+    
+    public void addAssociation(JetspeedPrincipal from, JetspeedPrincipal to, String associationName) throws PrincipalNotFoundException,
+            PrincipalAssociationUnsupportedException, PrincipalAssociationNotAllowedException
+    {
+        internalAddAssocation(principalAssociationsFrom,from,to,associationName);
+        internalAddAssocation(principalAssociationsTo,to,from,associationName);
+    }
+
+    public void addPrincipal(JetspeedPrincipal principal, Set<JetspeedPrincipalAssociationReference> associations)
+            throws PrincipalAssociationNotAllowedException, PrincipalAlreadyExistsException, PrincipalAssociationRequiredException, PrincipalNotFoundException,
+            PrincipalAssociationUnsupportedException
+    {
+        principals.put(principal.getName(),principal);
+    }
+
+    private List<JetspeedPrincipal> internalGetAssociatedPrincipals(Map<String,Map<String,List<JetspeedPrincipal>>> associationsMap, String principalFromName, JetspeedPrincipalType principalType, String associationName){
+        Map<String,List<JetspeedPrincipal>> fromToMap = associationsMap.get(associationName);
+        if (fromToMap!=null){
+            return fromToMap.get(principalFromName);
+        }
+        return null;
+    }
+    
+    public List<? extends JetspeedPrincipal> getAssociatedFrom(String principalFromName, JetspeedPrincipalType from, String associationName)
+    {
+        return internalGetAssociatedPrincipals(principalAssociationsFrom, principalFromName,from,associationName);
+    }
+
+    private List<String> internalGetAssociatedNames(Map<String,Map<String,List<JetspeedPrincipal>>> associationsMap, String principalFromName, JetspeedPrincipalType principalType, String associationName){
+        Map<String,List<JetspeedPrincipal>> fromToMap = associationsMap.get(associationName);
+        if (fromToMap!=null){
+            List<JetspeedPrincipal> relatedPrincipals = fromToMap.get(principalFromName);
+            List<String> relatedPrincipalNames = new ArrayList<String>();
+            for (JetspeedPrincipal relatedPrincipal : relatedPrincipals){
+                relatedPrincipalNames.add(relatedPrincipal.getName());
+            }
+            return relatedPrincipalNames;
+        }
+        return null;
+    }
+    
+    public List<String> getAssociatedNamesFrom(String principalFromName, JetspeedPrincipalType from, String associationName)
+    {
+        return internalGetAssociatedNames(principalAssociationsFrom,principalFromName,from,associationName);
+    }
+
+    public List<String> getAssociatedNamesTo(String principalToName, JetspeedPrincipalType to, String associationName)
+    {
+        return internalGetAssociatedNames(principalAssociationsTo,principalToName,to,associationName);
+    }
+
+    public List<? extends JetspeedPrincipal> getAssociatedTo(String principalToName, JetspeedPrincipalType to, String associationName)
+    {
+        return internalGetAssociatedPrincipals(principalAssociationsTo, principalToName,to,associationName);
+    }
+
+    public JetspeedPrincipal getPrincipal(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<String> getPrincipalNames(String nameFilter)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<? extends JetspeedPrincipal> getPrincipals(String nameFilter)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<? extends JetspeedPrincipal> getPrincipalsByAttribute(String attributeName, String attributeValue)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public JetspeedPrincipalType getPrincipalType()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public JetspeedPrincipal newTransientPrincipal(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean principalExists(String name)
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void removeAssociation(JetspeedPrincipal from, JetspeedPrincipal to, String associationName) throws PrincipalAssociationRequiredException,
+            PrincipalNotFoundException
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void removePrincipal(JetspeedPrincipal principal) throws PrincipalNotFoundException, PrincipalNotRemovableException, DependentPrincipalException
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void removePrincipal(String name) throws PrincipalNotFoundException, PrincipalNotRemovableException, DependentPrincipalException
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public List<? extends JetspeedPrincipal> resolveAssociatedFrom(String principalFromName, JetspeedPrincipalType from, String associationName)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<? extends JetspeedPrincipal> resolveAssociatedTo(String principalToName, JetspeedPrincipalType to, String associationName)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void updatePrincipal(JetspeedPrincipal principal) throws PrincipalUpdateException, PrincipalNotFoundException, PrincipalReadOnlyException
+    {
+        // TODO Auto-generated method stub
+        
+    }
+    
+}

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubUserManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubUserManager.java?rev=695786&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubUserManager.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubUserManager.java Tue Sep 16 02:29:45 2008
@@ -0,0 +1,42 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.stubs;
+
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.impl.UserImpl;
+
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ */
+
+public class StubUserManager extends StubJetspeedPrincipalManager
+{
+    public User newUser(String name, boolean mapped)
+    {
+        UserImpl user = new UserImpl(name);
+        user.setMapped(mapped);
+        return user;
+    }
+    
+    public JetspeedPrincipal newPrincipal(String name, boolean mapped)
+    {
+        return newUser(name, mapped);
+    }
+    
+}

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubUserManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubUserManager.java
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org